home *** CD-ROM | disk | FTP | other *** search
/ Gold Fish 2 / goldfish_vol2_cd1.bin / files / pack.sh < prev    next >
Linux/UNIX/POSIX Shell Script  |  1994-11-27  |  2KB  |  109 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.  
  13. for i in `cat $tmp`
  14. do
  15.     dname=`dirname $i`
  16.     fname=`basename $i`
  17.     cd $dname
  18.     prodname=""
  19.     lhafiles=""
  20.     pifilein=""
  21.     if test -d $fname
  22.     then
  23.         if test -f $fname/Product-Info
  24.         then
  25.             prodname=$fname
  26.             lhafiles="$fname"
  27.             pifilein=$fname/Product-Info
  28.             if test -f $fname.info
  29.             then
  30.                 lhafiles="$fname.info $lhafiles"
  31.             fi
  32.         else
  33.             echo WARNING 'pwd'/$fname is missing a Product-Info file
  34.         fi
  35.     elif test -f $fname.pi
  36.     then
  37.         prodname=$fname
  38.         lhafiles="$fname $fname.pi"
  39.         pifilein=$fname.pi
  40.         if test -f $fname.info
  41.         then
  42.             lhafiles="$lhafiles $fname.info"
  43.         fi
  44.     fi
  45.     if test -n "$pifilein"
  46.     then
  47.         prodname=`echo $pifilein | pitool -f - -b -F "%N" - | tr -d " \t"`
  48.     fi
  49.     if test -n "$prodname"
  50.     then
  51.         case "$prodname" in
  52.             *.anim) prodname=`basename $prodname .anim`;;
  53.             *.jpeg) prodname=`basename $prodname .jpeg`;;
  54.             *.jpg) prodname=`basename $prodname .jpg`;;
  55.             *) ;;
  56.         esac
  57.         if test -n "$pifilein"
  58.         then
  59.             version=`echo $pifilein | pitool -f - -b -F "%V" - | tr -d " \t"`
  60.             case "$version" in
  61.                 "");;
  62.                 "?.?");;
  63.                 *) prodname="$prodname-$version";;
  64.             esac
  65.         fi
  66.  
  67.         bbsdir=`dirname $dname`
  68.         lhaname=$prodname.lha
  69.         pifileout=$lhaname.pi
  70.  
  71.         #echo "==========="
  72.         #echo "dname = $dname"
  73.         #echo "bbsdir = $bbsdir"
  74.         #echo "prodname = $prodname"
  75.         #echo "lhaname = $lhaname"
  76.         #echo "lhafiles = $lhafiles"
  77.         #echo "pifilein = $pifilein"
  78.         #echo "pifileout = $pifileout"
  79.  
  80.         if test ! -d BBS:$bbsdir
  81.         then
  82.             echo "mkdir -p BBS:$bbsdir"
  83.             mkdir -p BBS:$bbsdir
  84.         fi
  85.         if test -f BBS:$bbsdir/$lhaname
  86.         then
  87.             echo "WARNING - Not superceding BBS:$bbsdir/$lhaname"
  88.         else
  89.     
  90.             # Add each of the files/directories to the lha archive.
  91.             # We do it this way because the shareware version of
  92.             # lha misbehaves if handled all args at once.
  93.  
  94.             while [ -n "${lhafiles}" ] ; do
  95.                 set ${lhafiles}; file=$1; shift; lhafiles=$*
  96.                 echo "lha -mraxeq a BBS:$bbsdir/$lhaname $file"
  97.                 lha -mraxeq a BBS:$bbsdir/$lhaname $file
  98.             done
  99.  
  100.             # Copy the associated product info file over.
  101.  
  102.             echo "cp $pifilein BBS:$bbsdir/$pifileout"
  103.             cp $pifilein BBS:$bbsdir/$pifileout
  104.         fi
  105.     fi
  106.     cd $home
  107. done
  108. rm -f $tmp
  109.