home *** CD-ROM | disk | FTP | other *** search
/ Complete Linux / Complete Linux.iso / docs / apps / database / postgres / postgre4.z / postgre4 / newconf / newtree < prev    next >
Encoding:
Text File  |  1992-08-27  |  4.8 KB  |  275 lines

  1. #!/bin/sh
  2. #
  3. #    newtree -- create a copy of the postgres master tree
  4. #
  5. # handle some command line arguments...
  6. #
  7. # - changed -d (debug) to -D so this script now supports
  8. #   checking out a tree as of a given date.  For example,
  9. #
  10. #     newtree -d28-April-1991,00:00-PST
  11. #
  12. #   will check out a tree consisting of all the revisions
  13. #   of all the files valid at midnight of April 28, 1991.
  14. #   -cim 5/2/91
  15. #
  16. # set -x
  17.  
  18. if [ -z "$PGMASTERTREE" ]; then
  19.     MASTER=/usr/local/dev/postgres/mastertree
  20. else
  21.     MASTER=$PGMASTERTREE
  22. fi
  23. if test `hostname` = "hermes.Berkeley.EDU"
  24. then
  25. PARALLELNEWTREE=t
  26. fi
  27.  
  28. cd $MASTER
  29.  
  30. debug=0
  31. quiet=0
  32. BUILDOBJ=1
  33. TREE=""
  34. PORT=""
  35. OD=""
  36. dateopt=
  37. name=$0
  38. create=0
  39. usage="Usage: $name [-q -c -noobj] [-p port] [-o obj_dir] full_path_to_tree"
  40.  
  41. while (test ! -z "$1")
  42. do
  43.     case $1 in
  44.     -D)
  45.         debug=1
  46.         shift ;;
  47.     -d*)
  48.         dateopt=$1
  49.         shift ;;
  50.     -c)
  51.         create=1
  52.         shift ;;
  53.     -p) 
  54.         PORT=$2
  55.         cd $MASTER/src/port
  56.         if (test ! -d $PORT) 
  57.         then
  58.             echo "$name: port $PORT does not exist - exiting..." >&2
  59.             exit 1
  60.         fi
  61.         if (test -z "$OD")
  62.         then
  63.             OD=obj.$port
  64.         fi
  65.         shift; shift ;;
  66.     -q)
  67.         quiet=1
  68.         shift;;
  69.     -noobj)
  70.         BUILDOBJ=0
  71.         shift ;;
  72.     -o)
  73.         OD=$2
  74.         shift; shift ;;
  75.     -parallel)
  76.     PARALLELNEWTREE=t
  77.     shift;;
  78.     -*)
  79.         echo "$usage" >&2
  80.         exit 1 ;;
  81.     /*)
  82.         TREE=$1
  83.         shift ;;
  84.     *)
  85.         echo "$usage" >&2
  86.         exit 1 ;;
  87.     esac
  88. done
  89. cocmd="co "$dateopt
  90.  
  91. if (test ! -z "$TREE")
  92. then
  93.     if (test $quiet -eq 0)
  94.     then
  95.         echo "using directory $TREE"
  96.     fi
  97. fi
  98.  
  99. if (test -z "$TREE")
  100. then
  101.     echo ""
  102.     echo -n "Full pathname of directory to contain new tree "
  103.     echo -n "(default /usr/postgres): "
  104.     read TREE
  105.  
  106.     if (test -z "$TREE")
  107.     then
  108.         TREE="/usr/postgres"
  109.     fi
  110. fi
  111.  
  112. if (test ! -d $TREE -a $create -eq 0)
  113. then
  114.     echo ""
  115.     echo -n "Directory $TREE does not exist; create (y/n)? "
  116.     read yn
  117.     if (test $yn != y)
  118.     then
  119.         echo "aborting newtree creation"
  120.         exit
  121.     fi
  122.     create=1
  123. fi
  124.  
  125. if (test $create -eq 1)
  126. then
  127.     TREEPATH=`echo $TREE | sed 's|/| |g' `
  128.     cd /
  129.     for i in $TREEPATH
  130.     do
  131.         if (test ! -d $i)
  132.         then
  133.             if (test $quiet -eq 0)
  134.         then
  135.         echo ===== creating `pwd`/$i =====
  136.         fi
  137.             mkdir $i
  138.         fi
  139.         cd $i
  140.     done
  141. fi
  142.  
  143. if (test $BUILDOBJ -eq 1) then
  144.     if (test -z "$PORT")
  145.     then
  146.         echo ""
  147.         cd $MASTER/src/port
  148.         echo "System-specific ports available are: "
  149.         echo "" ; echo "    " * ; echo ""
  150.         echo -n "Please choose a port (default is dec): "
  151.         read dir
  152.         if (test ! -z "$dir")
  153.         then
  154.             if (test ! -d $dir )
  155.             then
  156.                 echo "Port \"$d\" does not exist"
  157.             fi
  158.             PORT=$dir
  159.         else
  160.             PORT=dec
  161.         fi
  162.     fi
  163.  
  164.     if (test -z "$OD")
  165.     then
  166.         OD=obj.$PORT
  167.         echo ""
  168.         echo "Please enter the object directory name.  To accept the default"
  169.         echo -n "of $OD, hit return: "
  170.         read od
  171.         if (test ! -z "$od")
  172.         then
  173.             OD=$od
  174.         fi
  175.     fi
  176. fi
  177.  
  178. # generate the new tree
  179.  
  180. cd $MASTER/newconf
  181.  
  182. if (test ! -d $TREE/src )
  183. then
  184.     if (test $quiet -eq 0)
  185.     then
  186.         echo ""
  187.         echo ===== creating new source tree =====
  188.     fi
  189.     mkdir $TREE/src
  190. fi
  191.  
  192. #
  193. # Make src dirs.
  194. #
  195. for i in `$cocmd -q -p $MASTER/newconf/dirs.mk`
  196. do
  197.     mkdir $TREE/src/$i
  198.     if (test -d $MASTER/src/$i/RCS)
  199.     then
  200.         cd $TREE/src/$i
  201.         if (test $quiet -eq 0)
  202.         then
  203.             echo ===== checking out files in $i =====
  204.         fi
  205.         if (test $debug -eq 0)
  206.         then
  207.             ln -s $MASTER/src/$i/RCS
  208.         if test $PARALLELNEWTREE
  209.         then
  210.         $cocmd -q RCS/*,v &
  211.         else
  212.                 $cocmd -q RCS/*,v
  213.         fi
  214.         fi
  215.     fi
  216. done
  217.  
  218. #
  219. # Make "other" dirs
  220. #
  221.  
  222. if (test $quiet -eq 0) 
  223. then
  224.     echo ===== checking out other directories =====
  225. fi
  226.  
  227. for i in `$cocmd -q -p $MASTER/newconf/dirs_other.mk`
  228. do
  229.     mkdir $TREE/$i
  230.     if (test  -d $MASTER/$i/RCS )
  231.     then
  232.         cd $TREE/$i
  233.         if (test $quiet -eq 0) 
  234.         then
  235.             echo ===== checking out files in $i =====
  236.         fi
  237.         if (test $debug -eq 0)
  238.         then
  239.             ln -s $MASTER/$i/RCS
  240.         if test $PARALLELNEWTREE
  241.         then
  242.         $cocmd -q RCS/*,v &
  243.         else
  244.                 $cocmd -q RCS/*,v
  245.         fi
  246.         fi
  247.     fi
  248. done
  249.  
  250. if test $PARALLELNEWTREE
  251. then
  252. wait
  253. fi
  254.  
  255. if (test $BUILDOBJ -eq 1)
  256. then
  257.  
  258.     if (test $quiet -eq 0)
  259.     then
  260.         echo ===== building object tree =====
  261.     fi
  262.     cd $TREE/newconf
  263.     if (test $debug -eq 1) 
  264.     then
  265.         echo "debug  - not running newport"
  266.         exit
  267.     fi
  268.     if (test $quiet -eq 0)
  269.     then
  270.         csh ./newport $TREE $PORT $OD
  271.     else
  272.         csh ./newport -q $TREE $PORT $OD
  273.     fi
  274. fi
  275.