Annotation of elwix/build_rootfs.sh, revision 1.6.2.3
1.1 misho 1: #!/bin/sh
2: #
3: # ELWIX build script for rootfs firmware
4: #
5: # (C) AITNET ltd - Sofia/Bulgaria <office@aitnet.org>
6: # by Michael Pounov <misho@elwix.org>
7: #
1.6.2.3 ! misho 8: # $Id: build_rootfs.sh,v 1.4.2.1 2013/01/28 10:48:45 misho Exp $
1.1 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 - RootFS must build under root !?!"
29: echo
30: exit 1
31: fi
32:
1.6.2.3 ! misho 33: KRNNAME="kernel_rootfs"
! 34: NEWKERN="${REL}/${KRNNAME}"
! 35: MKF="Makefile.elwix"
! 36: MKH="Makefile.inc"
1.1 misho 37:
38: clean_elwix()
39: {
1.3 misho 40: echo "+++ Clean elwix binary from ELWIX World ..."
41: rm -rf $BSDOBJ/elwix
1.1 misho 42:
43: echo "+++ Clean ELWIX RootFS firmware ..."
1.6.2.3 ! misho 44: rm -rf $ROOTFS_MKDIR
! 45: mkdir $ROOTFS_MKDIR
1.1 misho 46:
47: echo "+++ Clean RootFS directory ..."
1.3 misho 48: chflags -R noschg $ROOTFS
1.1 misho 49: rm -rf $ROOTFS
50: mkdir $ROOTFS
51:
52: echo "+++ Clean Release directory ..."
53: rm -rf $REL/$ROOTFS_IMG ${NEWKERN}*
54: }
55:
56: prepare_elwix()
57: {
58: echo "+++ Prepair ELWIX RootFS firmware ..."
1.6.2.3 ! misho 59: cd $ROOTFS_MKDIR
1.1 misho 60: cat >$MKH <<_EOF
61: # Auto-generated Makefile include for crungegen
62: # !!! Dont edit by hand !!!
63: #
1.3 misho 64:
1.1 misho 65: LIBS += -L${WORLD}/lib -L${WORLD}/usr/lib
66: _EOF
67: cat >$ROOTFS_CONF <<_EOF
1.3 misho 68: srcdirs ${BSDSRC}/tools/tools ${BSDSRC}/tools/tools/ath
69: srcdirs ${BSDSRC}/release/picobsd/tinyware
1.1 misho 70: srcdirs ${BSDSRC}/bin ${BSDSRC}/sbin ${BSDSRC}/libexec ${BSDSRC}/cddl/sbin ${BSDSRC}/sbin/ggate
1.3 misho 71: srcdirs ${BSDSRC}/usr.bin ${BSDSRC}/usr.sbin ${BSDSRC}/usr.sbin/wpa
72: srcdirs ${BSDSRC}/secure/usr.bin ${BSDSRC}/secure/usr.sbin ${BSDSRC}/secure/libexec
73:
74: buildopts -DNO_PAM -DNO_KERBEROS WITHOUT_PAM_SUPPORT=yes WITHOUT_KERBEROS_SUPPORT=yes WITHOUT_KERBEROS=yes
75: buildopts TARGET=${TARGET} TARGET_ARCH=${TARGET_ARCH} MAKEOBJDIRPREFIX=${BSDOBJ}/elwix
1.1 misho 76: _EOF
77: cat $CFGDIR/$ROOTFS_CONF >>$ROOTFS_CONF
78:
1.3 misho 79: . ${CENV}
80: install -d ${BSDOBJ}/elwix
1.6.2.3 ! misho 81: crunchgen -f -o -p ${BSDOBJ}/elwix -h $ROOTFS_MKDIR/$MKH -m $MKF -c elwix.c -e elwix $ROOTFS_CONF
1.1 misho 82: cd -
83: }
84:
85: build_elwix()
86: {
87: echo "+++ Build ELWIX RootFS firmware ..."
1.6.2.3 ! misho 88: cd $ROOTFS_MKDIR
1.3 misho 89: . ${CENV}
90: MAKEOBJDIRPREFIX=${BSDOBJ}/elwix
1.1 misho 91: make -f $MKF clean
92: make -f $MKF
1.3 misho 93: if [ $? -ne 0 ]; then
94: exit 1
95: fi
1.1 misho 96: cd -
97: }
98:
99: build_rootdir()
100: {
101: echo "+++ Build RootFS directory ..."
102: cd $ROOTFS
103:
104: install -d bin;
105: install -d dev;
106: install -d elwix;
107: install -d elwix/etc;
1.3 misho 108: install -d libexec;
1.1 misho 109: install -d mnt;
110: install -d -m 0555 proc;
111: install -d sbin;
112: install -d -m 1777 tmp;
113: install -d usr;
1.3 misho 114: install -d usr/bin;
115: install -d usr/lib;
116: install -d usr/libexec;
117: install -d usr/sbin;
1.1 misho 118: install -d var;
1.3 misho 119: install -d var/sys;
1.1 misho 120:
121: ln -fs /usr/lib lib;
122:
123: ln -fs /elwix/etc etc;
124: ln -fs /elwix/exports exports;
125: ln -fs /elwix/home home;
126: ln -fs /elwix/root root;
127: ln -fs /elwix/tftpboot tftpboot;
128:
129: cd -
130: }
131:
132: install_rootfs()
133: {
134: BIN="${ROOTFS}/bin"
135: SBIN="${ROOTFS}/sbin"
1.3 misho 136: UBIN="${ROOTFS}/usr/bin"
137: LIBEXEC="${ROOTFS}/usr/libexec"
1.1 misho 138: ETC="${ROOTFS}/elwix/etc"
139:
1.3 misho 140: PRG="/sbin/elwix"
141: LNPRG="${SBIN}/elwix"
142:
1.1 misho 143: echo "+++ Install ELWIX into RootFS directory ..."
1.6.2.3 ! misho 144: install $ROOTFS_MKDIR/elwix $SBIN
1.1 misho 145:
146: InstallList ${ELWIX_ROOTFS} ${WORLD} ${ROOTFS}
147:
1.2 misho 148: InstallDir ${ROOTFS_ETC} $ETC
1.1 misho 149:
1.3 misho 150: # ln -s /usr/sbin/nologin $SBIN
1.1 misho 151:
152: ln -s $PRG $BIN/test
153: ln -s $PRG $BIN/\[
154: ln -s $PRG $BIN/cat
155: ln -s $PRG $BIN/chflags
156: ln -s $PRG $BIN/chio
157: ln -s $PRG $BIN/chmod
158: ln -s $PRG $BIN/cp
159: ln -s $PRG $BIN/date
160: ln -s $PRG $BIN/dd
161: ln -s $PRG $BIN/df
162: ln -s $PRG $BIN/domainname
163: ln -s $PRG $BIN/echo
164: ln -s $PRG $BIN/expr
165: ln -s $PRG $BIN/hostname
166: ln -s $PRG $BIN/kenv
167: ln -s $PRG $BIN/kill
168: ln -s $PRG $BIN/ln
169: ln -s $PRG $BIN/link
170: ln -s $PRG $BIN/ls
171: ln -s $PRG $BIN/mkdir
172: ln -s $PRG $BIN/mv
173: ln -s $PRG $BIN/pax
174: ln -s $PRG $BIN/pkill
175: ln -s $PRG $BIN/pgrep
176: ln -s $PRG $BIN/sh
177: ln -s $PRG $BIN/-sh
178: ln -s $PRG $BIN/ps
179: ln -s $PRG $BIN/pwait
180: ln -s $PRG $BIN/pwd
181: ln -s $PRG $BIN/realpath
182: ln -s $PRG $BIN/rm
183: ln -s $PRG $BIN/unlink
184: ln -s $PRG $BIN/rmdir
185: ln -s $PRG $BIN/sleep
186: ln -s $PRG $BIN/stty
187: ln -s $PRG $BIN/sync
188: ln -s $PRG $BIN/uuidgen
189:
1.3 misho 190: ln -s $PRG $BIN/true
191: ln -s $PRG $BIN/false
192: ln -s $PRG $BIN/basename
193: ln -s $PRG $BIN/tail
194: ln -s $PRG $BIN/nc
195: ln -s $PRG $BIN/w
196: ln -s $PRG $BIN/head
197: ln -s $PRG $BIN/uname
198: ln -s $PRG $BIN/tset
199: ln -s $PRG $BIN/vmstat
200: ln -s $PRG $BIN/systat
201: ln -s $PRG $BIN/tput
202: ln -s $PRG $BIN/grep
203: ln -s $PRG $BIN/awk
204: ln -s $PRG $BIN/less
205: ln -s $PRG $BIN/gzip
206: ln -s $PRG $BIN/cap_mkdb
207: ln -s $PRG $BIN/sed
208: ln -s $PRG $BIN/vi
209: ln -s $PRG $BIN/du
210: ln -s $PRG $BIN/getopt
211: ln -s $PRG $BIN/logger
212: ln -s $PRG $BIN/nice
213: ln -s $PRG $BIN/nohup
214: ln -s $PRG $BIN/seq
215: ln -s $PRG $BIN/sockstat
216: ln -s $PRG $BIN/stat
217: ln -s $PRG $BIN/tee
218: ln -s $PRG $BIN/tftp
219: ln -s $PRG $BIN/touch
220: ln -s $PRG $BIN/wc
221: ln -s $PRG $BIN/xargs
222: ln -s $PRG $BIN/printenv
223: ln -s $PRG $BIN/egrep
224: ln -s $PRG $BIN/fgrep
225: ln -s $PRG $BIN/tar
226: ln -s $PRG $BIN/cpio
227: ln -s $PRG $BIN/nawk
228: ln -s $PRG $BIN/gunzip
229: ln -s $PRG $BIN/gzcat
230: ln -s $PRG $BIN/zcat
231: ln -s $PRG $BIN/more
232: ln -s $PRG $BIN/reset
233: ln -s $PRG $BIN/readlink
234: ln -s $PRG $BIN/uptime
235: ln -s $PRG $BIN/bzip2
236: ln -s $PRG $BIN/bunzip2
237: ln -s $PRG $BIN/bzcat
238:
1.1 misho 239: ln -s $PRG $SBIN/bsdlabel
240: ln -s $PRG $SBIN/disklabel
241: ln -s $PRG $SBIN/camcontrol
242: ln -s $PRG $SBIN/comcontrol
243: ln -s $PRG $SBIN/conscontrol
244: ln -s $PRG $SBIN/devfs
245: ln -s $PRG $SBIN/dhclient
246: ln -s $PRG $SBIN/dmesg
247: ln -s $PRG $SBIN/dump
248: ln -s $PRG $SBIN/rdump
249: ln -s $PRG $SBIN/dumpon
250: ln -s $PRG $SBIN/fdisk
251: ln -s $PRG $SBIN/fsck
252: ln -s $PRG $SBIN/fsck_ffs
253: ln -s $PRG $SBIN/fsck_ufs
254: ln -s $PRG $SBIN/fsck_4.2bsd
255: ln -s $PRG $SBIN/fsck_msdosfs
1.3 misho 256: ln -s $PRG $SBIN/etherswitchcfg
1.1 misho 257: ln -s $PRG $SBIN/-geom
258: ln -s $PRG $SBIN/glabel
259: ln -s $PRG $SBIN/gpart
1.3 misho 260: ln -s $PRG $SBIN/graid
1.1 misho 261: ln -s $PRG $SBIN/growfs
262: ln -s $PRG $SBIN/hastctl
263: ln -s $PRG $SBIN/hastd
264: ln -s $PRG $SBIN/ifconfig
265: ln -s $PRG $SBIN/init
266: ln -s $PRG $SBIN/ipfw
267: ln -s $PRG $SBIN/iscontrol
268: ln -s $PRG $SBIN/kldconfig
269: ln -s $PRG $SBIN/kldload
270: ln -s $PRG $SBIN/kldstat
271: ln -s $PRG $SBIN/kldunload
272: ln -s $PRG $SBIN/ldconfig
273: ln -s $PRG $SBIN/md5
274: ln -s $PRG $SBIN/sha1
275: ln -s $PRG $SBIN/sha256
276: ln -s $PRG $SBIN/rmd160
277: ln -s $PRG $SBIN/mdconfig
278: ln -s $PRG $SBIN/mdmfs
279: ln -s $PRG $SBIN/mount_mfs
280: ln -s $PRG $SBIN/mknod
281: ln -s $PRG $SBIN/mksnap_ffs
282: ln -s $PRG $SBIN/mount
283: ln -s $PRG $SBIN/mount_cd9660
284: ln -s $PRG $SBIN/mount_msdosfs
285: ln -s $PRG $SBIN/mount_nfs
1.6.2.3 ! misho 286: # ln -s $PRG $SBIN/mount_ntfs
1.1 misho 287: ln -s $PRG $SBIN/mount_nullfs
288: ln -s $PRG $SBIN/mount_udf
289: ln -s $PRG $SBIN/mount_unionfs
290: ln -s $PRG $SBIN/newfs
291: ln -s $PRG $SBIN/newfs_msdos
292: ln -s $PRG $SBIN/nfsiod
293: ln -s $PRG $SBIN/nos-tun
1.3 misho 294: ln -s $PRG $SBIN/nvmecontrol
1.1 misho 295: ln -s $PRG $SBIN/pfctl
296: ln -s $PRG $SBIN/pflogd
297: ln -s $PRG $SBIN/quotacheck
298: ln -s $PRG $SBIN/reboot
299: ln -s $PRG $SBIN/halt
300: ln -s $PRG $SBIN/fastboot
301: ln -s $PRG $SBIN/fasthalt
302: ln -s $PRG $SBIN/recoverdisk
303: ln -s $PRG $SBIN/restore
304: ln -s $PRG $SBIN/rrestore
305: ln -s $PRG $SBIN/route
306: ln -s $PRG $SBIN/rtsol
1.3 misho 307: ln -s $PRG $SBIN/shutdown
1.1 misho 308: ln -s $PRG $SBIN/savecore
309: ln -s $PRG $SBIN/swapon
310: ln -s $PRG $SBIN/swapoff
311: ln -s $PRG $SBIN/swapctl
312: ln -s $PRG $SBIN/sysctl
313: ln -s $PRG $SBIN/tunefs
314: ln -s $PRG $SBIN/umount
315: ln -s $PRG $SBIN/zfs
316: ln -s $PRG $SBIN/zpool
317:
1.3 misho 318: ln -s $PRG $SBIN/ping
319: ln -s $PRG $SBIN/ping6
320: ln -s $PRG $SBIN/traceroute
321: ln -s $PRG $SBIN/traceroute6
322:
323: ln -s $PRG $SBIN/chown
324: ln -s $PRG $SBIN/pwd_mkdb
325: ln -s $PRG $SBIN/arp
326: ln -s $PRG $SBIN/gpioctl
327: ln -s $PRG $SBIN/hostapd
328: ln -s $PRG $SBIN/hostapd_cli
329: ln -s $PRG $SBIN/wpa_supplicant
330: ln -s $PRG $SBIN/wpa_cli
331: ln -s $PRG $SBIN/wpa_passphrase
332: ln -s $PRG $SBIN/wake
333: ln -s $PRG $SBIN/watchdog
334: ln -s $PRG $SBIN/watchdogd
335: ln -s $PRG $SBIN/inetd
336: ln -s $PRG $SBIN/wlandebug
337: ln -s $PRG $SBIN/chroot
338: ln -s $PRG $SBIN/i2c
339: ln -s $PRG $SBIN/iostat
340: ln -s $PRG $SBIN/jail
341: ln -s $PRG $SBIN/jexec
342: ln -s $PRG $SBIN/jls
343: ln -s $PRG $SBIN/ndp
344: ln -s $PRG $SBIN/newsyslog
345: ln -s $PRG $SBIN/nologin
346: ln -s $PRG $SBIN/pstat
347: ln -s $PRG $SBIN/rtadvctl
348: ln -s $PRG $SBIN/rtadvd
349: ln -s $PRG $SBIN/rtsold
350: ln -s $PRG $SBIN/syslogd
351: ln -s $PRG $SBIN/setfib
352: ln -s $PRG $SBIN/swapinfo
353: ln -s $PRG $SBIN/chgrp
354:
355: ln -s $PRG $UBIN/login
356: ln -s $PRG $UBIN/passwd
357:
358: ln -s $PRG $LIBEXEC/getty
359: ln -s $PRG $LIBEXEC/tftpd
360:
361: strip -s $LNPRG
362:
1.1 misho 363: chown -hR root:wheel $ROOTFS
1.3 misho 364:
365: echo "+++ ELWIX clean CVS tags ..."
366: CleanCVS $ETC
367: CleanCVS $ETC/etc
1.1 misho 368: }
369:
370: build_image()
371: {
372: echo "+++ Build ELWIX RootFS image ..."
373: makefs -s ${ROOTFS_SIZE} -o minfree=0 $REL/$ROOTFS_IMG $ROOTFS
374: }
375:
376: install_image()
377: {
378: echo "+++ Install ELWIX RootFS Image into kernel ..."
1.6.2.3 ! misho 379: START=`strings -td $KERNEL_ROOTFS | grep "MFS Filesystem" | cut -d ' ' -f 1 | head -1`
! 380: STOP=`strings -td $KERNEL_ROOTFS | grep "MFS Filesystem" | cut -d ' ' -f 1 | tail -1`
1.1 misho 381: STOP=$(($STOP + 1))
382:
1.6.2.3 ! misho 383: head -c $START $KERNEL_ROOTFS >$NEWKERN
1.1 misho 384: cat $REL/$ROOTFS_IMG >>$NEWKERN
1.6.2.3 ! misho 385: tail -c +$STOP $KERNEL_ROOTFS >>$NEWKERN
1.1 misho 386:
387: cd $REL
1.6.2.3 ! misho 388: gzip -9 $KRNNAME
1.1 misho 389: cd -
390: }
391:
392: ### main()
393: if SnitVer ${WORLD}/elwix.ver; then
394: clean_elwix
395: prepare_elwix
396: build_elwix
397:
398: build_rootdir
399: install_rootfs
400:
401: build_image
402: install_image
403: else
404: echo "Skipped ELWIX RootFS build ..."
405: fi
406:
407: echo "+++ Complete build ELWIX RootFS"
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>