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