# This file is part of the src2pkg program: # Copyright 2005-2010 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 "$PKG_DIR" > "$CWD"/provides.tmp if [[ -s "$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 [[ -s "${CWD}"/deps_list ]] ; then echo -n $BLUE"Creating $PKG_REQUIRED - "$NORMAL echo "# $NAME-$VERSION " > "$PKG_DIR"/install/$PKG_REQUIRED if [[ -n $BuildRequires ]] ; then echo "# BuildRequires='$BuildRequires'" >> "$PKG_DIR"/install/$PKG_REQUIRED elif [[ -n $BUILD_REQUIRES ]] ; then echo "# BuildRequires='$BUILD_REQUIRES'" >> "$PKG_DIR"/install/$PKG_REQUIRED fi 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 #! [[ $DEBUG ]] && rm -f "$CWD"/deps_list 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 $PKG_POSTINST-$NAME $PKG_POSTINST-$NAME.gz $PKG_POSTINST $PKG_POSTINST.gz $NAME-$PKG_POSTINST $NAME-$PKG_POSTINST.gz $NAME.$PKG_POSTINST $NAME.$PKG_POSTINST.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/$PKG_POSTINST ;; *) echo $BLUE"Found $DOINST_NAME in $SEARCH_PATH - "$NORMAL"Inserting in the package directory" mkdir -p "$PKG_DIR"/install cat "$DOINST" > "$PKG_DIR"/install/$PKG_POSTINST ;; esac else # no doinst.sh script was found, so create one, if needed if ! [[ $MAKE_LINKS = "NO" ]] ; then make_doinst_links "$PKG_DIR" 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 $PKG_POSTINST with its' contents" cat "$SEARCH_PATH"/doinst.prepend > "$PKG_DIR"/install/$PKG_POSTINST echo "" >> "$PKG_DIR"/install/$PKG_POSTINST fi done if [[ -e "$CWD"/doinst.links ]] ; then echo $BLUE"Adding links to $PKG_POSTINST - "$NORMAL"Adding links-creation to the $PKG_POSTINST" cat "$CWD"/doinst.links >> "$PKG_DIR"/install/$PKG_POSTINST rm -f "$CWD"/doinst.links fi # check to see if any files are installed to PKG_DIR/etc if [[ -d "$PKG_DIR"/etc ]] || [[ -d "$PKG_DIR"/var ]] ; then if [[ $(find "$PKG_DIR"/etc -type f -name "*.new" 2> /dev/null) != "" ]] || [[ $(find "$PKG_DIR"/var -type f -name "*.new" 2> /dev/null) != "" ]] ; then if [[ $(grep 'config()' "$PKG_DIR"/install/$PKG_POSTINST 2> /dev/null) = "" ]] ; then echo $BLUE"Found '.new' files in PKG_DIR/etc - "$NORMAL"Adding '.new' file routine to $PKG_POSTINST" echo '' >> "$PKG_DIR"/install/$PKG_POSTINST echo 'config() {' >> "$PKG_DIR"/install/$PKG_POSTINST echo ' NEW="$1"' >> "$PKG_DIR"/install/$PKG_POSTINST echo ' OLD="$(dirname $NEW)/$(basename $NEW .new)"' >> "$PKG_DIR"/install/$PKG_POSTINST echo ' if [ ! -r $OLD ] ; then' >> "$PKG_DIR"/install/$PKG_POSTINST echo ' mv $NEW $OLD' >> "$PKG_DIR"/install/$PKG_POSTINST echo ' echo ""' >> "$PKG_DIR"/install/$PKG_POSTINST echo ' echo " --> Installed new configuration file $OLD"' >> "$PKG_DIR"/install/$PKG_POSTINST echo ' elif [ "$(cat $OLD 2> /dev/null | md5sum)" = "$(cat $NEW 2> /dev/null | md5sum)" ] ; then' >> "$PKG_DIR"/install/$PKG_POSTINST # echo ' echo " --> Removed duplicate configuration file $NEW"' >> $PKG_DIR/install/$PKG_POSTINST echo ' rm -f $NEW' >> "$PKG_DIR"/install/$PKG_POSTINST echo ' else' >> "$PKG_DIR"/install/$PKG_POSTINST echo ' echo ""' >> "$PKG_DIR"/install/$PKG_POSTINST echo ' echo " --> Installed new configuration file $NEW"' >> "$PKG_DIR"/install/$PKG_POSTINST echo ' echo " --> Preserving your old configuration file $OLD"' >> "$PKG_DIR"/install/$PKG_POSTINST # echo ' echo ""' >> $PKG_DIR/install/$PKG_POSTINST echo ' echo " Please examine your existing configuration file: $OLD"' >> "$PKG_DIR"/install/$PKG_POSTINST echo ' echo " to see if it needs to be updated from: $NEW"' >> "$PKG_DIR"/install/$PKG_POSTINST echo ' echo ""' >> "$PKG_DIR"/install/$PKG_POSTINST echo ' fi' >> "$PKG_DIR"/install/$PKG_POSTINST echo '}' >> "$PKG_DIR"/install/$PKG_POSTINST echo '' >> "$PKG_DIR"/install/$PKG_POSTINST if [[ -d "$PKG_DIR"/etc ]] ; then cd "$PKG_DIR"/etc ; for conf in $(find * -type f -name "*.new") ; do echo "config etc/$conf" >> "$PKG_DIR"/install/$PKG_POSTINST done fi if [[ -d "$PKG_DIR"/var ]] ; then cd "$PKG_DIR"/var ; for conf in $(find * -type f -name "*.new") ; do echo "config etc/$conf" >> "$PKG_DIR"/install/$PKG_POSTINST done fi echo '' >> "$PKG_DIR"/install/$PKG_POSTINST fi fi fi if [[ -f "$INIT_DIR"/rc.$NAME.new ]] ; then echo $BLUE"Found rc.$NAME.new init file - "$NORMAL"Adding rc.local routine to $PKG_POSTINST" add_to_rc_local elif [[ -f "$INIT_DIR"/rc.$NAME ]] ; then echo $BLUE"Found rc.$NAME init file - "$NORMAL"Adding rc.local routine to $PKG_POSTINST" add_to_rc_local fi # if we have info files and they are not going to be split out into a docs package, # write postinst and postrm routines if [[ $(find "$INFO_DIR" -type f 2> /dev/null) != "" ]] ; then case $SPLIT_PACKAGE in *doc*) true ;; *) write_install_info_postinst $PKG_DIR if [[ $EXTENDED_DATABASE = "YES" ]] ; then write_install_info_postrm $PKG_DIR fi ;; esac fi # 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 [[ $(find "$PKG_DIR"/usr/share/applications -type f 2> /dev/null) != "" ]] ; then write_update_desktop_database_postinst $PKG_DIR if [[ $EXTENDED_DATABASE = "YES" ]] ; then write_update_desktop_database_postrm $PKG_DIR 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 [[ $(find "$ICONS_DIR"/ -type f 2> /dev/null) != "" ]] ; then write_gtk_update_icon_cache_postinst $PKG_DIR if [[ $EXTENDED_DATABASE = "YES" ]] ; then write_gtk_update_icon_cache_postrm $PKG_DIR fi fi # check to see if any mime-database files are installed. # If so, add code to the doinst.sh which will run 'update-mime-database' when the package is installed if [[ $(find "$PKG_DIR"/usr/share/mime -type f 2> /dev/null) != "" ]] ; then write_update_mime_database_postinst $PKG_DIR if [[ $EXTENDED_DATABASE = "YES" ]] ; then write_update_mime_database_postrm $PKG_DIR fi fi # check to see if any gtk immodules are installed. # If so, add code to the doinst.sh which will run 'updategtk-immodules-' when the package is installed if [[ $(find "$PKG_DIR"/usr/lib/gtk-2.0/immodules -type f 2> /dev/null) != "" ]] ; then write_update_gtk_immodules_postinst $PKG_DIR if [[ $EXTENDED_DATABASE = "YES" ]] ; then write_update_gtk_immodules_postrm $PKG_DIR 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 $PKG_POSTINST" cat "$SEARCH_PATH"/doinst.append >> "$PKG_DIR"/install/$PKG_POSTINST echo "" >> "$PKG_DIR"/install/$PKG_POSTINST fi done # clean up installed doinst.sh if it comes from PhantomX if [[ -f "${PKG_DIR}"/install/$PKG_DESC ]] ; then sed -i "s|Packager: _PACKAGER||g; s|on _BUILD_DATE||g" "${PKG_DIR}"/install/$PKG_DESC if [[ "$PACKAGER" != "src2pkg" ]] ; then sed -i "s|Packaged by src2pkg|Packaged by $PACKAGER|g" "${PKG_DIR}"/install/$PKG_DESC fi fi # 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/$PKG_POSTINST ]] && [[ $AUTO_SCRIPT ]] ; then echo $BLUE"Copying new $PKG_POSTINST - "$NORMAL"Copying as new.$PKG_POSTINST into the current directory" echo "Be sure to check it. For permanent use, edit and/or rename to $PKG_POSTINST" cat "$PKG_DIR"/install/$PKG_POSTINST > "$CWD"/new.$PKG_POSTINST 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 |egrep -v '(^./|linux-gate)')" != "" ]] ; then echo $BLUE"Package dependencies:"$NORMAL find . -type f |xargs -r file |grep ELF |egrep '(dynamically linked|shared object)' \ |cut -f 1 -d : |xargs -r _ldd |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 "$1" ; TMP=/tmp echo -n $BLUE"Searching for links in:"$NORMAL" ${1##*/} - "$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 [[ -s $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/$PKG_POSTINST &> /dev/nul) ]] && \ [[ ! $(grep rc.local "$CWD"/doinst.append &> /dev/null) ]] ; then echo "if [ \"\$(grep rc.$NAME $initdir/rc.local 2> /dev/null)\" = \"\" ] ; then" >> "$PKG_DIR"/install/$PKG_POSTINST echo " echo \" --> Adding an entry to $initdir/rc.local for $initdir/rc.$NAME\"" >> "$PKG_DIR"/install/$PKG_POSTINST echo " echo \"\"" >> "$PKG_DIR"/install/$PKG_POSTINST echo " echo \"# Start $NAME service\" >> $initdir/rc.local" >> "$PKG_DIR"/install/$PKG_POSTINST echo " echo \"if [ -x $initdir/rc.$NAME ] ; then\" >> $initdir/rc.local" >> "$PKG_DIR"/install/$PKG_POSTINST echo " echo \" echo $initdir/rc.local: Running '. $initdir/rc.$NAME start' ...\" >> $initdir/rc.local" >> "$PKG_DIR"/install/$PKG_POSTINST echo " echo \" . $initdir/rc.$NAME start & 2> /dev/null\" >> $initdir/rc.local" >> "$PKG_DIR"/install/$PKG_POSTINST echo " echo \"fi\" >> $initdir/rc.local" >> "$PKG_DIR"/install/$PKG_POSTINST echo " echo \"\" >> $initdir/rc.local" >> "$PKG_DIR"/install/$PKG_POSTINST echo "fi" >> "$PKG_DIR"/install/$PKG_POSTINST echo "" >> "$PKG_DIR"/install/$PKG_POSTINST fi } last_deps_sort() { if [[ -s "${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 true 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 -r file |grep ELF |egrep '(dynamically linked|shared object)')" != "" ]] ; then 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 rm -f "${CWD}"/deps_list # 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 # should only happen if we are packaging some pre-compiled program if ! [[ $(grep $LINE $PKG_DIR/install/$PKG_PROVIDES 2> /dev/null) ]] ; then echo $LINE >> "${CWD}"/unsatisfied_deps_list fi done <"${CWD}"/unsatisfied_deps_list.tmp rm -f "${CWD}"/unsatisfied_deps_list.tmp fi if [[ -s "${CWD}"/deps_list.tmp ]] ; then # get rid of extra white spaceegrep -v '(linux-gate|not found)' "${CWD}"/deps_list mv "${CWD}"/deps_list.tmp "${CWD}"/deps_list 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 if [[ $PKG_DEP != "" ]] ; then PKG_DEP=$(readlink /$PKG_DEP) # count the number of matches in packages or scripts if [[ $INCLUDE_BASE_LIBS = "YES" ]] ; then PKG_DEP_COUNT=$(grep ${PKG_DEP} $ADM_DIR_NAME/packages/* |wc -l) SCRIPT_DEP_COUNT=$(grep ${PKG_DEP} $ADM_DIR_NAME/$SCRIPT_DIR/* |wc -l) else PKG_DEP_COUNT=$(grep ${PKG_DEP} $ADM_DIR_NAME/packages/* |cut -f1 -d: |cut -f $DEPTH -d/ |grep -v glibc |wc -l) SCRIPT_DEP_COUNT=$(grep ${PKG_DEP} $ADM_DIR_NAME/$SCRIPT_DIR/* |cut -f1 -d: |cut -f $DEPTH -d/ |grep -v glibc |wc -l) fi if [[ $PKG_DEP_COUNT -eq 0 ]] && [[ $SCRIPT_DEP_COUNT -eq 0 ]] && [[ $PKG_DEP != "" ]] ; then # this lists files which are found on the system, but not in the package database if ! [[ $(grep $PKG_DEP $ADM_DIR_NAME/packages/glibc* 2> /dev/null) ]] ; then if [[ ! -f "$CWD"/unfound_depends ]] ; then echo "These dependencies were not found in the package database:" > "$CWD"/unfound_depends fi echo "$PKG_DEP" >> "$CWD"/unfound_depends fi fi # reverse the sort order for files contained in lib_gcc, cxxlibs or *solibs* packages # this has the effect of listing the possible packages so that solibs packages are # listed before full packages, and cxxlibs or lib_gcc before gcc* packages # This keeps dependency resolvers from installing all of gcc-g++ for libstdc++, for example REVERSE= case $PKG_DEP in *libgcc*|*libgomp*|*libmudflap*|*libssp*) REVERSE='-r' ;; esac if [[ $(grep -m 1 "${PKG_DEP}" $ADM_DIR_NAME/packages/*solibs* 2> /dev/null) ]] \ || [[ $(grep -m 1 "${PKG_DEP}" "$ADM_DIR_NAME/packages/cxxlibs*" 2> /dev/null) ]] ; then REVERSE='-r' fi if [[ $PKG_DEP_COUNT -gt 0 ]] ; then if [[ $INCLUDE_BASE_LIBS = "YES" ]] ; then THIS_DEP="$(grep -m 1 ${PKG_DEP} $ADM_DIR_NAME/packages/* |cut -f1 -d: |cut -f $DEPTH -d/ |sort $REVERSE |head -n 1)" else THIS_DEP="$(grep -m 1 ${PKG_DEP} $ADM_DIR_NAME/packages/* |cut -f1 -d: |cut -f $DEPTH -d/ |grep -v '^glibc-' |sort $REVERSE |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 -m 1 ${PKG_DEP} $ADM_DIR_NAME/packages/* |cut -f1 -d: |cut -f $DEPTH -d/ |sort $REVERSE |tail --lines +$COUNT |head -n1)" else NEXT_DEP="$(grep -m 1 ${PKG_DEP} $ADM_DIR_NAME/packages/* |cut -f1 -d: |cut -f $DEPTH -d/ |grep -v '^glibc-' |sort $REVERSE |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 for ONE_DEP in $THIS_DEP ; do case $NEXT_DEP in $ONE_DEP) HAVE_THIS_DEP=1 ; break ;; esac done if ! [[ $HAVE_THIS_DEP ]] ; then case $NEXT_DEP in $NAME-$VERSION-$ARCH-$BUILD*|$NAME) true ;; "") true ;; *) THIS_DEP="$THIS_DEP | $NEXT_DEP" ;; esac fi (( COUNT++ )) done # add THIS_DEP if not null case $THIS_DEP in "") true ;; *) printf "%-40s %-40s\n" "# File: $(basename $PKG_DEP)" "|: $THIS_DEP" >> "$CWD"/deps_list.tmp echo "$THIS_DEP" >> "$CWD"/deps_list.tmp ;; esac elif [[ $SCRIPT_DEP_COUNT -gt 0 ]] ; then if [[ $INCLUDE_BASE_LIBS = "YES" ]] ; then THIS_DEP="$(grep -m 1 ${PKG_DEP} $ADM_DIR_NAME/$SCRIPT_DIR/* |cut -f1 -d: |cut -f $DEPTH -d|sort $REVERSE |head -n 1)" else THIS_DEP="$(grep -m 1 ${PKG_DEP} $ADM_DIR_NAME/$SCRIPT_DIR/* |cut -f1 -d: |cut -f $DEPTH -d/ |grep -v '^glibc-' |sort $REVERSE |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 -m 1 ${PKG_DEP} $ADM_DIR_NAME/$SCRIPT_DIR/* |cut -f1 -d: |cut -f $DEPTH -d/ |sort $REVERSE |tail --lines +$COUNT |head -n1)" else NEXT_DEP="$(grep -m 1 ${PKG_DEP} $ADM_DIR_NAME/$SCRIPT_DIR/* |cut -f1 -d: |cut -f $DEPTH -d/ |grep -v '^glibc-' |sort $REVERSE |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 # check if we already have this NEXT_DEP in the list for ONE_DEP in $THIS_DEP ; do case $NEXT_DEP in $ONE_DEP) HAVE_THIS_DEP=1 ; break ;; esac done if ! [[ $HAVE_THIS_DEP ]] ; then case $NEXT_DEP in $NAME-$VERSION-$ARCH-$BUILD*|$NAME) true ;; "") true ;; *) THIS_DEP="$THIS_DEP | $NEXT_DEP" ;; esac fi (( COUNT++ )) done # add THIS_DEP if not null case $THIS_DEP in "") true ;; *) printf "%-40s %-40s\n" "# File: $(basename $PKG_DEP)" "|: $THIS_DEP" >> "$CWD"/deps_list.tmp echo "$THIS_DEP" >> "$CWD"/deps_list.tmp ;; esac fi fi done rm -f ${CWD}/deps_list last_deps_sort fi rm -f "${CWD}"/deps_list.tmp fi } gen_provides_list() { THIS_PKG_DIR="$1" cd "$THIS_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) ]] ; 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/$PKG_POSTINST ]] ; then IFS=' ' LINKS=$(grep 'ln -s' "$PKG_DIR"/install/$PKG_POSTINST |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() { TARGET_SCRIPT="$1" echo "" >> "$TARGET_SCRIPT" echo "# Figure out our root directory" >> "$TARGET_SCRIPT" echo 'ROOTDIR=$(pwd)' >> "$TARGET_SCRIPT" echo "unset CHROOT" >> "$TARGET_SCRIPT" echo 'if [ "${ROOTDIR}" != "/" ] ; then' >> "$TARGET_SCRIPT" echo ' ROOTDIR="${ROOTDIR}/"' >> "$TARGET_SCRIPT" echo ' CHROOT="chroot ${ROOTDIR} "' >> "$TARGET_SCRIPT" echo 'fi' >> "$TARGET_SCRIPT" } # write_install_info and write_delete_info may get called from here in 14-make_doinst for # the main package or from 15-make_package (segregate_package) for the split docs package. write_install_info_postinst() { THIS_PACKAGE="$1" if [[ ! $(grep install-info "$THIS_PACKAGE"/install/$PKG_POSTINST 2> /dev/null) ]] ; then echo $BLUE"Package contains info files - "$NORMAL"Adding 'install-info ' routine to $PKG_POSTRM" mkdir -p "$THIS_PACKAGE"/install if [[ $(grep 'CHROOT' "$THIS_PACKAGE"/install/$PKG_POSTINST 2> /dev/null) = "" ]] ; then write_chroot_script "$THIS_PACKAGE"/install/$PKG_POSTINST fi ( cd $INFO_DIR echo "" >> "$THIS_PACKAGE"/install/$PKG_POSTINST echo "if [ -x usr/bin/install-info ] ; then" >> "$THIS_PACKAGE"/install/$PKG_POSTINST find * |while read FILE ; do echo ' ${CHROOT} '"usr/bin/install-info --info-dir=${infodir:1} ${infodir:1}/$FILE 2>/dev/null" >> "$THIS_PACKAGE"/install/$PKG_POSTINST done echo "fi" >> "$THIS_PACKAGE"/install/$PKG_POSTINST echo "" >> "$THIS_PACKAGE"/install/$PKG_POSTINST ) fi } write_install_info_postrm() { THIS_PACKAGE="$1" if [[ ! $(grep 'install-info --delete' "$THIS_PACKAGE"/install/$PKG_POSTRM 2> /dev/null |grep 'delete') ]] ; then echo $BLUE"Package contains info files - "$NORMAL"Adding 'install-info --delete' routine to $PKG_POSTRM" mkdir -p "$THIS_PACKAGE"/install if [[ $(grep 'CHROOT' "$THIS_PACKAGE"/install/$PKG_POSTRM 2> /dev/null) = "" ]] ; then write_chroot_script "$THIS_PACKAGE"/install/$PKG_POSTRM fi ( cd $INFO_DIR echo "" >> "$THIS_PACKAGE"/install/$PKG_POSTRM echo "if [ -x usr/bin/install-info ] ; then" >> "$THIS_PACKAGE"/install/$PKG_POSTRM find * |while read FILE ; do echo ' ${CHROOT} '"usr/bin/install-info --info-dir=${infodir:1} --delete --info-file=${infodir:1}/$FILE 2>/dev/null" >> "$THIS_PACKAGE"/install/$PKG_POSTRM done echo "fi" >> "$THIS_PACKAGE"/install/$PKG_POSTRM echo "" >> "$THIS_PACKAGE"/install/$PKG_POSTRM ) fi } # This routine creates the install/PKG_META file with a rich set of information # about who, when, how the package was built # This may be called from here for the main package or from 15-make_package # (segregate_package) for the split devel and/or solibs packages write_meta_data() { THIS_PACKAGE="$1" mkdir -p "$THIS_PACKAGE"/install echo "# Package: ${THIS_PACKAGE##*/}.$PKG_FORMAT" >> "$THIS_PACKAGE"/install/$PKG_META echo "# Created by: '$PACKAGER' on hostname: $(hostname)" >> "$THIS_PACKAGE"/install/$PKG_META echo "# Date: $(date)" >> "$THIS_PACKAGE"/install/$PKG_META echo "# Processor: $(uname -p) $(uname -m)" >> "$THIS_PACKAGE"/install/$PKG_META echo "" >> "$THIS_PACKAGE"/install/$PKG_META echo "# Kernel: $(uname -r) $(uname -v)" >> "$THIS_PACKAGE"/install/$PKG_META echo "# TOOLCHAIN:" >> "$THIS_PACKAGE"/install/$PKG_META /lib/libc.so.6 > "$SRC_DIR"/glibc-info.txt echo -n "# LIBC: " >> "$THIS_PACKAGE"/install/$PKG_META head -n 1 "$SRC_DIR"/glibc-info.txt |cut -f 1 -d',' >> "$THIS_PACKAGE"/install/$PKG_META grep "Compiled by" "$SRC_DIR"/glibc-info.txt >> "$THIS_PACKAGE"/install/$PKG_META grep "Compiled on" "$SRC_DIR"/glibc-info.txt >> "$THIS_PACKAGE"/install/$PKG_META grep "Available extensions" "$SRC_DIR"/glibc-info.txt >> "$THIS_PACKAGE"/install/$PKG_META tail -n +9 "$SRC_DIR"/glibc-info.txt |head -n 4 >> "$THIS_PACKAGE"/install/$PKG_META echo "# COMPILER: GCC-$(gcc -dumpversion) $(gcc -dumpmachine)" >> "$THIS_PACKAGE"/install/$PKG_META echo "" >> "$THIS_PACKAGE"/install/$PKG_META if [[ "$SOURCE_URL" != "" ]] ; then echo "# Source URL: $SOURCE_URL" >> "$THIS_PACKAGE"/install/$PKG_META else echo "# Source name: $SOURCE_NAME" >> "$THIS_PACKAGE"/install/$PKG_META fi if [[ "$PATCHLIST" != "" ]] ; then #echo "# Patches applied: $PATCHLIST" >> "$THIS_PACKAGE"/install/$PKG_META echo "# Patches applied:" >> "$THIS_PACKAGE"/install/$PKG_META for PATCH in $PATCHLIST ; do echo " ${PATCH##*/}" >> "$THIS_PACKAGE"/install/$PKG_META done fi echo "" >> "$THIS_PACKAGE"/install/$PKG_META echo "# Nominal architecture: $ARCH" >> "$THIS_PACKAGE"/install/$PKG_META echo "# Build configuration:" >> "$THIS_PACKAGE"/install/$PKG_META if [[ -f "$SRC_DIR"/$NAME-config-command.txt ]] ; then cat "$SRC_DIR"/$NAME-config-command.txt >> "$THIS_PACKAGE"/install/$PKG_META else echo " LDLAGS=\"$LDFLAGS\" \\" >> "$THIS_PACKAGE"/install/$PKG_META echo " CFLAGS=\"$FLAG_LINE\" \\" >> "$THIS_PACKAGE"/install/$PKG_META echo " $CONFIG_COMMAND $CONFIG_ARGS" >> "$THIS_PACKAGE"/install/$PKG_META fi if [[ -f "$SRC_DIR"/$NAME-compressed-bins ]] ; then echo "" >> "$THIS_PACKAGE"/install/$PKG_META echo "# Package contains these binaries compressed with $BIN_COMPRESSOR:" >> "$THIS_PACKAGE"/install/$PKG_META cat "$SRC_DIR"/$NAME-compressed-bins >> "$THIS_PACKAGE"/install/$PKG_META echo "# If you have problems running any of the above listed binaries," >> "$THIS_PACKAGE"/install/$PKG_META echo "# please report the problem to the package creator. If you have" >> "$THIS_PACKAGE"/install/$PKG_META echo "# '$BIN_COMPRESSOR' on your system, you can first try running them" >> "$THIS_PACKAGE"/install/$PKG_META echo "# after decompressing them with the following command:" >> "$THIS_PACKAGE"/install/$PKG_META echo "# $BIN_COMPRESSOR -d prog-name" >> "$THIS_PACKAGE"/install/$PKG_META fi echo "" >> "$THIS_PACKAGE"/install/$PKG_META } write_update_desktop_database_postinst(){ THIS_PACKAGE="$1" if [[ $(grep 'CHROOT' "$THIS_PACKAGE"/install/$PKG_POSTINST 2> /dev/null) = "" ]] ; then write_chroot_script "$THIS_PACKAGE"/install/$PKG_POSTINST fi if [[ $(grep update-desktop-database "$THIS_PACKAGE"/install/$PKG_POSTINST 2> /dev/null) = "" ]] ; then echo $BLUE"Found .desktop files - "$NORMAL"Adding 'update-desktop-database' routine to $PKG_POSTINST" echo '' >> "$THIS_PACKAGE"/install/$PKG_POSTINST echo '# update the applications menu database' >> "$THIS_PACKAGE"/install/$PKG_POSTINST echo 'if [ -x usr/bin/update-desktop-database ] ; then' >> "$THIS_PACKAGE"/install/$PKG_POSTINST echo ' ${CHROOT} usr/bin/update-desktop-database -q usr/share/applications 2> /dev/null' >> "$THIS_PACKAGE"/install/$PKG_POSTINST echo 'fi' >> "$THIS_PACKAGE"/install/$PKG_POSTINST echo '' >> "$THIS_PACKAGE"/install/$PKG_POSTINST fi } write_update_desktop_database_postrm(){ THIS_PACKAGE="$1" if [[ $(grep 'CHROOT' "$THIS_PACKAGE"/install/$PKG_POSTRM 2> /dev/null) = "" ]] ; then write_chroot_script "$THIS_PACKAGE"/install/$PKG_POSTRM fi if [[ $(grep update-desktop-database "$THIS_PACKAGE"/install/$PKG_POSTRM 2> /dev/null) = "" ]] ; then echo $CYAN" Notice - "$NORMAL"Adding 'update-desktop-database' (remove) routine to $PKG_POSTRM" echo '' >> "$THIS_PACKAGE"/install/$PKG_POSTRM echo '# update the applications menu database' >> "$THIS_PACKAGE"/install/$PKG_POSTRM echo 'if [ -x usr/bin/update-desktop-database ] ; then' >> "$THIS_PACKAGE"/install/$PKG_POSTRM echo ' ${CHROOT} usr/bin/update-desktop-database -q usr/share/applications 2> /dev/null' >> "$THIS_PACKAGE"/install/$PKG_POSTRM echo 'fi' >> "$THIS_PACKAGE"/install/$PKG_POSTRM echo '' >> "$THIS_PACKAGE"/install/$PKG_POSTRM fi } write_gtk_update_icon_cache_postinst(){ THIS_PACKAGE="$1" if [[ $(grep 'CHROOT' "$THIS_PACKAGE"/install/$PKG_POSTINST 2> /dev/null) = "" ]] ; then write_chroot_script "$THIS_PACKAGE"/install/$PKG_POSTINST fi if [[ $(grep gtk-update-icon-cache "$THIS_PACKAGE"/install/$PKG_POSTINST 2> /dev/null) = "" ]] ; then echo $BLUE"Found icon files - "$NORMAL"Adding 'gtk-update-icon-cache' routine to $PKG_POSTINST" echo '' >> "$THIS_PACKAGE"/install/$PKG_POSTINST echo '# update the gtk-icon-cache' >> "$THIS_PACKAGE"/install/$PKG_POSTINST echo 'if [ -x usr/bin/gtk-update-icon-cache ] ; then' >> "$THIS_PACKAGE"/install/$PKG_POSTINST echo ' for dir in usr/share/icons/* ; do' >> "$THIS_PACKAGE"/install/$PKG_POSTINST echo ' if [ -d $dir ]; then' >> "$THIS_PACKAGE"/install/$PKG_POSTINST echo ' ${CHROOT} '"usr/bin/gtk-update-icon-cache --quiet -f -t \$dir 2> /dev/null" >> "$THIS_PACKAGE"/install/$PKG_POSTINST echo ' fi' >> "$THIS_PACKAGE"/install/$PKG_POSTINST echo ' done' >> "$THIS_PACKAGE"/install/$PKG_POSTINST echo 'fi' >> "$THIS_PACKAGE"/install/$PKG_POSTINST echo '' >> "$THIS_PACKAGE"/install/$PKG_POSTINST fi } write_gtk_update_icon_cache_postrm(){ THIS_PACKAGE="$1" if [[ $(grep 'CHROOT' "$THIS_PACKAGE"/install/$PKG_POSTRM 2> /dev/null) = "" ]] ; then write_chroot_script "$THIS_PACKAGE"/install/$PKG_POSTRM fi if [[ $(grep gtk-update-icon-cache "$THIS_PACKAGE"/install/$PKG_POSTRM 2> /dev/null) = "" ]] ; then echo $CYAN" Notice - "$NORMAL"Adding 'gtk-update-icon-cache' routine to $PKG_POSTRM" echo '' >> "$THIS_PACKAGE"/install/$PKG_POSTRM echo '# update the gtk-icon-cache' >> "$THIS_PACKAGE"/install/$PKG_POSTRM echo 'if [ -x usr/bin/gtk-update-icon-cache ] ; then' >> "$THIS_PACKAGE"/install/$PKG_POSTRM echo ' for dir in usr/share/icons/* ; do' >> "$THIS_PACKAGE"/install/$PKG_POSTRM echo ' if [ -d $dir ]; then' >> "$THIS_PACKAGE"/install/$PKG_POSTRM echo ' ${CHROOT} '"usr/bin/gtk-update-icon-cache --quiet -f -t \$dir 2> /dev/null" >> "$THIS_PACKAGE"/install/$PKG_POSTRM echo ' fi' >> "$THIS_PACKAGE"/install/$PKG_POSTRM echo ' done' >> "$THIS_PACKAGE"/install/$PKG_POSTRM echo 'fi' >> "$THIS_PACKAGE"/install/$PKG_POSTRM echo '' >> "$THIS_PACKAGE"/install/$PKG_POSTRM fi } write_update_mime_database_postinst() { THIS_PACKAGE="$1" if [[ $(grep 'CHROOT' "$THIS_PACKAGE"/install/$PKG_POSTINST 2> /dev/null) = "" ]] ; then write_chroot_script "$THIS_PACKAGE"/install/$PKG_POSTINST fi if [[ $(grep update-mime-database "$THIS_PACKAGE"/install/$PKG_POSTINST 2> /dev/null) = "" ]] ; then echo $BLUE"Found mime-database files - "$NORMAL"Adding 'update-mime-database' routine to $PKG_POSTINST" echo '' >> "$THIS_PACKAGE"/install/$PKG_POSTINST echo '# update the mime database' >> "$THIS_PACKAGE"/install/$PKG_POSTINST echo 'if [ -x usr/bin/update-mime-database ] ; then' >> "$THIS_PACKAGE"/install/$PKG_POSTINST echo ' ${CHROOT} usr/bin/update-mime-database -q usr/share/mime 2> /dev/null' >> "$THIS_PACKAGE"/install/$PKG_POSTINST echo 'fi' >> "$THIS_PACKAGE"/install/$PKG_POSTINST echo '' >> "$THIS_PACKAGE"/install/$PKG_POSTINST fi } write_update_mime_database_postrm() { THIS_PACKAGE="$1" if [[ $(grep 'CHROOT' "$THIS_PACKAGE"/install/$PKG_POSTRM 2> /dev/null) = "" ]] ; then write_chroot_script "$THIS_PACKAGE"/install/$PKG_POSTRM fi if [[ $(grep update-mime-database "$THIS_PACKAGE"/install/$PKG_POSTRM 2> /dev/null) = "" ]] ; then echo $BLUE"Found mime-database files - "$NORMAL"Adding 'update-mime-database' routine to $PKG_POSTRM" echo '' >> "$THIS_PACKAGE"/install/$PKG_POSTRM echo '# update the mime database' >> "$THIS_PACKAGE"/install/$PKG_POSTRM echo 'if [ -x usr/bin/update-mime-database ] ; then' >> "$THIS_PACKAGE"/install/$PKG_POSTRM echo ' ${CHROOT} usr/bin/update-mime-database -q usr/share/mime 2> /dev/null' >> "$THIS_PACKAGE"/install/$PKG_POSTRM echo 'fi' >> "$THIS_PACKAGE"/install/$PKG_POSTRM echo '' >> "$THIS_PACKAGE"/install/$PKG_POSTRM fi } write_update_gtk_immodules_postinst() { THIS_PACKAGE="$1" if [[ $(grep 'CHROOT' "$THIS_PACKAGE"/install/$PKG_POSTINST 2> /dev/null) = "" ]] ; then write_chroot_script "$THIS_PACKAGE"/install/$PKG_POSTINST fi if [[ $(grep update-gtk-immodules "$THIS_PACKAGE"/install/$PKG_POSTINST 2> /dev/null) = "" ]] ; then echo $BLUE"Found gtk-immodules - "$NORMAL"Adding 'update-gtk-immodules' routine to $PKG_POSTINST" echo '' >> "$THIS_PACKAGE"/install/$PKG_POSTINST echo '# update the gtk immodules' >> "$THIS_PACKAGE"/install/$PKG_POSTINST echo 'if [ -x usr/bin/update-gtk-immodules ] ; then' >> "$THIS_PACKAGE"/install/$PKG_POSTINST echo ' ${CHROOT} usr/bin/update-gtk-immodules 2> /dev/null' >> "$THIS_PACKAGE"/install/$PKG_POSTINST echo 'fi' >> "$THIS_PACKAGE"/install/$PKG_POSTINST echo '' >> "$THIS_PACKAGE"/install/$PKG_POSTINST fi } write_update_gtk_immodules_postrm() { THIS_PACKAGE="$1" if [[ $(grep 'CHROOT' "$THIS_PACKAGE"/install/$PKG_POSTRM 2> /dev/null) = "" ]] ; then write_chroot_script "$THIS_PACKAGE"/install/$PKG_POSTRM fi if [[ $(grep update-gtk-immodules "$THIS_PACKAGE"/install/$PKG_POSTRM 2> /dev/null) = "" ]] ; then echo $BLUE"Found gtk-immodules - "$NORMAL"Adding 'update-gtk-immodules' routine to $PKG_POSTRM" echo '' >> "$THIS_PACKAGE"/install/$PKG_POSTRM echo '# update the gtk immodules' >> "$THIS_PACKAGE"/install/$PKG_POSTRM echo 'if [ -x usr/bin/update-gtk-immodules ] ; then' >> "$THIS_PACKAGE"/install/$PKG_POSTRM echo ' ${CHROOT} usr/bin/update-gtk-immodules > /dev/null' >> "$THIS_PACKAGE"/install/$PKG_POSTRM echo 'fi' >> "$THIS_PACKAGE"/install/$PKG_POSTRM echo '' >> "$THIS_PACKAGE"/install/$PKG_POSTRM fi }