"Fossies" - the Fresh Open Source Software Archive

Member "checkinstall-1.6.2/makepak" (11 Nov 2008, 6413 Bytes) of package /linux/privat/old/checkinstall-1.6.2.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) Bash source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file.

    1 #!/bin/sh
    2 # Copyright 1994, 1998  Patrick Volkerding, Moorhead, Minnesota USA 
    3 # All rights reserved.
    4 #
    5 # Redistribution and use of this script, with or without modification, is
    6 # permitted provided that the following conditions are met:
    7 #
    8 # 1. Redistributions of this script must retain the above copyright
    9 #    notice, this list of conditions and the following disclaimer.
   10 #
   11 #  THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
   12 #  WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
   13 #  MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO
   14 #  EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   15 #  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
   16 #  PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
   17 #  OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
   18 #  WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
   19 #  OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
   20 #  ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
   21 #
   22 # Wed Mar 18 15:32:33 CST 1998
   23 # Patched to avoid possible symlink attacks in /tmp.
   24 #
   25 # Sat Dec 09 2000 - Felipe Sanchez <izto@asic-linux.com.mx>
   26 # Removed the code for the questions about symlinks and sane permissions
   27 # They are useless to CheckInstall
   28 #
   29 # Fri Jul 20 2001 - Felipe Sanchez <izto@asic-linux.com.mx>
   30 # Included the patch made to makepkg in the Slackware 8.0 release.
   31 #
   32 # Fri Jun 04 2004 - Felipe Sanchez <izto@asic-linux.com.mx>
   33 # Check for the existence of the directory before creating the
   34 # symlinks in make_install_script().
   35 
   36 
   37 make_install_script() {
   38  COUNT=1
   39  LINE="`sed -n "$COUNT p" $1`"
   40  while [ ! "$LINE" = "" ]; do
   41   LINKGOESIN="`echo "$LINE" | cut -f 1 -d " "`" 
   42   LINKGOESIN="`dirname $LINKGOESIN`" 
   43   LINKNAMEIS="`echo "$LINE" | cut -f 1 -d ' '`"
   44   LINKNAMEIS="`basename "$LINKNAMEIS"`"
   45   LINKPOINTSTO="`echo "$LINE" | cut -f 3 -d ' '`"
   46   echo "( cd $LINKGOESIN && rm -rf $LINKNAMEIS )"
   47   echo "( cd $LINKGOESIN && ln -sf $LINKPOINTSTO $LINKNAMEIS )"
   48   COUNT=`expr $COUNT + 1`
   49   LINE="`sed -n "$COUNT p" $1`"
   50  done
   51 }
   52 
   53 usage() {
   54  cat << EOF
   55 
   56 Usage: makepkg package_name.tgz
   57 
   58 Makes a Slackware compatible "*.tgz" package containing the contents of the 
   59 current and all subdirectories. If symbolic links exist, they will be removed
   60 and an installation script will be made to recreate them later. This script
   61 will be called "install/doinst.sh". You may add any of your own ash-compatible
   62 shell scripts to this file and rebuild the package if you wish.
   63 
   64 EOF
   65 }
   66 
   67 TMP=/tmp # This can be a hole, but I'm going to be careful about file
   68          # creation in there, so don't panic. :^)
   69 
   70 # These tests, while by no means exhaustive, will give a usage message
   71 # and exit with a wide range of bad input.
   72 
   73 if [ ! $# = 1 -a ! $# = 0 ]; then
   74  usage;
   75  exit
   76 fi
   77 echo
   78 echo "Slackware package maker, version 1.1-CheckInstall"
   79 if [ $# = 0 ]; then
   80  usage;
   81  echo "You have not provided a name for this package."
   82  echo -n "What would you like to call it? "
   83  read PACKAGE_NAME;
   84 else
   85  PACKAGE_NAME=$1
   86 fi
   87 TARGET_NAME="`dirname $PACKAGE_NAME`"
   88 PACKAGE_NAME="`basename $PACKAGE_NAME`"
   89 TAR_NAME="`basename $PACKAGE_NAME .tgz`"
   90 echo
   91 echo "Searching for symbolic links:"
   92 # Get rid of possible pre-existing trouble:
   93 rm -rf $TMP/iNsT-a.$$
   94 touch $TMP/iNsT-a.$$
   95 
   96 # In Slackware 8.0 the makepkg script is patched to fix an "off-by-one"
   97 # problem in the "find . -type ....." line below. This will set the
   98 # right number to use if we're running on that version.
   99 
  100 if ( grep 8 /etc/slackware-version &> /dev/null ); then 
  101    BYTE_COUNT=59
  102 else
  103    BYTE_COUNT=58
  104 fi
  105 
  106 find . -type l -exec ls -l {} \; | cut -b${BYTE_COUNT}- | tee $TMP/iNsT-a.$$
  107 if [ ! "`filesize $TMP/iNsT-a.$$`" = "0" ]; then
  108  echo
  109  echo "Making symbolic link creation script:"
  110  make_install_script $TMP/iNsT-a.$$ | tee doinst.sh
  111 fi
  112 echo
  113 if [ ! "`filesize $TMP/iNsT-a.$$`" = "0" ]; then
  114 # if [ -r install/doinst.sh ]; then
  115 #  echo "Unless your existing installation script already comtains the code"
  116 #  echo "to create these links, you should append these lines to your existing"
  117 #  echo "install script. Now's your chance. :^)"
  118 #  echo
  119 #  echo "Would you like to add this stuff to the existing install script and"
  120 #  echo -n "remove the symbolic links ([y]es, [n]o)? "
  121 # else
  122 #  echo "It is recommended that you make these lines your new installation script."
  123 #  echo
  124 #  echo "Would you like to make this stuff the install script for this package"
  125 #  echo -n "and remove the symbolic links ([y]es, [n]o)? "
  126 # fi
  127 # read SCRIPTADD;
  128 SCRIPTADD="y"
  129  if [ "$SCRIPTADD" = "y" ]; then
  130   if [ -r install/doinst.sh ]; then
  131    UPDATE="t"
  132    cat doinst.sh >> install/doinst.sh
  133   else
  134    mkdir install
  135    cat doinst.sh > install/doinst.sh
  136   fi
  137   echo
  138   echo "Removing symbolic links:"
  139   find . -type l -exec rm -v {} \;
  140   echo
  141   if [ "$UPDATE" = "t" ]; then
  142    echo "Updating your ./install/doinst.sh..."
  143   else
  144    echo "Creating your new ./install/doinst.sh..."
  145   fi
  146  fi
  147 else
  148  echo "No symbolic links were found, so we won't make an installation script."
  149  echo "You can make your own later in ./install/doinst.sh and rebuild the"
  150  echo "package if you like."
  151 fi
  152 rm -f doinst.sh $TMP/iNsT-a.$$
  153 #echo
  154 #echo "This next step is optional - you can set the directories in your package"
  155 #echo "to some sane permissions. If any of the directories in your package have"
  156 #echo "special permissions, then DO NOT reset them here!"
  157 #echo 
  158 #echo "Would you like to reset all directory permissions to 755 (drwxr-xr-x) and"
  159 #echo -n "directory ownerships to root.root ([y]es, [n]o)? "
  160 #read PERMS;
  161 PERMS="n"
  162 echo
  163 if [ "$PERMS" = "y" ]; then
  164  find . -type d -exec chmod -v 755 {} \; 
  165  find . -type d -exec chown -v root.root {} \;
  166 fi
  167 echo
  168 echo "Creating tar file $TAR_NAME.tar..."
  169 echo
  170 $TAR -cvf $TAR_NAME.tar .
  171 # Warn of zero-length files:
  172 find . -type f -size 0c | while read file ; do
  173   echo "WARNING: zero length file $file"
  174 done
  175 find . -type f -name '*.gz' -size 20c | while read file ; do
  176   echo "WARNING: possible empty gzipped file $file"
  177 done
  178 echo
  179 echo "Gzipping $TAR_NAME.tar..."
  180 gzip -9 $TAR_NAME.tar
  181 echo
  182 echo "Renaming $TAR_NAME.tar.gz to $PACKAGE_NAME..."
  183 mv $TAR_NAME.tar.gz $PACKAGE_NAME
  184 if [ ! "$TARGET_NAME" = "." ]; then
  185   echo
  186   echo "Moving $PACKAGE_NAME to $TARGET_NAME..."
  187   mv $PACKAGE_NAME $TARGET_NAME
  188 fi
  189 echo
  190 echo "Package creation complete."
  191 echo