#!/bin/bash # 26.08.2004 ################################################### # function install_direcories # # install_direcories $PKGNAME # ################################################### install_directories() { local PKGNAME PKGNAME=$1 if [ -e ${BUILDDIR}/${PKGNAME}/.dirs ] then #sets fieldseperator to "§" instead of " " IFS=§ while read pathto posix user group do if [ ! -z $pathto ] then echo -e "\t>>> DIR: ${ROOT}$pathto" install -m $posix -o $user -g $group -d ${ROOT}${pathto} fi done < ${BUILDDIR}/${PKGNAME}/.dirs #very important: unsetting the '§' fieldseperator unset IFS else fatal_error .dir fi } ################################################### # function install_files # # install_files $PKGNAME # ################################################### install_files(){ local PKGNAME local RETVAL local COUNTER local FILENAME local DESTINATION PKGNAME=$1 if [ -e ${BUILDDIR}/${PKGNAME}/.files ] then #sets fieldseperator to "§" instead of " " IFS=§ while read pathto posix user group mtime md5sum do if [ ! -z $pathto ] then echo -e "\t>>> FILE: ${ROOT}${pathto}" ### kleiner notfall fix ### if [ ! -d `dirname $pathto` ] then install -d `dirname ${ROOT}${pathto}` fi FILE="${pathto}" install -m ${posix} -o ${user} -g ${group} \ ${BUILDDIR}/${PKGNAME}/binfiles/$FILE \ ${ROOT}${pathto} fi done < ${BUILDDIR}/${PKGNAME}/.files #very important: unsetting the '§' fieldseperator unset IFS else fatal_error .files fi } ################################################### # function install_symlinks # # install_symlinks $PKGNAME # ################################################### install_symlinks() { local PKGNAME PKGNAME=$1 if [ -e ${BUILDDIR}/${PKGNAME}/.symlinks ] then #sets fieldseperator to "§" instead of " " IFS=§ while read pathto posix link mtime do if [ ! -z $pathto ] then echo -e "\t>>> LINK: ${ROOT}${pathto}" ln -snf $link ${ROOT}${pathto} fi done < ${BUILDDIR}/${PKGNAME}/.symlinks #very important: unsetting the '§' fieldseperator unset IFS else fatal_error .symlinks fi } ################################################### # function install_blockdevices # # install_blockdevices $PKGNAME # ################################################### install_blockdevices() { local PKGNAME PKGNAME=$1 if [ -e ${BUILDDIR}/${PKGNAME}/.pipes ] then #sets fieldseperator to "§" instead of " " IFS=§ while read pathto posix do if [ ! -z $pathto ] then echo -e "\t>>> PIPE: ${ROOT}${pathto}" mkfifo -m $posix ${ROOT}${pathto} fi done < ${BUILDDIR}/${PKGNAME}/.pipes #very important: unsetting the '§' fieldseperator unset IFS else fatal_error .pipes fi } ################################################### # function install_characterdevices # # install_characterdevices $PKGNAME # ################################################### install_characterdevices() { local PKGNAME PKGNAME=$1 if [ -e ${BUILDDIR}/${PKGNAME}/.char ] then #sets fieldseperator to "§" instead of " " IFS=§ while read pathto posix do if [ ! -z $pathto ] then echo -e "\t>>> CHAR: ${ROOT}${pathto}" mknode -m $posix -c ${ROOT}${pathto} fi done < ${BUILDDIR}/${PKGNAME}/.char #very important: unsetting the '§' fieldseperator unset IFS else fatal_error .char fi #very important: unsetting the '§' fieldseperator unset IFS } ################################################### # function build_doinstall # # build_doinstall $PKGNAME # # NOTE: this is an wrapper do install packages # ################################################### build_doinstall() { #this is only a wrapper # NOTE: # !! we use § as field seperator !! # doing so prevent us to get errors by filenames with spaces local PKGNAME PKGNAME=$1 install_directories ${PKGNAME} install_files ${PKGNAME} install_symlinks ${PKGNAME} install_blockdevices ${PKGNAME} install_characterdevices ${PKGNAME} } usage(){ echo echo -e "Usage:" echo -e "$(basename $0) /path/to/foo.mpk" echo echo -e "Use ROOT=/path/to/install-location" echo -e "to overide the default-root '/'" echo exit 1 } [ -z "$1" ] && usage PKGFILE=$1 PKGNAME=$(basename ${PKGFILE} .mpk) if [ -z "${BUILDDIR}" ] then export BUILDDIR=/var/tmp/magebuild install -d ${BUILDDIR} fi echo -e "\nInstallation of Package: ${COLGREEN}${PKGNAME/-${ARCH}/}${COLDEFAULT}\n" echo -en "Unpacking Package ... " tar xjmf ${PKGFILE} -C ${BUILDDIR} echo "done" #fake root ? if [ -n "${ROOT}" ] then echo echo "Installing package to fake ROOT '${ROOT}'" echo fi #build_doinstall build_doinstall ${PKGNAME} #cleanup if [ -d ${BUILDDIR}/${PKGNAME} ] then rm -rf ${BUILDDIR}/${PKGNAME} fi echo -e "\nPackage '${PKGNAME/-${ARCH}/}' sucessfully installed.\n"