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.8 2017/10/08 00:05:36 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: #
43: # Structure of ELWIX CF Drive mount on /elwix
44: #
45: echo "+++ Build ELWIX FS directory ... $1"
46: mkdir -p $1
47:
48: cd $1
49: # boot
50: install -d boot;
51: # cf
52: install -d cf;
53: # etc
54: install -d etc;
55: # exports
56: install -d exports;
57: # home
58: install -d home;
59: # local
60: install -d local;
61: # root
62: install -d -m 0750 root;
63: # pkg
64: install -d pkg;
65: # tftpboot
66: install -d tftpboot;
67:
68: chown -hR root:wheel .
69: cd -
70: }
71:
72: create_etc_fstab()
73: {
74: cat >$1/etc/fstab <<_EOF
75: # Automatic generated fstab for ELWIX $2 at ${BUILD_DATE}
76: #
77: _EOF
78: }
79:
80: update_etc_cfexec()
81: {
82: echo "mount = \"/elwix\"" >> $1/etc/cfexec.conf
83: }
84:
85: install_fsdir()
86: {
87: echo "+++ Install ELWIX RootFS $1 in bundle OS install file ..."
88: OSZ=""
89:
90: install -v ${REL}/${ROOTFS_KERN} $1/boot/kernel/kernel.gz
91:
92: case "$2" in
93: [Ee][Xx][Tt])
94: install -d $1/usr
95: cd $1/usr
96: pax -r -z -pe -f ${REL}/${ROMFS_IMG}
97: cd -
98:
99: install -d $1/pkg
100: cd $1/pkg
101: pax -r -z -pe -f ${REL}/${ROMFS_IMG2}
102: cd -
103:
104: OSZ=${REL}/${OS_EXT}
105: ;;
106: *)
107: install -v ${REL}/${ROMFS_IMG} \
108: $1/altroot/elwix-firmware-${VERSION}_${TARGET_ARCH}
109: ln $1/altroot/elwix-firmware-${VERSION}_${TARGET_ARCH} \
110: $1/altroot/${ROMFS_IMG}
111: ln -s /elwix/altroot/elwix-firmware-${VERSION}_${TARGET_ARCH} \
112: $1/${ROMFS_IMG}
113:
114: install -v ${REL}/${ROMFS_IMG2} \
115: $1/altroot/elwix-firmware2-${VERSION}_${TARGET_ARCH}
116: ln $1/altroot/elwix-firmware2-${VERSION}_${TARGET_ARCH} \
117: $1/altroot/${ROMFS_IMG2}
118: ln -s /elwix/altroot/elwix-firmware2-${VERSION}_${TARGET_ARCH} \
119: $1/${ROMFS_IMG2}
120:
121: OSZ=${REL}/${OS}
122: ;;
123: esac
124:
125: cd $1
126: tar -czvf $OSZ .
127:
128: echo "+++ Completed ELWIX RootFS $1 --> $OSZ"
129: }
130:
131: ### main()
132: if [ ! -r ${REL}/${ROOTFS_KERN} -o ! -r ${REL}/${ROMFS_IMG} ]; then
133: echo
134: echo "Error:: not found kernel or firmware elwix files ..."
135: echo
136: echo " For fix this issue, please re-run build_rootfs.sh or build_romfs.sh"
137: echo
138: exit 1
139: fi
140:
141: clean_fsdir ${FS} ${REL}/${OS} || exit 1
142: clean_fsdir ${FS_EXT} ${REL}/${OS_EXT} || exit 1
143:
144: build_fsdir ${FS} || exit 1
145: build_fsdir ${FS_EXT} || exit 1
146:
147: MakeFS_home ${FS} || exit 1
148: MakeFS_home ${FS_EXT} || exit 1
149:
150: MakeFS_var ${FS} ${FS_ETC} || exit 1
151: MakeFS_var ${FS_EXT} ${FS_EXT_ETC} || exit 1
152:
153: MakeFS_etc ${FS} ${FS_ETC} || exit 1
154: MakeFS_etc ${FS_EXT} ${FS_EXT_ETC} ext || exit 1
155:
156: create_etc_fstab ${FS} || exit 1
157: create_etc_fstab ${FS_EXT} ext || exit 1
158:
159: update_etc_cfexec ${FS} || exit 1
160: update_etc_cfexec ${FS_EXT} ext || exit 1
161:
162: MakeFS_boot ${FS} || exit 1
163: MakeFS_boot ${FS_EXT} || exit 1
164:
165: install_fsdir ${FS} || exit 1
166: install_fsdir ${FS_EXT} ext || exit 1
167:
168: echo "+++ Complete build ELWIX RootFS system"
169: echo "ELWIX RootFS finish version ${VERSION}, Good luck!"
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>