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