#!/bin/sh ############################################################################## # # checkinstall 1.0 # # # ######################## # # # # Installs a compiled program from the program's source directory using # # "make install" or any other command supplied on checkinstall's command # # line. checkinstall will create a Slackware-compatible package named after # # the source directory's name and install it using's Slackware's package # # administration utilities. # # # # This version of checkinstall needs enough free space on the partition # # holding /tmp to write there a temporary copy of the package. # # # # Copyright 2000 Felipe Eduardo Sanchez Diaz Duran # # This software is released under the GNU GPL, # # read the file COPYING for details. # # # ############################################################################## # # 001118-BaP: v1.0-BaP by Kevin D. Knerr, Sr. # # Summary of changes: # * Reorganized output statements to suit my personal tastes # * Incorporated more variables to simplify the script & ease maintenance # * Added ${} syntax to existing variables when concatenated w/ strings # * Created a simple function to handle Y/N inputs # * Added an option to let checkinstall create a basic set of package docs # based on commonly used doc names # * Reorganized some sections to improve program flow while reducing # some instances of duplication # * Didn't change version number, but appended -BaP to indicate that this # is essentially a forked version echo "checkinstall 1.0-BaP, Copyright 2000 Felipe Eduardo Sanchez Diaz Duran" echo " This is GNU software" echo # # Variable initialization and other preparations # INSTALLWATCH=/usr/local/bin/installwatch if [ ! -x $INSTALLWATCH ]; then echo "***** ABEND *****" echo "$INSTALLWATCH does not exist." echo echo "Please install installwatch or modify this script so that" echo "INSTALLWATCH is set to the correct pathname before attempting" echo "to run checkinstall again." exit 1 fi # 001117-BaP: We can make some things easier on ourselves if we *don't* # include the package suffix--which I changed to pkg for aesthetic reasons. DIRECTORIO_FUENTE=`pwd` PKG_BASENAME=`basename $DIRECTORIO_FUENTE` NOMBRE_DEL_PAQUETE=${PKG_BASENAME}-pkg.tgz PKG_DOC_DIR=doc-pak # 001117-BaP: Use a simpler syntax to set INSTALLCMD INSTALLCMD=${1:-'make install'} # 001117-BaP: Define a function or two function yorn { read YN YN=`echo $YN | tr 'a-z' 'A-Z'` } # Ensure that our directories exist if ! [ -d /tmp/package ]; then echo "Creating directory /tmp/package" mkdir /tmp/package fi # 001117-BaP: We can create a default set of docs on the fly . . . # The list I've included should cover most packages adequately. If not, # then you should really create the package doc set *manually* if ! [ -d $PKG_DOC_DIR ]; then echo "The package documentation directory ./${PKG_DOC_DIR} does not exist." echo -n "Should I create a default set of package docs? [Y/N] " yorn if [ $YN = "Y" ]; then echo "Preparing package documentation . . ." mkdir $PKG_DOC_DIR for f in ABOUT ABOUT-NLS ANNOUNCE AUTHORS BUGS CHANGES CONFIGURATION COPYING COPYING.LIB COPYRIGHT CREDITS ChangeLog Changelog FAQ FEATURES FILES HACKING INSTALL KNOWN_BUGS LICENSE LSM MANIFEST NEWS README RELEASE RELNOTES THANKS TIPS TODO VERSION ; do if [ -f $f ]; then cp -a $f $PKG_DOC_DIR fi done else echo -n "Do you wish to continue without any package docs? [Y/N] " yorn if ! [ $YN = "Y" ]; then echo "Aborting installation." exit 1 fi fi fi echo # # We run the program installation from the source directory # echo "Installing with \"${INSTALLCMD}...\"" # 001117-BaP: Why go through the trouble of setting $INSTALLWATCH and # checking if it exists if we're then going to simply assume it's in # the path??? #installwatch -o /tmp/newfiles.tmp $INSTALLCMD &> /tmp/install.log $INSTALLWATCH -o /tmp/newfiles.tmp $INSTALLCMD &> /tmp/install.log # 001117-BaP: Let's eliminate some duplication here--and make it more friendly # to boot . . . INSTALL_FAILED=$? echo if [ $INSTALL_FAILED -gt 0 ]; then echo " ***** ABEND *****" echo "An error was encountered during installation. Installation aborted." else echo "Installation successful!" fi echo echo -n "Do you wish to view the log file (/tmp/install.log) now? [Y/N] " yorn if [ $YN = "Y" ] ; then less /tmp/install.log fi if [ $INSTALL_FAILED -gt 0 ]; then exit $INSTALL_FAILED fi echo # # Remove garbage from the modified files list # cat /tmp/newfiles.tmp | cut -f 3 | egrep -v '/dev|/tmp' | sort -u > /tmp/newfiles # # Copy the files to /tmp/package # echo "Copying package files to the temporary directory . . ." cd / for i in `cat /tmp/newfiles`; do if ! [ -d $i ]; then (tar cp $i| tar xvpC /tmp/package) &> /tmp/checkinstall.log fi done # Copy the documentation files, if they exist if [ -d ${DIRECTORIO_FUENTE}/$PKG_DOC_DIR ]; then mkdir -p /tmp/package/usr/doc/$PKG_BASENAME cd ${DIRECTORIO_FUENTE}/$PKG_DOC_DIR tar cp * | tar xvpC /tmp/package/usr/doc/$PKG_BASENAME &> /dev/null fi # # Create packagee (TODO: make this automatic) # echo "Creating the $PKG_BASENAME package . . ." cd /tmp/package /sbin/makepkg $NOMBRE_DEL_PAQUETE mv $NOMBRE_DEL_PAQUETE $DIRECTORIO_FUENTE # # Install the package to register it in Slacware's installed packages list # so we can list it's contents with pkgtool or remove it with removepkg # echo "Installing new package: $NOMBRE_DEL_PAQUETE . . ." /sbin/installpkg ${DIRECTORIO_FUENTE}/$NOMBRE_DEL_PAQUETE # # Remove trash from /tmp # echo 'Erasing temporary files . . .' rm -rf /tmp/{newfiles*,package/*} # Go back to where we started cd $DIRECTORIO_FUENTE echo "Done." echo echo "The new package has been installed and saved to:" echo " ${DIRECTORIO_FUENTE}/$NOMBRE_DEL_PAQUETE" echo echo "To remove it, use:" echo " /sbin/removepkg $NOMBRE_DEL_PAQUETE" echo exit 0