# This file is part of the src2pkg program: # Copyright 2005-2009 Gilbert Ashley # src2pkg is released under the GNU General Public License Version 2 # Each routine that writes lines to the doinst.sh should add a blank line afterwards, but not before ## make_doinst make_doinst() { if [[ $ALLOW_USER_EXTENSIONS = "YES" ]] ; then # check if the user has any pre-execution extensions to this file and run them, if so. [[ -f "$HOME"/.src2pkg/extensions/14.pre ]] && . "$HOME"/.src2pkg/extensions/14.pre fi if [[ "$FAILED" = "" ]] && [[ ! $USER_CANCELLED ]] ; then if [[ ! $RESUME ]] || [[ $RESUME = $FUNCNAME ]] || [[ $HAVE_RESUMED ]] ; then [[ $RESUME = $FUNCNAME ]] && HAVE_RESUMED=1 && echo $CYAN"Notice - "$BLUE"Resuming build at: "$NORMAL "$FUNCNAME" if [[ $PAUSE = "BEFORE" ]] || [[ $PAUSE = $FUNCNAME ]] ; then echo $MAGENTA"Notice - "$BLUE"Pausing before: "$NORMAL" '$FUNCNAME' Press ENTER to continue" read fi # take care of slack-provides and slack-required first if [[ "$ADD_PROVIDES_FILE" = "YES" ]] && [[ ! -f "$PKG_DIR"/install/$PKG_PROVIDES ]] ; then for FILENAME in $PKG_PROVIDES $PKG_PROVIDES-$NAME $NAME-$PKG_PROVIDES $NAME.$PKG_PROVIDES ; do for SEARCH_PATH in "$CWD" "$CWD"/Resources "$PATCHES_DIR"/$NAME-patches "$CWD"/patches ; do if [[ -f "$SEARCH_PATH"/$FILENAME ]] ; then echo $BLUE"Found $FILENAME - "$NORMAL"Copying to PKG_DIR/install/$PKG_PROVIDES" cat "$SEARCH_PATH"/$FILENAME > "$PKG_DIR"/install/$PKG_PROVIDES HAVE_PROVIDES=1 fi done done if ! [[ $HAVE_PROVIDES ]] ; then gen_provides_list > "$CWD"/provides.tmp if [[ $(cat "$CWD"/provides.tmp) != "" ]] ; then echo $BLUE"Creating $PKG_PROVIDES - "$NORMAL"Copying to PKG_DIR/install/$PKG_PROVIDES" echo "# $NAME-$VERSION Provides these libraries and links to them:" > "$PKG_DIR"/install/$PKG_PROVIDES sort -u "$CWD"/provides.tmp |uniq -u >> "$PKG_DIR"/install/$PKG_PROVIDES if [[ $AUTO_SCRIPT ]] ; then echo $BLUE"Copying $PKG_PROVIDES to: "$NORMAL"CWD/$PKG_PROVIDES" cp "$PKG_DIR"/install/$PKG_PROVIDES "$CWD"/new.$PKG_PROVIDES fi fi rm -f "$CWD"/provides.tmp fi fi if [[ "$ADD_REQUIRED_FILE" = "YES" ]] && [[ ! -f "$PKG_DIR"/install/$PKG_REQUIRED ]] ; then for FILENAME in $PKG_REQUIRED $PKG_REQUIRED-$NAME $NAME-$PKG_REQUIRED $NAME.$PKG_REQUIRED ; do for SEARCH_PATH in "$CWD" "$CWD"/Resources "$PATCHES_DIR"/$NAME-patches "$CWD"/patches ; do if [[ -f $SEARCH_PATH/$FILENAME ]] ; then echo $BLUE"Found $FILENAME - "$NORMAL"Copying to PKG_DIR/install/$PKG_REQUIRED" cat "$SEARCH_PATH"/$FILENAME > "$PKG_DIR"/install/$PKG_REQUIRED HAVE_REQUIRED=1 break ; fi done done if [[ ! $HAVE_REQUIRED ]] ; then echo -n $BLUE"Generating dependency list - "$NORMAL gen_deps_list echo $GREEN"Done"$NORMAL if [[ -f "${CWD}"/deps_list ]] && [[ $(cat "${CWD}"/deps_list) != "" ]] ; then echo -n $BLUE"Creating $PKG_REQUIRED - "$NORMAL echo "# $NAME-$VERSION " > "$PKG_DIR"/install/$PKG_REQUIRED printf "%-40s %-40s\n" "# Requires: " "|Supplied by: " >> "$PKG_DIR"/install/$PKG_REQUIRED cat "$CWD"/deps_list >> "$PKG_DIR"/install/$PKG_REQUIRED echo $GREEN"Done"$NORMAL fi rm -f "$CWD"/deps_list fi # if the package has a required file and none is in CWD, then copy it there if [[ -f "$PKG_DIR"/install/$PKG_REQUIRED ]] && [[ $AUTO_SCRIPT ]] ; then if [[ ! -f "$CWD"/$PKG_REQUIRED ]] ; then cat "$PKG_DIR"/install/$PKG_REQUIRED > "$CWD"/new.$PKG_REQUIRED fi fi fi ## desktop_create # If a doinst.sh is present, assume that it is final and copy as-is into the PKG_DIR # 4 filenames are possible: $NAME-doinst.sh, doinst.sh, $NAME-doinst.sh.gz or doinst.sh.gz # We look for them in the CWD, then CWD/$NAME-patches, then CWD/patches then CWD/Resources mkdir -p "$PKG_DIR"/install for DOINST_NAME in doinst.sh-$NAME doinst.sh-$NAME.gz doinst.sh doinst.sh.gz $NAME-doinst.sh $NAME-doinst.sh.gz $NAME.doinst.sh $NAME.doinst.sh.gz ; do for SEARCH_PATH in "$CWD" "$PATCHES_DIR"/$NAME-patches "$CWD"/patches "$CWD"/Resources ; do if [[ -f "$SEARCH_PATH"/$DOINST_NAME ]] ; then DOINST="$SEARCH_PATH"/$DOINST_NAME # shorten the path name for the prompt below [[ "$SEARCH_PATH" = "$CWD" ]] && SEARCH_PATH=CWD || SEARCH_PATH=$(basename "$SEARCH_PATH") HAVE_DOINST=1 break ; fi done [[ $HAVE_DOINST ]] && break ; done if [[ $HAVE_DOINST ]] ; then case "$DOINST" in *.gz) echo $BLUE"Found $DOINST_NAME in $SEARCH_PATH - "$NORMAL"Decompressing in the package directory" mkdir -p "$PKG_DIR"/install zcat "$DOINST" > "$PKG_DIR"/install/doinst.sh ;; *) echo $BLUE"Found $DOINST_NAME in $SEARCH_PATH - "$NORMAL"Inserting in the package directory" mkdir -p "$PKG_DIR"/install cat "$DOINST" > "$PKG_DIR"/install/doinst.sh ;; esac else # no doinst.sh script was found, so create one, if needed if ! [[ $MAKE_LINKS = "NO" ]] ; then make_doinst_links fi for SEARCH_PATH in "$CWD" "$CWD"/Resources "$PATCHES_DIR"/$NAME-patches "$CWD"/patches ; do if [[ -e "$SEARCH_PATH"/doinst.prepend ]] ; then echo $BLUE"Found doinst.prepend - "$NORMAL"Starting a new doinst.sh with its' contents" cat "$SEARCH_PATH"/doinst.prepend > "$PKG_DIR"/install/doinst.sh echo "" >> "$PKG_DIR"/install/doinst.sh fi done 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 # check to see if any files are installed to PKG_DIR/etc if [[ -d "$PKG_DIR"/etc ]] ; then if [[ $(find "$PKG_DIR"/etc -type f -name "*.new") != "" ]] ; then for conf in $(find "$PKG_DIR"/etc -type f -name "*.new") ; do if [[ $(grep 'config()' "$PKG_DIR"/install/doinst.sh 2> /dev/null) = "" ]] ; then echo $BLUE"Found '.new' files in PKG_DIR/etc - "$NORMAL"Adding '.new' file routine to doinst.sh" 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 ' echo ""' >> "$PKG_DIR"/install/doinst.sh echo ' echo " --> Installed new configuration file $OLD"' >> "$PKG_DIR"/install/doinst.sh echo ' elif [ "$(cat $OLD 2> /dev/null | md5sum)" = "$(cat $NEW 2> /dev/null | md5sum)" ] ; then' >> "$PKG_DIR"/install/doinst.sh # echo ' echo " --> Removed duplicate configuration file $NEW"' >> $PKG_DIR/install/doinst.sh echo ' rm -f $NEW' >> "$PKG_DIR"/install/doinst.sh echo ' else' >> "$PKG_DIR"/install/doinst.sh echo ' echo ""' >> "$PKG_DIR"/install/doinst.sh echo ' echo " --> Installed new configuration file $NEW"' >> "$PKG_DIR"/install/doinst.sh echo ' echo " --> Preserving your old configuration file $OLD"' >> "$PKG_DIR"/install/doinst.sh # echo ' echo ""' >> $PKG_DIR/install/doinst.sh echo ' echo " Please examine your existing configuration file: $OLD"' >> "$PKG_DIR"/install/doinst.sh echo ' echo " to see if it needs to be updated from: $NEW"' >> "$PKG_DIR"/install/doinst.sh echo ' echo ""' >> "$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 -name "*.new") ; do echo "config etc/$conf" >> "$PKG_DIR"/install/doinst.sh done echo '' >> "$PKG_DIR"/install/doinst.sh fi done fi fi if [[ -f "$PKG_DIR"/etc/rc.d/rc.$NAME.new ]] ; then echo $BLUE"Found rc.$NAME.new init file - "$NORMAL"Adding rc.local routine to doinst.sh" add_to_rc_local elif [[ -f "$PKG_DIR"/etc/rc.d/rc.$NAME ]] ; then echo $BLUE"Found rc.$NAME init file - "$NORMAL"Adding rc.local routine to doinst.sh" add_to_rc_local fi # check if we need to add code to handle info pages if [[ -d "$INFO_DIR" ]] && [[ ! $(grep install-info "$PKG_DIR"/install/doinst.sh &> /dev/null) ]] ; then echo $BLUE"Found info files - "$NORMAL"Adding install-info command to doinst.sh" if [[ $(grep 'CHROOT' "$PKG_DIR"/install/doinst.sh 2> /dev/null) = "" ]] ; then write_chroot_script fi INFO_LIST=$(ls -1 "$INFO_DIR") 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 ' ${CHROOT} '"/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 # create a desktop file if needed and none is present # create_desktop_file # check to see if any *.desktop files are installed. # If so, add code to the doinst.sh which will run 'update-desktop-database' when the package is installed if [[ -d "$PKG_DIR"/usr/share/applications ]] ; then if [[ $(find "$PKG_DIR"/usr/share/applications -type f) != "" ]] ; then if [[ $(grep 'CHROOT' "$PKG_DIR"/install/doinst.sh 2> /dev/null) = "" ]] ; then write_chroot_script fi if [[ $(grep update-desktop-database "$PKG_DIR"/install/doinst.sh 2> /dev/null) = "" ]] ; then echo $BLUE"Found .desktop files - "$NORMAL"Adding 'update-desktop-database' routine to doinst.sh" echo '' >> "$PKG_DIR"/install/doinst.sh echo '# update the applications menu database' >> "$PKG_DIR"/install/doinst.sh echo 'if [ -x usr/bin/update-desktop-database ] ; then' >> "$PKG_DIR"/install/doinst.sh echo ' ${CHROOT} /usr/bin/update-desktop-database -q /usr/share/applications 2> /dev/null' >> "$PKG_DIR"/install/doinst.sh echo 'fi' >> "$PKG_DIR"/install/doinst.sh echo '' >> "$PKG_DIR"/install/doinst.sh fi fi fi # check to see if any icons are installed. # If so, add code to the doinst.sh which will run 'gtk-update-icon-cache' when the package is installed if [[ -d "$ICONS_DIR" ]] ; then if [[ $(find "$ICONS_DIR"/ -type f) != "" ]] ; then if [[ $(grep 'CHROOT' "$PKG_DIR"/install/doinst.sh 2> /dev/null) = "" ]] ; then write_chroot_script fi if [[ $(grep gtk-update-icon-cache "$PKG_DIR"/install/doinst.sh 2> /dev/null) = "" ]] ; then echo $BLUE"Found icon files - "$NORMAL"Adding 'gtk-update-icon-cache' routine to doinst.sh" echo '' >> "$PKG_DIR"/install/doinst.sh echo '# update the gtk-icon-cache' >> "$PKG_DIR"/install/doinst.sh echo 'if [ -x usr/bin/gtk-icon-cache ] ; then' >> "$PKG_DIR"/install/doinst.sh echo ' ${CHROOT} '"/usr/bin/gtk-icon-cache --quiet $iconsdir 2> /dev/null" >> "$PKG_DIR"/install/doinst.sh echo 'fi' >> "$PKG_DIR"/install/doinst.sh echo '' >> "$PKG_DIR"/install/doinst.sh fi fi fi # check to see if any mime-databse files are installed. # If so, add code to the doinst.sh which will run 'update-mime-database' when the package is installed if [[ -d "$PKG_DIR"/usr/share/mime ]] ; then if [[ $(find "$PKG_DIR"/usr/share/mime -type f) != "" ]] ; then if [[ $(grep 'CHROOT' "$PKG_DIR"/install/doinst.sh 2> /dev/null) = "" ]] ; then write_chroot_script fi if [[ $(grep update-mime-database "$PKG_DIR"/install/doinst.sh 2> /dev/null) = "" ]] ; then echo $BLUE"Found mime-database files - "$NORMAL"Adding 'update-mime-database' routine to doinst.sh" echo '' >> "$PKG_DIR"/install/doinst.sh echo '# update the mime database' >> "$PKG_DIR"/install/doinst.sh echo 'if [ -x usr/bin/update-mime-database ] ; then' >> "$PKG_DIR"/install/doinst.sh echo ' ${CHROOT} /usr/bin/update-mime-database -q /usr/share/mime 2> /dev/null' >> "$PKG_DIR"/install/doinst.sh echo 'fi' >> "$PKG_DIR"/install/doinst.sh echo '' >> "$PKG_DIR"/install/doinst.sh fi fi fi # add the code from doinst.append, if present for SEARCH_PATH in "$CWD" "$CWD"/Resources "$PATCHES_DIR"/$NAME-patches "$CWD"/patches ; do if [[ -e "$SEARCH_PATH"/doinst.append ]] ; then echo $BLUE"Found doinst.append - "$NORMAL"Adding its' contents to doinst.sh" cat "$SEARCH_PATH"/doinst.append >> "$PKG_DIR"/install/doinst.sh echo "" >> "$PKG_DIR"/install/doinst.sh fi done # clean up installed doinst.sh if it comes from PhantomX sed -i "s|Packager: _PACKAGER||g; s|on _BUILD_DATE||g" "${PKG_DIR}"/install/slack-desc # if not running trackinstall or src2pkg without auto-scripting enabled copy the new doinst.sh into the CWD if [[ "$EXEC_NAME" = "trackinstall" ]] && [[ ! $AUTO_SCRIPT ]] ; then true elif [[ -e "$PKG_DIR"/install/doinst.sh ]] && [[ $AUTO_SCRIPT ]] ; 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 # this routine shows the raw library names -not the packages they belong to if [[ $SHOW_DEPS ]] ; then cd "$PKG_DIR" ; if [[ -f $PKG_DIR/install/$PKG_REQUIRED ]] ; then echo $BLUE"Package dependencies:"$NORMAL grep '^# File:' $PKG_DIR/install/$PKG_REQUIRED |cut -f 3 -d ' ' elif [[ "$(find . |xargs -r file |grep ELF |egrep '(dynamically linked|shared object)'|cut -f 1 -d : |xargs -r ldd 2> /dev/null |white_out |egrep -v '(^./|linux-gate)' |cut -f1 -d' ')" != "" ]] ; then echo $BLUE"Package dependencies:"$NORMAL #find . |xargs file |grep ELF |grep -v 'statically linked' |cut -f 1 -d : |xargs -r ldd |white_out |cut -f1 -d' ' |grep -v "./" |sort -u find . -type f |xargs -r file |grep ELF |egrep '(dynamically linked|shared object)' |cut -f 1 -d : |xargs -r ldd |white_out |cut -f1 -d' ' |egrep -v '(^./|linux-gate|ld-linux)' |sort -u fi fi # These extra routines have been moved into a separate file 14A-last_minute_details do_last_minute_details if [[ $PAUSE = "AFTER" ]] || [[ $PAUSE = $FUNCNAME ]] ; then echo $MAGENTA"Notice - "$BLUE"Pausing after: "$NORMAL" '$FUNCNAME' Press ENTER to continue" read fi fi fi if [[ $ALLOW_USER_EXTENSIONS = "YES" ]] ; then # check if the user has any post-execution extensions to this file and run them, if so. [[ -f "$HOME"/.src2pkg/extensions/14.post ]] && . "$HOME"/.src2pkg/extensions/14.post fi } # end make_doinst main routine ## below here are sub-functions: # 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 } # Add a routine to etc/rc.d/rc.local for an init script in etc/rc.d # really tricky syntax with escapes, double and single quotes # since this script function writes a script which writes a script... add_to_rc_local() { if [[ ! $(grep rc.local "$PKG_DIR"/install/doinst.sh &> /dev/nul) ]] && \ [[ ! $(grep rc.local "$CWD"/doinst.append &> /dev/null) ]] ; then echo "if [ \"\$(grep rc.$NAME /etc/rc.d/rc.local 2> /dev/null)\" = \"\" ] ; then" >> "$PKG_DIR"/install/doinst.sh echo " echo \" --> Adding an entry to /etc/rc.d/rc.local for /etc/rc.d/rc.$NAME\"" >> "$PKG_DIR"/install/doinst.sh echo " echo \"\"" >> "$PKG_DIR"/install/doinst.sh echo " echo \"# Start $NAME service\" >> /etc/rc.d/rc.local" >> "$PKG_DIR"/install/doinst.sh echo " echo \"if [ -x /etc/rc.d/rc.$NAME ] ; then\" >> /etc/rc.d/rc.local" >> "$PKG_DIR"/install/doinst.sh echo " echo \" echo /etc/rc.d/rc.local: Running '. /etc/rc.d/rc.$NAME start' ...\" >> /etc/rc.d/rc.local" >> "$PKG_DIR"/install/doinst.sh echo " echo \" . /etc/rc.d/rc.$NAME start & 2> /dev/null\" >> /etc/rc.d/rc.local" >> "$PKG_DIR"/install/doinst.sh echo " echo \"fi\" >> /etc/rc.d/rc.local" >> "$PKG_DIR"/install/doinst.sh echo " echo \"\" >> /etc/rc.d/rc.local" >> "$PKG_DIR"/install/doinst.sh echo "fi" >> "$PKG_DIR"/install/doinst.sh echo "" >> "$PKG_DIR"/install/doinst.sh fi } last_deps_sort() { if [[ -e "${CWD}"/deps_list.tmp ]] && [[ $(cat "${CWD}"/deps_list.tmp) != "" ]] ; then OLD_IFS=$IFS IFS=' ' sort -u "$CWD"/deps_list.tmp |uniq -u >> "$CWD"/deps_list IFS=$OLD_IFS rm -f "$CWD"/deps_list.tmp else rm -f "$CWD"/deps_list.tmp fi } gen_deps_list() { # this routine is pretty slow, but things had to be broken down into many steps for dependability cd "$PKG_DIR" ; # if [[ "$(find . |xargs file |grep ELF |grep -v 'statically linked')" != "" ]] ; then if [[ "$(find . |xargs -r file |grep ELF |egrep '(dynamically linked|shared object)')" != "" ]] ; then # find . -type f |xargs file |grep ELF |grep -v 'statically linked' |cut -f 1 -d : |xargs ldd |grep -v '^./' |grep -v 'not found' > "${CWD}"/deps_list #find . -type f |xargs file |grep ELF |grep -v 'statically linked' |cut -f 1 -d : |xargs ldd |egrep -v '('^./'|'not found'|'not a dynamic executable')' > "${CWD}"/deps_list #find . -type f |xargs file |grep ELF |egrep '(dynamically linked|shared object)' |cut -f 1 -d : |xargs ldd |grep -v '^./' |grep -v 'not found' > "${CWD}"/deps_list find . -type f |xargs -r file |grep ELF |egrep '(dynamically linked|shared object)' |cut -f 1 -d : |xargs -r ldd |grep -v '^./' > "${CWD}"/deps_list # isolate any libraries which are shown as 'not found' by ldd if [[ $(grep "not found" "${CWD}"/deps_list) ]] ; then grep "not found" "${CWD}"/deps_list |sort -u |uniq -u > "${CWD}"/unsatisfied_deps_list cat "${CWD}"/unsatisfied_deps_list |white_out |cut -f1 -d ' ' > "${CWD}"/unsatisfied_deps_list.tmp rm -f "${CWD}"/unsatisfied_deps_list fi # ignore the non-existent linux-gate and also remove the 'not found' items egrep -v '(linux-gate|not found)' "${CWD}"/deps_list > "${CWD}"/deps_list.tmp # now figure out if the 'not found' items are a part of this package if [[ -f "${CWD}"/unsatisfied_deps_list.tmp ]] ; then while read LINE ; do # any items 'not found' which aren't in this package get reported. Of course, this # can only happen if we are packaging some pre-compiled program if ! [[ $(grep $LINE $PKG_DIR/install/$PKG_PROVIDES) ]] ; then echo $LINE >> "${CWD}"/unsatisfied_deps_list fi done <"${CWD}"/unsatisfied_deps_list.tmp rm -f "${CWD}"/unsatisfied_deps_list.tmp fi if [[ $(cat "${CWD}"/deps_list.tmp) != "" ]] ; then # get rid of extra white space cat "${CWD}"/deps_list.tmp | white_out > "${CWD}"/deps_list # pull the third field cut -f3 -d' ' "${CWD}"/deps_list > "${CWD}"/deps_list.tmp # strip leading slashes cut -f2- -d'/' "${CWD}"/deps_list.tmp > "${CWD}"/deps_list # sort it and remove redundant lines sort -u "${CWD}"/deps_list > "${CWD}"/deps_list.tmp uniq "${CWD}"/deps_list.tmp > "${CWD}"/deps_list rm -f "${CWD}"/deps_list.tmp for PKG_DEP in $(cat "${CWD}"/deps_list); do # filter out depends which are a part of this package if [[ -f "${CWD}"/$PKG_PROVIDES ]] && [[ $(grep $(basename $PKG_DEP) "${CWD}"/$PKG_PROVIDES) ]] ; then continue elif [[ -f "${CWD}"/new.$PKG_PROVIDES ]] && [[ $(grep $(basename $PKG_DEP) "${CWD}"/new.$PKG_PROVIDES) ]] ; then continue fi THIS_DEP="" PKG_DEP_COUNT=0 SCRIPT_DEP_COUNT=0 COUNT=0 # make a special case for libgcc_s.so.1 -this is the only library included in aaa_elflibs which doesn't also reside # in another reasonably-sized package -it is only available otherwise as part of the huge gcc package. Not everyone # installs gcc, so it would be a shame and misleading to show gcc as a dependency just because of this tiny library. # A double exception is used here, because for my distro I package the lib in the libgcc package -not aaa_elflibs # This is also the only place where gcc will show up in the deps list as it is ignored below, along with glibc if [[ $(basename $PKG_DEP) = "libgcc_s.so.1" ]] ; then if [[ $INCLUDE_DEP_VERSIONS = "NO" ]] ; then if [[ $(ls /var/log/packages/libgcc* 2> /dev/null) ]] ; then THIS_DEP="libgcc | gcc" else THIS_DEP="aaa_elflibs | gcc" fi else if [[ $(ls /var/log/packages/libgcc* 2> /dev/null) ]] ; then THIS_DEP=$(ls /var/log/packages/libgcc* |head -n 1 |cut -f1 -d: |cut -f 5 -d/) THIS_DEP="$THIS_DEP | $(ls /var/log/packages/gcc* |head -n 1 |cut -f1 -d: |cut -f 5 -d/)" else THIS_DEP=$(ls /var/log/packages/aaa_elflibs* |head -n 1 |cut -f1 -d: |cut -f 5 -d/) THIS_DEP="$THIS_DEP | $(ls /var/log/packages/gcc* |head -n 1 |cut -f1 -d: |cut -f 5 -d/)" fi fi printf "%-40s %-40s\n" "# File: $(basename $PKG_DEP)" "|: $THIS_DEP" >> "$CWD"/deps_list.tmp echo "$THIS_DEP" >> $CWD/deps_list.tmp elif [[ $PKG_DEP != "" ]] ; then #echo PKG_DEP=$PKG_DEP PKG_DEP=$(readlink /$PKG_DEP) #echo PKG_DEP=$PKG_DEP # count the number of matches in packages or scripts if [[ $INCLUDE_BASE_LIBS = "YES" ]] ; then PKG_DEP_COUNT=$(grep -m 1 ${PKG_DEP} $ADM_DIR_NAME/packages/* |wc -l) SCRIPT_DEP_COUNT=$(grep -m 1 ${PKG_DEP} $ADM_DIR_NAME/scripts/* |wc -l) else PKG_DEP_COUNT=$(grep -m 1 ${PKG_DEP} $ADM_DIR_NAME/packages/* |cut -f1 -d: |cut -f 5 -d/ |grep -v glibc |grep -v '^gcc' |wc -l) SCRIPT_DEP_COUNT=$(grep -m 1 ${PKG_DEP} $ADM_DIR_NAME/scripts/* |cut -f1 -d: |cut -f 5 -d/ |grep -v glibc |grep -v '^gcc-' |wc -l) fi if [[ $PKG_DEP_COUNT -gt 0 ]] ; then if [[ $INCLUDE_BASE_LIBS = "YES" ]] ; then THIS_DEP="$(grep -n -m 1 ${PKG_DEP} $ADM_DIR_NAME/packages/* |cut -f1 -d: |cut -f 5 -d/ |sort -r |head -n 1)" #THIS_DEP="$(grep -n -m 1 ${PKG_DEP} $ADM_DIR_NAME/packages/* |cut -f1 -d: |cut -f 5 -d/ |head -n 1)" else THIS_DEP="$(grep -n -m 1 ${PKG_DEP} $ADM_DIR_NAME/packages/* |cut -f1 -d: |cut -f 5 -d/ |grep -v glibc |grep -v '^gcc-' |sort -r |head -n 1)" #THIS_DEP="$(grep -n -m 1 ${PKG_DEP} $ADM_DIR_NAME/packages/* |cut -f1 -d: |cut -f 5 -d/ |grep -v glibc |grep -v '^gcc-' |head -n 1)" fi if [[ $INCLUDE_DEP_VERSIONS = "NO" ]] ; then THIS_DEP=${THIS_DEP%-*-*-*} else THIS_DEP_NAME=${THIS_DEP%-*-*-*} THIS_DEP_VERSION=${THIS_DEP#*$THIS_DEP_NAME-} THIS_DEP="$THIS_DEP_NAME >= $THIS_DEP_VERSION" fi case $THIS_DEP in $NAME|"$NAME =") THIS_DEP="" ;; esac COUNT=2 while [[ $COUNT -le $PKG_DEP_COUNT ]] ; do if [[ $INCLUDE_BASE_LIBS = "YES" ]] ; then NEXT_DEP="$(grep -n -m 1 ${PKG_DEP} $ADM_DIR_NAME/packages/* |cut -f1 -d: |cut -f 5 -d/ |sort -r |tail --lines +$COUNT |head -n1)" #NEXT_DEP="$(grep -n -m 1 ${PKG_DEP} $ADM_DIR_NAME/packages/* |cut -f1 -d: |cut -f 5 -d/ |tail --lines +$COUNT |head -n1)" else NEXT_DEP="$(grep -n -m 1 ${PKG_DEP} $ADM_DIR_NAME/packages/* |cut -f1 -d: |cut -f 5 -d/ |grep -v glibc |grep -v '^gcc-' |sort -r |tail --lines +$COUNT |head -n1)" #NEXT_DEP="$(grep -n -m 1 ${PKG_DEP} $ADM_DIR_NAME/packages/* |cut -f1 -d: |cut -f 5 -d/ |grep -v glibc |grep -v '^gcc-' |tail --lines +$COUNT |head -n1)" fi if [[ $INCLUDE_DEP_VERSIONS = "NO" ]] ; then NEXT_DEP=${NEXT_DEP%-*-*-*} else NEXT_DEP_NAME=${NEXT_DEP%-*-*-*} NEXT_DEP_VERSION=${NEXT_DEP#*$NEXT_DEP_NAME-} NEXT_DEP="$NEXT_DEP_NAME >= $NEXT_DEP_VERSION" fi if [[ $(echo "$THIS_DEP" |grep "$NEXT_DEP") = "" ]] ; then case $NEXT_DEP in $NAME|"$NAME =") NEXT_DEP="" ;; *)THIS_DEP="$THIS_DEP | $NEXT_DEP" ;; esac fi (( COUNT++ )) done case $THIS_DEP in $NAME-$VERSION-$ARCH-$BUILD*|$NAME) true ;; *) if [[ -n $THIS_DEP ]] ; then #echo "# File: $(basename $PKG_DEP) |: $THIS_DEP" >> $CWD/deps_list.tmp printf "%-40s %-40s\n" "# File: $(basename $PKG_DEP)" "|: $THIS_DEP" >> "$CWD"/deps_list.tmp echo "$THIS_DEP" >> "$CWD"/deps_list.tmp fi ;; esac elif [[ $SCRIPT_DEP_COUNT -gt 0 ]] ; then if [[ $INCLUDE_BASE_LIBS = "YES" ]] ; then THIS_DEP="$(grep -n -m 1 ${PKG_DEP} $ADM_DIR_NAME/scripts/* |cut -f1 -d: |cut -f 5 -d|sort -r |head -n 1)" else THIS_DEP="$(grep -n -m 1 ${PKG_DEP} $ADM_DIR_NAME/scripts/* |cut -f1 -d: |cut -f 5 -d/ |grep -v '^glibc' |grep -v '^gcc-' |sort -r |head -n 1)" fi if [[ $INCLUDE_DEP_VERSIONS = "NO" ]] ; then THIS_DEP=${THIS_DEP%-*-*-*} else THIS_DEP_NAME=${THIS_DEP%-*-*-*} THIS_DEP_VERSION=${THIS_DEP#*$THIS_DEP_NAME-} THIS_DEP="$THIS_DEP_NAME >= $THIS_DEP_VERSION" fi case $THIS_DEP in $NAME|"$NAME =") THIS_DEP="" ;; esac COUNT=2 while [[ $COUNT -le $PKG_DEP_COUNT ]] ; do if [[ $INCLUDE_BASE_LIBS = "YES" ]] ; then NEXT_DEP="$(grep -n -m 1 ${PKG_DEP} $ADM_DIR_NAME/scripts/* |cut -f1 -d: |cut -f 5 -d/ |sort -r |tail --lines +$COUNT |head -n1)" else NEXT_DEP="$(grep -n -m 1 ${PKG_DEP} $ADM_DIR_NAME/scripts/* |cut -f1 -d: |cut -f 5 -d/ |grep -v '^glibc' |grep -v '^gcc-' |sort -r |tail --lines +$COUNT |head -n1)" fi if [[ $INCLUDE_DEP_VERSIONS = "NO" ]] ; then NEXT_DEP=${NEXT_DEP%-*-*-*} else NEXT_DEP_NAME=${NEXT_DEP%-*-*-*} NEXT_DEP_VERSION=${NEXT_DEP#*$NEXT_DEP_NAME-} NEXT_DEP="$NEXT_DEP_NAME >= $NEXT_DEP_VERSION" fi if [[ $(echo "$THIS_DEP" |grep $NEXT_DEP) = "" ]] ; then case $NEXT_DEP in $NAME|"$NAME =") NEXT_DEP="" ;; *) THIS_DEP="$THIS_DEP | $NEXT_DEP" ;; esac fi (( COUNT++ )) done case $THIS_DEP in $NAME-$VERSION-$ARCH-$BUILD*|$NAME) true ;; *) if [[ -n $THIS_DEP ]] ; then #echo "# Link: $(basename $PKG_DEP) |: $THIS_DEP" >> $CWD/deps_list.tmp printf "%-40s %-40s\n" "# File: $(basename $PKG_DEP)" "|: $THIS_DEP" >> "$CWD"/deps_list.tmp echo "$THIS_DEP" >> "$CWD"/deps_list.tmp fi ;; esac fi fi done rm -f ${CWD}/deps_list last_deps_sort fi fi } gen_provides_list() { cd "$PKG_DIR" for FILE in $(find * -type f -name "*.a" -o -name "*.so" -o -name "*.so.*" -o -name "*.la") ; do case $FILE in *.so|*.so.*) if [[ $(file $FILE grep 'shared object' 2> /dev/null) ]] \ || [[ $(file $FILE |grep 'relocatable object' 2> /dev/null) ]] \ || [[ $(file $FILE |grep 'archive' 2> /dev/null) ]] ; then echo $FILE fi;; *.a) [[ $(file $FILE |grep 'current ar archive' 2> /dev/null) ]] && echo $FILE ;; *.la) [[ $(grep 'libtool library file' $FILE 2> /dev/null) ]] && echo $FILE ;; esac done OLD_IFS=$IFS if [[ -f "$PKG_DIR"/install/doinst.sh ]] ; then IFS=' ' LINKS=$(grep 'ln -s' "$PKG_DIR"/install/doinst.sh |grep "lib$LIBDIRSUFFIX") for LINK in $LINKS ; do LINK_DIR=$(echo "$LINK" |cut -f 3 -d' ') THIS_LINK="$(echo "${LINK%% )*}")" THIS_LINK=${THIS_LINK##* } # It's too complicated to really check the link target as above, but this will cull most false positives case $THIS_LINK in *.a|*.so|*.so*|*.la) echo $LINK_DIR/$THIS_LINK ;; esac done IFS=$OLD_IFS fi } write_chroot_script() { echo "" >> "$PKG_DIR"/install/doinst.sh echo "# Figure out our root directory" >> "$PKG_DIR"/install/doinst.sh echo 'ROOTDIR=$(pwd)' >> "$PKG_DIR"/install/doinst.sh echo "unset CHROOT" >> "$PKG_DIR"/install/doinst.sh echo 'if test "${ROOTDIR}" != "/"; then' >> "$PKG_DIR"/install/doinst.sh echo ' CHROOT="chroot ${ROOTDIR} "' >> "$PKG_DIR"/install/doinst.sh echo ' ROOTDIR="${ROOTDIR}/"' >> "$PKG_DIR"/install/doinst.sh echo 'fi' >> "$PKG_DIR"/install/doinst.sh }