## /usr/libexec/src2pkg/FUNCTIONS ## src2pkg FUNCTIONS Version-1.4 ## src2pkg (formerly PkgBuild) - Copyright 2005-2007 Gilbert Ashley # How were we called? EXEC_NAME="${0##*/}" # Where were we called from? CWD ! [[ $CWD ]] && CWD=$(pwd) && cd $CWD && CWD=$(pwd) ; # If GLOBAL_CONF is not specified, look for the default GLOBAL.conf file ! [[ $GLOBAL_CONF ]] && GLOBAL_CONF="/etc/src2pkg/src2pkg.conf" # Read in the global configuration if it's there, though you can run without one. [[ -e $GLOBAL_CONF ]] && source $GLOBAL_CONF ## The DEFINES file sets some very important default variables which are needed for ## the functions below. The code is kept separately because it mostly sets up the basic ## src2pkg behaviour that an advanced user might ever want to tweak. ## They are kept apart to avoid the user editing *this* FUNCTIONS file. ! [[ $DEFINES ]] && DEFINES=/usr/libexec/src2pkg/DEFINES if [[ -e $DEFINES ]] ; then source $DEFINES else echo "Warning! DEFINES file not found." FAILED="NO DEFINES" exit 0 fi ## Note that only the above code is executed when this file is 'sourced' by src2pkg, trackinstall ## or a *.src2pkg script. All the code below here is written as functions which are only read-in, ## that is they are saved in RAM and only executed when their name is called by the script or ## program. Each function must be supplied with certain variable values which are given by ## the script or program or as environmental variables. ### The function do_all_processes summarizes the default execution order into a single ### command. Showing this here provides an overview of the standard list of commands. ### Most of the functions in this list also call other internal functions. But this list is the ### list used for a standard build and combined with the variables constitutes an API. ### src2pkg scripts which contain no custom code can be abbreviated by using ### this do_all_processes function instead of listing all 16 steps. ### Function do_all_processes ######################################## do_all_processes() { pre_process find_source make_dirs unpack_source fix_source_perms configure_source compile_source fake_install fix_pkg_perms strip_bins create_docs compress_man_pages make_description make_doinst make_package post_process } ### End Function do_all_processes ############################### ### The function do_track_install summarizes the execution order for trackinstall. ### find_source, unpack_source, configure_source and compile_source are not used. ### This function is not called, but may be used as an abbreviation in a TrackBuild script. do_track_install() { pre_process make_dirs fake_install fix_pkg_perms strip_bins create_docs compress_man_pages make_description make_doinst make_package post_process } ### ############### Process Functions ######################## ## The individual processing functions -mostly in their order of execution. ## Most small or distracting internal functions are near the end of this file ## to make better readability of the code in the most important places. ## The pre_process and post_process functions perform extra operations ## ##### pre_process ##### This is the only function which is really required as it is where all ##### the main variables get setup and crunched into usable form pre_process() { # color is on only if COLOR_PROMPT=YES get_color_options ; # you must be root to run src2pkg if ! [[ "$(whoami)" = "root" ]] ; then echo $RED"FATAL!!! "$NORMAL"You must be logged in as root or use su to run src2pkg." exit 1 fi # These are important defaults that need to be set ! [[ $STD_MASK ]] && STD_MASK="000" umask $STD_MASK ! [[ $MAKE_LINKS ]] && MAKE_LINKS="YES" # REALLY_INSTALL=YES is similar to what checkinstall does. ! [[ $REALLY_INSTALL = "YES" ]] && REALLY_INSTALL="NO" # This is the most-used option of all. But if not specified it should be nulled. ! [[ $EXTRA_CONFIGS ]] && EXTRA_CONFIGS="" ! [[ $BUILD ]] && BUILD="1" # get the ARCH and compiler tuning flags for CFLAGS (function is near end of file) get_flags ; # Use our own statically-linked binaries at least for the most critical stuff ! [[ $STATIC_DIR ]] && STATIC_DIR=/usr/libexec/src2pkg/static # These are the programs needed during restoration of overwritten files # and removal of any left over new files, before running ldconfig in fake_install # we use a version of tar from the full sources instead of the busybox version # The static tar program is use throughout src2pkg TAR_STATIC=$STATIC_DIR/tar # these all come from busybox and are only used in fake_install CAT_STATIC=$STATIC_DIR/cat cp_STATIC=$STATIC_DIR/cp CUT_STATIC=$STATIC_DIR/cut EGREP_STATIC=$STATIC_DIR/egrep GREP_STATIC=$STATIC_DIR/grep MKDIR_STATIC=$STATIC_DIR/mkdir RM_STATIC=$STATIC_DIR/rm SORT_STATIC=$STATIC_DIR/sort UNIQ_STATIC=$STATIC_DIR/uniq # find out what version of tar we are using if [[ "$(${TAR_STATIC} --version |grep '1.13')" != "" ]] ; then OLDTAR=1 else OLDTAR=0 fi # try to get the name, version and source suffix(SOURCE_NAME # early PkgBuild versions supplied NAME VERSION and SRC_SUFFIX separately if [ "$NAME" -a "$VERSION" -a "$SRC_SUFFIX" ] ; then SOURCE_NAME="$NAME-$VERSION$SRC_SUFFIX" fi # newer versions of src2pkg derive NAME & VERSION from SOURCE_URL, SOURCE or SOURCE_NAME if [[ "$SOURCE_URL" != "" ]] ; then # SOURCE_URL was given explicitly SOURCE_NAME="$(basename $SOURCE_URL)" SOURCE=$SOURCES_DIR/$SOURCE_NAME elif [[ "$SOURCE" != "" ]] ; then SOURCE_NAME=$(basename $SOURCE) case $SOURCE in # SOURCE is a URL *://*) SOURCE_URL="$SOURCE" ; SOURCE=$SOURCES_DIR/$SOURCE_NAME ; shift ;; # Double slashes get corrected if this is not a URL //*) SOURCE=${SOURCE#*/} ; shift ;; # Relative path(./) ./*) SOURCE=$CWD/${SOURCE#*/} ; shift ;; # Absoulte path" /*) SOURCE=$SOURCE ;; # Extended relative path [a-z,A-Z,0-9]*/*) SOURCE=$CWD/$SOURCE ; shift ;; # No path given *) SOURCE=$SOURCES_DIR/$SOURCE ; shift ;; esac elif [[ "$SOURCE_NAME" != "" ]] ; then case $SOURCE_NAME in # SOURCE_NAME is a URL *://*) SOURCE_URL="$SOURCE" ; SOURCE=$SOURCES_DIR/$SOURCE_NAME SOURCE_NAME=$(basename $SOURCE_NAME) ; shift ;; //*) SOURCE=${SOURCE_NAME#*/} ;; ./*) SOURCE=$CWD/${SOURCE_NAME#*/} ;; /*) SOURCE=$SOURCE_NAME ;; [a-z,A-Z,0-9]*/*) SOURCE=$CWD/$SOURCE_NAME ;; *) SOURCE=$SOURCES_DIR/$SOURCE_NAME ;; esac fi # local function get_my_arch() { ARCH_CHUNK=$(echo $NAMVERS |rev |cut -f1,2 -d'-' |rev) case $ARCH_CHUNK in *i386*) MYARCH=i386 ;; *i486*) MYARCH=i486 ;; *i586*) MYARCH=i586 ;; *i686*) MYARCH=i686 ;; *ppc*) MYARCH=ppc ;; *powerpc*) MYARCH=powerpc ;; *x86_64*) MYARCH=x86_64 ;; *s390*) MYARCH=s390 ;; *noarch*) MYARCH=noarch ;; esac } # local function translate_underlines() { if [[ $(echo $NAMVERS |grep -v "_") = "" ]] ; then if [[ $(echo $NAMVERS |grep -v ".") = "" ]] ; then #echo "Translating underlines to periods" NAMVERS=$(echo $NAMVERS |tr '_' '.') fi fi } # The next +-200 lines analyze the SOURCE_NAME and try to figure out the correct NAME and VERSION # Handling of debian and especially rpm archives make this pretty complex. if [[ "$SOURCE_NAME" != "" ]] ; then [[ $DEBUG ]] && echo -n $BLUE"Guessing content type based on file suffix: "$NORMAL NAMVERS=$(basename $SOURCE_NAME) case $NAMVERS in *src.rpm) EXT='src.rpm' ;; *src.tgz) EXT='src.tgz' ;; *src.tar.gz) EXT='src.tar.gz' ;; *rpm) EXT='rpm' ;; *deb) EXT='deb' ;; *orig.tar.gz) EXT='orig.tar.gz' ;; *orig.tar.bz2) EXT='orig.tar.bz2' ;; *tgz) EXT='tgz' ;; *tbz) EXT='tbz' ;; *tar.gz) EXT='tar.gz' ;; *tar.bz2) EXT='tar.bz2' ;; esac if [[ $NAMVERS = ".$EXT" ]] || [[ $NAMVERS = $EXT ]] ; then echo "We're crapping out (probably null name or suffix-only" exit else RAW_SOURCE_NAME=$(basename $NAMVERS ."$EXT") fi NAMVERS=$RAW_SOURCE_NAME case $EXT in src.rpm|src.tgz|src.tar.gz) if [[ $DEBUG ]] ; then [[ "$EXT" = "src.rpm" ]] && echo -n "RPM source archive" \ || echo -n "rpm2tgz-converted RPM source" fi translate_underlines if [[ $(echo $NAMVERS |grep '-') ]] ; then if [[ $(echo $NAMVERS |rev |cut -f2 -d'-') != $(echo $NAMVERS |rev |cut -f3 -d'-') ]] ; then if [[ $(echo $NAMVERS |rev |cut -f1 -d'.' |grep "-") ]] ; then # [[ $DEBUG ]] && echo " Rule 1" CHUNK=$(echo $NAMVERS |rev |cut -f1 -d'.' |rev) CARRY=$(echo $CHUNK |cut -f1 -d'-') REV_CHUNK=$(echo $CHUNK |cut -f2- -d'-') NAMVERS=$(basename $NAMVERS .$CHUNK).$CARRY else # [[ $DEBUG ]] && echo " Rule 2" REV_CHUNK=$(echo $NAMVERS |rev |cut -f1 -d'-' |rev) NAMVERS=$(echo $NAMVERS |rev |cut -f2- -d'-' |rev) fi fi VERSION=$(echo $NAMVERS |rev |cut -f1 -d'-' |rev) NAME=$(echo $NAMVERS |rev |cut -f2- -d'-' |rev) else # [[ $DEBUG ]] && echo "Name contains no dashes" true fi if [[ $NAME = $VERSION ]] ; then # [[ $DEBUG ]] && echo "Reconverting! This is not an RPM-type name" VERSION=$(echo $RAW_SOURCE_NAME |rev |cut -f1 -d'-' |rev) NAME=$(basename $RAW_SOURCE_NAME -$VERSION) fi [[ "$VERSION" = "$NAME" ]] && VERSION=0.0.0 ;; rpm) translate_underlines get_my_arch if [[ $(echo $NAMVERS |grep "$MYARCH") != "" ]] ; then [[ $DEBUG ]] && echo -n "RPM binary package" ARCH=$(echo $NAMVERS |rev |cut -f1 -d'.' |rev) NAMVERS=$(basename $NAMVERS .$ARCH) if [[ $(echo $ARCH |grep "-") ]] ; then ARCH=$(echo $ARCH |rev |cut -f2- -d'-' |rev) fi else [[ $DEBUG ]] && echo -n "Generic RPM archive" fi if [[ $(echo $NAMVERS |rev |cut -f2 -d'-') != $(echo $NAMVERS |rev |cut -f3 -d'-') ]] ; then if [[ $(echo $NAMVERS |rev |cut -f1 -d'.' |grep "-") ]] ; then # [[ $DEBUG ]] && echo -n " Rule 1" CHUNK=$(echo $NAMVERS |rev |cut -f1 -d'.' |rev) REV_CHUNK=$(echo $CHUNK |cut -f2- -d'-') CARRY=$(echo $CHUNK |cut -f1 -d'-') NAMVERS=$(basename $NAMVERS .$CHUNK).$CARRY else #[[ $DEBUG ]] && echo -n " Rule 2" REV_CHUNK=$(echo $NAMVERS |rev |cut -f1 -d'-' |rev) NAMVERS=$(echo $NAMVERS |rev |cut -f2- -d'-' |rev) fi fi if [[ $(echo $NAMVERS |rev |cut -f1 -d'-' |rev |grep "_") ]] ; then #[[ $DEBUG ]] && echo -n " Rule 3" VERSION=$(echo $NAMVERS |rev |cut -f1 -d'-' |rev) VERSION=$(echo $NAMVERS |tr '_' '.') NAME=$(echo $NAMVERS |rev |cut -f2- -d'-' |rev) else #[[ $DEBUG ]] && echo -n " Rule 4" VERSION=$(echo $NAMVERS |rev |cut -f1 -d'-' |rev) NAME=$(echo $NAMVERS |rev |cut -f2- -d'-' |rev) fi ;; deb) [[ $DEBUG ]] && echo "Debian binary package" ARCH=$(echo $NAMVERS |rev |cut -f1 -d'_' |rev) NAMVERS=$(echo $NAMVERS |rev |cut -f2- -d'_' |rev) if [[ $(echo $NAMVERS |rev |cut -f1 -d'.' |grep '-') ]] ; then NAMVERS=$(echo $NAMVERS |rev |cut -f2- -d'-' |rev) fi VERSION=$(echo $NAMVERS |cut -f2- -d'_') NAME=$(echo $NAMVERS |cut -f1 -d'_') ;; *) get_my_arch if [[ "$MYARCH" != "" ]] ; then if [[ $(echo $ARCH_CHUNK |cut -f1 -d '-') = $ARCH ]] ; then [[ $DEBUG ]] && echo "Slackware binary package" ARCH=$(echo $NAMVERS |rev |cut -f2 -d'-' |rev) NAMVERS=$(echo $NAMVERS |rev |cut -f2- -d'-' |rev) VERSION=$(echo $NAMVERS |rev |cut -f2 -d'-' |rev) NAME=$(basename $NAMVERS -$VERSION-$ARCH) elif [[ $(echo $NAMVERS |rev |cut -f1 -d'.' |rev |grep $MYARCH) != "" ]] ; then translate_underlines ARCH_CHUNK=$(echo $NAMVERS |rev |cut -f1 -d'.' |rev) [[ $DEBUG ]] && echo "Binary rpm2$EXT archive" NAMVERS=$(basename $NAMVERS .$ARCH_CHUNK) if [[ $(echo $ARCH_CHUNK |grep '-') ]] ; then ARCH=$(echo $ARCH_CHUNK |rev |cut -f2- -d'-' |rev) else ARCH="$ARCH_CHUNK" fi if [[ $(echo $NAMVERS |rev |cut -f1 -d'.' |grep "-") ]] ; then CHUNK=$(echo $NAMVERS |rev |cut -f1 -d'.' |rev) REV_CHUNK=$(echo $CHUNK |cut -f2- -d'-') CARRY=$(echo $CHUNK |cut -f1 -d'-') NAMVERS=$(basename $NAMVERS .$CHUNK).$CARRY else REV_CHUNK=$(echo $NAMVERS |rev |cut -f1 -d'-' |rev) NAMVERS=$(echo $NAMVERS |rev |cut -f2- -d'-' |rev) fi VERSION=$(echo $NAMVERS |rev |cut -f1 -d'-' |rev) NAME=$(echo $NAMVERS |rev |cut -f2- -d'-' |rev) else translate_underlines [[ $DEBUG ]] && echo "Generic binary $EXT archive" if [[ $(echo $NAMVERS |grep '-') ]] ; then VERSION=$(echo $NAMVERS |rev |cut -f1 -d'-' |rev) NAME=$(basename $NAMVERS -$VERSION) elif [[ $(echo $NAMVERS |grep '.') ]] ; then NAME=$(echo $NAMVERS |cut -f1 -d'.') NAME=$(echo $NAMVERS |cut -f2- -d'.') else echo "What is this?" NAME=unknown VERSION=0.0 fi fi else case $EXT in tgz|tar.gz|tbz|tar.bz2|orig.tar.gz|orig.tar.bz2) if [[ $(basename $SOURCE_NAME |grep ".orig.") ]] ; then [[ $DEBUG ]] && echo -n "Debian source archive" NAMVERS=$(basename $NAMVERS ".orig") elif [[ $(basename $SOURCE_NAME |grep "_") ]] ; then [[ $DEBUG ]] && echo -n "Possible Debian source archive" elif [[ $(basename $SOURCE_NAME |grep ".source.") ]] ; then [[ $DEBUG ]] && echo -n "Converted RPM source archive" NAMVERS=$(basename $NAMVERS ".source") else [[ $DEBUG ]] && echo -n "Generic source archive" fi translate_underlines if [[ $(echo $NAMVERS |grep '-') != "" ]] ; then #[[ $DEBUG ]] && echo " Rule 1" VERSION=$(echo $NAMVERS |rev |cut -f1 -d'-' |rev) NAME=$(basename $NAMVERS -$VERSION) elif [[ $(echo $NAMVERS |grep '_') != "" ]] ; then VERSION=$(echo $NAMVERS |rev |cut -f1 -d'_' |rev) NAME=$(basename $NAMVERS _$VERSION) else #[[ $DEBUG ]] && echo " Rule 2" NAME=$(echo $NAMVERS |cut -f1 -d'.') VERSION=$(echo $NAMVERS |cut -f2- -d'.') [[ "$VERSION" = "$NAME" ]] && VERSION=0.0.0 fi ;; esac fi ;; esac [[ $DEBUG ]] && echo "" # Whew!! The derived name and can always be overridden else if [[ $NAME ]] && [[ $VERSION ]] ; then NAMVERS="$NAME-$VERSION" echo $BLUE"Client or user supplied NAME and VERSION: "$NORMAL"$NAMVERS" else NAMVERS=$(basename $CWD) echo $BLUE"Using NAME and VERSION from CWD: "$NORMAL"$NAMVERS" fi if [[ $(echo $NAMVERS |grep '-') != "" ]] ; then VERSION=$(echo $NAMVERS |rev |cut -f1 -d'-' |rev) NAME=$(basename $NAMVERS -$VERSION) elif [[ $(echo $NAMVERS |grep '_') != "" ]] ; then VERSION=$(echo $NAMVERS |rev |cut -f1 -d'_' |rev) NAME=$(basename $NAMVERS _$VERSION) elif [[ $(echo $NAMVERS |grep '.') ]] ; then NAME=$(echo $NAMVERS |cut -f1 -d'.') VERSION=$(echo $NAMVERS |cut -f2- -d'.') [[ "$VERSION" = "$NAME" ]] && VERSION=0.0.0 else echo "What in the world is this?" NAME=unknown VERSION=0.unknown.0 fi VERSION=$(echo $VERSION |tr '-' '_') fi # ORIG_NAME & ORIG_VERSION are the 'best guess' from above. We save the values before # correcting or overriding them. They are used later to help second-guess tarball names, if needed. ORIG_NAME="$NAME" ORIG_VERSION="$VERSION" # [[ $DEBUG ]] && [[ $ARCH_CHUNK ]] && echo $BLUE"ARCH_CHUNK="$NORMAL"$ARCH_CHUNK" # [[ $DEBUG ]] && [[ $MYARCH ]] && echo $BLUE"MYARCH="$NORMAL"$MYARCH" # [[ $DEBUG ]] && [[ $REV_CHUNK ]] && echo $BLUE"REV_CHUNK="$NORMAL"$REV_CHUNK" [[ $DEBUG ]] && echo $BLUE"ORIG_NAME="$NORMAL"$ORIG_NAME" [[ $DEBUG ]] && echo $BLUE"ORIG_VERSION="$NORMAL"$ORIG_VERSION" # Now correct the name for capital letters if needed if [[ $(echo $NAME | grep -e "[A-Z]") ]] ; then echo $BLUE"Notice - "$NORMAL"Source name contains capital letters." if [[ "$CORRECT_NAMES" = "YES" ]] && [[ ! $ALT_NAME ]] ; then ALT_NAME=$(echo $NAME | tr 'A-Z' 'a-z') elif [[ $ALT_NAME ]] ; then if echo $ALT_NAME | grep -e "[A-Z]" &> /dev/null ; then echo $BLUE"Notice - "$NORMAL"Alternate Name contains capital letters." echo -n "A better name for $ALT_NAME would be: " echo $ALT_NAME | tr 'A-Z' 'a-z' fi fi fi if [[ "$ALT_VERSION" != "" ]] ; then if echo $ALT_VERSION | grep -e "-" &> /dev/null ; then echo $YELLOW"ERROR - "$NORMAL"Version numbers with a '-' character are not allowed." ALT_VERSION=$(echo $ALT_VERSION |tr '-' '.') fi echo $BLUE"Resetting version number - "$NORMAL"Using: "$BLUE"$ALT_VERSION"$NORMAL VERSION="$ALT_VERSION" fi if [[ "$ALT_NAME" != "" ]] ; then echo $BLUE"Resetting package name - "$NORMAL"Using: "$BLUE"$ALT_NAME"$NORMAL NAME="$ALT_NAME" fi # exit if no NAME or VERSION are found if [[ ! $NAME ]] ; then echo $RED"ERROR - "$NORMAL"Unable to find a NAME. Please give one!" exit elif [[ ! $VERSION ]] ; then echo $RED"ERROR - "$NORMAL"Unable to find a VERSION. Please give one!" exit fi if [[ $TRACK_INSTALL ]] ; then SRC_DIR=$CWD OBJ_DIR=$SRC_DIR elif [[ $USE_OBJ_DIR ]] ; then SRC_DIR_NAME=$NAME-$VERSION-src-$BUILD$SIG SRC_DIR=$SRC_BUILDS_DIR/$SRC_DIR_NAME OBJ_DIR_NAME=$NAME-$VERSION-obj-$BUILD$SIG OBJ_DIR=$SRC_BUILDS_DIR/$OBJ_DIR_NAME elif [[ $SOURCE_NAME ]] ; then # let configure_source sort our CONFIG_DIR and OBJ_DIR SRC_DIR_NAME=$NAME-$VERSION-src-$BUILD$SIG SRC_DIR=$SRC_BUILDS_DIR/$SRC_DIR_NAME elif [[ $NAME ]] && [[ $VERSION ]] ; then # try assuming this, which should allow using a src2pkg script inside sources SRC_DIR=$CWD OBJ_DIR=$SRC_DIR fi PKG_DIR_NAME=$NAME-$VERSION-pkg-$BUILD$SIG PKG_DIR=$PKG_BUILDS_DIR/$PKG_DIR_NAME # make script writing easier by using DOC_DIR and MAN_DIR DOC_DIR=usr/doc/$NAME-$VERSION MAN_DIR=/usr/man # This should help make code from SlackBuild scripts compatible PKG=$PKG_DIR # these are internal abbreviations to shorten code lines SHORT_NAME="$NAME-$VERSION-$ARCH-$BUILD$SIG" PKG_NAME=$SHORT_NAME.tgz PACKAGE=$PKG_DEST_DIR/$PKG_NAME # check the validity of the directories (function near end of file) check_dirs1 } # end pre_process # this function gets used for downloading build scripts, sources and extra sources download_url() { if ! [[ $DOWNLOADER ]] ; then if [[ $(which wget) ]] ; then DOWNLOADER=wget elif [[ $(which rsync) ]] ; then DOWNLOADER=rsync elif [[ $(which curl) ]] ; then DOWNLOADER=curl elif [[ $(which lynx) ]] ; then DOWNLOADER=lynx else DOWNLOADER="" fi fi case $DOWNLOADER in wget) echo $BLUE"Downloading ${URL_TYPE} with wget from: "$NORMAL"$URL_ADDRESS" ; wget -nv -O "${URL_DEST}" "${URL_ADDRESS}" &> /dev/null ;; rsync) echo $BLUE"Downloading ${URL_TYPE} with rsync from: "$NORMAL"$URL_ADDRESS" rsync "${URL_ADDRESS}" >"${URL_DEST}" &> /dev/null ;; curl) echo $BLUE"Downloading ${URL_TYPE} with curl from: "$NORMAL"$URL_ADDRESS" ; curl -s "${URL_ADDRESS}" >"${URL_DEST}" &> /dev/null ;; lynx) echo $BLUE"Downloading ${URL_TYPE} with lynx from: "$NORMAL"$URL_ADDRESS" ; lynx -source "${URL_ADDRESS}" >"${URL_DEST}" &> /dev/null ;; *) echo "No downloader available." ; exit ;; esac } ### find_source find_source() { if [[ "$EXTRA_SOURCES" != "" ]] ; then for URL in $EXTRA_SOURCES ; do if ! [[ -e $CWD/$(basename ${URL}) ]] ; then if [ ! -w "$CWD" ] ; then echo $RED"FAILED! "$NORMAL"CWD is not writable... exiting." FAILED="READONLY CWD" else URL_ADDRESS=${URL} URL_DEST=${CWD}/$(basename $URL) URL_TYPE="extra sources" download_url if [ $? -ne 0 ] ; then mv -f "${CWD}/$(basename $URL)" ${CWD}/$(basename $URL).FAIL echo $RED"FAILED! "$NORMAL"Downloading '$(basename ${URL})' failed or cancelled." FAILED="EXTRA_SOURCES DOWNLOAD" else if [ "$DOWNLOAD_ONLY" ]; then echo $BLUE"Download completed to: "$NORMAL"${CWD}/$(basename $URL)" exit 0 else echo $BLUE"Extra sources downloaded to: "$NORMAL"${CWD}/$(basename $URL)" fi fi fi fi done fi if [[ "$SOURCE" != "" ]] || [[ "$SOURCE_NAME" != "" ]] ; then if [[ -L $SOURCE ]] ; then echo $BLUE"Found source archive: "$NORMAL"$(basename $SOURCE)" echo "It's really a symlink to: $(readlink -f $SOURCE)" SOURCE=$(readlink -f $SOURCE) elif [[ -f $SOURCE ]] ; then echo $BLUE"Found source archive: "$NORMAL"$(basename $SOURCE)" SOURCE=$SOURCE elif [[ -f $SOURCES_DIR/$SOURCE_NAME ]] ; then echo $BLUE"Found source archive in SOURCES_DIR: "$NORMAL"$(basename $SOURCE_NAME)" SOURCE=$SOURCES_DIR/$SOURCE_NAME elif [[ -f $CWD/$SOURCE ]] ; then echo $BLUE"Found source archive in CWD: "$NORMAL"$(basename $SOURCE)" SOURCE=$CWD/$SOURCE elif [ "${SOURCE_URL}" != "" ]; then if [ ! -w "$SOURCES_DIR" ] ; then echo $RED"FAILED! "$NORMAL"SOURCES_DIR is not writable... exiting." FAILED="READONLY SOURCES_DIR" else URL_ADDRESS=${SOURCE_URL} URL_DEST=${SOURCE} URL_TYPE="sources" download_url if [ $? -ne 0 ]; then mv -f "${SOURCE}" "${SOURCE}".FAIL echo $RED"FAILED! "$NORMAL"Downloading '$(basename ${SOURCE})' failed or cancelled." FAILED="SOURCE DOWNLOAD" else if [ "$DOWNLOAD_ONLY" ]; then echo $BLUE"Download completed to: "$NORMAL"$SOURCE" exit 0 else echo $BLUE"Sources downloaded to: "$NORMAL"$SOURCE" fi fi fi else echo $RED"FAILED! "$NORMAL"File: $(basename $SOURCE) not found!" echo "Check for errors in the NAME, VERSION or SRC_SUFFIX. " FAILED="SOURCE LOCATION" fi fi } ### make_dirs make_dirs() { if [[ "$PACKAGE" = "$SOURCE" ]] ; then echo $RED"FAILED! "$NORMAL"You appear to be trying to repackage" echo "a package with the same name from inside your PKG_DEST_DIR." FAILED=" SOURCE_EQUALS_PACKAGE" fi if [[ "$FAILED" = "" ]] ; then # check validity of directories again check_dirs2 # clean up any leftover directories, packages and logs if [[ -f $PACKAGE ]] || [[ -d $PKG_DIR ]] ; then [[ "$QUIET" = "YES" ]] && echo -n $BLUE"Deleting old build files - "$NORMAL if [[ -f $PKG_DEST_DIR/$PKG_NAME ]] && [[ "$PACKAGE" != "$SOURCE" ]] ; then [[ "$QUIET" = "NO" ]] && echo $BLUE"Removing existing package from previous build - "$NORMAL ( cd $PKG_DEST_DIR && rm -f $PKG_NAME 2> /dev/null 1> /dev/null ) fi if [[ -d $PKG_BUILDS_DIR/$PKG_DIR_NAME ]] ; then [[ "$QUIET" = "NO" ]] && echo $BLUE"Removing existing package build directory from previous build - "$NORMAL ( cd $PKG_BUILDS_DIR && rm -rf $PKG_DIR_NAME 2> /dev/null 1> /dev/null ) fi if [[ $OBJ_DIR_NAME != "" ]] && [[ -d $SRC_BUILDS_DIR/$OBJ_DIR_NAME ]] ; then [[ "$QUIET" = "NO" ]] && echo $BLUE"Removing existing object build directory from previous build - "$NORMAL ( cd $SRC_BUILDS_DIR && rm -rf $OBJ_DIR_NAME 2> /dev/null 1> /dev/null ) fi if [[ -d $SRC_BUILDS_DIR/$SRC_DIR_NAME ]] ; then if [[ $SRC_DIR = $CWD ]] || [[ $SRC_BUILDS_DIR/$SRC_DIR_NAME = $CWD ]] ; then [[ "$QUIET" = "NO" ]] && echo $BLUE"Skipping source build directory - "$NORMAL # be sure to skip this if SRC_DIR=CWD or we remove ourselves true else [[ "$QUIET" = "NO" ]] && echo $BLUE"Removing existing source build directory from previous build - "$NORMAL ( cd $SRC_BUILDS_DIR && rm -rf $SRC_DIR_NAME 2> /dev/null 1> /dev/null ) fi fi # remove any logfiles leftover from fake_install. They should only exist if the build # was interrupted or if we were asked to save them [[ -e $CWD/FILELIST ]] && rm -f $CWD/FILELIST 2> /dev/null 1> /dev/null [[ -e $CWD/FILELIST.tmp ]] && rm -f $CWD/FILELIST.tmp 2> /dev/null 1> /dev/null [[ -e $CWD/DIRLIST ]] && rm -f $CWD/DIRLIST 2> /dev/null 1> /dev/null # clean up any debugging list or logs [[ -e $CWD/LINKLIST ]] && rm -f $CWD/LINKLIST 2> /dev/null 1> /dev/null [[ -e $CWD/FILELIST.orig ]] && rm -f $CWD/LINKLIST 2> /dev/null 1> /dev/null # cleanup any reports left from post_process [[ -e $DATABASE_FILE ]] && rm -f $DATABASE_FILE [[ -e $REPORT_FILE ]] && rm -f $REPORT_FILE # if the -backup dir still exists something went wrong last time -remove it anyway if [[ -d $BACKUP_DIR/$NAME-$VERSION-backup-$BUILD$SIG ]] ; then cd $BACKUP_DIR rm -rf $NAME-$VERSION-backup-$BUILD$SIG 2> /dev/null 1> /dev/null fi [[ "$QUIET" = "YES" ]] && echo $GREEN"Done"$NORMAL fi # create new working directories echo $BLUE"Creating working directories:"$NORMAL # these general directories are usually already present -we don't ever remove these # since by default all these are equal to /tmp. [[ ! -d $SRC_BUILDS_DIR ]] && mkdir -p $SRC_BUILDS_DIR [[ ! -d $PKG_BUILDS_DIR ]] && mkdir -p $PKG_BUILDS_DIR [[ ! -d $PKG_DEST_DIR ]] && mkdir -p $PKG_DEST_DIR # create the PKG_DIR where package content is prepared. PRE_FIX is only created later # in fake_install if installation is successful. Empty PKG_DIR serves as a test later. if [[ ! -d $PKG_DIR ]] ; then cd $PKG_BUILDS_DIR && mkdir -p $PKG_DIR_NAME && echo " PKG_DIR=$PKG_DIR" fi # create a separate OBJ_DIR if asked for if [[ $USE_OBJ_DIR ]] ; then cd $SRC_BUILDS_DIR && mkdir -p $OBJ_DIR_NAME && echo " OBJ_DIR=$OBJ_DIR" fi # be extra careful with this if [[ $SOURCE_NAME ]] && [[ "$SRC_DIR" != "$CWD" ]] ; then cd $SRC_BUILDS_DIR [[ ! -d $SRC_DIR_NAME ]] && mkdir -p $SRC_DIR_NAME && echo " SRC_DIR=$SRC_DIR" fi #echo $GREEN"Okay"$NORMAL fi } # end make_dirs ### unpack_source unpack_source() { if [[ ! $SOURCE_NAME ]] || [[ $SRC_DIR = $CWD ]] ; then true elif [[ "$FAILED" = "" ]] ; then echo -n $BLUE"Unpacking source archive - "$NORMAL cd $SRC_BUILDS_DIR/$SRC_DIR_NAME ; if [[ "$EXT" = "deb" ]] || [[ "$EXT" = "rpm" ]] || [[ "$EXT" = "src.rpm" ]] ; then if [[ $QUIET = "YES" ]] ; then disrpm -x $SOURCE &> /dev/null else echo "" disrpm -x $SOURCE fi elif [[ $QUIET = "YES" ]] ; then case $SOURCE in *.tar.bz2|*.tbz) ${TAR_STATIC} xjvf $SOURCE 1> /dev/null ;; *.tar.gz|*.tgz) ${TAR_STATIC} xzvf $SOURCE 1> /dev/null ;; esac else echo "" ${TAR_STATIC} xvf $SOURCE fi if [[ $? -ne 0 ]] ; then echo $RED"FAILED!"$NORMAL echo "This may be caused by a defective or non-tar archive. "$RED"Exiting..."$NORMAL FAILED="UNPACK" else [[ $QUIET = "YES" ]] && echo $GREEN"Done"$NORMAL || echo "" UNPACK_NAME=$(ls $SRC_BUILDS_DIR/$SRC_DIR_NAME) examine_source fi fi } # local function called by unpack_source examine_source() { cd $SRC_BUILDS_DIR ; if [[ $(ls $SRC_DIR_NAME/*) != "" ]] ; then cd $SRC_DIR_NAME ; CONTENT=$(ls) for item in $CONTENT ; do case $item in usr|etc|var|lib|bin|opt|sbin|boot|dev|tmp) [[ -d $item ]] && BIN_CONTENT=1 ;; control) [[ -f control ]] && SRC_TYPE="DEB" ;; install) [[ -d install ]] && SRC_TYPE="SLK" ; BIN_CONTENT=1 ;; *.spec) SRC_TYPE="RPM" ;; *.tar.bz2|*.tar.gz|*.tgz|*.tbz) [[ -f $item ]] && FOUND_SOURCE=1 ;; esac done if [[ $BIN_CONTENT -eq 1 ]] ; then CONFIG_COMMAND="skip" ; INSTALL_COMMAND="skip" MAKE_COMMAND="copyall" else if [[ $(ls |wc -l) -eq 1 ]] ; then UNPACK_NAME=$(ls) if [[ -d $UNPACK_NAME ]] ; then [[ $DEBUG ]] && echo $BLUE"Found sources: "$NORMAL"$UNPACK_NAME"$NORMAL [[ $DEBUG ]] && echo $BLUE"Moving into SRC_DIR: "$NORMAL"$SRC_DIR_NAME" if [[ -e $UNPACK_NAME/$UNPACK_NAME ]] ; then mv $UNPACK_NAME/$UNPACK_NAME $UNPACK_NAME/$UNPACK_NAME.gotcha fi ( cd $UNPACK_NAME && mv ./* ../ ) cd $SRC_BUILDS_DIR/$SRC_DIR_NAME ; rm -rf $UNPACK_NAME if [[ -e $UNPACK_NAME.gotcha ]] ; then mv $UNPACK_NAME.gotcha $UNPACK_NAME fi #OPEN_SOURCE=1 fi fi ls *.spec &> /dev/null if [[ $? = 0 ]] ; then if [[ "$EXT" = "tgz" ]] || [[ "$EXT" = "tar.gz" ]] ; then echo $BLUE"Found 'rpm2tgz' format:"$NORMAL elif [[ "$EXT" = "rpm" ]] || [[ "$EXT" = "src.rpm" ]] ; then echo $BLUE"Found RPM format:"$NORMAL fi fi if ! [[ $OPEN_SOURCE ]] ; then for item in $(ls) ; do case $item in *.tar.bz2|*.tar.gz|*.tgz|*.tbz) # echo "Found archive: $item" case $item in *.tar.bz2) INT_EXT='tar.bz2' ;; *.tbz) INT_EXT='tbz' ;; *.tar.gz) INT_EXT='tar.bgz' ;; *.tgz) INT_EXT='tgz' ;; esac if [[ $(echo $item |grep "patch") ]] || [[ $(echo $item |grep "diff") ]]; then echo -n $BLUE"Ignoring compressed patch: "$NORMAL"$item " else #UNPACK_NAME=$(tar -tf $item |head -1 |cut -f1 -d'/') ITEM_NAME=$(basename $item .tar.bz2) ; ITEM_NAME=$(basename $item .tbz) ITEM_NAME=$(basename $item .tar.gz) ; ITEM_NAME=$(basename $item .tgz) GUESSED_NAME=$(basename $RAW_SOURCE_NAME |rev |cut -f2- -d'-' |rev) case $item in $NAME-$VERSION.*|$GUESSED_NAME.*|$ORIG_NAME-$ORIG_VERSION.*|$NAME-cvs*) echo -n $BLUE"Decompressing matching archive: "$NORMAL"$item " case $item in *.tar.gz|.tgz) UNPACK_NAME=$(${TAR_STATIC} -tzf $item |head -1 |cut -f1 -d'/') tar xzf $item &> /dev/null ;; *.tar.bz2|*.tbz) UNPACK_NAME=$(${TAR_STATIC} -tjf $item |head -1 |cut -f1 -d'/') tar xjf $item &> /dev/null ;; esac if [[ $? = 0 ]] && [[ -d $UNPACK_NAME ]] ; then echo $GREEN"Done!"$NORMAL if [[ -e $UNPACK_NAME/$UNPACK_NAME ]] ; then mv $UNPACK_NAME/$UNPACK_NAME $UNPACK_NAME/$UNPACK_NAME.gotcha fi ( cd $UNPACK_NAME && mv ./* ../ && cd .. ) rm -rf $UNPACK_NAME if [[ -e $UNPACK_NAME.gotcha ]] ; then mv $UNPACK_NAME.gotcha $UNPACK_NAME fi rm -f $item UNPACK_SUCCESS=1 else echo $RED"FAILED!"$NORMAL echo "Unable to unpack archive: $item "$RED"Exiting..."$NORMAL FAILED="UNPACK_RENAME" fi ;; *) if ! [[ $UNPACK_SUCCESS ]] ; then echo -n $BLUE"Decompressing (unknown) archive: "$NORMAL"$item " case $item in *.tar.gz|.tgz) UNPACK_NAME=$(${TAR_STATIC} -tzf $item |head -1 |cut -f1 -d'/') ${TAR_STATIC} xzf $item &> /dev/null ;; *.tar.bz2|*.tbz) UNPACK_NAME=$(${TAR_STATIC} -tjf $item |head -1 |cut -f1 -d'/') ${TAR_STATIC} xjf $item &> /dev/null ;; esac if [[ $? = 0 ]] && [[ -d $UNPACK_NAME ]] ; then echo $GREEN"Done!"$NORMAL if [[ -e $UNPACK_NAME/$UNPACK_NAME ]] ; then mv $UNPACK_NAME/$UNPACK_NAME $UNPACK_NAME/$UNPACK_NAME.gotcha fi echo $CYAN"Notice - "$NORMAL"Internal archive name mismatch: $UNPACK_NAME" ( cd $UNPACK_NAME && mv ./* ../ && cd .. ) rm -rf $UNPACK_NAME if [[ -e $UNPACK_NAME.gotcha ]] ; then mv $UNPACK_NAME.gotcha $UNPACK_NAME fi rm -f $item UNPACK_SUCCESS=1 else echo $RED"FAILED!"$NORMAL echo "Unable to unpack $item. "$RED"Exiting..."$NORMAL FAILED="UNPACK_RENAME" fi else echo $BLUE"Ignoring archive: "$NORMAL"$item" fi ;; esac fi ;; esac done fi fi else echo $RED"FAILED!"$NORMAL echo "Source directory is empty. "$RED"Exiting..."$NORMAL FAILED="EMPTY_SOURCE" fi } fix_source_perms() { if [[ "$FAILED" = "" ]] ; then if [[ "$CORRECT_PERMS" = "YES" ]] ; then echo -n $BLUE"Correcting source permissions - "$NORMAL chown -R root:root $SRC_DIR cd $SRC_DIR find . -type d -exec chmod 755 {} \; find . -perm 666 -perm 664 -perm 600 -exec chmod 644 {} \; find . -perm 444 -perm 440 -perm 400 -exec chmod 644 {} \; find . -perm 555 -perm 511 -exec chmod 755 {} \; find . -perm 777 -perm 775 -perm 754 -perm 711 -exec chmod 755 {} \; ! [[ $CORRECT_SUID_PERMS = "NO" ]] && find . -perm 2775 -perm 2755 -exec chmod 755 {} \; echo $GREEN"Done"$NORMAL fi # Auto-Patching works for most patches, but patch -p option and application order # can be controlled by renaming the files. patches should be in the CWD or CWD/patches directory apply_patches() { case $p in *.p0.diff*|*.p0.patch*) PATCH_OPTIONS="-p0" ;; *.p1.diff*|*.p1.patch*) PATCH_OPTIONS="-p1" ;; *.p2.diff*|*.p2.patch*) PATCH_OPTIONS="-p2" ;; *.p3.diff*|*.p3.patch*) PATCH_OPTIONS="-p3" ;; *) PATCH_OPTIONS="-p1" ;; esac case $p in *.gz) echo " Applying: $(basename $p)" ; if [[ $(file $CWD/$p |grep compressed) != "" ]] ; then cd $SRC_DIR && zcat $CWD/$p | patch "$PATCH_OPTIONS" -l else # Debian patches are plain-text patches named with a .gz suffix to avoid corruption cd $SRC_DIR && patch "$PATCH_OPTIONS" -l < $CWD/$p fi ;; *.bz2) echo " Applying: $(basename $p)" ; cd $SRC_DIR && bzcat $CWD/$p | patch "$PATCH_OPTIONS" -l ;; *.patch|*.diff) echo " Applying: $(basename $p)" ; cd $SRC_DIR && patch "$PATCH_OPTIONS" -l < $CWD/$p ;; esac } if [[ $PATCHLIST ]] ; then echo $BLUE"Applying patches - "$NORMAL"from User-Supplied PATCHLIST" for p in $PATCHLIST ; do apply_patches ; done elif [[ ! "$AUTO_PATCH" = "NO" ]] ; then echo -n $BLUE"Checking for patches - "$NORMAL get_patch_list if [[ "$PATCHLIST" = "" ]] ; then echo "None found" else echo "Found" for p in $PATCHLIST ; do apply_patches ; done fi fi fi } get_patch_list() { cd $CWD ; if [[ -d $CWD/patches ]] ; then PATCHLIST=$(find ./patches -maxdepth 1 -type f -name '*.patch*' -o -name '*.diff*' | sort) else PATCHLIST=$(find . -maxdepth 1 -type f -name '*.patch*' -o -name '*.diff*' | sort) fi } ### configure_source configure_source() { if [[ "$FAILED" = "" ]] ; then if [[ "$CONFIG_COMMAND" = "skip" ]] ; then echo $BLUE"Skipped configure_source - "$NORMAL CONFIG_DIR=$SRC_DIR else # find the main configuration directory if [[ $CONFIG_SUBDIR ]] ; then CONFIG_DIR=$SRC_DIR/$CONFIG_SUBDIR else for keydir in $SRC_DIR $SRC_DIR/src $SRC_DIR/Src $SRC_DIR/$NAME-$VERSION $SRC_DIR/$NAME $SRC_DIR/$NAMElib $SRC_DIR/lib$NAME $SRC_DIR/abi ; do for keyfile in configure Makefile configure.in configure.ac Makefile.in Makefile.am autogen.sh GNUmakefile GNUmakefile.in GNUmakefile.am Imakefile SConstruct makefile Jamfile install.sh ; do if [[ -e $keydir/$keyfile ]] ; then CONFIG_SUBDIR=$keydir KEYFILE="$keyfile" break ; fi done if [[ $CONFIG_SUBDIR ]] ; then CONFIG_DIR=$keydir break ; fi if [[ $CONFIG_DIR ]] ; then CONFIG_DIR=$keydir break ; fi done fi [[ $DEBUG ]] && echo $BLUE"Using keyfile: "$NORMAL"$KEYFILE" ! [[ "$CONFIG_DIR" ]] && CONFIG_DIR=$SRC_DIR if [[ "$CONFIG_DIR" != "$SRC_DIR" ]] ; then FUNNY_SUBDIR=$(basename $CONFIG_DIR) echo $BLUE"Notice - "$NORMAL"The main files are in a subdirectory: $FUNNY_SUBDIR" ! [[ $USE_OBJ_DIR ]] && OBJ_DIR=$CONFIG_DIR fi ! [[ $USE_OBJ_DIR ]] && [[ ! $OBJ_DIR ]] && OBJ_DIR=$CONFIG_DIR if [[ -e $CONFIG_DIR/GNUmakefile.in ]] ; then echo $BLUE"Notice - "$NORMAL"This packages uses GNUmakefiles, instead of Makefiles." if ! [[ $USE_DEFAULT_MAKEFILES = "YES" ]] ; then MAKEFILE="GNUmakefile" if [[ -e $CONFIG_DIR/Makefile ]] ; then echo "But, we found a default Makefile. We rename to Makefile.found and start fresh." echo "If not, the Makefile would be used instead of the new GNUmakefile." mv $CONFIG_DIR/Makefile $CONFIG_DIR/Makefile.found fi fi fi if [[ -e $CONFIG_DIR/makefile ]] ; then MAKEFILE="makefile" elif [[ -e $CONFIG_DIR/GNUmakefile ]] || [[ -e $CONFIG_DIR/GNUmakefile.am ]] ; then MAKEFILE="GNUmakefile" elif [[ -e $CONFIG_DIR/Makefile ]] || [[ -e $CONFIG_DIR/Makefile.am ]] ; then MAKEFILE="Makefile" fi if [[ "$PATCHLIST" != "" ]] && [[ "$AUTORECONF" != "NO" ]] ; then if [[ -e $CONFIG_DIR/$MAKEFILE.am ]] ; then echo $BLUE"Note: "$NORMAL"Patched sources may need this, or disable it with AUTORECONF=NO." echo -n $BLUE"Regenerating config files - "$NORMAL"Using: autoreconf -if " autoreconf --install --force &> /dev/null autoconf &> /dev/null echo $GREEN"Done!"$NORMAL fi fi if ! [[ -x $CONFIG_DIR/configure ]] ; then if [[ -e $CONFIG_DIR/configure.in ]] || [[ -e $CONFIG_DIR/configure.ac ]] ; then if [[ -e $CONFIG_DIR/$MAKEFILE.in ]] && [[ -e $CONFIG_DIR/$MAKEFILE.am ]] ; then echo -n $BLUE"Found autoconf files. "$NORMAL"We'll try running autoconf - " cd $CONFIG_DIR ; autoconf 1> /dev/null && echo $GREEN"Done"$NORMAL || echo $YELLOW"FAILED!"$NORMAL elif [[ -e $CONFIG_DIR/$MAKEFILE.am ]] ; then echo -n $BLUE"Found incomplete autoconf sources - "$NORMAL"Running autoreconf -if " autoreconf --install --force &> /dev/null autoconf echo $GREEN"Done!"$NORMAL fi fi fi if ! [[ -x $CONFIG_DIR/configure ]] && [[ -e $CONFIG_DIR/autogen.sh ]] ; then echo "Found an autogen.sh script. We'll try running that - " cd $CONFIG_DIR ; sh ./autogen.sh 2> /dev/null && echo $GREEN"Done"$NORMAL || echo $YELLOW"FAILED!"$NORMAL echo -n "Now we'll try running autoconf - " autoconf 2> /dev/null && echo $GREEN"Done"$NORMAL || echo $YELLOW"FAILED!"$NORMAL fi # if all else fails try this generic routine. if ! [[ -x $CONFIG_DIR/configure ]] && [[ -e $CONFIG_DIR/$MAKEFILE.am ]] && [[ -e $CONFIG_DIR/$MAKEFILE.in ]] ; then if [[ -e $CONFIG_DIR/configure.ac ]] || [[ -e $CONFIG_DIR/configure.in ]] ; then echo $BLUE"Found Makefile.am and configure.in. "$NORMAL"We'll try with these generic commands:" echo "aclocal -I. ; autoheader ; automake -a --force --copy --foreign ; autoconf" [[ -d $CONFIG_DIR/autom4te.cache ]] && rm -rf $CONFIG_DIR/autom4te.cache [[ -d $CONFIG_DIR/.deps ]] && rm -rf $CONFIG_DIR/.deps [[ -f $CONFIG_DIR/.deps ]] && rm -f $CONFIG_DIR/.deps [[ -f $CONFIG_DIR/config.status ]] && rm -f $CONFIG_DIR/config.status [[ -f $CONFIG_DIR/config.cache ]] && rm -f $CONFIG_DIR/config.cache cd $CONFIG_DIR ; # automake aclocal -I . 2> /dev/null 1> /dev/null autoheader 2> /dev/null 1> /dev/null # automake --add-missing --copy --foreign 2> /dev/null 1> /dev/null automake -a --force --copy --foreign 2> /dev/null 1> /dev/null autoconf 2> /dev/null fi if ! [[ -x $CONFIG_DIR/configure ]] ; then echo $YELLOW"WARNING! "$NORMAL"This looks like a non-working autoconf package or maybe needs automake-1.4." if [[ -e $CONFIG_DIR/$MAKEFILE ]] ; then echo "But we have a Makefile, so we'll proceed anyway. Maybe it's your lucky day." else echo $YELLOW"WARNING! "$NORMAL"No Makefile and no configure script found. "$BLUE"Skipping..."$NORMAL fi fi fi if [[ -x $CONFIG_DIR/configure ]] ; then trap safe_user_cancel 2 echo -n $BLUE"Found configure script - "$NORMAL if [[ $USE_OBJ_DIR = "YES" ]] ; then #REL_CONFIG_PATH=$(basename $CONFIG_DIR) echo "" echo $BLUE"Using OBJ_DIR: "$NORMAL "$(basename ${OBJ_DIR})" if [[ -e $CONFIG_DIR/$MAKEFILE ]] ; then echo $BLUE"NOTICE - "$NORMAL"Stale Makefile found. Running 'make distclean' - " cd $CONFIG_DIR && make distclean &> /dev/null && echo $GREEN"Okay"$NORMAL fi if ! [[ $CONFIG_COMMAND ]] ; then #CONFIG_COMMAND="../$REL_CONFIG_PATH/configure" ; CONFIG_COMMAND="../$SRC_DIR_NAME/configure" ; # CONFIG_ARGS="--prefix=$PRE_FIX $STD_CONFIGS $EXTRA_CONFIGS" ; else CONFIG_COMMAND="../$SRC_DIR_NAME/$CONFIG_COMMAND" ; fi fi if ! [[ $CONFIG_COMMAND ]] ; then CONFIG_COMMAND="$CONFIG_DIR/configure" else CONFIG_COMMAND="$CONFIG_DIR/$CONFIG_COMMAND" fi CONFIG_ARGS="$(echo --prefix=$PRE_FIX $STD_CONFIGS $EXTRA_CONFIGS| white_out)" if ! [[ $FLAG_LINE ]] ; then FLAG_LINE="$(echo $STD_FLAGS $EXTRA_FLAGS |white_out)" CFLAGS=$FLAG_LINE fi if [[ $QUIET = "YES" ]] ; then cd $OBJ_DIR ; echo "Configuring sources using:" echo " CFLAGS=$FLAG_LINE ./$(basename $CONFIG_COMMAND) $CONFIG_ARGS" export CFLAGS=$FLAG_LINE $CONFIG_COMMAND $CONFIG_ARGS &> /dev/null else cd $OBJ_DIR ; echo "Now trying to configure sources using:" echo " CFLAGS=$FLAG_LINE ./$(basename $CONFIG_COMMAND) $CONFIG_ARGS" echo "Messages from configure:" export CFLAGS=$FLAG_LINE $CONFIG_COMMAND $CONFIG_ARGS fi if [[ $? -eq 0 ]] ; then echo $BLUE"Configuration has been - "$GREEN"Successful!"$NORMAL elif [[ $USER_CANCELLED ]] ; then echo $RED"STOPPED! "$NORMAL"Operation cancelled during configuration!" FAILED="CANCELLED" else FAILED="configure_source" echo $RED"ERROR! "$NORMAL"Configuring sources has failed!"$NORMAL echo "This usually happens because of missing libraries, or you" echo "may need to pass extra options to configure using EXTRA_CONFIGS." if [[ $REPLAY_ERRORS = "YES" ]] && [[ $QUIET = "YES" ]] ; then if [[ $DISPLAY ]] ; then cd $CONFIG_DIR ; echo $CYAN"NOTICE-"$NORMAL"Replaying failed configuration in a separate xterm:" export CFLAGS=$STD_FLAGS$EXTRA_FLAGS ( xterm -hold -e "$CONFIG_COMMAND" "$CONFIG_ARGS" & ) else cd $CONFIG_DIR ; echo $CYAN"NOTICE-"$NORMAL"Replaying failed configuration:" export CFLAGS=$STD_FLAGS$EXTRA_FLAGS $CONFIG_COMMAND $CONFIG_ARGS fi fi show_requires fi elif [[ -f $CONFIG_DIR/Imakefile ]] ; then if ! [[ $USE_DEFAULT_MAKEFILES = "YES" ]] ; then echo -n $BLUE"Found Imakefile - "$NORMAL"Configuring using: 'xmkmf -a' - " cd $CONFIG_DIR ; xmkmf -a 2> /dev/null 1> /dev/null MAKEFILE="Makefile" echo $GREEN"Done"$NORMAL fi elif [[ -f $CONFIG_DIR/SConstruct ]] ; then echo -n $BLUE"Found SConstruct file - "$NORMAL"Configuring using: 'scons configure' - " cd $CONFIG_DIR ; if [[ $QUIET = "YES" ]] ; then scons configure 2> /dev/null 1> /dev/null else scons configure fi MAKEFILE="SConstruct" echo $GREEN"Done"$NORMAL elif [[ -f $CONFIG_DIR/$MAKEFILE ]] ; then echo $BLUE"Skipping configure_source - "$NORMAL"Continuing since we found a "$BLUE"$MAKEFILE"$NORMAL cd $CONFIG_DIR ; if [[ ! "$PRE_FIX" = "/usr/local" ]] && [[ $(find . -name "$MAKEFILE" |wc -l) -eq 1 ]] ; then if [[ $(grep 'PREFIX=/usr/local' $MAKEFILE) ]] ; then mv $MAKEFILE $MAKEFILE.ours echo $BLUE"Correcting $MAKEFILE - "$NORMAL"Fixed mismatching arbitrary PREFIX" sed -e s:"PREFIX=/usr/local":"PREFIX=$PRE_FIX": $MAKEFILE.ours > $MAKEFILE elif [[ $(grep 'PREFIX = /usr/local' $MAKEFILE) ]] ; then mv $MAKEFILE $MAKEFILE.ours echo $BLUE"Correcting $MAKEFILE - "$NORMAL"Fixed mismatching arbitrary PREFIX" sed -e s:"PREFIX[\t, ]=[\t, ]/usr/local":"PREFIX = ${PRE_FIX}": $MAKEFILE.ours > $MAKEFILE elif [[ $(grep 'prefix=/usr/local' $MAKEFILE) ]] ; then mv $MAKEFILE $MAKEFILE.ours echo $BLUE"Correcting $MAKEFILE - "$NORMAL"Fixed mismatching arbitrary PREFIX" sed -e s:"prefix=/usr/local":"prefix=${PRE_FIX}": $MAKEFILE.ours > $MAKEFILE elif [[ $(grep 'prefix = /usr/local' $MAKEFILE) ]] ; then mv $MAKEFILE $MAKEFILE.ours echo $BLUE"Correcting $MAKEFILE - "$NORMAL"Fixed mismatching arbitrary PREFIX" sed -e s:"prefix[\t, ]=[\t, ]/usr/local":"prefix = ${PRE_FIX}": $MAKEFILE.ours > $MAKEFILE fi fi else echo $BLUE"Skipping configure_source - "$NORMAL fi fi fi } # show_requires() { if [[ -e $CONFIG_DIR/$NAME.spec ]] ; then if grep "Requires:" $CONFIG_DIR/$NAME.spec 1> /dev/null ; then echo $BLUE"Found an RPM .spec file which shows this:"$NORMAL grep "Requires:" $CONFIG_DIR/$NAME.spec |uniq else echo "No Requires information found in $NAME.spec." fi elif [[ -e $CONFIG_DIR/$NAME.spec.in ]] ; then if grep "Requires:" $CONFIG_DIR/$NAME.spec.in 1> /dev/null ; then echo $BLUE"Searching the RPM .spec.in file turns up this:"$NORMAL grep "Requires:" $CONFIG_DIR/$NAME.spec.in |uniq else echo "No Requires information found in $NAME.spec.in." fi elif [[ -e $CONFIG_DIR/debian/control ]] ; then if grep "Depends:" $CONFIG_DIR/debian/control 1> /dev/null ; then echo $BLUE"Searching the Debian control file turns up this:"$NORMAL grep "Depends:" $CONFIG_DIR/debian/control |uniq else echo $BLUE"Sorry! "$NORMAL"No Depends: information found in Debian control file.." fi else echo $BLUE"Sorry! ""$NORMAL""No Dependency or Requirements information found." fi echo "" } # find_makefile() { if [[ -e $OBJ_DIR/GNUmakefile ]] ;then MAKEFILE="GNUmakefile" ! [[ $MAKE_COMMAND ]] && MAKE_COMMAND="make" ! [[ $INSTALL_COMMAND ]] && INSTALL_COMMAND="make" ! [[ $INSTALL_RULE ]] && INSTALL_RULE="install" elif [[ -e $OBJ_DIR/Makefile ]] ; then MAKEFILE="Makefile" ! [[ $MAKE_COMMAND ]] && MAKE_COMMAND="make" ! [[ $INSTALL_COMMAND ]] && INSTALL_COMMAND="make" ! [[ $INSTALL_RULE ]] && INSTALL_RULE="install" elif [[ -e $OBJ_DIR/makefile ]] ; then MAKEFILE="makefile" ! [[ $MAKE_COMMAND ]] && MAKE_COMMAND="make" ! [[ $INSTALL_COMMAND ]] && INSTALL_COMMAND="make" ! [[ $INSTALL_RULE ]] && INSTALL_RULE="install" elif [[ -e $OBJ_DIR/SConstruct ]] ; then MAKEFILE="SConstruct" ! [[ $MAKE_COMMAND ]] && MAKE_COMMAND="scons" ! [[ $INSTALL_COMMAND ]] && INSTALL_COMMAND="scons" ! [[ $INSTALL_RULE ]] && INSTALL_RULE="install" elif [[ -e $OBJ_DIR/Jamfile ]] ; then MAKEFILE="Jamfile" ! [[ $MAKE_COMMAND ]] && MAKE_COMMAND="jam" ! [[ $INSTALL_COMMAND ]] && INSTALL_COMMAND="jam" ! [[ $INSTALL_RULE ]] && INSTALL_RULE="install" fi } ### compile_source compile_source() { if [[ "$FAILED" = "" ]] ; then if [[ "$MAKE_COMMAND" = "skip" ]] ; then echo $BLUE"Skipping compile_source - "$NORMAL elif [[ "$MAKE_COMMAND" = "copyall" ]] ; then # examine_source sets MAKE_COMMAND to copyall for sources with binary content. We copy it here directly to PKG_DIR SHOW_DEPS=1 cd $SRC_DIR ; if [[ -f control ]] ; then echo $BLUE"Found Debian binary content - "$NORMAL elif [[ -d install ]] ; then echo $BLUE"Found Slackware package content - "$NORMAL"Contents of the install directory are" echo "copied into the CWD. Be sure to correct if needed and rebuild package." elif [[ $EXT = "rpm" ]] ; then echo $BLUE"Found RPM binary content - "$NORMAL else echo $BLUE"Found generic binary package content - "$NORMAL fi DOCPATH=$(find . -type d -name doc) if [[ -d $DOCPATH ]] ; then cd $DOCPATH ; DOCDIR=$(ls) else mkdir -p $SRC_DIR/usr/doc/$NAME-$VERSION DOCPATH="usr/doc" DOCDIR="$NAME-$VERSION" fi echo -n $BLUE"Checking contents - "$NORMAL ; [[ $DEBUG ]] && echo "" cd $SRC_DIR for item in $(ls) ; do if [[ -d $item ]] ; then case $item in # looks like some kind of installable directory structure. usr|etc|var|lib|bin|opt|sbin|boot|dev|tmp) [[ $DEBUG ]] && echo "Found directory: $item" ; shift ;; # var) echo ; echo $YELLOW"Warning! "$NORMAL"Directory 'var' may need special permissons" ; shift ;; install) cp -a $SRC_DIR/install/* $CWD; shift ;; esac elif [[ -f $item ]] ; then case $item in preinst|prerm|postinst|md5sums|control) [[ $DEBUG ]] && echo "Moving file: $item into docs" ; cp -a $item $DOCPATH/$DOCDIR/ ; rm -f $item ; ;; # What's this? maybe some sort of installer or other debian file? *) [[ $DEBUG ]] && echo "Removing unrecognized file: $item " ; rm -f $item ;; esac else [[ $DEBUG ]] && echo "Removing unrecognized item: $item " ; rm -f $item fi done ! [[ $DEBUG ]] && echo $GREEN"Done!"$NORMAL if [[ $(ls $DOCPATH/$DOCDIR) = "" ]] ; then echo $CYAN"Notice - "$NORMAL"No documents were found in the content. Creating default README" echo "Notice - This package was created by src2pkg from:" > $DOCPATH/$DOCDIR/README echo "$SOURCE_NAME" >> $DOCPATH/$DOCDIR/README echo "No documents were installed for the package." >> $DOCPATH/$DOCDIR/README fi [[ -d $PKG_DIR ]] && mkdir -p $PKG_DIR echo -n $BLUE"Copying contents to PKG_DIR - "$NORMAL cp -a * $PKG_DIR &> /dev/null echo $GREEN"Done!"$NORMAL else # this is the routine for compiling sources ! [[ $OBJ_DIR ]] && OBJ_DIR="$CONFIG_DIR" find_makefile if [[ $MAKEFILE ]] && [[ $MAKE_COMMAND ]] ; then trap safe_user_cancel 2 CFLAGS="$(echo $STD_FLAGS $EXTRA_FLAGS |white_out)" echo $BLUE"Compiling sources - "$NORMAL"Using: '$MAKE_COMMAND'" export CFLAGS if [[ $QUIET = "YES" ]] ; then cd $OBJ_DIR ; make clean 1> /dev/null 2> /dev/null $MAKE_COMMAND &> /dev/null else cd $OBJ_DIR ; echo $BLUE"Compiler Messages:"$NORMAL make clean 1> /dev/null 2> /dev/null $MAKE_COMMAND fi if [[ $? -eq 0 ]] ; then echo $BLUE"Compiling has been - "$GREEN"Successful!"$NORMAL elif [[ $USER_CANCELLED ]] ; then echo $RED"STOPPED! "$NORMAL"Operation cancelled during compilation! "$NORMAL FAILED="CANCELLED" else FAILED="compile_source" echo "$RED""ERROR! "$NORMAL"Compiling source code has failed." echo "This usually happens because of missing libraries, or" echo "badly written Makefiles or configure scripts." show_requires if [[ $REPLAY_ERRORS = "YES" ]] && [[ $QUIET = "YES" ]] ; then cd $OBJ_DIR ; export CFLAGS=$STD_FLAGS$EXTRA_FLAGS if [[ $DISPLAY ]] ; then echo $CYAN"NOTICE-"$NORMAL"Replaying failed compilation in a separate xterm." ( xterm -hold -e $MAKE_COMMAND & ) else echo $CYAN"NOTICE-"$NORMAL"Replaying failed compilation:" $MAKE_COMMAND fi fi fi else echo $BLUE"Skipping compile_source - "$NORMAL fi fi fi } check_makefile() { if [[ -f $OBJ_DIR/$MAKEFILE ]] && [ "$INSTALL_RULE" = "install" -o "$INSTALL_LINE" = "make install" ] ; then if ! [[ $(grep "DESTDIR" $OBJ_DIR/$MAKEFILE 2> /dev/null) ]] ; then echo $CYAN"NOTICE! "$NORMAL"DESTDIR not supported. We don't use it anyway, since it's unreliable." fi if ! [[ $(grep "install:" $OBJ_DIR/$MAKEFILE 2> /dev/null) ]] ; then echo $RED"FATAL ERROR! "$NORMAL"No 'install' rule was found in the Makefile! You'll have to" echo "write a manual install rule for this one. We could guess, but better not! "$RED"Exiting..."$NORMAL FAILED="NO INSTALL RULE" exit 0 fi fi } fake_install() { if [[ "$INSTALL_COMMAND" = "skip" ]] ; then echo $BLUE"Skipping fake_install - "$NORMAL elif [[ "$FAILED" = "" ]] ; then ! [[ $OBJ_DIR ]] && OBJ_DIR=$SRC_DIR find_makefile # install using an install.sh script or other named script # The -S option turns off redirection of stdout and stderr -allowing tracking of interactive install scripts. # But if we are running QUIET it will be reset just after critical install install operations if [[ $SHELL_INSTALL ]] ; then if ! [[ $INSTALL_LINE ]] ; then INSTALL_LINE="sh install.sh" if [[ -e $OBJ_DIR/install.sh ]] ; then echo $BLUE"Found install.sh script - "$NORMAL"Interactive input may be required." sleep 2 else echo $CYAN"NOTICE! "$NORMAL"No install.sh script found!" fi fi [[ "$QUIET" = "YES" ]] && RESTORE_QUIET=1 QUIET="NO" elif [[ ! $MAKEFILE ]] ; then [[ "$QUIET" = "YES" ]] && RESTORE_QUIET=1 QUIET="NO" fi #BLURB='i=cp -aL \* /' ; $(echo ${BLURB##*=} |sed 's/\\//') if [[ $INSTALL_LINE ]] ; then INSTALL_LINE=$(echo $INSTALL_LINE |sed 's/\\//') elif [[ $INSTALL_COMMAND ]] && [[ $INSTALL_RULE ]] ; then INSTALL_LINE=$(echo $INSTALL_COMMAND $INSTALL_RULE |sed 's/\\//') else FAILED="NO INSTALL_LINE" echo $RED"FAILED!! "$NORMAL"No INSTALL_LINE given." exit fi echo $BLUE"Tracking Installation - "$NORMAL"Using: '$INSTALL_LINE'"$NORMAL ! [[ $BACKUP_DIR ]] && BACKUP_DIR=/tmp # ! [[ $BACKUP_DIRECTORY ]] && BACKUP_DIRECTORY=$BACKUP_DIR/$NAME-$VERSION-backup-$BUILD$SIG ! [[ $BACKUP_DIR_NAME ]] && BACKUP_DIR_NAME=$NAME-$VERSION-backup-$BUILD$SIG # ! [[ $BACKUP_DIRECTORY ]] && BACKUP_DIRECTORY=$BACKUP_DIR/$NAME-$VERSION-backup-$BUILD$SIG ! [[ $BACKUP_DIRECTORY ]] && BACKUP_DIRECTORY=$BACKUP_DIR/$BACKUP_DIR_NAME export BACKUP_DIRECTORY # installwatch-0.6.3 unset INSTALLWATCH_BACKUP_PATH INSTALLWATCH_BACKUP_PATH=$BACKUP_DIRECTORY export INSTALLWATCH_BACKUP_PATH # installwatch-0.7 unset INSTW_ROOTPATH INSTW_ROOTPATH=$BACKUP_DIRECTORY export INSTW_ROOTPATH # we need to call it this when removing since INSTW_ROOTPATH gets unset mkdir -p $BACKUP_DIRECTORY # installwatch-0.7 needs this -installwatch-0.6 assumes this if INSTALLWATCH_BACKUP_PATH is set INSTW_BACKUP=1 export INSTW_BACKUP # installwatch-0.7 INSTW_EXCLUDE=$CWD export INSTW_EXCLUDE # installwatch-0.6 INSTALLWATCHFILE=$CWD/FILELIST.tmp export INSTALLWATCHFILE # installwatch-0.7 INSTW_LOGFILE=$CWD/FILELIST.tmp export INSTW_LOGFILE # get this ready, but exporting it below is what turns it on LD_PRELOAD=/usr/libexec/src2pkg/installwatch.so if cat /dev/null > $INSTW_LOGFILE ; then true else echo $RED"FAILED! - "$NORMAL "Unable to prepare $INSTW_LOGFILE" exit 1 fi cd $OBJ_DIR; if [[ $QUIET = "YES" ]] ; then trap trap_int 2 export LD_PRELOAD $INSTALL_LINE &> /dev/null else trap trap_int 2 export LD_PRELOAD $INSTALL_LINE fi ## 2 this routine ends at the end of the function. It checks the exit status of the INSTALL_LINE and ## acts accordingly. To assure maximum robustness, the first parts of this routine use statically-compiled ## programs which don't need any installed libraries at all. If you just whacked something really bad, like glibc, ## this routine should get your system back right away. The bad thing is that you may not even notice. Since all ## these programs are out of the normal path it makes it possible to safely compile and package tar and the other ## programs which are used in this routine. if [[ $? -gt 0 ]] ; then # make install itself returned an error if [[ -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_STATIC} -p $PKG_DIR/$PRE_FIX/bin [[ -x $OBJ_DIR/$NAME ]] && ${CP_STATIC} -a $OBJ_DIR/$NAME $PKG_DIR/$PRE_FIX/bin [[ -x $OBJ_DIR/$ORIG_NAME ]] && ${CP_STATIC} -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_STATIC} -p $PKG_DIR/usr/man/man1 [[ -e $OBJ_DIR/$NAME.1 ]] && ${CP_STATIC} -a $OBJ_DIR/$NAME.1 $PKG_DIR/usr/man/man1 [[ -e $OBJ_DIR/$NAME.man ]] && ${CP_STATIC} -a $OBJ_DIR/$NAME.man $PKG_DIR/usr/man/man1 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 unset INSTW_ROOTPATH unset INSTALLWATCH_BACKUP_PATH unset LD_PRELOAD ( cd $BACKUP_DIR && ${RM_STATIC} -rf $BACKUP_DIR_NAME ) ${RM_STATIC} -f $CWD/FILELIST.tmp elif [[ $(${CAT_STATIC} $CWD/FILELIST.tmp |${GREP_STATIC} -v FILELIST.tmp 2> /dev/null) = "" ]] ; then # 'make install' produced no errors but also produced no output echo $RED"FATAL! "$NORMAL"Running '$INSTALL_LINE' with installwatch produced no files list. " echo "This may be the result of an empty or faulty install rule. "$RED"Exiting..."$NORMAL unset INSTW_ROOTPATH unset INSTALLWATCH_BACKUP_PATH unset LD_PRELOAD ( cd $BACKUP_DIR && ${RM_STATIC} -rf $BACKUP_DIR_NAME ) ${RM_STATIC} -f $CWD/FILELIST.tmp FAILED="make_install NO FILES" elif [[ $FAILED = "CANCELLED" ]] ; then unset INSTW_ROOTPATH unset INSTALLWATCH_BACKUP_PATH unset LD_PRELOAD ( cd $BACKUP_DIR && ${RM_STATIC} -rf $BACKUP_DIR_NAME ) [[ -d /no-backup ]] && ${RM_STATIC} -rf /no-backup #exit FAILED="CANCELLED" else # Commands have succeeded and we have files. # remove the no-backup directory ${RM_STATIC} -rf ${BACKUP_DIRECTORY}/no-backup &> /dev/null # installwatch-0.7 ${RM_STATIC} -rf ${BACKUP_DIRECTORY}/BACKUP/no-backup &> /dev/null # unset these INSTW_ROOTPATH is unwritable otherwise unset INSTALLWATCH_BACKUP_PATH # installwatch-0.7 unset INSTW_ROOTPATH unset LD_PRELOAD # used by SHELL_INSTALL [[ $RESTORE_QUIET ]] && QUIET="YES" #echo $BLUE"Installation Tracking - "$GREEN"Successful! "$NORMAL"Creating package content:" # echo $BLUE"Creating package content - "$NORMAL [[ $DEBUG ]] && echo -n $BLUE"Processing installation FILELIST - "$NORMAL # Parse the full original installwatch log FILELIST.tmp # extract a list of the regular files ${CAT_STATIC} $CWD/FILELIST.tmp | ${CUT_STATIC} -f 3 | ${EGREP_STATIC} -v "^(/dev|$CWD|/tmp)" | ${SORT_STATIC} -u > $CWD/FILELIST # extract a list of symlinks ${CAT_STATIC} $CWD/FILELIST.tmp | ${CUT_STATIC} -f 4 | ${EGREP_STATIC} -v "^(/dev|$CWD|/tmp)" | ${GREP_STATIC} -v "#success" | ${SORT_STATIC} -u >> $CWD/FILELIST # DIRLIST extract the directories to a separate DIRLIST so they can be handled apart ${CAT_STATIC} $CWD/FILELIST.tmp | ${GREP_STATIC} 'mkdir' | ${GREP_STATIC} -v '#File exists' | ${GREP_STATIC} '#success' | ${CUT_STATIC} -f3 | ${SORT_STATIC} -r -u >> $CWD/DIRLIST # DEBUG_FILELISTS if [[ $DEBUG_FILELISTS ]] ; then # get a list of the links created ${CAT_STATIC} $CWD/FILELIST.tmp | ${GREP_STATIC} 'symlink' | ${GREP_STATIC} "#success" | ${CUT_STATIC} -f4 | ${SORT_STATIC} -u >> $CWD/LINKLIST # copy the full installwatch log ${CP_STATIC} $CWD/FILELIST.tmp $CWD/FILELIST.orig KEEP_FILELIST="YES" KEEP_DIRLIST="YES" fi # Delete the original list so we can recycle the name ${RM_STATIC} -f $CWD/FILELIST.tmp # sort and remove duplicates ${SORT_STATIC} -u < $CWD/FILELIST | ${UNIQ_STATIC} | while read file; do ! [[ -d "$file" ]] && [[ -e "$file" ]] && echo $file >> $CWD/FILELIST.tmp done # remove more cruft ${CAT_STATIC} $CWD/FILELIST.tmp | ${GREP_STATIC} -v "$CWD" | ${GREP_STATIC} -v "#success"> $CWD/FILELIST ${RM_STATIC} -f $CWD/FILELIST.tmp [[ $DEBUG ]] && echo $GREEN"Done"$NORMAL # End parsed FILELIST creation # Create $PKG_DIR$PRE_FIX -is only created if make install succeeds ${MKDIR_STATIC} -p $PKG_DIR$PRE_FIX [[ $DEBUG ]] && echo -n $BLUE"Copying installed files to PKG_DIR - "$NORMAL # copy files from root directory into PKG_DIR using the FILELIST cd / ; ${CAT_STATIC} $CWD/FILELIST | while read i; do if ! [[ -d "$i" ]] && [[ -e "$i" ]] ; then (${TAR_STATIC} -cpf - "$i"| ${TAR_STATIC} -f - -xvpC $PKG_DIR) 2> /dev/null 1> /dev/null fi done [[ $DEBUG ]] && echo $GREEN"Done"$NORMAL # Once we have the file list and have copied the installed files into PKG_DIR # immediately restore any files which were overwritten by the installation # installwatch-0.7 # ls $BACKUP_DIRECTORY/BACKUP/* &> /dev/null ls $BACKUP_DIR/$NAME-$VERSION-backup-$BUILD$SIG/* &> /dev/null if [[ $? -eq 0 ]] ; then # installwatch-0.7 # if [[ $(find $BACKUP_DIRECTORY/BACKUP -type f) != "" ]] ; then # cd $BACKUP_DIRECTORY/BACKUP if [[ $(find $BACKUP_DIR/$NAME-$VERSION-backup-$BUILD$SIG -type f) != "" ]] ; then cd $BACKUP_DIR/$NAME-$VERSION-backup-$BUILD$SIG [[ $DEBUG ]] && echo -n $BLUE"Restoring overwritten files - "$NORMAL # checkinstall uses this with tar whatever? # tar -cpf - . | tar -f - -xvpC / &> /dev/null # Slackware's installpkg uses -U(unlink) and -l with tar-1.13 # (cd $ROOT/ ; $TAR -xzlUpvf - ) < $package >> $TMP/$shortname 2> /dev/null # tar -cpf - . | tar -f - -xlUvpC / &> /dev/null # with tar-1.13 the -l option means --one-filesystem # tar-1.4 added the explicit --no-overwrite-dirs option. This was standard behaviour before, but # now must be specified. tar-1.15 drops the -l option as a transition period # tar-1.16 re-intriduces the -l option but with another meaning(--check-links) # If only Slackwares' installpkg used --no-overwrite-dirs --one-filesystem -xUvpC it could # do without tar-1.13. See tiny_makepkg for more notes about tar-1.13 compatibility # this has the right behaviour # tar-1.16 -xzpvf - < ../test.tar.gz >> ./testit 2> /dev/null # if [[ $OLDTAR ]] ;then ${TAR_STATIC} -cpf - . | ${TAR_STATIC} -f - -xlUvpC / &> /dev/null else # this works and seems to be the equivalent of the above #tar -cpf - . | tar -f - --no-overwrite-dirs --one-filesystem -xUvpC / &> /dev/null # this is simpler and seems to work(I haven't checked --one-filesystem) ${TAR_STATIC} -cpf - . | ${TAR_STATIC} -f - -xvpC / &> /dev/null fi [[ $DEBUG ]] && echo $GREEN"Done"$NORMAL fi fi # Now remove the files and links installed from the system, unless they were just backed up above. # Compare the list of installed file and links with the contents of the backup directory [[ $DEBUG ]] && echo -n $BLUE"Removing other files installed by: "$NORMAL"'$INSTALL_LINE' - " cd / ; ${CAT_STATIC} $CWD/FILELIST | while read i; do if [ -e "$i" -o -L "$i" ] && ! [ -d "$i" ] ; then if [[ $QUIET = "YES" ]] ; then # installwatch-0.7 # if ! [[ -e "$BACKUP_DIRECTORY/BACKUP/$i" ]] ; then if ! [[ -e "$BACKUP_DIR/$NAME-$VERSION-backup-$BUILD$SIG/$i" ]] ; then ( ${RM_STATIC} -f $i ) 1> /dev/null fi else # installwatch-0.7 # if ! [[ -e "$BACKUP_DIRECTORY/BACKUP/$i" ]] ; then if ! [[ -e "$BACKUP_DIR/$NAME-$VERSION-backup-$BUILD$SIG/$i" ]] ; then ( ${RM_STATIC} -f $i ) fi fi fi done [[ $DEBUG ]] && echo $GREEN"Done "$NORMAL"" # run ldconfig immediately after restoring backups and removing new files if [[ -x /sbin/ldconfig ]] ; then [[ $DEBUG ]] && echo -n $BLUE"Running ldconfig - "$NORMAL"Updating shared library links - " /sbin/ldconfig [[ $DEBUG ]] && echo $GREEN"Done"$NORMAL fi ### After restoring overwritten files, removing new ones and running ldconfig the system should ### be running just as before running 'make install', or whatever install command was run. ### So we stop using the static programs and go back to running whatever binaries are in the path. # Now remove any new directories from the system that were created by the INSTALL_LINE . # Our DIRLIST only includes directories which didn't exist before and they should already be empty. cd / ; if [[ "$(cat $CWD/DIRLIST)" != "" ]] ; then [[ $DEBUG ]] && echo -n $BLUE"Removing empty directories installed "$NORMAL"by '$INSTALL_LINE' - " cat $CWD/DIRLIST | while read i; do if [[ -d "$i" ]] ; then ( rm -rf $i ) fi done [[ $DEBUG ]] && echo $GREEN"Done"$NORMAL"" fi # create backup tarball if requested if [[ $KEEP_BACKUPS = "YES" ]] ; then ! [[ $BACKUPS_SAVE_DIR ]] && BACKUPS_SAVE_DIR="$CWD" # installwatch-0.7 # if [[ "$(find $BACKUP_DIRECTORY/BACKUP -type f)" != "" ]] ; then # cd $BACKUP_DIRECTORY/BACKUP if [[ "$(find $BACKUP_DIR/$NAME-$VERSION-backup-$BUILD$SIG -type f)" != "" ]] ; then cd $BACKUP_DIR/$NAME-$VERSION-backup-$BUILD$SIG echo -n $BLUE"Creating backup package - "$NORMAL # installwatch-0.7 #tar -cpf - . | gzip -9 > "${BACKUPS_SAVE_DIR}/backup-$(date +%m%d%Y%H%M)-pre-${SHORT_NAME}.tar.gz" ${TAR_STATIC} -cpf - . | gzip -9 > "${BACKUPS_SAVE_DIR}/backup-$(date +%m%d%Y%H%M)-pre-${SHORT_NAME}.tar.gz" rm -f $CWD/BACKUP.list echo $GREEN"Done"$NORMAL fi fi # remove the backup directory # installwatch-0.7 # if [[ -d $BACKUP_DIRECTORY/BACKUP ]] ; then # ls $BACKUP_DIRECTORY/BACKUP/* &> /dev/null if [[ -d $BACKUP_DIR/$NAME-$VERSION-backup-$BUILD$SIG ]] ; then ls $BACKUP_DIR/$NAME-$VERSION-backup-$BUILD$SIG/* &> /dev/null if [[ $? -eq 0 ]] ; then cd $BACKUP_DIR ; # installwatch-0.7 # if [[ "$(find $BACKUP_DIRECTORY/BACKUP -type f)" != "" ]] ; then if [[ "$(find $BACKUP_DIR/$NAME-$VERSION-backup-$BUILD$SIG -type f)" != "" ]] ; then [[ $DEBUG ]] && echo -n $BLUE"Removing backup files - "$NORMAL rm -rf $BACKUP_DIRECTORY 2> /dev/null 1> /dev/null else [[ $DEBUG ]] && echo -n $BLUE"Removing empty backup directories - "$NORMAL rm -rf $BACKUP_DIRECTORY 2> /dev/null 1> /dev/null fi [[ $DEBUG ]] && echo $GREEN"Done"$NORMAL else cd $BACKUP_DIR ; [[ $DEBUG ]] && echo $BLUE"Removing unused backup directory - "$NORMAL rm -rf $BACKUP_DIRECTORY 2> /dev/null 1> /dev/null fi fi # remove filelists unless we are debugging ! [[ $KEEP_FILELIST = "YES" ]] && rm -f $CWD/FILELIST ! [[ $KEEP_DIRLIST = "YES" ]] && rm -f $CWD/DIRLIST echo $BLUE"Safe installation - "$GREEN"Successful!"$NORMAL echo $BLUE"Processing package content:"$NORMAL fi ## 2 trap safe_user_cancel 2 fi } # end fake_install post_fake_install() { # Move any man-pages installed to usr/share/man by 'make install' if [[ -d $PKG_DIR/usr/share/man ]] && [[ "$CORRECT_MANS" = "YES" ]] ; then mkdir -p $PKG_DIR/usr/man cp -a $PKG_DIR/usr/share/man/* $PKG_DIR/usr/man/ rm -rf $PKG_DIR/usr/share/man echo $YELLOW"NOTICE! "$NORMAL"Makefile installed man-pages to /usr/share/man!" echo "Better 'policy' places them under /usr/man so they'll be moved there." echo "You can safely ignore this warning or try EXTRA_CONFIGS='--mandir=/usr/man'." MOVEMANS=1 fi # Move any info pages installed to usr/share/info by 'make install' if [[ -d $PKG_DIR/usr/share/info ]] && [[ "$CORRECT_MANS" = "YES" ]] ; then mkdir -p $PKG_DIR/usr/info cp -a $PKG_DIR/usr/share/info/* $PKG_DIR/usr/info/ rm -rf $PKG_DIR/usr/share/info echo $YELLOW"NOTICE! "$NORMAL"Makefile installed info pages to /usr/share/info!" echo "Better 'policy' places them under /usr/info so they'll be moved there." echo "You can safely ignore this warning or try EXTRA_CONFIGS='--infodir=/usr/info'." MOVEINFO=1 fi # Move any docs installed to usr/share/doc by 'make install' if [[ -d $PKG_DIR/usr/share/doc ]] && [[ "$CORRECT_DOCS" = "YES" ]] ; then mkdir -p $PKG_DIR/usr/doc cp -a $PKG_DIR/usr/share/doc/* $PKG_DIR/usr/doc/ rm -rf $PKG_DIR/usr/share/doc echo $YELLOW"NOTICE! "$NORMAL"Makefile installed docs to /usr/share/doc!" echo "Better 'policy' places them under /usr/doc so they'll be moved there." MOVEDOCS=1 fi # Below are advanced routines # shortcut switch for deleting all development files [[ $RUNTIME_ONLY = "YES" ]] && { DELETE_STATIC_LIBS="YES" DELETE_HEADERS="YES" } # Remove only static libs [[ $DELETE_STATIC_LIBS = "YES" ]] && { for dir in $LIB_DIRS ; do rm -f $PKG_DIR/$dir/*.a done } # Remove only include header files and directories [[ $DELETE_HEADERS = "YES" ]] && { for dir in $INC_DIRS ; do rm -rf $PKG_DIR/$dir done } } fix_pkg_perms() { if [[ "$FAILED" = "" ]] ; then if [[ "$CORRECT_PKG_PERMS" != "NO" ]] ; then echo -n $BLUE"Correcting package permissions - "$NORMAL chown -R root:root $PKG_DIR cd $PKG_DIR ; find . -type d -exec chmod 755 {} \; [[ -d $PKG_DIR/tmp ]] && chmod 1755 $PKG_DIR/tmp [[ -d $PKG_DIR/var/tmp ]] && chmod 1755 $PKG_DIR/var/tmp #for dir in $BIN_DIRS ; do #[[ -d $dir ]] && chmod 755 $dir/* #done find . | xargs -r file | grep "executable" | grep ELF | cut -f 1 -d : | xargs -r chmod 755 2> /dev/null echo $GREEN"Done"$NORMAL fi fi } # Strip ELF Binaries and Libraries strip_bins() { if [[ "$FAILED" = "" ]] ; then if [[ $STRIP_BINS = "YES" ]] ; then cd $PKG_DIR ; find . | xargs -r file | grep "executable" | grep ELF 2> /dev/null 1> /dev/null && { echo -n $BLUE"Stripping ELF binaries - "$NORMAL ( cd $PKG_DIR find . | xargs -r file | grep "executable" | grep ELF | cut -f 1 -d : | xargs -r strip $BIN_STRIP_COMMAND 2> /dev/null ) echo $GREEN"Done"$NORMAL } || { ! [[ $QUIET = "YES" ]] && echo "No unstripped ELF binaries were found. "$BLUE"Skipping..."$NORMAL } fi if [[ $STRIP_LIBS = "YES" ]] ; then cd $PKG_DIR ; find . | xargs -r file | grep "not stripped" | grep shared | grep ELF 2> /dev/null 1> /dev/null && { echo -n $BLUE"Stripping shared libraries - "$NORMAL ( cd $PKG_DIR find . | xargs -r file | grep "not stripped" | grep shared | grep ELF | cut -f 1 -d : | xargs -r strip $LIB_STRIP_COMMAND 2> /dev/null ) echo $GREEN"Done"$NORMAL } || { ! [[ $QUIET = "YES" ]] && echo "No unstripped shared libraries found. "$BLUE"Skipping..."$NORMAL } find . | xargs -r file | grep "current ar archive" > /dev/null 1> /dev/null && { echo -n $BLUE"Stripping static archives - "$NORMAL ( cd $PKG_DIR find . | xargs -r file | grep "current ar archive" | cut -f 1 -d : | xargs -r strip $LIB_STRIP_COMMAND 2> /dev/null ) echo $GREEN"Done"$NORMAL } || { ! [[ $QUIET = "YES" ]] && echo "No unstripped static archives found. "$BLUE"Skipping..."$NORMAL } fi [[ $COMPRESS_BINS = "YES" ]] && compress_bins fi } # compress binaries with upx if requested and available compress_bins() { if [[ "$FAILED" = "" ]] ; then [[ $COMPRESS_BINS = "YES" ]] && [[ $(which upx) ]] && { cd $PKG_DIR ; for d in $BIN_DIRS ; do [[ -d $d ]] && { for f in $(ls $d) ; do [[ "$(file $f |grep 'ELF')" ]] && continue || { echo $CYAN"NOTE- "$NORMAL"Attempting to compress binary file ""$BLUE""$d/$f""$NORMAL" echo "upx won't compress files smaller than about 50K." echo "Be aware that files compressed with UPX normally show a corrupt header." [[ $QUIET != "YES" ]] && upx $d/$f \ || upx $d/$f 2> /dev/null 1> /dev/null } done } done } fi } create_docs() { if [[ "$FAILED" = "" ]] ; then cd $PKG_DIR ; if [[ $(find . -type f) = "" ]] ; then echo $RED"ERROR! "$NORMAL"The package tree has no content!" echo "For now, we bail out from the top of create_docs." FAILED="EMPTY PKG_DIR" else # Move docs badly placed by the script writer -note that only stuff under /usr/share gets moved if [[ -e $PKG_DIR/usr/share/doc ]] && [[ "$CORRECT_DOCS" = "YES" ]] ; then echo $CYAN"NOTICE! "$NORMAL"Moving docs installed under usr/share/doc to usr/doc." mkdir -p $PKG_DIR/usr/doc cp -a $PKG_DIR/usr/share/doc/* $PKG_DIR/usr/doc/ rm -rf $PKG_DIR/usr/share/doc # if nothing else was installed under share then remove it [[ $(ls $PKG_DIR/usr/share) = "" ]] && rm -rf $PKG_DIR/usr/share MOVEDOCS=1 fi # if docs have been installed without a version number correct it if [[ -d $PKG_DIR/usr/doc ]] && [ $(ls $PKG_DIR/usr/doc |wc -l) -eq 1 ] ; then if [[ ! -d $PKG_DIR/usr/doc/$NAME-$VERSION ]] && [[ "$CORRECT_DOCS" = "YES" ]] ; then DIRME=$(ls $PKG_DIR/usr/doc) echo $CYAN"NOTICE! "$NORMAL"Renaming doc directory installed without a version number." mv $PKG_DIR/usr/doc/$DIRME $PKG_DIR/usr/doc/$NAME-$VERSION rm -rf $PKG_DIR/usr/doc/$DIRME MOVEDOCSVERSION=1 fi fi ! [[ -d $PKG_DIR/usr/doc/$NAME-$VERSION ]] && mkdir -p $PKG_DIR/usr/doc/$NAME-$VERSION if ! [[ $DOCLIST = "" ]] ; then echo -n $BLUE"Copying documents - "$NORMAL"Using user-supplied DOCLIST - " for doc in $DOCLIST ; do if [[ -f $CONFIG_DIR/$doc ]] ; then cp $CONFIG_DIR/$doc $PKG_DIR/usr/doc/$NAME-$VERSION/ 2> /dev/null 1> /dev/null elif [[ -f $SRC_DIR/$doc ]] ; then cp $SRC_DIR/$doc $PKG_DIR/usr/doc/$NAME-$VERSION/ 2> /dev/null 1> /dev/null fi done else echo -n $BLUE"Checking for standard documents - "$NORMAL for doc in ABOUT ANNOUNCE AUTHORS BUGS CHANGELOG CHANGES ChangeLog Changelog CONTRIBUTORS COPYING COPYRIGHT CREDITS FAQ FEATURES History HISTORY INSTALL LICENSE LSM MANIFEST NEWS README README.txt README.TXT README.* *.README Readme readme readme.txt THANKS TIPS TODO VERSION CONFIGURATION GPL LGPL License ; do if [[ -f $CONFIG_DIR/$doc ]] ; then cp -a $CONFIG_DIR/$doc $PKG_DIR/usr/doc/$NAME-$VERSION/ 2> /dev/null 1> /dev/null elif [[ -f $SRC_DIR/$doc ]] ; then cp -a $SRC_DIR/$doc $PKG_DIR/usr/doc/$NAME-$VERSION/ 2> /dev/null 1> /dev/null fi done fi if [[ "$(find $PKG_DIR/usr/doc -type f)" != "" ]] ; then echo $GREEN"Done"$NORMAL else if [[ -d $SRC/doc ]] ; then cp -a $SRC/doc/*.txt $SRC/doc/*.doc $SRC/doc/*.ps \ $SRC/doc/*.html $SRC/doc/*.htm $PKG_DIR/usr/doc/$NAME-$VERSION/ 1> /dev/null 2> /dev/null echo $GREEN"Done"$NORMAL fi fi if [[ "$(find $PKG_DIR/usr/doc -type f)" = "" ]] ; then echo $YELLOW"Warning! "$NORMAL"No documents were found for the package." else cd $PKG_DIR/usr/doc ; if [[ $(find . -type f -size 0) ]] && ! [[ "$CORRECT_DOCS" = "NO" ]] ; then echo $BLUE"Found empty documents - "$NORMAL"Removing zero-length files in /usr/doc." find . -type f -size 0 -exec rm -f {} \; fi cd $PKG_DIR ; find $PKG_DIR/usr/doc -type f -exec chmod 644 {} \; # be more thorough... for really weird installations find $PKG_DIR$PRE_FIX -path './*/doc/*' -type f -exec chmod 644 {} \; find $PKG_DIR$PRE_FIX -path './*/share/doc/*' -type f -exec chmod 644 {} \; find $PKG_DIR$PRE_FIX -path './*/share/$NAME/doc/*' -type f -exec chmod 644 {} \; advanced_docs fi fi fi } # Internal Routine advanced_docs() { # look for pkgconfig .pc files in sources if [[ $(find $SRC_DIR -maxdepth 1 -name '*.pc' 2> /dev/null) ]] ; then echo $BLUE"Found pkgconfig '*.pc' file - "$NORMAL"Copying into the PKG_DIR" mkdir -p $PKG_DIR/usr/share/pkgconfig find $SRC_DIR -maxdepth 1 -name '*.pc' -exec cp -a {} $PKG_DIR/usr/share/pkgconfig \; find $PKG_DIR -maxdepth 1 -name '*uninstalled.pc' -exec rm -f {} \; fi # look for *.desktop file in sources: if [[ $(find $SRC_DIR -maxdepth 1 -name '*.desktop' 2> /dev/null) ]] ; then echo $BLUE"Found '*.desktop' file - "$NORMAL"Copying into the PKG_DIR" mkdir -p $PKG_DIR/usr/share/applications find $SRC_DIR -maxdepth 1 -name '*.desktop' -exec cp -a {} $PKG_DIR/usr/share/applications \; fi # look for *.desktop file in CWD also if [[ $(find $CWD -maxdepth 1 -name '*.desktop' 2> /dev/null) ]] ; then echo $BLUE"Found '*.desktop' file in CWD - "$NORMAL"Copying into the PKG_DIR" mkdir -p $PKG_DIR/usr/share/applications find $CWD -maxdepth 1 -name '*.desktop' -exec cp -a {} $PKG_DIR/usr/share/applications \; &> /dev/null fi # Below are Advanced package handling routines [[ $SAVE_SPACE -gt 2 ]] && \ [[ -f $PKG_DIR/usr/doc/$NAME-$VERSION/COPYING ]] && \ { mkdir -p $PKG_DIR/usr/share/licenses mv $PKG_DIR/usr/doc/$NAME-$VERSION/COPYING $PKG_DIR/usr/share/licenses/COPYING cd $PKG_DIR/usr/doc/$NAME-$VERSION ln -sf ../../share/licenses/COPYING $COPYING } [[ $SAVE_SPACE -gt 1 ]] && \ { cd $PKG_DIR/usr/doc ${TAR_STATIC} -cjf $NAME-$VERSION-doc.tbz $NAME-$VERSION cd $PKG_DIR rm -rf $PKG_DIR/usr/doc/$NAME-$VERSION } # purge_locales if [[ "$PURGE_LOCALES" = "YES" ]] ; then ! [[ $DONT_PURGE_LIST ]] && DONT_PURGE_LIST="/etc/src2pkg/DONT_PURGE.locales" ! [[ $LOCALE_LIST ]] && LOCALE_LIST="/etc/src2pkg/all-locales.txt" if [[ -e $DONT_PURGE_LIST ]] && [[ -e $LOCALE_LIST ]] ; then $BLUE"Purging locale files- "$NORMAL"Removing extra language files if found" for LOCALE_DIR in $LOCALE_DIRS ; do if [[ -d $PKG_DIR/$LOCALE_DIR ]] ; then for LOCALE in $(/bin/ls $PKG_DIR/$LOCALE_DIR) ; do [[ "$(grep -x ^$LOCALE $LOCALE_LIST)" ]] && \ [[ ! "$(grep -x ^$LOCALE $DONT_PURGE_LIST)" ]] && \ [[ -d $PKG_DIR/$LOCALE_DIR/$LOCALE/LC_MESSAGES ]] && { rm -f $(find $PKG_DIR/$LOCALE_DIR/$LOCALE -type f) rm -f $(find $PKG_DIR/$LOCALE_DIR/$LOCALE/LC_MESSAGES -type f) rmdir $PKG_DIR/$LOCALE_DIR/$LOCALE/LC_MESSAGES rmdir $PKG_DIR/$LOCALE_DIR/$LOCALE } done fi done else echo $YELLOW"Notice! "$NORMAL"LOCALE_PURGE configuration files were not found." echo "See the documentation for how to set up locale purging. "$BLUE"Skipping..."$NORMAL fi fi } # End advanced_docs ### compress_man_pages compress_man_pages() { if [[ "$FAILED" = "" ]] ; then # Move man-pages badly placed by the 'operator' if [[ -d $PKG_DIR/usr/share/man ]] && [[ "$CORRECT_MANS" = "YES" ]] ; then mkdir -p $PKG_DIR$PRE_FIX/man cp -a $PKG_DIR$PRE_FIX/share/man $PKG_DIR$PRE_FIX rm -rf $PKG_DIR/usr/share/man [[ $(ls $PKG_DIR/usr/share) = "" ]] && rm -rf $PKG_DIR/usr/share echo $CYAN"NOTICE! "$NORMAL"Moving man pages installed under usr/share/man to usr/man" MOVEMANS=1 fi # Move info pages badly placed by the 'operator' if [[ -d $PKG_DIR/usr/share/info ]] && [[ "$CORRECT_MANS" = "YES" ]] ; then mkdir -p $PKG_DIR$PRE_FIX/info cp -a $PKG_DIR$PRE_FIX/share/info $PKG_DIR$PRE_FIX rm -rf $PKG_DIR/usr/share/info [[ $(ls $PKG_DIR/usr/share) = "" ]] && rm -rf $PKG_DIR/usr/share echo $CYAN"NOTICE! "$NORMAL"Moving info pages installed under usr/share/info to usr/info" MOVEINFO=1 fi [[ $SAVE_SPACE -gt 0 ]] && MAN_COMPRESS="bzip2" cd $PKG_DIR ; # decompress any existing zipped man-pages, make non-executable and re-compress find . -path './*/man*/*' -name '*.gz' | xargs -r gunzip find . -path './*/man*/*' -name '*.bz2' | xargs -r bunzip2 find . -path './*/man*/*' -name '*.*' | xargs -r chmod 644 # find . -path './*/man*/*' -name '*.[1-9]' | xargs -r $MAN_COMPRESS find . -path './*/man*/*' -name '*.*' | xargs -r $MAN_COMPRESS && MANSCOMPRESSED=1 # do the same for info pages find . -path './usr/info/*' -name '*.gz' | xargs -r gunzip find . -path './usr/info/*' -name '*.bz2' | xargs -r bunzip2 find . -path './usr/info/*' -name '*.*' | xargs -r chmod 644 # find . -path './usr/info/*' -name '*.info' -o -name '*.info-[0-9]' -o -name '*.info-[0-9][0-9]' | xargs -r $MAN_COMPRESS find . -path './*/info/*' -name '*.*' | xargs -r $MAN_COMPRESS && INFOSCOMPRESSED=1 if [[ $(find . -path './*/man*/*' -name '*.*') != "" ]] ; then echo $BLUE"Compressing man pages - "$GREEN"Done"$NORMAL fi if [[ $(find . -path './*/info/*' -name '*.*') != "" ]] ; then echo $BLUE"Compressing info pages - "$GREEN"Done"$NORMAL fi fi } # Internal function called by make_description make_default_desc() { if [[ "$FAILED" = "" ]] ; then [[ ! $CREATOR ]] && CREATOR="src2pkg" touch $PKG_DIR/install/$PKG_DESC #echo "# This file should have 11 lines with NAME:" >> $PKG_DIR/install/$PKG_DESC #echo "# NAME must match exactly with the package name." >> $PKG_DIR/install/$PKG_DESC #echo "# Lines beginning with '#' are okay above the description." >> $PKG_DIR/install/$PKG_DESC #echo "# Finally, this file should end with a final blank line." >> $PKG_DIR/install/$PKG_DESC # use awk to align the guide starting at ':' (plus one space) echo -n "# " >> $PKG_DIR/install/$PKG_DESC HR_SPACES=$(echo $NAME | wc -c| awk '{ for (i=1;substr ($0,i,1) ~ /[[:blank:]]/ ;i++); print substr ($0,i);}') awk -v S=$HR_SPACES 'BEGIN {ORS=""; for (i=1; i < S; i++) print " ";}' >> $PKG_DIR/install/$PKG_DESC echo "|-----Use this guide to format your text with------------------|" >> $PKG_DIR/install/$PKG_DESC cat >> $PKG_DIR/install/$PKG_DESC << END $NAME: $NAME $NAME: $NAME: No description was given for this package. $NAME: $NAME: $NAME: $NAME: $NAME: $NAME: $NAME: $NAME: Packaged by: ${CREATOR} END if [ "$EXEC_NAME" = "trackinstall" -o "$EXEC_NAME" = "src2pkg" ] && [[ ! $AUTO_SCRIPT ]] ; then # skip this if we are using trackinstall or src2pkg without AUTO_SCRIPT true else echo "A copy of it named new.$PKG_DESC will be placed in the current directory." echo "Edit, if needed, and copy or rename to $PKG_DESC for permanent use." cp $PKG_DIR/install/$PKG_DESC $CWD/new.$PKG_DESC fi fi } make_description() { if [[ "$FAILED" = "" ]] ; then cd $CWD; mkdir -p $PKG_DIR/install ! [[ $CREATOR ]] && CREATOR="src2pkg" if [[ -e $CWD/$PKG_DESC ]] ; then nol=$(cat $CWD/$PKG_DESC | sed -e '/^$/d' -e '/^[ #]/d' | grep $NAME: | wc -l) if [[ $nol -ne 11 ]] ; then echo $YELLOW"WARNING! "$NORMAL"The supplied $PKG_DESC file is not valid." echo "You need 11 lines that begin with '$NAME:' for this package." REMAKE_DESC=1 fi if [[ $REMAKE_DESC ]] ; then if ! [[ -e $CWD/rej.$PKG_DESC ]] ; then echo "It will be renamed to rej.$PKG_DESC and a new one created." mv $CWD/$PKG_DESC $CWD/rej.$PKG_DESC else rm $CWD/$PKG_DESC fi echo $BLUE"Creating $PKG_DESC - "$NORMAL"Inserting new $PKG_DESC file in the package tree" make_default_desc else cat $CWD/$PKG_DESC > $PKG_DIR/install/$PKG_DESC && \ chmod 644 $PKG_DIR/install/$PKG_DESC && \ echo $BLUE"Verified $PKG_DESC found - "$NORMAL"Inserting in the package tree " fi else echo $BLUE"Creating $PKG_DESC - "$NORMAL"Inserting new $PKG_DESC file in the package tree" make_default_desc 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 the 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 # echo -n $BLUE"Making link creation script - "$NORMAL make_install_script $INST | tee $CWD/doinst.links 1> /dev/null # echo $GREEN"Done"$NORMAL else echo "None found" fi rm -f $INST } # 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 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 if [ "$EXEC_NAME" = "trackinstall" -o "$EXEC_NAME" = "src2pkg" ] && [[ ! $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/slack-requires ]] ; then cat $CWD/slack-requires > $PKG_DIR/install/slack-requires 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 fi } # tiny_make_package tiny_make_package() { PACKAGE_NAME=$1 TARGET_NAME="$(dirname $PACKAGE_NAME)" PACKAGE_NAME="$(basename $PACKAGE_NAME)" TAR_NAME="$(basename $PACKAGE_NAME .tgz)" # this is probably not needed umask 022 echo ${TAR_STATIC} cvf $TAR_NAME.tar . echo echo "Gzipping $TAR_NAME.tar to $TAR_NAME.tar.gz" gzip -9 $TAR_NAME.tar echo "Renaming $TAR_NAME.tar.gz to $PACKAGE_NAME" mv $TAR_NAME.tar.gz $PACKAGE_NAME if [ ! "$TARGET_NAME" = "." ]; then echo "Moving $PACKAGE_NAME to $TARGET_NAME" mv $PACKAGE_NAME $TARGET_NAME fi } # Create package make_package() { if [[ "$FAILED" = "" ]] ; then # first get rid of any zero-length files if ! [[ $FORCE_ZERO_LENGTH = "YES" ]] ; then cd $PKG_DIR ; if [[ $(find . -type f -size 0) ]] ; then echo $CYAN"NOTICE! "$NORMAL" Zero-length files were found in the package tree These are" echo "usually blank documents, so we remove them by default. You can always force" echo "installation with: FORCE_ZERO_LENGTH=YES if any of them are really needed." echo "Zero-length files installed under /etc are allowed (some conf files are blank)." echo $BLUE"List of removed files:"$NORMAL for dir in $(ls |grep -v etc) ; do ( cd $dir find . -type f -size 0 -exec echo $(basename {}) \; find . -type f -size 0 -exec rm -f {} \; cd ../ ) done fi find . -type f -name '*.gz' -size 20c | while read file ; do echo "WARNING: Possible empty gzipped file $file" done fi echo -n $BLUE"Making installable package - "$NORMAL # Build the package: if [[ $QUIET = "YES" ]] ; then cd $PKG_DIR ; tiny_make_package $PACKAGE &> /dev/null else cd $PKG_DIR ; echo "" tiny_make_package $PACKAGE fi if [[ $? -ne 0 ]] ; then echo "" echo $RED"FAILED! "$NORMAL"Creation of package has failed." FAILED="PACKAGE CREATION" else [[ $QUIET = "YES" ]] && echo $GREEN"Done"$NORMAL || echo "" echo $BLUE"Package Creation - "$GREEN"Successful! "$BLUE"- Package Location:"$NORMAL echo $PACKAGE fi [[ $REALLY_INSTALL = "YES" ]] && really_install fi } # Internal Routines mini_installpkg() { echo $BLUE"Installing package "$NORMAL"$PKG_NAME" ( cd $ROOT/ ; $TAR_STATIC -xzlUpvf - ) < $PACKAGE 2> /dev/null DATABASE_FILE=$ROOT/$ADM_DIR_NAME/packages/$SHORT_NAME ; make_database if [ -x /sbin/ldconfig ]; then /sbin/ldconfig fi if [ -f $ROOT/install/doinst.sh ]; then echo "Executing install script for $SHORT_NAME..." ( cd $ROOT/ ; sh install/doinst.sh -install; ) fi if [ -d $ROOT/install ]; then if [ -r $ROOT/install/doinst.sh ]; then cp $ROOT/install/doinst.sh $ROOT/$ADM_DIR_NAME/scripts/$SHORT_NAME chmod 755 $ROOT/$ADM_DIR_NAME/scripts/$SHORT_NAME fi # /install/doinst.sh and /install/slack-* are reserved locations for the package system. ( cd $ROOT/install ; rm -f doinst.sh slack-* *desc *require* 1> /dev/null 2>&1 ) rmdir $ROOT/install 1> /dev/null 2>&1 fi } # really install the package only if REALLY_INSTALL="YES" really_install() { if [[ "$FAILED" = "" ]] && [[ $REALLY_INSTALL = "YES" ]] ; then if [[ "$INSTALLPKG" = "internal" ]] ; then mini_installpkg else echo $BLUE"Installing package $PKG_NAME"$NORMAL if [[ $QUIET="YES" ]] ; then $INSTALLPKG $PACKAGE 2> /dev/null 1> /dev/null else $INSTALLPKG $PACKAGE fi fi fi } post_process() { if [[ "$FAILED" = "" ]] ; then # The following produces if [[ $MAKE_REPORT = "YES" ]] ; then echo $BLUE"Creating REPORT: "$NORMAL"$SHORT_NAME.REPORT" REPORT_FILE="$CWD/$SHORT_NAME.REPORT" echo "Build Log for ""$SHORT_NAME" > $REPORT_FILE echo "" >> $REPORT_FILE echo -n "Uncompressed Package Size:" >> $REPORT_FILE echo "$(du $PKG_DIR -ch |grep total |cut -f1)"" bytes" >> $REPORT_FILE echo "TGZ Package Contents:" >> $REPORT_FILE ${TAR_STATIC} -tzf $PKG_DEST_DIR/$PKG_NAME >> $REPORT_FILE echo "" >> $REPORT_FILE echo "Permissions from PKG_DIR:" >> $REPORT_FILE cd $PKG_DIR && ls -lR |grep -v total >> $REPORT_FILE echo "" >> $REPORT_FILE echo "src2pkg script:" >> $REPORT_FILE cat $CWD/$EXEC_NAME >> $REPORT_FILE echo "" >> $REPORT_FILE if [[ -e $PKG_DIR/install/doinst.sh ]] ; then echo "doinst.sh contents:" >> $REPORT_FILE cat $PKG_DIR/install/doinst.sh >> $REPORT_FILE echo "" >> $REPORT_FILE fi # chk_pkg_deps() { echo "Package dependencies:" >> $REPORT_FILE cd $PKG_DIR ; if [[ "$(find . | xargs file | grep ELF | cut -f 1 -d : | xargs ldd | white_out | cut -f1 -d' ')" != "" ]] ; then echo $CYAN"Notice- "$NORMAL"The package depends on the following installed libraries:" >> $REPORT_FILE find . | xargs file | grep ELF | cut -f 1 -d : | xargs ldd | white_out | cut -f1 -d' ' >> $REPORT_FILE fi fi #Create a DATABASE file. This is a replica of what installpkg puts in /var/log/packages when the package is installed if [[ $MAKE_DATABASE = "YES" ]] ; then echo $BLUE"Creating DATABASE: "$NORMAL"$SHORT_NAME.DATABASE" DATABASE_FILE=$CWD/$SHORT_NAME.DATABASE make_database fi # cleanup build files if asked for -trackinstall sets this to PKG but lets be redundant if [[ $CLEANUP ]] ; then [[ $TRACK_INSTALL ]] && CLEANUP="PKG" echo -n $BLUE"Deleting build directories - "$NORMAL if [[ $CLEANUP = "SRC" ]] || [[ $CLEANUP = "ALL" ]] ; then if [[ -d $SRC_DIR ]] ; then echo -n "SRC_DIR " cd $SRC_BUILDS_DIR ; rm -rf $SRC_DIR_NAME fi if [[ -d $OBJ_DIR ]] ; then echo -n "OBJ_DIR " cd $SRC_BUILDS_DIR ; rm -rf $OBJ_DIR_NAME fi fi if [[ $CLEANUP = "PKG" ]] || [[ $CLEANUP = "ALL" ]] ; then if [[ -d $PKG_DIR ]] ; then echo -n "PKG_DIR " cd $PKG_BUILDS_DIR ; rm -rf $PKG_DIR_NAME fi fi echo $GREEN"Done"$NORMAL fi elif [[ $USER_CANCELLED ]] ; then echo $RED"Exiting! "$NORMAL"User cancelled operation." elif [[ $FAILED = "CANCELLED" ]] ; then echo $RED"Exiting! "$NORMAL exit 0 else echo $(basename $0) $RED"FAILURE "$NORMAL"in $FAILED" exit 0 fi } # End post_process ## General Functions used internally # Eliminate whitespace function: white_out() { while read GAGA ; do echo $GAGA done } safe_user_cancel() { USER_CANCELLED=1 } trap_int() { echo echo $RED"*** OUCH!!! ***"$NORMAL emergency_restore FAILED="CANCELLED" exit } emergency_restore() { echo "Please don't interrupt during installation!" ls $BACKUP_DIR/$NAME-$VERSION-backup-$BUILD$SIG/* &> /dev/null if [[ $? -eq 0 ]] ; then rm -rf $BACKUP_DIR/$NAME-$VERSION-backup-$BUILD$SIG/no-backup 2> /dev/null 1> /dev/null if [[ $(ls $BACKUP_DIR/$NAME-$VERSION-backup-$BUILD$SIG/*) != "" ]] ; then cd $BACKUP_DIR/$NAME-$VERSION-backup-$BUILD$SIG echo "Emergency restoration of backup files!" ${TAR_STATIC} -cpf - . | ${TAR_STATIC} -f - -xvpC / # &> /dev/null echo "Backup file restoration complete." fi fi } make_database() { COMPRESSED=$(gzip -l $PACKAGE | grep -v uncompressed_name | white_out | cut -f 1 -d ' ') COMPRESSED="$(expr $COMPRESSED / 1024) K" UNCOMPRESSED=$(gzip -l $PACKAGE | grep -v uncompressed_name | white_out | cut -f 2 -d ' ') UNCOMPRESSED="$(expr $UNCOMPRESSED / 1024) K" echo "PACKAGE NAME: $NAME-$VERSION" > $DATABASE_FILE echo "COMPRESSED PACKAGE SIZE: $COMPRESSED" >> $DATABASE_FILE echo "UNCOMPRESSED PACKAGE SIZE: $UNCOMPRESSED" >> $DATABASE_FILE echo "PACKAGE LOCATION: $PKG_NAME" >> $DATABASE_FILE echo "PACKAGE DESCRIPTION:" >> $DATABASE_FILE cat $PKG_DIR/install/$PKG_DESC | grep -v '#' >> $DATABASE_FILE echo "FILE LIST:" >> $DATABASE_FILE ${TAR_STATIC} -tzf $PACKAGE >> $DATABASE_FILE } check_dirs1 () { for VAR_NAME in PKG_BUILDS_DIR PKG_DEST_DIR SRC_DIR PKG_DIR CWD; do if [[ "${VAR_NAME}" = "" ]] ; then echo $RED"FATAL! "$NORMAL"Null value given for critical src2pkg variable." echo "Please read the src2pkg documentation for help." exit 1 fi if [[ "${VAR_NAME}" = "/" ]] ; then echo $RED"FATAL! "$NORMAL"Root directory was given as a critical src2pkg variable," echo "or is the current directory. Please read the src2pkg documentation for help." exit 1 fi if [[ "${VAR_NAME}" = "${HOME}" ]] ; then if [[ "${VAR_NAME}" = "PKG_DEST_DIR" ]] ; then true else echo $RED"FATAL! "$NORMAL"Home directory was given as a critical src2pkg variable," echo "or is the current directory. Please read the src2pkg documentation for help." exit 1 fi fi # MISC_DIRS="boot etc dev home mnt opt proc root sys usr var usr/share usr/local" CRITICAL_DIRS="$BIN_DIRS $LIB_DIRS $INC_DIRS $LOCALE_DIRS $MAN_DIRS $MISC_DIRS" for SYSTEM_DIR in $(echo $CRITICAL_DIRS 2> /dev/null) ; do SYSTEM_DIR="/""$SYSTEM_DIR" if [[ "${VAR_NAME}" = "$SYSTEM_DIR" ]] ; then echo $RED"FATAL! "$NORMAL"$SYSTEM_DIR was given as a critical src2pkg variable," echo "or is the current directory. Please read the src2pkg documentation for help." exit 1 fi done done } check_dirs2() { if [[ "${SRC_BUILDS_DIR}" = "" ]] || [[ "${SRC_BUILDS_DIR}" = "/" ]] ; then echo $RED"FATAL ERROR "$NORMAL"Please give a valid SRC_BUILDS_DIR." exit 1 fi if [[ "${PKG_BUILDS_DIR}" = "" ]] || [[ "${PKG_BUILDS_DIR}" = "/" ]] ; then echo $RED"FATAL ERROR "$NORMAL"Please give a valid PKG_BUILDS_DIR." echo "Don't give a null PKG_BUILDS_DIR or use / !" exit 1 fi if [[ "${PRE_FIX}" = "" ]] || [[ "${PRE_FIX}" = "/" ]] ; then echo $RED"FATAL ERROR "$NORMAL"Please give a valid PRE_FIX." echo "Don't give a null PRE_FIX or use / !" exit 1 fi if [[ "${SRC_DIR}" = "" ]] || [[ "${SRC_DIR}" = "/" ]] ; then echo $RED"FATAL ERROR "$NORMAL"Please give a valid SRC_DIR." exit 1 fi if [[ "${PKG_DIR}" = "" ]] || [[ "${PKG_DIR}" = "/" ]] ; then echo $RED"FATAL ERROR "$NORMAL"Please give a valid PKG_DIR." exit 1 fi # This shouldn't happen either [[ "${PACKAGE}" = "" ]] || [[ "${PACKAGE}" = "/" ]] && echo $RED"ERROR "$NORMAL"Bad PACKAGE name!" && exit 1 } get_flags() { # # Compiler options # Using -O3 gives results similar to -Os. ! [[ $OPTIM_FLAGS ]] && OPTIM_FLAGS="-O2" # Optimize for smaller binaries [[ $OPTIMIZE_4_SIZE = "YES" ]] && OPTIM_FLAGS="-Os" # Machine architecture tuning flags and package ARCH if [[ "$(uname -m)" = "ppc" ]] ; then ! [[ $ARCH ]] && ARCH="powerpc" TUNE_FLAGS="" elif [[ "$(uname -m)" = "s390" ]] ; then ! [[ $ARCH ]] && ARCH="s390" TUNE_FLAGS="" elif [[ "$(uname -m)" = "x86_64" ]] ; then ! [[ $ARCH ]] && ARCH="x86_64" TUNE_FLAGS="-fPIC" elif [[ "$(uname -m |grep 86)" != "" ]] ; then GCCVERSION=$(gcc --version|grep 'GCC' |cut -f3 -d' ') if [[ $(expr $GCCVERSION) > 3.4 ]] ; then CPU_TAG="-mtune" else CPU_TAG="-mcpu" fi # MARCH_FLAG="i486" CPU_FLAG="i686" # Could set dynamically : MARCH_FLAG= or CPU_FLAG="$(uname -m)" # This ARCH is for the package name. ! [[ $ARCH ]] && ARCH="$MARCH_FLAG" TUNE_FLAGS="-march=$MARCH_FLAG $CPU_TAG=$CPU_FLAG" else ! [[ $ARCH ]] && ARCH="unknown" TUNE_FLAGS="" fi ! [[ $STD_FLAGS ]] && STD_FLAGS="$OPTIM_FLAGS $TUNE_FLAGS" ! [[ $EXTRA_FLAGS ]] && EXTRA_FLAGS="" } # color get_color_options() { # Check for color prompting if [[ $COLOR_PROMPT = "YES" ]] ; then # ANSI COLORS CRE="" NORMAL="" # RED: Failure or error message RED="" # GREEN: Success message GREEN="" # YELLOW: Warnings YELLOW="" # BLUE: Summary messages BLUE="" # CYAN: Current Process CYAN="" fi } #####-----------------------------------------------------------------------------------------------------------------------