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.15 2020/06/11 00:56:31 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/lua;
53: install -d boot/modules;
54: install -d boot/zfs;
55: install -d dev;
56: install -d elwix;
57: install -d elwix/altroot;
58: install -d elwix/altroot/var;
59: install -d elwix/cf;
60: install -d elwix/etc;
61: install -d -o 883 -g 883 elwix/etc/mqtt;
62: install -d elwix/exports;
63: install -d elwix/home;
64: install -d -m 0750 elwix/root;
65: install -d -m 0750 elwix/root/.ssh;
66: install -d elwix/tftpboot;
67: install -d elwix/pkg;
68: install -d elwix/local;
69: install -d elwix/local/lib;
70: install -d etc;
71: ln -fs /elwix/exports exports;
72: ln -fs /elwix/home home;
73: ln -fs /elwix/root root;
74: ln -fs /elwix/tftpboot tftpboot;
75: install -d mnt;
76: install -d -m 0555 proc;
77: install -d sbin;
78: install -d tmp;
79: install -d usr;
80: install -d usr/bin;
81: install -d usr/lib;
82: ln -fs /usr/lib lib;
83: install -d usr/lib/engines;
84: install -d usr/lib/geom;
85: case ${TARGET} in
86: amd64)
87: install -d usr/lib32;
88: ;;
89: *)
90: ;;
91: esac
92: install -d usr/libdata;
93: install -d usr/libexec;
94: ln -fs /usr/libexec libexec;
95: ln -fs /elwix/local usr/local;
96: ln -fs /elwix/pkg usr/pkg;
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 BaseFS software ... $BASEFS"
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.\* ! -name \*.debug -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.\* ! -name \*.debug -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: echo "+++ Completed ELWIX BaseFS software ... $BASEFS"
156: }
157:
158: prepare_fs()
159: {
160: echo "+++ Prepare ELWIX fs ... $BASEFS --> $1"
161: mkdir -p $1
162:
163: if [ -d ${BASEFS} ]; then
164: cd ${BASEFS}
165: pax -rw -pe -X . $1
166: cd -
167: fi
168: }
169:
170: create_etc_fstab()
171: {
172: cat >$1/etc/fstab <<_EOF
173: # Automatic generated fstab for ELWIX $2 at ${BUILD_DATE}
174: #
175: /dev/ufs/elwix / ufs ro 0 1
176: tmpfs /tmp tmpfs rw 0 0
177: md2 /var mfs rw,-s16m,-S,-n 0 0
178: _EOF
179: }
180:
181: update_etc_cfexec()
182: {
183: echo "mount = \"/\"" >> $1/etc/cfexec.conf
184: }
185:
186: install_fs()
187: {
188: echo "+++ Install ELWIX BaseFS $1 in bundle OS install file ..."
189: OSZ=""
190:
191: install -v ${KERNEL} $1/boot/kernel;
192: cd $1/boot/kernel;
193: gzip -9 kernel;
194: cp kernel.gz ${REL}
195: cd -;
196: echo "+++ Released native ELWIX kernel ... ${REL}/kernel.gz"
197:
198: case "$2" in
199: *)
200: OSZ=${REL}/${BASE_OS}
201: ;;
202: esac
203:
204: cd $1
205: tar -czvf $OSZ .
206: echo "+++ Completed ELWIX BaseFS $1 --> $OSZ"
207: }
208:
209: ### main()
210: clean_basefs
211: build_basefs
212:
213: install_basefs
214:
215: # build fs
216: prepare_fs ${BASE_FS}
217: MakeFS_home ${BASE_FS}/elwix
218: MakeFS_var ${BASE_FS}/elwix ${BASE_ETC}
219: MakeFS_etc ${BASE_FS} ${BASE_ETC} base
220: create_etc_fstab ${BASE_FS} base
221: update_etc_cfexec ${BASE_FS}
222: MakeFS_boot ${BASE_FS}
223: install_fs ${BASE_FS}
224:
225: echo "+++ Complete build ELWIX BaseFS system"
226: echo "ELWIX BaseFS finish version ${VERSION}, Good luck!"
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>