Annotation of elwix/build_fs.sh, revision 1.11.2.3
1.2 misho 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: #
1.11.2.3! misho 8: # $Id: build_fs.sh,v 1.11.2.2 2017/06/16 13:41:05 misho Exp $
1.2 misho 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: {
1.11 misho 35: echo "+++ Clean ELWIX FS ... $1"
1.10 misho 36: chflags -Rf nosunlink $1
1.8 misho 37: rm -rf $1 $2
1.2 misho 38: }
39:
40: build_fsdir()
41: {
1.11 misho 42: echo "+++ Build ELWIX FS directory ... $1"
1.4 misho 43: mkdir -p $1
1.2 misho 44:
1.4 misho 45: cd $1
1.2 misho 46: # boot
47: install -d boot;
48: # cf
49: install -d cf;
1.10 misho 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
1.2 misho 58: # etc
59: install -d etc;
1.4 misho 60: install -d -o 883 -g 883 etc/mqtt;
1.2 misho 61: # exports
62: install -d exports;
63: # home
64: install -d home;
1.11.2.1 misho 65: # local
66: install -d local;
1.2 misho 67: # root
1.9 misho 68: install -d -m 0750 root;
1.4 misho 69: # pkg
70: install -d pkg;
1.2 misho 71: # tftpboot
72: install -d tftpboot;
73:
74: chown -hR root:wheel .
75: cd -
76: }
77:
78: create_etc_fstab()
79: {
1.8 misho 80: cat >$1/etc/fstab <<_EOF
81: # Automatic generated fstab for ELWIX $2 at ${BUILD_DATE}
1.2 misho 82: #
83: /dev/ufs/elwix /elwix ufs ro 0 1
84: _EOF
85: }
86:
1.11 misho 87: update_etc_cfexec()
88: {
89: echo "mount = \"/elwix\"" >> $1/etc/cfexec.conf
90: }
91:
1.2 misho 92: install_fsdir()
93: {
1.11 misho 94: echo "+++ Install ELWIX RootFS $1 in bundle OS install file ..."
1.4 misho 95: OSZ=""
96:
1.8 misho 97: install -v ${REL}/${ROOTFS_KERN} $1/boot/kernel/kernel.gz
1.2 misho 98:
1.5 misho 99: case "$2" in
1.8 misho 100: [Ee][Xx][Tt])
1.5 misho 101: install -d $1/usr
102: cd $1/usr
103: pax -r -z -pe -f ${REL}/${ROMFS_IMG}
104: cd -
105:
1.11.2.3! misho 106: install -d $1/pkg
! 107: cd $1/pkg
1.5 misho 108: pax -r -z -pe -f ${REL}/${ROMFS_IMG2}
109: cd -
110:
1.8 misho 111: OSZ=${REL}/${OS_EXT}
1.5 misho 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
1.2 misho 131:
1.4 misho 132: cd $1
133: tar -czvf $OSZ .
1.11 misho 134:
135: echo "+++ Completed ELWIX RootFS $1 --> $OSZ"
1.2 misho 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:
1.10 misho 148: clean_fsdir ${FS} ${REL}/${OS} || exit 1
149: clean_fsdir ${FS_EXT} ${REL}/${OS_EXT} || exit 1
1.4 misho 150:
1.10 misho 151: build_fsdir ${FS} || exit 1
152: build_fsdir ${FS_EXT} || exit 1
1.8 misho 153:
1.10 misho 154: MakeFS_home ${FS} || exit 1
155: MakeFS_home ${FS_EXT} || exit 1
1.8 misho 156:
1.10 misho 157: MakeFS_var ${FS} ${FS_ETC} || exit 1
158: MakeFS_var ${FS_EXT} ${FS_EXT_ETC} || exit 1
1.8 misho 159:
1.10 misho 160: MakeFS_etc ${FS} ${FS_ETC} || exit 1
161: MakeFS_etc ${FS_EXT} ${FS_EXT_ETC} ext || exit 1
1.8 misho 162:
1.10 misho 163: create_etc_fstab ${FS} || exit 1
164: create_etc_fstab ${FS_EXT} ext || exit 1
1.8 misho 165:
1.11 misho 166: update_etc_cfexec ${FS} || exit 1
167: update_etc_cfexec ${FS_EXT} ext || exit 1
168:
1.10 misho 169: MakeFS_backup ${FS} || exit 1
170: MakeFS_backup ${FS_EXT} || exit 1
1.2 misho 171:
1.10 misho 172: MakeFS_boot ${FS} || exit 1
173: MakeFS_boot ${FS_EXT} || exit 1
1.2 misho 174:
1.10 misho 175: install_fsdir ${FS} || exit 1
176: install_fsdir ${FS_EXT} ext || exit 1
1.2 misho 177:
1.11 misho 178: echo "+++ Complete build ELWIX RootFS system"
179: echo "ELWIX RootFS finish version ${VERSION}, Good luck!"
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>