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