# This file is part of the src2pkg program: # Copyright 2005-2008 Gilbert Ashley # src2pkg is released under the GNU General Public License Version 2 # This method installs all files into a 'false root' directory, the PKG_DIR. # This usually works when using DESTDIR is not supported by the Makefiles and # is less intrusive than installing to the real root directory, backing up # overwritten files and then restoring them install_to_jail_root() { echo $BLUE"Installing in jail root - "$NORMAL"Using: '$INSTALL_COMMAND $INSTALL_RULE'"$NORMAL if [ $PKG_DIR != "" ] ; then ! [ $INSTALLSENTRY_ROOT_DIR ] && INSTALLSENTRY_ROOT_DIR=${PKG_DIR} fi export INSTALLSENTRY_ROOT_DIR # The libsentry variable is INSTW_ROOTPATH # We give it a second name since INSTW_ROOTPATH gets unset # This is supposed to have been done already mkdir -p $INSTALLSENTRY_ROOT_DIR # make sure all these are unset unset INSTW_ROOTPATH unset INSTW_TRANSL unset INSTW_BACKUP unset INSTW_LOGFILE unset INSTW_DBGFILE unset INSTW_DBGLVL unset INSTW_EXCLUDE # This method installs the files in PKG_DIR/TRANSL INSTW_ROOTPATH="${INSTALLSENTRY_ROOT_DIR}" export INSTW_ROOTPATH if [ $DEBUG_FILELISTS ] ; then INSTW_LOGFILE="${CWD}/FILELIST.tmp" INSTW_DBGFILE="${CWD}/libsentry.debug" INSTW_DBGLVL=2 if cat /dev/null >"${INSTW_LOGFILE}" ; then true else echo $RED"FAILED! - "$NORMAL "Unable to prepare $INSTW_LOGFILE" exit 1 fi if cat /dev/null >"${INSTW_DBGFILE}" ; then true else echo $RED"FAILED! - "$NORMAL "Unable to prepare $INSTW_DBGFILE" exit 1 fi fi export INSTW_LOGFILE export INSTW_DBGFILE export INSTW_DBGLVL # turn the backup feature off INSTW_BACKUP=0 export INSTW_BACKUP # turn the translation fetaure on INSTW_TRANSL=1 export INSTW_TRANSL # this doesn't seem to work any other way INSTW_EXCLUDE="/dev,/proc,/tmp,/var/tmp,${INSTW_EXCLUDE}" OIFS="$IFS" IFS=',' INSTW_EXCLUDE=$(for name in $INSTW_EXCLUDE; do echo $name done | sort -u | while read elem; do echo -n "$elem," done) export INSTW_EXCLUDE IFS="$OIFS" # LD_PRELOAD="/usr/libexec/src2pkg/lib/libsentry.so" export LD_PRELOAD trap trap_int 2 ( cd $OBJ_DIR; if [[ $QUIET = "YES" ]] ; then $INSTALL_COMMAND $INSTALL_RULE &> /dev/null else $INSTALL_COMMAND $INSTALL_RULE fi ) RETVAL=$? if [ $RETVAL -eq 0 -o $RETVAL -gt 1 ] ; then unset INSTW_ROOTPATH unset LD_PRELOAD # libsentry tracks the writing of its' own logfile so a 'shadow' directory of # the current working directory gets created which must be removed # *Carefully* remove the shadow CWD from the INSTALLSENTRY_ROOT_DIR # strip off the leading '/' SHADOW_CWD=${CWD:1} # strip off the trainling subdirs to get the main base dir name SHADOW_CWD_BASE=${SHADOW_CWD%%/*} # cd into the BACKUP and then rm -rf ( cd $INSTALLSENTRY_ROOT_DIR/TRANSL && rm -rf $SHADOW_CWD_BASE ) # also remove the META directory ( cd $INSTALLSENTRY_ROOT_DIR && rm -rf META ) if [[ $(find ${INSTALLSENTRY_ROOT_DIR}/TRANSL -type f) != "" ]] ; then if [ $DEBUG ] && [ $RETVAL -gt 1 ] ; then echo $CYAN"NOTICE - "$NORMAL"Possible error($RETVAL) running '$INSTALL_LINE'" echo " This may be a false error since some files have been installed." echo " But you should check the package content just to be sure." fi # echo "Must have been a false error as files were found." # now move the installed content into the main PKG_DIR ( cd ${INSTALLSENTRY_ROOT_DIR}/TRANSL && mv ./* $PKG_DIR/ ) # then remove the TRANSL directory ( cd ${INSTALLSENTRY_ROOT_DIR} && rm -rf TRANSL ) echo $BLUE"Safe installation - "$GREEN"Successful!"$NORMAL echo $BLUE"Processing package content:"$NORMAL else echo $RED"FATAL! "$NORMAL"Running '$INSTALL_LINE' has failed with error: $? " echo "Try using INSTALL_LINE 'make -i install' "$RED"Exiting..."$NORMAL FAILED="make_install" fi else # make install itself returned a possible error # try to do a generic installation unset INSTW_ROOTPATH unset LD_PRELOAD # libsentry tracks the writing of its' own logfile so a 'shadow' directory of # the current working directory gets created which must be removed # *Carefully* remove the shadow CWD from the INSTALLSENTRY_ROOT_DIR SHADOW_CWD=${CWD:1} SHADOW_CWD_BASE=${SHADOW_CWD%%/*} ( cd $INSTALLSENTRY_ROOT_DIR/TRANSL && rm -rf $SHADOW_CWD_BASE ) # also remove the META directory ( cd $INSTALLSENTRY_ROOT_DIR && rm -rf META ) if [[ $(find ${INSTALLSENTRY_ROOT_DIR}/TRANSL -type f) != "" ]] ; then echo $CYAN"Notice - "$NORMAL"Possible error running '$INSTALL_LINE'" echo " This is probably a false error since files have been installed." echo " But you should check the package content just to be sure." # echo "Must have been a false error as files were found." ( cd ${INSTALLSENTRY_ROOT_DIR}/TRANSL && mv ./* .. ) ( cd ${INSTALLSENTRY_ROOT_DIR} && rm -rf TRANSL ) elif [[ -x $OBJ_DIR/$NAME ]] || [[ -x $OBJ_DIR/$ORIG_NAME ]]; then echo $CYAN"Notice - "$NORMAL"Running '$INSTALL_LINE' has failed." echo "But, there seems to be a matching executable in the SRC_DIR." echo $BLUE"Doing generic install - "$NORMAL mkdir -p $PKG_DIR/$PRE_FIX/bin [[ -x $OBJ_DIR/$NAME ]] && cp -a $OBJ_DIR/$NAME $PKG_DIR/$PRE_FIX/bin [[ -x $OBJ_DIR/$ORIG_NAME ]] && cp -a $OBJ_DIR/$ORIG_NAME $PKG_DIR/$PRE_FIX/bin if [[ -e $OBJ_DIR/$NAME.1 ]] || [[ -e $OBJ_DIR/$NAME.man ]] ; then echo $BLUE"Found man-page - "$NORMAL"Copying into PKG_DIR" mkdir -p $PKG_DIR/usr/man/man1 [[ -e $OBJ_DIR/$NAME.1 ]] && cp -a $OBJ_DIR/$NAME.1 $PKG_DIR/usr/man/man1/$NAME.1 [[ -e $OBJ_DIR/$NAME.man ]] && cp -a $OBJ_DIR/$NAME.man $PKG_DIR/usr/man/man1/$NAME.1 fi else echo $RED"FATAL! "$NORMAL"Running '$INSTALL_LINE' has failed with error: $? " echo "Try using INSTALL_LINE 'make -i install' "$RED"Exiting..."$NORMAL FAILED="make_install" fi fi }