#!/bin/bash # new header not using prereqs if [ "$1" = "prereqs" ]; then echo "" exit 0 fi # Hooks for install binaries for tcos boot # . /usr/share/initramfs-tools/hook-functions # read conf file => /etc/tcos/initramfs.conf . $CONFDIR/initramfs.conf # read from env vars TCOS_BOOT TCOS_BOOT=$(env| awk -F "=" '/^TCOS_BOOT=/ {print $2}') if [ "${TCOS_BOOT}" != "" ]; then BOOT=$TCOS_BOOT fi if [ "${BOOT}" = "tcos" ]; then . $CONFDIR/tcos.conf [ -f $CONFDIR/version.conf ] && . $CONFDIR/version.conf . $TCOS_DIR/tcos-generation-functions.sh for tpl in $(tcos_get_templates); do _verbose "(tcosbin) loading template $(basename $tpl)" . $tpl done # load forced settings for derivatives if [ -d $CONFDIR/conf.d/ ]; then for file in $CONFDIR/conf.d/tcos*conf; do [ -e $file ] && . $file done fi # load hooks-addons (small files with group of packages inside) _files=$(ls -1 ${TCOS_DIR}/hooks-addons/ | grep -v -e .dpkg -e .svn) for addon in $_files ; do _verbose "(tcosbin) LOADING: system addon: ${addon}" . ${TCOS_DIR}/hooks-addons/${addon} done # load hooks-addons in /etc/tcos (small files with group of packages inside) _files=$(ls -1 ${TCOS_CONF}/hooks-addons/ | grep -v -e dpkg -e .svn) for addon in $_files ; do _echo " LOADING: personal addon: ${TCOS_CONF}/hooks-addons/${addon}" . ${TCOS_CONF}/hooks-addons/${addon} done # read all files in ${TCOS_CONF}/hacking/ and load it ( personal files ) _files=$(ls -1 ${TCOS_CONF}/hacking/ | grep -v -e dpkg -e .svn) for hack in $_files ; do if [ "${hack}" != "template" ]; then _echo " LOADING: hack: ${TCOS_CONF}/hacking/${hack}" fi . ${TCOS_CONF}/hacking/${hack} done # to be sure that /usr have files and not links # we search links delete them and put file instead convert_links2files # read from env vars TCOS_BOOT TCOS_ENV_DISABLE_SQUASHFS=$(env| awk -F "=" '/^TCOS_ENV_DISABLE_SQUASHFS=/ {print $2}') if [ "${TCOS_ENV_DISABLE_SQUASHFS}" != "" ]; then TCOS_DISABLE_SQUASHFS=$TCOS_ENV_DISABLE_SQUASHFS fi MKSQUASHFS=mksquashfs [ -x /usr/bin/mksquashfs ] && MKSQUASHFS=/usr/bin/mksquashfs [ -x /usr/sbin/mksquashfs ] && MKSQUASHFS=/usr/sbin/mksquashfs if [ -z $TCOS_DISABLE_SQUASHFS ]; then # create usr.squashfs if [ $(env | grep -c ^TCOS_SUFFIX) = 1 ]; then TCOS_SUFFIX=$(env | grep ^TCOS_SUFFIX | awk -F "=" '{print $2}') echo "SQUASHFS_FILE=\"usr${TCOS_SUFFIX}-${version}.squashfs\"" >> $DESTDIR/conf/tcos.conf fi SQUASHFS_FILE="usr${TCOS_SUFFIX}-${version}.squashfs" _echo " Creating ${SQUASHFS_FILE} of /usr" mkdir -p $DESTDIR/mnt/tmp $MKSQUASHFS $DESTDIR/usr/ $DESTDIR/mnt/tmp/${SQUASHFS_FILE} > /tmp/tcos-mksquashfs.log 2>&1 # check for mksquashfs errors if [ $? != 0 ]; then _echo " ERROR:" _echo " mksquashfs error" _echo "#############################################" cat /tmp/tcos-mksquashfs.log _echo "#############################################" fi rm -f /tmp/tcos-mksquashfs.log # mksquashfs create files with 700 rights, change to 644 chmod 644 $DESTDIR/mnt/tmp/${SQUASHFS_FILE} rm -rf $DESTDIR/usr/ && mkdir $DESTDIR/usr # usplash/plymouth support outside squashfs . ${TCOS_DIR}/hooks-addons/90usplash . ${TCOS_DIR}/hooks-addons/90plymouth # overwrite TCOS_SQUASHFS from shell env var # this allow to create cdrom with usr.squashfs embedded if [ $(env | grep -c ^TCOS_SQUASHFS) = 1 ]; then TCOS_SQUASHFS=$(env | grep ^TCOS_SQUASHFS | awk -F "=" '{print $2}') _echo "DEBUG: overwrite TCOS_SQUASHFS=$TCOS_SQUASHFS" else if [ "${TCOS_SQUASHFS}" = "1" ] ; then _echo " Moving ${SQUASHFS_FILE} to ${TFTP_DIR}" mv $DESTDIR/mnt/tmp/${SQUASHFS_FILE} ${TFTP_DIR} fi fi # end of TCOS_SQUASHFS fi # end of TCOS_DISABLE_SQUASHFS TCOS_INCLUDE_INIT=1 . ${TCOS_DIR}/hooks-addons/00init unset TCOS_INCLUDE_INIT # clean /lib/tls if needed if [ -d $DESTDIR/lib/tls ]; then _echo " * WARNING: /lib/tls exists in image" for lib in ${DESTDIR}/lib/tls/*; do tlslib=$lib notlslib=$(echo $lib | sed 's/tls\///g') notlslib1=$(basename $lib) notlslib2=$(basename $lib | awk -F "." '{print $1}') if [ -f $notlslib ]; then _echo "WARNING rm -f $lib" elif [ -f /lib/${notlslib1} ]; then _echo "WARNING cp -a /lib/${notlslib} $DESTDIR/lib" else _echo "$tlslib not found" fi done fi # end of /lib/tls dir exists # clean /lib/i686 if needed if [ -d $DESTDIR/lib/i686 ]; then # convert symlinks to files into lib/i686 dir convert_links2files "lib/i686" for lib in $(find ${DESTDIR}/lib/i686 -type f); do i686lib=$lib noi686lib=$(echo $lib | sed 's/i686\/cmov\///g') noi686lib1=$(basename $lib) if [ -f $noi686lib ]; then rm -f $lib elif [ -f /lib/${noi686lib1} ]; then cp -f /lib/${noi686lib1} $DESTDIR/lib/ rm -f $lib else _echo "WARNING equivalent to $i686lib not found" fi done (rmdir ${DESTDIR}/lib/i686/cmov && rmdir ${DESTDIR}/lib/i686) || _echo " * WARNING can't delete /lib/i686 from image (not empty)" fi # end of /lib/i686 dir exists # clean /usr/lib/i686 if needed if [ -d $DESTDIR/usr/lib/i686 ]; then # convert symlinks to files into usr/lib/i686 dir convert_links2files "usr/lib/i686" for lib in $(find ${DESTDIR}/usr/lib/i686 -type f); do i686lib=$lib noi686lib=$(echo $lib | sed 's/i686\/cmov\///g') noi686lib1=$(basename $lib) if [ -f $noi686lib ]; then rm -f $lib elif [ -f /usr/lib/${noi686lib1} ]; then cp -f /usr/lib/${noi686lib1} $DESTDIR/usr/lib/ rm -f $lib else _echo "WARNING equivalent to $i686lib not found" fi done (rmdir ${DESTDIR}/usr/lib/i686/cmov && rmdir ${DESTDIR}/usr/lib/i686) || _echo " * WARNING can't delete /usr/lib/i686 from image (not empty)" fi # end of /usr/lib/i686 dir exists if [ $TCOS_DISABLE_ACPI ]; then stat_before rm -rf $DESTDIR/lib/modules/*/drivers/md/ rm -rf $DESTDIR/lib/modules/*/drivers/acpi/ rm -rf $DESTDIR/scripts/usb* rm -rf $DESTDIR/scripts/live* rm -rf $DESTDIR/scripts/local* rm -rf $DESTDIR/scripts/casper* rm -rf $DESTDIR/scripts/init-premount/thermal rm -rf $DESTDIR/sbin/mdadm rm -rf $DESTDIR/sbin/mdrun rm -rf $DESTDIR/sbin/vgchange rm -rf $DESTDIR/sbin/cryptsetup rm -rf $DESTDIR/sbin/dmsetup rm -rf $DESTDIR/lib/lvm* rm -rf ${DESTDIR}/lib/modules/${version}/kernel/drivers/md/ rm -rf ${DESTDIR}/lib/modules/${version}/kernel/drivers/scsi manual_add_modules scsi_mod manual_add_modules sd_mod manual_add_modules sr_mod stat_after "Disable ACPI and RAID support" else _verbose "(tcosbin)TCOS_DISABLE_ACPI not set" fi # read shell env variables to search TCOS_ALL_MODULES if [ $(env | grep -c ^TCOS_ALL_MODULES) = 1 ]; then TCOS_ALL_MODULES=$(env | grep ^TCOS_ALL_MODULES | awk -F "=" '{print $2}') fi # create allmodules.squashfs if [ $TCOS_ALL_MODULES ]; then _echo "Running depmod of kernel ${version}" DEPMOD_ARGS="-a -F /boot/System.map-${TCOS_KERNEL}" if depmod -h 2>&1|grep -q map; then DEPMOD_ARGS="-am -F /boot/System.map-${TCOS_KERNEL}" fi depmod $DEPMOD_ARGS ${version} _echo " Creating allmodules-${version}.squashfs file" mkdir -p $DESTDIR/mnt/tmp > /dev/null 2>&1 $MKSQUASHFS /lib/modules/${version}/ $DESTDIR/mnt/tmp/allmodules-${version}.squashfs -e volatile -noappend > /dev/null 2>&1 # mksquashfs create files with 700 rights, change to 644 chmod 644 ${DESTDIR}/mnt/tmp/allmodules-${version}.squashfs _echo " Moving allmodules-${version}.squashfs to ${TFTP_DIR}" mv ${DESTDIR}/mnt/tmp/allmodules-${version}.squashfs ${TFTP_DIR} fi fi