# This file is part of the src2pkg program: # Copyright 2005-2008 Gilbert Ashley # src2pkg is released under the GNU General Public License Version 2 ## make_doinst make_doinst() { if [[ "$FAILED" = "" ]] ; then # If a doinst.sh is present, assume that it is final and copy as-is into the PKG_DIR if [[ -e $CWD/doinst.sh ]] ; then echo $BLUE"Found doinst.sh - "$NORMAL"Inserting in the package directory" cat $CWD/doinst.sh > $PKG_DIR/install/doinst.sh elif [[ -e $CWD/doinst.sh.gz ]] ; then echo $BLUE"Found doinst.sh.gz - "$NORMAL"Decompressing in the package directory" zcat $CWD/doinst.sh.gz > $PKG_DIR/install/doinst.sh else if ! [[ $MAKE_LINKS = "NO" ]] ; then make_doinst_links fi if [[ -e $CWD/doinst.prepend ]] ; then echo $BLUE"Found doinst.prepend - "$NORMAL"Starting a new doinst.sh with its' contents" cat $CWD/doinst.prepend > $PKG_DIR/install/doinst.sh echo "" >> $PKG_DIR/install/doinst.sh fi if [[ -e $CWD/doinst.links ]] ; then echo $BLUE"Adding links to doinst.sh - "$NORMAL"Adding links-creation to the doinst.sh" cat $CWD/doinst.links >> $PKG_DIR/install/doinst.sh rm -f $CWD/doinst.links fi if [ -e $CWD/doinst.append ] ; then echo $BLUE"Found doinst.append - "$NORMAL"Adding its' contents to doinst.sh" cat $CWD/doinst.append >> $PKG_DIR/install/doinst.sh echo "" >> $PKG_DIR/install/doinst.sh fi # check if we need to add code to handle info pages if [[ -d $PKG_DIR/usr/info ]] && [[ ! $(grep install-info $PKG_DIR/install/doinst.sh &> /dev/null) ]] ; then echo $BLUE"Found info files - "$NORMAL"Adding install-info command to doinst.sh" INFO_LIST=$(ls -1 $PKG_DIR/usr/info) echo "" >> $PKG_DIR/install/doinst.sh echo "if [ -x /usr/bin/install-info ] ; then" >> $PKG_DIR/install/doinst.sh for page in $(echo $INFO_LIST) ; do echo " /usr/bin/install-info --info-dir=/usr/info /usr/info/$page 2>/dev/null" >> $PKG_DIR/install/doinst.sh done echo "fi" >> $PKG_DIR/install/doinst.sh echo "" >> $PKG_DIR/install/doinst.sh fi if [[ "$EXEC_NAME" = "trackinstall" ]] && [[ ! $AUTO_SCRIPT ]] ; then true elif [ -e $PKG_DIR/install/doinst.sh ] ; then echo $BLUE"Copying new doinst.sh - "$NORMAL"Copying as new.doinst.sh into the current directory" echo "Be sure to check it. For permanent use, edit and/or rename to doinst.sh" cat $PKG_DIR/install/doinst.sh > $CWD/new.doinst.sh fi fi # Remove symbolic links if ! [[ $REMOVE_LINKS = "NO" ]] ; then cd $PKG_DIR ; if [[ $(find . -type l) != "" ]] ; then echo $BLUE"Deleting symbolic links - "$NORMAL"Removing links from the package directory" find . -type l -exec rm -f {} \; fi fi # I dont't even know if this is right. if [[ -f $CWD/$PKG_REQUIRED ]] && [[ ! -f $PKG_DIR/install/$PKG_REQUIRED ]] ; then cp $CWD/$PKG_REQUIRED > $PKG_DIR/install/$PKG_REQUIRED fi if [[ $SHOW_DEPS ]] ; then cd $PKG_DIR ; if [[ "$(find . | xargs file | grep ELF | cut -f 1 -d : | xargs ldd | white_out | cut -f1 -d' ')" != "" ]] ; then echo $BLUE"Package dependencies:"$NORMAL find . | xargs file | grep ELF | cut -f 1 -d : | xargs ldd | white_out | cut -f1 -d' ' |grep -v "./" |sort -u fi fi # check to see if any files are installed to PKG_DIR/etc if [[ -d $PKG_DIR/etc ]] ; then for conf in $(find $PKG_DIR/etc -type f) ; do [[ "${conf: -4}" = ".new" ]] && continue mv $conf $conf.new done if [[ $(find $PKG_DIR/etc -type f) != "" ]] ; then if [[ $(grep 'config()' $PKG_DIR/install/doinst.sh 2> /dev/null) = "" ]] ; then echo '' >> $PKG_DIR/install/doinst.sh echo 'config() {' >> $PKG_DIR/install/doinst.sh echo ' NEW="$1"' >> $PKG_DIR/install/doinst.sh echo ' OLD="$(dirname $NEW)/$(basename $NEW .new)"' >> $PKG_DIR/install/doinst.sh echo ' if [ ! -r $OLD ] ; then' >> $PKG_DIR/install/doinst.sh echo ' mv $NEW $OLD' >> $PKG_DIR/install/doinst.sh echo ' elif [ "$(cat $OLD | md5sum)" = "$(cat $NEW | md5sum)" ] ; then' >> $PKG_DIR/install/doinst.sh echo ' rm $NEW' >> $PKG_DIR/install/doinst.sh echo ' fi' >> $PKG_DIR/install/doinst.sh echo '}' >> $PKG_DIR/install/doinst.sh echo '' >> $PKG_DIR/install/doinst.sh cd $PKG_DIR/etc ; for conf in $(find . -type f) ; do conf=${conf:2} echo "config etc/$conf" >> $PKG_DIR/install/doinst.sh done echo '' >> $PKG_DIR/install/doinst.sh fi fi fi fi } # make_link_script make_install_script() { COUNT=1 LINE="$(sed -n "$COUNT p" $1)" while [ ! "$LINE" = "" ]; do LINKGOESIN="$(echo "$LINE" | cut -f 1 -d " ")" LINKGOESIN="$(dirname $LINKGOESIN)" LINKNAMEIS="$(echo "$LINE" | cut -f 1 -d ' ')" LINKNAMEIS="$(basename "$LINKNAMEIS")" LINKPOINTSTO="$(echo "$LINE" | cut -f 3 -d ' ')" echo "( cd $LINKGOESIN ; rm -rf $LINKNAMEIS )" echo "( cd $LINKGOESIN ; ln -sf $LINKPOINTSTO $LINKNAMEIS )" COUNT=$(expr $COUNT + 1) LINE="$(sed -n "$COUNT p" $1)" done } #search for links and make link creation script if necessary make_doinst_links() { cd $PKG_DIR ; TMP=/tmp echo -n $BLUE"Searching for links in PKG_DIR - "$NORMAL INST=$(mktemp $TMP/src2pkg.XXXXXX) # This requires the ls from coreutils-5.0 (or newer): find . -type l -exec ls -l --time-style=long-iso {} \; | white_out | cut -f 8- -d ' ' | cut -b3- | tee $INST 1> /dev/null if [ ! "$(cat $INST)" = "" ]; then echo $GREEN"Done"$NORMAL make_install_script $INST | tee $CWD/doinst.links 1> /dev/null else echo "None found" fi rm -f $INST }