#!/bin/bash # trackinstall Copyright 2006-2007 Gilbert Ashley TRACKINSTALL_VERSION="1.1" CWD=$(pwd) cd $CWD && CWD=$(pwd) TRACK_INSTALL=1 show_usage() { echo "" echo " $(basename $0) - Build an installable package from pre-compiled sources" echo " or from other content in the current directory." echo "" echo " $(basename $0) [-ABCHINPSV(VV)(VVV)W] [-abdinv]" echo "" echo " Capitalized Options take no argument:" echo " -A Auto-generate a TrackBuild script if successful." echo " -B Backup any files overwritten by this installation." echo " -I Install the created package when finished." echo " -C Place final package in the current directory." echo " -H Place final package in your home directory." echo " -N New TrackBuild script and slack-desc file only." echo " -P Preserve permissions in the source directory." echo " -S Run special install commands - 'sh install.sh' by default" echo " -V,VV Be verbose. Show all output from the steps." echo " -VVV DEBUG -show detailed prompts for debugging." echo " -W Wipe up -cleanup temporary files when finished." echo " Lowercase options require an argument separated by the '=' sign:" echo " -a Set the architecture of the package (--arch)[-a=noarch]." echo " -b Set the package build/release number (--build)[-b=4]." echo " -d Specify the included documents (-doclist)[-d='README foo.HOWTO AUTHORS']." echo " -i Set the install command line (--install)[-i='make install']." echo " -n Set alternate name for the package and (--alt-name)[-n=newname]" echo " -v Set alternate version for the package (--alt-version)[-v=0.0.0a]." echo "" echo " Examples:" echo " trackinstall -C -W" echo " Place final package in the current directory and delete temporary files." echo " trackinstall -b=2" echo " Set the BUILD number to '2'." echo " trackinstall -i='make install install_data'" echo " install with 'make install install_data (same as running 'make install' and 'make install_data')" echo " trackinstall -P -S -i='bash ./install.script'" echo " Preserve permissions and use 'bash ./install.script' instead of 'make install'" echo "" echo " For more usage help, run 'man trackinstall' or see the documentation." } NAMVERS=$(basename $CWD) VERSION=$(echo "$NAMVERS" | rev | cut -f1 -d"-" | rev) NAME=$(echo "$NAMVERS" | rev | cut -f2,3,4 -d"-" | rev) source /usr/libexec/src2pkg/FUNCTIONS if ! [[ -z $1 ]] ; then if [ "$1" = "-h" -o "$1" = "--help" ] ; then show_usage exit 0 fi if [[ "$1" = "--version" ]] ; then echo "trackinstall version-$TRACKINSTALL_VERSION" exit 0 fi for word in "$@" ; do case $word in -A) AUTO_SCRIPT=1 ; shift ;; -B) KEEP_BACKUPS="YES" ; shift ;; -I) REALLY_INSTALL="YES" ;; -C) PKG_DEST_DIR="$CWD" ; shift ;; -H) PKG_DEST_DIR="$HOME" ; shift ;; -N) NEW_BUILD=1 ; shift ;; -P) CORRECT_PERMS="NO" ; shift ;; -S) SHELL_INSTALL=1 ; shift ;; -V|-VV) QUIET="NO" ; shift ;; -VVV) DEBUG=1 ; shift ;; -W) CLEANUP="PKG" ; shift ;; -a=*|--arch=*) ARCH=$(echo $word |cut -f2 -d'=') ; shift ;; -b=*|--build=*) BUILD=$(echo $word |cut -f2 -d'=') ; shift ;; -d=*|--doclist=*) DOCLIST=$(echo $word |cut -f2 -d'=') ; shift ;; -i=*|--install=*) INSTALL_LINE=$(echo $word |cut -f2- -d'=') ; shift ;; -n=*|--alt-name=*) ALT_NAME=$(echo $word |cut -f2 -d'=') ; shift ;; -v=*|--alt-version=*) ALT_VERSION=$(echo $word |cut -f2 -d'=') ; shift ;; *) echo "Ignoring unrecognized option: $word" ; sleep 2 ;; esac done fi pre_process if ! [[ $NEW_BUILD ]] ; then make_dirs fake_install fix_pkg_perms strip_bins create_docs compress_man_pages make_description make_doinst make_package post_process if [[ $FAILED = "" ]] ; then true else echo $RED"FAILED!! "$NORMAL"Creation of package $PKG_NAME has failed." fi if [[ $FAILED = "CANCELLED" ]] ; then echo "Operation cancelled by user. "$RED"Exiting!"$NORMAL exit elif [[ $FAILED != "" ]] ; then echo $(basename $0) $RED"ERROR "$NORMAL"in $FAILED" exit fi fi # 3 write the script if [[ $AUTO_SCRIPT ]] || [[ $NEW_BUILD ]]; then echo -n $CYAN"NOTICE- "$NORMAL"Writing build script: $NAME.TrackBuild for you... " # TrackBuild echo "#!/bin/bash" > $CWD/$NAME.TrackBuild echo "## TrackBuild script for: $NAME" >> $CWD/$NAME.TrackBuild echo "## Auto-generated by 'trackinstall'" >> $CWD/$NAME.TrackBuild echo "## trackinstall Copyright 2006-2007 Gilbert Ashley " >> $CWD/$NAME.TrackBuild echo "## Full package name: $SHORT_NAME.tgz" >> $CWD/$NAME.TrackBuild echo "" >> $CWD/$NAME.TrackBuild echo "NAME='$NAME'" >> $CWD/$NAME.TrackBuild echo "VERSION='$VERSION'" >> $CWD/$NAME.TrackBuild echo "ARCH='$ARCH'" >> $CWD/$NAME.TrackBuild echo "BUILD='$BUILD'" >> $CWD/$NAME.TrackBuild echo "TRACK_INSTALL='YES'" >> $CWD/$NAME.TrackBuild [[ $SHELL_INSTALL ]] && echo "SHELL_INSTALL='YES'" >> $CWD/$NAME.TrackBuild echo "PRE_FIX='$PRE_FIX'" >> $CWD/$NAME.TrackBuild echo "" >> $CWD/$NAME.TrackBuild echo "# Any extra options go here:" >> $CWD/$NAME.TrackBuild ! [[ "$INSTALL_LINE" = "" ]] && echo "INSTALL_LINE='$INSTALL_LINE'" >> $CWD/$NAME.TrackBuild ! [[ "$DOCLIST" = "" ]] && echo "DOCLIST='$DOCLIST'" >> $CWD/$NAME.TrackBuild [[ "$CORRECT_PERMS" = "NO" ]] && echo "CORRECT_PERMS='NO'" >> $CWD/$NAME.TrackBuild echo "" >> $CWD/$NAME.TrackBuild echo "# Read in the config file and functions:" >> $CWD/$NAME.TrackBuild echo "source /usr/libexec/src2pkg/FUNCTIONS ;" >> $CWD/$NAME.TrackBuild echo "" >> $CWD/$NAME.TrackBuild echo "# do_track_install can substitute the following functions:" >> $CWD/$NAME.TrackBuild echo "" >> $CWD/$NAME.TrackBuild cat >> $CWD/$NAME.TrackBuild << EOF pre_process make_dirs fake_install fix_pkg_perms strip_bins create_docs compress_man_pages make_description make_doinst make_package post_process EOF echo "" >> $CWD/$NAME.TrackBuild echo "# src2pkg and trackinstall - Copyright 2005-2007 Gilbert Ashley " >> $CWD/$NAME.TrackBuild echo "# See /usr/doc/src2pkg-x.x.x, run 'man trackinstall' or 'trackinstall --help' for help. Below" >> $CWD/$NAME.TrackBuild echo "# are some common trackinstall options for easy cut-and-paste use if you need them." >> $CWD/$NAME.TrackBuild echo "# INSTALL_LINE ='' DOCLIST=''" >> $CWD/$NAME.TrackBuild echo "# SHELL_INSTALL='YES' CORRECT_PERMS='NO'" >> $CWD/$NAME.TrackBuild echo $GREEN"DONE!"$NORMAL fi #3 if [[ $NEW_BUILD ]] ; then echo $BLUE"Creating new.slack-desc file. "$NORMAL"Edit, if needed and rename to slack-desc for use." cat > $CWD/new.slack-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 fi exit 0