1: #!/bin/sh
2: #
3: # ELWIX Build script for ELWIX raw base firmware
4: #
5: # (C) AITNET ltd - Sofia/Bulgaria <office@aitnet.org>
6: # by Michael Pounov <misho@elwix.org>
7: #
8: # $Id: build_base.sh,v 1.2.6.3 2014/01/21 09:21:55 misho Exp $
9: #
10:
11: [ -r ./config/rc.elwix ] && . ./config/rc.elwix
12: if [ X"${ELWIX_IS_CONFIGURED}" != X"YES" ]; then
13: echo
14: echo "ELWIX project is not configured !?!"
15: echo
16: exit 1
17: fi
18:
19: if [ ! -d ${BSDSRC} ]; then
20: echo
21: echo "ELWIX project is not configured - missing BSD sources !?!"
22: echo
23: exit 1
24: fi
25:
26: if [ "${USER}" != "root" ]; then
27: echo
28: echo "ELWIX project is not configured - base must build under root !?!"
29: echo
30: exit 1
31: fi
32:
33: clean_basefs()
34: {
35: echo "+++ Clean ELWIX base firmware ..."
36: chflags -Rf noschg $BASEFS $BASE_FS
37: rm -rf $BASEFS $BASE_FS ${REL}/${BASE_OS} ${REL}/kernel.gz
38: }
39:
40: build_basefs()
41: {
42: echo "+++ Build ELWIX base directory ..."
43: mkdir -p $BASEFS
44:
45: cd $BASEFS
46:
47: install -d bin;
48: install -d boot;
49: install -d boot/defaults;
50: install -d boot/firmware;
51: install -d boot/kernel;
52: install -d boot/modules;
53: install -d boot/zfs;
54: install -d dev;
55: install -d elwix;
56: install -d elwix/altroot;
57: install -d elwix/altroot/var;
58: install -d elwix/cf;
59: install -d elwix/etc;
60: install -d -o 883 -g 883 elwix/etc/mqtt;
61: install -d elwix/exports;
62: install -d elwix/home;
63: install -d -m 0750 elwix/root;
64: install -d -m 0750 elwix/root/.ssh;
65: install -d elwix/tftpboot;
66: install -d elwix/pkg;
67: install -d elwix/pkg/bin;
68: install -d elwix/pkg/lib;
69: install -d elwix/pkg/libexec;
70: install -d elwix/pkg/libdata;
71: install -d elwix/pkg/sbin;
72: ln -fs /elwix/etc etc;
73: ln -fs /elwix/exports exports;
74: ln -fs /elwix/home home;
75: ln -fs /elwix/root root;
76: ln -fs /elwix/tftpboot tftpboot;
77: install -d mnt;
78: install -d -m 0555 proc;
79: install -d sbin;
80: install -d tmp;
81: install -d usr;
82: install -d usr/bin;
83: install -d usr/lib;
84: ln -fs /usr/lib lib;
85: install -d usr/lib/engines;
86: install -d usr/lib/geom;
87: install -d usr/lib32;
88: install -d usr/libdata;
89: install -d usr/libexec;
90: ln -fs /usr/libexec libexec;
91: install -d usr/local;
92: install -d usr/local/bin;
93: install -d usr/local/lib;
94: install -d usr/local/libexec;
95: install -d usr/local/libdata;
96: install -d usr/local/sbin;
97: install -d usr/sbin;
98: install -d usr/share;
99: install -d usr/share/misc;
100: install -d usr/share/skel;
101: install -d usr/share/zoneinfo;
102: install -d var;
103:
104: chown -hR root:wheel .
105: cd -
106: }
107:
108: install_basefs()
109: {
110: LIBS="${BASEFS}/usr/lib"
111: LIBEXEC="${BASEFS}/usr/libexec"
112: LIBDATA="${BASEFS}/usr/libdata"
113: BIN="${BASEFS}/bin"
114: UBIN="${BASEFS}/usr/bin"
115: SBIN="${BASEFS}/sbin"
116: USBIN="${BASEFS}/usr/sbin"
117: SHARE="${BASEFS}/usr/share"
118: SKEL="${SHARE}/skel"
119: MISC="${SHARE}/misc"
120:
121: echo "+++ Install ELWIX base software ..."
122: if [ -r ${BSDSRC}/release/picobsd/mfs_tree/etc/termcap ]; then
123: install -v -m 644 ${BSDSRC}/release/picobsd/mfs_tree/etc/termcap $MISC;
124: install -v -m 644 ${BSDSRC}/release/picobsd/mfs_tree/etc/services $MISC;
125: else
126: install -v -m 644 ${BSDSRC}/etc/termcap.small $MISC/termcap;
127: install -v -m 644 ${BSDSRC}/etc/services $MISC;
128: fi
129:
130: install -v ${CFGDIR}/root.skel/cshrc $SKEL/dot.cshrc;
131: install -v ${CFGDIR}/root.skel/login $SKEL/dot.login;
132: install -v ${CFGDIR}/root.skel/logout $SKEL/dot.logout;
133: install -v ${CFGDIR}/root.skel/profile $SKEL/dot.profile;
134: install -v ${CFGDIR}/root.skel/vimrc $SKEL/dot.vimrc;
135:
136: find ${WORLD}/libexec -type f -name ld-elf.so\* -exec install {} $LIBEXEC \;
137:
138: find ${WORLD}/lib -type f -name \*.so.\* -exec install {} $LIBS \;
139: find ${WORLD}/lib -type f -name libalias_\*.so -exec install {} $LIBS \;
140: find ${WORLD}/lib/geom -type f -name \*.so -exec install {} $LIBS/geom \;
141: find ${WORLD}/usr/lib -type f -name \*.so.\* -exec install {} $LIBS \;
142: find ${WORLD}/usr/lib/engines -type f -name \*.so -exec install {} $LIBS/engines \;
143:
144: InstallList ${ELWIX_BASEFS} ${WORLD} ${BASEFS}
145:
146: ln ${BIN}/tcsh ${UBIN}/tcsh
147:
148: InstallDir ${WORLD}/usr/local/bin $UBIN
149: InstallDir ${WORLD}/usr/local/sbin $USBIN
150: InstallFiles \*.so\* ${WORLD}/usr/local/lib $LIBS
151: InstallDir ${WORLD}/usr/local/libdata $LIBDATA
152:
153: chown -R root:wheel $SBIN $BIN $USBIN $UBIN $LIBDATA $LIBEXEC $LIBS
154: }
155:
156: prepare_fs()
157: {
158: echo "+++ Prepare ELWIX fs ..."
159: mkdir -p $1
160:
161: if [ -d ${BASEFS} ]; then
162: cd ${BASEFS}
163: pax -rw -pe -X . $1
164: cd -
165: fi
166: }
167:
168: create_etc_fstab()
169: {
170: cat >$1/etc/fstab <<_EOF
171: # Automatic generated fstab for ELWIX $2 at ${BUILD_DATE}
172: #
173: /dev/ufs/elwix / ufs ro 0 1
174: md0 /tmp mfs rw,-s8m,-oasync,-S 0 0
175: md1 /var mfs rw,-s16m,-S 0 0
176: _EOF
177: }
178:
179: install_fs()
180: {
181: echo "+++ Install ELWIX base $1 in bundle OS install file ..."
182: OSZ=""
183:
184: install -v ${KERNEL} $1/boot/kernel;
185: cd $1/boot/kernel;
186: gzip -9 kernel;
187: cp kernel.gz ${REL}
188: cd -;
189:
190: case "$2" in
191: *)
192: OSZ=${REL}/${BASE_OS}
193: ;;
194: esac
195:
196: cd $1
197: tar -czvf $OSZ .
198: }
199:
200: ### main()
201: clean_basefs
202: build_basefs
203:
204: install_basefs
205:
206: # build fs
207: prepare_fs ${BASE_FS}
208: MakeFS_home ${BASE_FS}/elwix
209: MakeFS_var ${BASE_FS}/elwix ${BASE_ETC}
210: MakeFS_etc ${BASE_FS}/elwix ${BASE_ETC} base
211: create_etc_fstab ${BASE_FS}/elwix base
212: MakeFS_backup ${BASE_FS}/elwix
213: MakeFS_boot ${BASE_FS}
214: install_fs ${BASE_FS}
215:
216: echo "+++ Complete build ELWIX base"
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>