home *** CD-ROM | disk | FTP | other *** search
/ Fresh Fish 8 / FreshFishVol8-CD1.bin / useful / pack.sh < prev    next >
Linux/UNIX/POSIX Shell Script  |  1995-01-29  |  3KB  |  113 lines

  1. #! /bin/sh
  2. #
  3. # Find all submission root directories, and pack the submission
  4. # into an appropriate directory in the BBS section.  Also copy
  5. # the associated product info file to the BBS section, alongside
  6. # the archive.
  7.  
  8. tmpd=`date +%j%H%M%S`
  9. tmp="/tmp/sh1-$tmpd"
  10. home=`pwd`
  11. grep "^[^/]*/[^/]*/[^/]*$" <$1 >$tmp
  12. bbsroot=$2
  13.  
  14. for i in `cat $tmp`
  15. do
  16.     dname=`dirname $i`
  17.     fname=`basename $i`
  18.     cd $dname
  19.     prodname=""
  20.     lhafiles=""
  21.     pifilein=""
  22.     if test -d $fname
  23.     then
  24.         if test -f $fname/Product-Info
  25.         then
  26.             prodname=$fname
  27.             lhafiles="$fname"
  28.             pifilein=$fname/Product-Info
  29.             if test -f $fname.info
  30.             then
  31.                 lhafiles="$fname.info $lhafiles"
  32.             fi
  33.         else
  34.             echo WARNING 'pwd'/$fname is missing a Product-Info file
  35.         fi
  36.     elif test -f $fname.pi
  37.     then
  38.         prodname=$fname
  39.         lhafiles="$fname $fname.pi"
  40.         pifilein=$fname.pi
  41.         if test -f $fname.info
  42.         then
  43.             lhafiles="$lhafiles $fname.info"
  44.         fi
  45.     fi
  46.     if test -n "$prodname"
  47.     then
  48.         case "$prodname" in
  49.             *.anim) prodname=`basename $prodname .anim`;;
  50.             *.jpeg) prodname=`basename $prodname .jpeg`;;
  51.             *.jpg) prodname=`basename $prodname .jpg`;;
  52.             *) ;;
  53.         esac
  54.         if test -n "$pifilein"
  55.         then
  56.             version=`echo $pifilein | pitool -f - -b -F "%V" - | tr -d " \t"`
  57.             case "$version" in
  58.                 "");;
  59.                 "?.?");;
  60.                 *) prodname="$prodname-$version";;
  61.             esac
  62.         fi
  63.  
  64.         bbsdir=`dirname $dname`
  65.         lhaname=$prodname.lha
  66.         pifileout=$lhaname.pi
  67.  
  68.         #echo "==========="
  69.         #echo "dname = $dname"
  70.         #echo "bbsdir = $bbsdir"
  71.         #echo "prodname = $prodname"
  72.         #echo "lhaname = $lhaname"
  73.         #echo "lhafiles = $lhafiles"
  74.         #echo "pifilein = $pifilein"
  75.         #echo "pifileout = $pifileout"
  76.  
  77.         if test ! -d $bbsroot/$bbsdir
  78.         then
  79.             echo "mkdir -p $bbsroot/$bbsdir"
  80.             mkdir -p $bbsroot/$bbsdir
  81.         fi
  82.         # Begin FIXME - this should be an option, comment it out for now
  83.         #  if test -f $bbsroot/$bbsdir/$lhaname
  84.         #  then
  85.         #      echo "rm -f $bbsroot/$bbsdir/$lhaname"
  86.         #      rm -f $bbsroot/$bbsdir/$lhaname
  87.         #  fi
  88.         # End FIXME
  89.         if test -f $bbsroot/$bbsdir/$lhaname
  90.         then
  91.             echo "Not superceding $bbsroot/$bbsdir/$lhaname"
  92.         else
  93.     
  94.             # Add each of the files/directories to the lha archive.
  95.             # We do it this way because the shareware version of
  96.             # lha misbehaves if handled all args at once.
  97.  
  98.             while [ -n "${lhafiles}" ] ; do
  99.                 set ${lhafiles}; file=$1; shift; lhafiles=$*
  100.                 echo "lha -mraxeq a $bbsroot/$bbsdir/$lhaname $file"
  101.                 lha -mraxeq a $bbsroot/$bbsdir/$lhaname $file
  102.             done
  103.  
  104.             # Copy the associated product info file over.
  105.  
  106.             echo "cp $pifilein $bbsroot/$bbsdir/$pifileout"
  107.             cp $pifilein $bbsroot/$bbsdir/$pifileout
  108.         fi
  109.     fi
  110.     cd $home
  111. done
  112. rm -f $tmp
  113.