home *** CD-ROM | disk | FTP | other *** search
/ Fresh Fish 8 / FreshFishVol8-CD1.bin / new / pack.sh < prev    next >
Linux/UNIX/POSIX Shell Script  |  1995-01-29  |  3KB  |  117 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 "$pifilein"
  47.     then
  48.         prodname=`echo $pifilein | pitool -f - -b -F "%N" - | tr -d " \t"`
  49.     fi
  50.     if test -n "$prodname"
  51.     then
  52.         case "$prodname" in
  53.             *.anim) prodname=`basename $prodname .anim`;;
  54.             *.jpeg) prodname=`basename $prodname .jpeg`;;
  55.             *.jpg) prodname=`basename $prodname .jpg`;;
  56.             *) ;;
  57.         esac
  58.         if test -n "$pifilein"
  59.         then
  60.             version=`echo $pifilein | pitool -f - -b -F "%V" - | tr -d " \t"`
  61.             case "$version" in
  62.                 "");;
  63.                 "?.?");;
  64.                 *) prodname="$prodname-$version";;
  65.             esac
  66.         fi
  67.  
  68.         bbsdir=`dirname $dname`
  69.         lhaname=$prodname.lha
  70.         pifileout=$lhaname.pi
  71.  
  72.         #echo "==========="
  73.         #echo "dname = $dname"
  74.         #echo "bbsdir = $bbsdir"
  75.         #echo "prodname = $prodname"
  76.         #echo "lhaname = $lhaname"
  77.         #echo "lhafiles = $lhafiles"
  78.         #echo "pifilein = $pifilein"
  79.         #echo "pifileout = $pifileout"
  80.  
  81.         if test ! -d $bbsroot/$bbsdir
  82.         then
  83.             echo "mkdir -p $bbsroot/$bbsdir"
  84.             mkdir -p $bbsroot/$bbsdir
  85.         fi
  86.         # Begin FIXME - this should be an option, comment it out for now
  87.         # if test -f $bbsroot/$bbsdir/$lhaname
  88.         # then
  89.         #    echo "rm -f $bbsroot/$bbsdir/$lhaname"
  90.         #    rm -f $bbsroot/$bbsdir/$lhaname
  91.         # fi
  92.         # End FIXME
  93.         if test -f $bbsroot/$bbsdir/$lhaname
  94.         then
  95.             echo "WARNING - Not superceding $bbsroot/$bbsdir/$lhaname"
  96.         else
  97.     
  98.             # Add each of the files/directories to the lha archive.
  99.             # We do it this way because the shareware version of
  100.             # lha misbehaves if handled all args at once.
  101.  
  102.             while [ -n "${lhafiles}" ] ; do
  103.                 set ${lhafiles}; file=$1; shift; lhafiles=$*
  104.                 echo "lha -mraxeq a $bbsroot/$bbsdir/$lhaname $file"
  105.                 lha -mraxeq a $bbsroot/$bbsdir/$lhaname $file
  106.             done
  107.  
  108.             # Copy the associated product info file over.
  109.  
  110.             echo "cp $pifilein $bbsroot/$bbsdir/$pifileout"
  111.             cp $pifilein $bbsroot/$bbsdir/$pifileout
  112.         fi
  113.     fi
  114.     cd $home
  115. done
  116. rm -f $tmp
  117.