home *** CD-ROM | disk | FTP | other *** search
/ BUG 1 / BUGCD1996_0708.ISO / pc / util / minilin / minilin.exe / SBIN / MAKEPKG < prev    next >
Text File  |  1994-05-25  |  5KB  |  151 lines

  1. #!/bin/sh
  2. # Copyright 1994, 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. make_install_script() {
  23.  COUNT=1
  24.  LINE="`sed -n "$COUNT p" $1`"
  25.  while [ ! "$LINE" = "" ]; do
  26.   LINKGOESIN="`echo "$LINE" | cut -f 1 -d " "`" 
  27.   LINKGOESIN="`dirname $LINKGOESIN`" 
  28.   LINKNAMEIS="`echo "$LINE" | cut -f 1 -d ' '`"
  29.   LINKNAMEIS="`basename "$LINKNAMEIS"`"
  30.   LINKPOINTSTO="`echo "$LINE" | cut -f 3 -d ' '`"
  31.   echo "( cd $LINKGOESIN ; rm -rf $LINKNAMEIS )"
  32.   echo "( cd $LINKGOESIN ; ln -sf $LINKPOINTSTO $LINKNAMEIS )"
  33.   COUNT=`expr $COUNT + 1`
  34.   LINE="`sed -n "$COUNT p" $1`"
  35.  done
  36. }
  37.  
  38. usage() {
  39.  cat << EOF
  40.  
  41. Usage: makepkg package_name.tgz
  42.  
  43. Makes a Slackware compatible "*.tgz" package containing the contents of the 
  44. current and all subdirectories. If symbolic links exist, they will be removed
  45. and an installation script will be made to recreate them later. This script
  46. will be called "install/doinst.sh". You may add any of your own ash-compatible
  47. shell scripts to this file and rebuild the package if you wish.
  48.  
  49. EOF
  50. }
  51.  
  52. # These tests, while by no means exhaustive, will give a usage message
  53. # and exit with a wide range of bad input.
  54.  
  55. if [ ! $# = 1 -a ! $# = 0 ]; then
  56.  usage;
  57.  exit
  58. fi
  59. echo
  60. echo "Slackware package maker, version 1.0."
  61. if [ $# = 0 ]; then
  62.  usage;
  63.  echo "You have not provided a name for this package."
  64.  echo -n "What would you like to call it? "
  65.  read PACKAGE_NAME;
  66. else
  67.  PACKAGE_NAME=$1
  68. fi
  69. TARGET_NAME="`dirname $PACKAGE_NAME`"
  70. PACKAGE_NAME="`basename $PACKAGE_NAME`"
  71. TAR_NAME="`basename $PACKAGE_NAME .tgz`"
  72. echo
  73. echo "Searching for symbolic links:"
  74. find . -type l -exec ls -l {} \; | cut -b58- | tee /tmp/iNsT-a.$$
  75. if [ ! "`filesize /tmp/iNsT-a.$$`" = "0" ]; then
  76.  echo
  77.  echo "Making symbolic link creation script:"
  78.  make_install_script /tmp/iNsT-a.$$ | tee doinst.sh
  79. fi
  80. echo
  81. if [ ! "`filesize /tmp/iNsT-a.$$`" = "0" ]; then
  82.  if [ -r install/doinst.sh ]; then
  83.   echo "Unless your existing installation script already comtains the code"
  84.   echo "to create these links, you should append these lines to your existing"
  85.   echo "install script. Now's your chance. :^)"
  86.   echo
  87.   echo "Would you like to add this stuff to the existing install script and"
  88.   echo -n "remove the symbolic links ([y]es, [n]o)? "
  89.  else
  90.   echo "It is recommended that you make these lines your new installation script."
  91.   echo
  92.   echo "Would you like to make this stuff the install script for this package"
  93.   echo -n "and remove the symbolic links ([y]es, [n]o)? "
  94.  fi
  95.  read SCRIPTADD;
  96.  if [ "$SCRIPTADD" = "y" ]; then
  97.   if [ -r install/doinst.sh ]; then
  98.    UPDATE="t"
  99.    cat doinst.sh >> install/doinst.sh
  100.   else
  101.    mkdir install
  102.    cat doinst.sh > install/doinst.sh
  103.   fi
  104.   echo
  105.   echo "Removing symbolic links:"
  106.   find . -type l -exec rm -v {} \;
  107.   echo
  108.   if [ "$UPDATE" = "t" ]; then
  109.    echo "Updating your ./install/doinst.sh..."
  110.   else
  111.    echo "Creating your new ./install/doinst.sh..."
  112.   fi
  113.  fi
  114. else
  115.  echo "No symbolic links were found, so we won't make an installation script."
  116.  echo "You can make your own later in ./install/doinst.sh and rebuild the"
  117.  echo "package if you like."
  118. fi
  119. rm -f doinst.sh /tmp/iNsT-a.$$
  120. echo
  121. echo "This next step is optional - you can set the directories in your package"
  122. echo "to some sane permissions. If any of the directories in your package have"
  123. echo "special permissions, then DO NOT reset them here!"
  124. echo 
  125. echo "Would you like to reset all directory permissions to 755 (drwxr-xr-x) and"
  126. echo -n "directory ownerships to root.root ([y]es, [n]o)? "
  127. read PERMS;
  128. echo
  129. if [ "$PERMS" = "y" ]; then
  130.  find . -type d -exec chmod -v 755 {} \; 
  131.  find . -type d -exec chown -v root.root {} \;
  132. fi
  133. echo
  134. echo "Creating tar file $TAR_NAME.tar..."
  135. echo
  136. tar -cvf $TAR_NAME.tar .
  137. echo
  138. echo "Gzipping $TAR_NAME.tar..."
  139. gzip $TAR_NAME.tar
  140. echo
  141. echo "Renaming $TAR_NAME.tar.gz to $PACKAGE_NAME..."
  142. mv $TAR_NAME.tar.gz $PACKAGE_NAME
  143. if [ ! "$TARGET_NAME" = "." ]; then
  144.   echo
  145.   echo "Moving $PACKAGE_NAME to $TARGET_NAME..."
  146.   mv $PACKAGE_NAME $TARGET_NAME
  147. fi
  148. echo
  149. echo "Package creation complete."
  150. echo
  151.