1: #!/bin/sh
2: #
3: # ELWIX Build script for ELWIX CompactFlash image
4: #
5: # (C) AITNET ltd - Sofia/Bulgaria <office@aitnet.org>
6: # by Michael Pounov <misho@elwix.org>
7: #
8: # $Id: build_fs.sh,v 1.11.2.3 2017/06/18 21:01:32 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 - FS must build under root !?!"
29: echo
30: exit 1
31: fi
32:
33: clean_fsdir()
34: {
35: echo "+++ Clean ELWIX FS ... $1"
36: chflags -Rf nosunlink $1
37: rm -rf $1 $2
38: }
39:
40: build_fsdir()
41: {
42: echo "+++ Build ELWIX FS directory ... $1"
43: mkdir -p $1
44:
45: cd $1
46: # boot
47: install -d boot;
48: # cf
49: install -d cf;
50: case ${TARGET} in
51: i386)
52: ln -fs /dev/ada0g cf/map.cfg
53: ;;
54: mips)
55: ln -fs /dev/map/cfg cf/map.cfg
56: ;;
57: esac
58: # etc
59: install -d etc;
60: install -d -o 883 -g 883 etc/mqtt;
61: # exports
62: install -d exports;
63: # home
64: install -d home;
65: # local
66: install -d local;
67: # root
68: install -d -m 0750 root;
69: # pkg
70: install -d pkg;
71: # tftpboot
72: install -d tftpboot;
73:
74: chown -hR root:wheel .
75: cd -
76: }
77:
78: create_etc_fstab()
79: {
80: cat >$1/etc/fstab <<_EOF
81: # Automatic generated fstab for ELWIX $2 at ${BUILD_DATE}
82: #
83: /dev/ufs/elwix /elwix ufs ro 0 1
84: _EOF
85: }
86:
87: update_etc_cfexec()
88: {
89: echo "mount = \"/elwix\"" >> $1/etc/cfexec.conf
90: }
91:
92: install_fsdir()
93: {
94: echo "+++ Install ELWIX RootFS $1 in bundle OS install file ..."
95: OSZ=""
96:
97: install -v ${REL}/${ROOTFS_KERN} $1/boot/kernel/kernel.gz
98:
99: case "$2" in
100: [Ee][Xx][Tt])
101: install -d $1/usr
102: cd $1/usr
103: pax -r -z -pe -f ${REL}/${ROMFS_IMG}
104: cd -
105:
106: install -d $1/pkg
107: cd $1/pkg
108: pax -r -z -pe -f ${REL}/${ROMFS_IMG2}
109: cd -
110:
111: OSZ=${REL}/${OS_EXT}
112: ;;
113: *)
114: install -v ${REL}/${ROMFS_IMG} \
115: $1/altroot/elwix-firmware-${VERSION}_${TARGET_ARCH}
116: ln $1/altroot/elwix-firmware-${VERSION}_${TARGET_ARCH} \
117: $1/altroot/${ROMFS_IMG}
118: ln -s /elwix/altroot/elwix-firmware-${VERSION}_${TARGET_ARCH} \
119: $1/${ROMFS_IMG}
120:
121: install -v ${REL}/${ROMFS_IMG2} \
122: $1/altroot/elwix-firmware2-${VERSION}_${TARGET_ARCH}
123: ln $1/altroot/elwix-firmware2-${VERSION}_${TARGET_ARCH} \
124: $1/altroot/${ROMFS_IMG2}
125: ln -s /elwix/altroot/elwix-firmware2-${VERSION}_${TARGET_ARCH} \
126: $1/${ROMFS_IMG2}
127:
128: OSZ=${REL}/${OS}
129: ;;
130: esac
131:
132: cd $1
133: tar -czvf $OSZ .
134:
135: echo "+++ Completed ELWIX RootFS $1 --> $OSZ"
136: }
137:
138: ### main()
139: if [ ! -r ${REL}/${ROOTFS_KERN} -o ! -r ${REL}/${ROMFS_IMG} ]; then
140: echo
141: echo "Error:: not found kernel or firmware elwix files ..."
142: echo
143: echo " For fix this issue, please re-run build_rootfs.sh or build_romfs.sh"
144: echo
145: exit 1
146: fi
147:
148: clean_fsdir ${FS} ${REL}/${OS} || exit 1
149: clean_fsdir ${FS_EXT} ${REL}/${OS_EXT} || exit 1
150:
151: build_fsdir ${FS} || exit 1
152: build_fsdir ${FS_EXT} || exit 1
153:
154: MakeFS_home ${FS} || exit 1
155: MakeFS_home ${FS_EXT} || exit 1
156:
157: MakeFS_var ${FS} ${FS_ETC} || exit 1
158: MakeFS_var ${FS_EXT} ${FS_EXT_ETC} || exit 1
159:
160: MakeFS_etc ${FS} ${FS_ETC} || exit 1
161: MakeFS_etc ${FS_EXT} ${FS_EXT_ETC} ext || exit 1
162:
163: create_etc_fstab ${FS} || exit 1
164: create_etc_fstab ${FS_EXT} ext || exit 1
165:
166: update_etc_cfexec ${FS} || exit 1
167: update_etc_cfexec ${FS_EXT} ext || exit 1
168:
169: MakeFS_backup ${FS} || exit 1
170: MakeFS_backup ${FS_EXT} || exit 1
171:
172: MakeFS_boot ${FS} || exit 1
173: MakeFS_boot ${FS_EXT} || exit 1
174:
175: install_fsdir ${FS} || exit 1
176: install_fsdir ${FS_EXT} ext || exit 1
177:
178: echo "+++ Complete build ELWIX RootFS system"
179: echo "ELWIX RootFS finish version ${VERSION}, Good luck!"
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>