Annotation of elwix/build_romfs.sh, revision 1.6.2.9

1.1       misho       1: #!/bin/sh
                      2: #
                      3: # ELWIX Build script for ELWIX userland RomFS firmware
                      4: #
                      5: # (C) AITNET ltd - Sofia/Bulgaria <office@aitnet.org>
                      6: #    by Michael Pounov <misho@elwix.org>
                      7: #
1.6.2.9 ! misho       8: # $Id: build_romfs.sh,v 1.6.2.8 2013/07/31 13:31:39 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 - RomFS must build under root !?!"
                     29:        echo
                     30:        exit 1
                     31: fi
                     32: 
                     33: clean_romfs()
                     34: {
                     35:        echo "+++ Clean ELWIX RomFS firmware ..."
                     36:        chflags -Rf noschg $ROMFS
                     37:        rm -rf $ROMFS
                     38: 
                     39:        echo "+++ Clean ELWIX RomFS image ..."
                     40:        rm -f $REL/$ROMFS_IMG
                     41: }
                     42: 
                     43: build_romfs()
                     44: {
                     45:        echo "+++ Build ELWIX RomFS directory ..."
1.6.2.2   misho      46:        mkdir -p $ROMFS
1.1       misho      47: 
1.6.2.2   misho      48:        cd $ROMFS
1.1       misho      49: 
                     50:        install -d bin;
1.6.2.2   misho      51:        install -d boot;
                     52:        install -d boot/defaults;
                     53:        install -d boot/firmware;
                     54:        install -d boot/kernel;
                     55:        install -d boot/modules;
                     56:        install -d boot/zfs;
                     57:        install -d dev;
                     58:        install -d elwix;
1.6.2.4   misho      59:        install -d elwix/altroot;
                     60:        install -d elwix/altroot/var;
                     61:        install -d elwix/cf;
1.6.2.2   misho      62:        install -d elwix/etc;
1.6.2.6   misho      63:        install -d -o 883 -g 883 elwix/etc/mqtt;
1.6.2.2   misho      64:        install -d elwix/exports;
                     65:        install -d elwix/home;
                     66:        install -d -m 0750 elwix/root;
                     67:        install -d -m 0750 elwix/root/.ssh;
                     68:        install -d elwix/system;
                     69:        install -d elwix/tftpboot;
1.6.2.8   misho      70:        install -d elwix/pkg;
                     71:        install -d elwix/pkg/bin;
                     72:        install -d elwix/pkg/lib;
                     73:        install -d elwix/pkg/libexec;
                     74:        install -d elwix/pkg/libdata;
                     75:        install -d elwix/pkg/sbin;
1.6.2.2   misho      76:        ln -fs /elwix/etc etc;
                     77:        ln -fs /elwix/exports exports;
                     78:        ln -fs /elwix/home home;
                     79:        ln -fs /elwix/root root;
                     80:        ln -fs /elwix/system system;
                     81:        ln -fs /elwix/tftpboot tftpboot;
                     82:        install -d mnt;
                     83:        install -d -m 0555 proc;
1.1       misho      84:        install -d sbin;
1.6.2.7   misho      85:        install -d tmp;
1.6.2.2   misho      86:        install -d usr;
                     87:        install -d usr/bin;
                     88:        install -d usr/lib;
                     89:        ln -fs /usr/lib lib;
                     90:        install -d usr/lib/engines;
                     91:        install -d usr/lib/geom;
                     92:        install -d usr/lib32;
                     93:        install -d usr/libdata;
                     94:        install -d usr/libexec;
                     95:        ln -fs /usr/libexec libexec;
                     96:        install -d usr/local;
                     97:        install -d usr/local/bin;
                     98:        install -d usr/local/lib;
                     99:        install -d usr/local/libexec;
                    100:        install -d usr/local/libdata;
                    101:        install -d usr/local/sbin;
                    102:        install -d usr/sbin;
                    103:        install -d usr/share;
                    104:        install -d usr/share/misc;
                    105:        install -d usr/share/skel;
                    106:        install -d usr/share/zoneinfo;
                    107:        install -d var;
1.1       misho     108: 
                    109:        chown -hR root:wheel .
                    110:        cd -
                    111: }
                    112: 
                    113: install_romfs()
                    114: {
1.6.2.2   misho     115:        LIBS="${ROMFS}/usr/lib"
                    116:        LIBEXEC="${ROMFS}/usr/libexec"
                    117:        LIBDATA="${ROMFS}/usr/libdata"
                    118:        BIN="${ROMFS}/bin"
                    119:        UBIN="${ROMFS}/usr/bin"
                    120:        SBIN="${ROMFS}/sbin"
                    121:        USBIN="${ROMFS}/usr/sbin"
                    122:        SHARE="${ROMFS}/usr/share"
1.3       misho     123:        SKEL="${SHARE}/skel"
                    124:        MISC="${SHARE}/misc"
1.1       misho     125: 
                    126:        echo "+++ Install ELWIX RomFS software ..."
                    127:        if [ -r ${BSDSRC}/release/picobsd/mfs_tree/etc/termcap ]; then
                    128:                install -v -m 644 ${BSDSRC}/release/picobsd/mfs_tree/etc/termcap $MISC;
                    129:                install -v -m 644 ${BSDSRC}/release/picobsd/mfs_tree/etc/services $MISC;
                    130:        else
                    131:                install -v -m 644 ${BSDSRC}/etc/termcap.small $MISC/termcap;
                    132:                install -v -m 644 ${BSDSRC}/etc/services $MISC;
                    133:        fi
                    134: 
                    135:        install -v ${CFGDIR}/root.skel/cshrc $SKEL/dot.cshrc;
                    136:        install -v ${CFGDIR}/root.skel/login $SKEL/dot.login;
                    137:        install -v ${CFGDIR}/root.skel/logout $SKEL/dot.logout;
                    138:        install -v ${CFGDIR}/root.skel/profile $SKEL/dot.profile;
                    139:        install -v ${CFGDIR}/root.skel/vimrc $SKEL/dot.vimrc;
                    140: 
1.6.2.3   misho     141:        find ${WORLD}/libexec -type f -name ld-elf.so\* -exec install {} $LIBEXEC \;
                    142: 
1.1       misho     143:        find ${WORLD}/lib -type f -name \*.so.\* -exec install {} $LIBS \;
                    144:        find ${WORLD}/lib -type f -name libalias_\*.so -exec install {} $LIBS \;
                    145:        find ${WORLD}/lib/geom -type f -name \*.so -exec install {} $LIBS/geom \;
                    146:        find ${WORLD}/usr/lib -type f -name \*.so.\* -exec install {} $LIBS \;
1.6.2.2   misho     147:        find ${WORLD}/usr/lib/engines -type f -name \*.so -exec install {} $LIBS/engines \;
1.1       misho     148: 
                    149:        InstallList ${ELWIX_ROMFS} ${WORLD} ${ROMFS}
                    150: 
1.6.2.9 ! misho     151:        ln ${BIN}/tcsh ${UBIN}/tcsh
        !           152: 
1.6.2.2   misho     153:        InstallDir ${WORLD}/usr/local/bin $UBIN
                    154:        InstallDir ${WORLD}/usr/local/sbin $USBIN
1.6.2.1   misho     155:        InstallFiles \*.so\* ${WORLD}/usr/local/lib $LIBS
1.2       misho     156:        InstallDir ${WORLD}/usr/local/libdata $LIBDATA
                    157: 
1.6.2.2   misho     158:        chown -R root:wheel $SBIN $BIN $USBIN $UBIN $LIBDATA $LIBEXEC $LIBS
1.3       misho     159: }
                    160: 
                    161: build_image2()
                    162: {
                    163:        echo "+++ Build ELWIX Firmware secondary image ..."
                    164: 
                    165:        cd ${ROMFS_USR2}
                    166:        pax -w -z -v -f${REL}/${ROMFS_IMG2} .
                    167:        cd -
                    168: 
                    169: # Stop using uzip fs
                    170: #      makefs -ominfree=0,bsize=8192,fsize=1024,optimization=space -s${ROMFS_SIZE2} \
                    171: #              ${REL}/${ROMFS_IMG2} ${ROMFS_USR2}
                    172: 
                    173: #      MDDEV=$(mdconfig -a -t vnode -f ${REL}/${ROMFS_IMG2});
                    174: #      tunefs -L elwixFirmware2 /dev/$MDDEV;
                    175: #      mdconfig -d -u $MDDEV;
                    176: 
                    177: #      mkuzip -s 8192 -o ${REL}/${ROMFS_IMG2}.uzip ${REL}/${ROMFS_IMG2};
                    178: #      mv ${REL}/${ROMFS_IMG2}.uzip ${REL}/${ROMFS_IMG2}
                    179: }
                    180: 
                    181: install_romfs2()
                    182: {
                    183:        LIBS="${ROMFS_USR2}/lib"
                    184:        LIBEXEC="${ROMFS_USR2}/libexec"
                    185:        LIBDATA="${ROMFS_USR2}/libdata"
                    186:        BIN="${ROMFS_USR2}/bin"
                    187:        SBIN="${ROMFS_USR2}/sbin"
                    188: 
                    189:        echo "+++ Install ELWIX RomFS secondary software ..."
                    190: 
                    191:        install -d ${PKGDIR}/bin
                    192: #      InstallDir ${PKGDIR}/bin $BIN
                    193:        install -d ${PKGDIR}/sbin
                    194:        InstallDir ${PKGDIR}/sbin $SBIN
                    195: 
1.4       misho     196:        StripFiles \*.so\* ${PKG}/lib
1.2       misho     197:        InstallFiles \*.so\* ${PKG}/lib $LIBS
1.4       misho     198:        StripFiles \* ${PKG}/libexec
1.2       misho     199:        InstallFiles \* ${PKG}/libexec $LIBEXEC
1.4       misho     200:        StripFiles \* ${PKG}/libdata
1.2       misho     201:        InstallFiles \* ${PKG}/libdata $LIBDATA
1.4       misho     202:        StripFiles \* ${PKG}/bin
1.2       misho     203:        InstallFiles \* ${PKG}/bin $BIN
1.4       misho     204:        StripFiles \* ${PKG}/sbin
1.2       misho     205:        InstallFiles \* ${PKG}/sbin $SBIN
                    206: 
                    207:        chown -R root:wheel $SBIN $BIN $LIBDATA $LIBEXEC $LIBS
1.1       misho     208: }
                    209: 
                    210: ### main()
1.3       misho     211: clean_romfs
                    212: build_romfs
1.1       misho     213: 
1.3       misho     214: install_romfs
1.1       misho     215: 
1.6.2.7   misho     216: #install_romfs2
                    217: #build_image2
1.1       misho     218: 
                    219: echo "+++ Complete build ELWIX RomFS"

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>