1: #!/bin/sh
2: #
3: # ELWIX Build script for ELWIX raw BaseFS 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.4.2.13 2018/01/02 01:38:18 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 - BaseFS must build under root !?!"
29: echo
30: exit 1
31: fi
32:
33: clean_basefs()
34: {
35: echo "+++ Clean ELWIX BaseFS firmware ... $BASEFS"
36: chflags -Rf noschg,nosunlink $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 BaseFS directory ... $BASEFS"
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/local;
68: install -d elwix/local/lib;
69: install -d etc;
70: ln -fs /elwix/exports exports;
71: ln -fs /elwix/home home;
72: ln -fs /elwix/root root;
73: ln -fs /elwix/tftpboot tftpboot;
74: install -d mnt;
75: install -d -m 0555 proc;
76: install -d sbin;
77: install -d tmp;
78: install -d usr;
79: install -d usr/bin;
80: install -d usr/lib;
81: ln -fs /usr/lib lib;
82: install -d usr/lib/engines;
83: install -d usr/lib/geom;
84: case ${TARGET} in
85: amd64)
86: install -d usr/lib32;
87: ;;
88: *)
89: ;;
90: esac
91: install -d usr/libdata;
92: install -d usr/libexec;
93: ln -fs /usr/libexec libexec;
94: ln -fs /elwix/local usr/local;
95: ln -fs /elwix/pkg usr/pkg;
96: install -d usr/sbin;
97: install -d usr/share;
98: install -d usr/share/misc;
99: install -d usr/share/skel;
100: install -d usr/share/zoneinfo;
101: install -d var;
102:
103: chown -hR root:wheel .
104: cd -
105: }
106:
107: install_basefs()
108: {
109: LIBS="${BASEFS}/usr/lib"
110: LIBEXEC="${BASEFS}/usr/libexec"
111: LIBDATA="${BASEFS}/usr/libdata"
112: BIN="${BASEFS}/bin"
113: UBIN="${BASEFS}/usr/bin"
114: SBIN="${BASEFS}/sbin"
115: USBIN="${BASEFS}/usr/sbin"
116: SHARE="${BASEFS}/usr/share"
117: SKEL="${SHARE}/skel"
118: MISC="${SHARE}/misc"
119:
120: echo "+++ Install ELWIX BaseFS software ... $BASEFS"
121: if [ -r ${BSDSRC}/release/picobsd/mfs_tree/etc/termcap ]; then
122: install -v -m 644 ${BSDSRC}/release/picobsd/mfs_tree/etc/termcap $MISC;
123: install -v -m 644 ${BSDSRC}/release/picobsd/mfs_tree/etc/services $MISC;
124: else
125: install -v -m 644 ${BSDSRC}/etc/termcap.small $MISC/termcap;
126: install -v -m 644 ${BSDSRC}/etc/services $MISC;
127: fi
128:
129: install -v ${CFGDIR}/root.skel/cshrc $SKEL/dot.cshrc;
130: install -v ${CFGDIR}/root.skel/login $SKEL/dot.login;
131: install -v ${CFGDIR}/root.skel/logout $SKEL/dot.logout;
132: install -v ${CFGDIR}/root.skel/profile $SKEL/dot.profile;
133: install -v ${CFGDIR}/root.skel/vimrc $SKEL/dot.vimrc;
134:
135: find ${WORLD}/libexec -type f -name ld-elf.so\* -exec install {} $LIBEXEC \;
136:
137: find ${WORLD}/lib -type f -name \*.so.\* ! -name \*.debug -exec install {} $LIBS \;
138: find ${WORLD}/lib -type f -name libalias_\*.so -exec install {} $LIBS \;
139: find ${WORLD}/lib/geom -type f -name \*.so -exec install {} $LIBS/geom \;
140: find ${WORLD}/usr/lib -type f -name \*.so.\* ! -name \*.debug -exec install {} $LIBS \;
141: find ${WORLD}/usr/lib/engines -type f -name \*.so -exec install {} $LIBS/engines \;
142:
143: InstallList ${ELWIX_BASEFS} ${WORLD} ${BASEFS}
144:
145: ln ${BIN}/tcsh ${UBIN}/tcsh
146:
147: InstallDir ${WORLD}/usr/local/bin $UBIN
148: InstallDir ${WORLD}/usr/local/sbin $USBIN
149: InstallFiles \*.so\* ${WORLD}/usr/local/lib $LIBS
150: InstallDir ${WORLD}/usr/local/libdata $LIBDATA
151:
152: chown -R root:wheel $SBIN $BIN $USBIN $UBIN $LIBDATA $LIBEXEC $LIBS
153:
154: echo "+++ Completed ELWIX BaseFS software ... $BASEFS"
155: }
156:
157: prepare_fs()
158: {
159: echo "+++ Prepare ELWIX fs ... $BASEFS --> $1"
160: mkdir -p $1
161:
162: if [ -d ${BASEFS} ]; then
163: cd ${BASEFS}
164: pax -rw -pe -X . $1
165: cd -
166: fi
167: }
168:
169: create_etc_fstab()
170: {
171: cat >$1/etc/fstab <<_EOF
172: # Automatic generated fstab for ELWIX $2 at ${BUILD_DATE}
173: #
174: tmpfs /tmp tmpfs rw 0 0
175: md2 /var mfs rw,-s16m,-S,-n 0 0
176: _EOF
177: }
178:
179: update_etc_cfexec()
180: {
181: echo "mount = \"/\"" >> $1/etc/cfexec.conf
182: }
183:
184: install_fs()
185: {
186: echo "+++ Install ELWIX BaseFS $1 in bundle OS install file ..."
187: OSZ=""
188:
189: install -v ${KERNEL} $1/boot/kernel;
190: cd $1/boot/kernel;
191: gzip -9 kernel;
192: cp kernel.gz ${REL}
193: cd -;
194: echo "+++ Released native ELWIX kernel ... ${REL}/kernel.gz"
195:
196: case "$2" in
197: *)
198: OSZ=${REL}/${BASE_OS}
199: ;;
200: esac
201:
202: cd $1
203: tar -czvf $OSZ .
204: echo "+++ Completed ELWIX BaseFS $1 --> $OSZ"
205: }
206:
207: ### main()
208: clean_basefs
209: build_basefs
210:
211: install_basefs
212:
213: # build fs
214: prepare_fs ${BASE_FS}
215: MakeFS_home ${BASE_FS}/elwix
216: MakeFS_var ${BASE_FS}/elwix ${BASE_ETC}
217: MakeFS_etc ${BASE_FS} ${BASE_ETC} base
218: create_etc_fstab ${BASE_FS} base
219: update_etc_cfexec ${BASE_FS}
220: MakeFS_boot ${BASE_FS}
221: install_fs ${BASE_FS}
222:
223: echo "+++ Complete build ELWIX BaseFS system"
224: echo "ELWIX BaseFS finish version ${VERSION}, Good luck!"
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>