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.4 2014/02/25 22:46:39 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: install -d usr/libexec/casper
91: ln -fs /usr/libexec libexec;
92: install -d usr/local;
93: install -d usr/local/bin;
94: install -d usr/local/lib;
95: install -d usr/local/libexec;
96: install -d usr/local/libdata;
97: install -d usr/local/sbin;
98: install -d usr/sbin;
99: install -d usr/share;
100: install -d usr/share/misc;
101: install -d usr/share/skel;
102: install -d usr/share/zoneinfo;
103: install -d var;
104:
105: chown -hR root:wheel .
106: cd -
107: }
108:
109: install_basefs()
110: {
111: LIBS="${BASEFS}/usr/lib"
112: LIBEXEC="${BASEFS}/usr/libexec"
113: LIBDATA="${BASEFS}/usr/libdata"
114: BIN="${BASEFS}/bin"
115: UBIN="${BASEFS}/usr/bin"
116: SBIN="${BASEFS}/sbin"
117: USBIN="${BASEFS}/usr/sbin"
118: SHARE="${BASEFS}/usr/share"
119: SKEL="${SHARE}/skel"
120: MISC="${SHARE}/misc"
121:
122: echo "+++ Install ELWIX base software ..."
123: if [ -r ${BSDSRC}/release/picobsd/mfs_tree/etc/termcap ]; then
124: install -v -m 644 ${BSDSRC}/release/picobsd/mfs_tree/etc/termcap $MISC;
125: install -v -m 644 ${BSDSRC}/release/picobsd/mfs_tree/etc/services $MISC;
126: else
127: install -v -m 644 ${BSDSRC}/etc/termcap.small $MISC/termcap;
128: install -v -m 644 ${BSDSRC}/etc/services $MISC;
129: fi
130:
131: install -v ${CFGDIR}/root.skel/cshrc $SKEL/dot.cshrc;
132: install -v ${CFGDIR}/root.skel/login $SKEL/dot.login;
133: install -v ${CFGDIR}/root.skel/logout $SKEL/dot.logout;
134: install -v ${CFGDIR}/root.skel/profile $SKEL/dot.profile;
135: install -v ${CFGDIR}/root.skel/vimrc $SKEL/dot.vimrc;
136:
137: find ${WORLD}/libexec -type f -name ld-elf.so\* -exec install {} $LIBEXEC \;
138:
139: find ${WORLD}/lib -type f -name \*.so.\* -exec install {} $LIBS \;
140: find ${WORLD}/lib -type f -name libalias_\*.so -exec install {} $LIBS \;
141: find ${WORLD}/lib/geom -type f -name \*.so -exec install {} $LIBS/geom \;
142: find ${WORLD}/usr/lib -type f -name \*.so.\* -exec install {} $LIBS \;
143: find ${WORLD}/usr/lib/engines -type f -name \*.so -exec install {} $LIBS/engines \;
144:
145: InstallList ${ELWIX_BASEFS} ${WORLD} ${BASEFS}
146:
147: ln ${BIN}/tcsh ${UBIN}/tcsh
148:
149: InstallDir ${WORLD}/usr/local/bin $UBIN
150: InstallDir ${WORLD}/usr/local/sbin $USBIN
151: InstallFiles \*.so\* ${WORLD}/usr/local/lib $LIBS
152: InstallDir ${WORLD}/usr/local/libdata $LIBDATA
153: InstallDir ${WORLD}/libexec/casper $LIBEXEC/casper
154:
155: chown -R root:wheel $SBIN $BIN $USBIN $UBIN $LIBDATA $LIBEXEC $LIBS
156: }
157:
158: prepare_fs()
159: {
160: echo "+++ Prepare ELWIX fs ..."
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: md0 /tmp mfs rw,-s8m,-oasync,-S 0 0
177: md1 /var mfs rw,-s16m,-S 0 0
178: _EOF
179: }
180:
181: install_fs()
182: {
183: echo "+++ Install ELWIX base $1 in bundle OS install file ..."
184: OSZ=""
185:
186: install -v ${KERNEL} $1/boot/kernel;
187: cd $1/boot/kernel;
188: gzip -9 kernel;
189: cp kernel.gz ${REL}
190: cd -;
191:
192: case "$2" in
193: *)
194: OSZ=${REL}/${BASE_OS}
195: ;;
196: esac
197:
198: cd $1
199: tar -czvf $OSZ .
200: }
201:
202: ### main()
203: clean_basefs
204: build_basefs
205:
206: install_basefs
207:
208: # build fs
209: prepare_fs ${BASE_FS}
210: MakeFS_home ${BASE_FS}/elwix
211: MakeFS_var ${BASE_FS}/elwix ${BASE_ETC}
212: MakeFS_etc ${BASE_FS}/elwix ${BASE_ETC} base
213: create_etc_fstab ${BASE_FS}/elwix base
214: MakeFS_backup ${BASE_FS}/elwix
215: MakeFS_boot ${BASE_FS}
216: install_fs ${BASE_FS}
217:
218: echo "+++ Complete build ELWIX base"
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>