]> www.hackdaworld.org Git - hdw-linux/hdw-linux.git/blob - scripts/Update-Tree
strip -x from package names
[hdw-linux/hdw-linux.git] / scripts / Update-Tree
1 #!/bin/sh
2 #
3 # hdw - linux ./scripts/Update-Tree script
4 #
5 # author: hackbard@hackdaworld.dyndns.org
6 #
7
8 # defaults
9 mode="keep"
10
11 while [ "$1" ] ; do
12         case "$1" in
13                 -mode)  mode="$2"       ; shift 2 ;;
14                 *)      echo "usage:"
15                         echo
16                         echo "$0 -mode [keep|del|update]"
17                         echo
18                         exit 1 ;;
19         esac
20 done
21
22 # reading Config file
23 . ./Config
24
25 # test - u need cvs installed!
26 if [ ! -f /usr/bin/cvs ] ; then
27         echo "you need cvs for updating the tree"
28         echo "aborting."
29         exit 1
30 fi
31
32 # make sure cvs works ..
33 [ ! -f $HOME/.cvspass ] && touch $HOME/.cvspass
34
35 # does he use cvs?
36 if [ -d ./CVS ] ; then
37         echo "updating from official cvs tree first ..."
38         cvs up -d > /dev/null 2>&1
39         echo "done"
40 fi
41
42 # fetching packages
43 mkdir temp && cd temp
44 echo "fetching developers packages ..."
45 cvs -d:pserver:anonymous@hackdaworld.dyndns.org:/hdw-repos co packages targets > /dev/null 2>&1
46 echo "done"
47
48 # add targets to $part one day
49 for part in packages; do
50 for dir in `ls -A --ignore="CVS" ./$part`; do
51         if [ ! -d ../$part/$dir ] ; then
52                 echo "creating new repository $dir ..."
53                 mkdir ../$part/$dir
54         fi
55         for object in `ls -A --ignore="CVS" ./$part/$dir`; do
56                 if [ ! -d ../$part/$dir/$object ] ; then
57                         existing_p=`find ../$part -type d -name $object`
58                         if [ -z "$existing_p" ] ; then
59                                 echo "creating new package $object"
60                                 mkdir ../$part/$dir/$object
61                                 cp -r ./$part/$dir/$object/* \
62                                         ../$part/$dir/$object
63                         else
64                                 if [ "$mode" = "del" ] ; then
65                                         echo "del mode: overwriting $object ..."
66                                         rm -rf $existing_p/*
67                                         cp -r ./$part/$dir/$object/* \
68                                         $existing_p
69                                 else
70                                         echo "$object exists."
71                                         if [ "$mode" = "update" ] ; then
72                                                 cd $existing_p
73                                                 echo "running cvs ..."
74                                                 cvs up -d >/dev/null 2>&1
75                                                 cd -
76                                         fi
77                                 fi
78                         fi
79                 else
80                         if [ "$mode" = "del" ] ; then
81                                 echo "del mode: overwriting $object ..."
82                                 rm -rf ../$part/$dir/$object/*
83                                 cp -r ./$part/$dir/$object/* \
84                                         ../$part/$dir/$object
85                                 echo "done"
86                         else
87                                 echo "$object exists."
88                                 if [ "$mode" = "update" ] ; then
89                                         cd ../$part/$dir/$object
90                                         echo "running cvs ..."
91                                         cvs up -d >/dev/null 2>&1
92                                         cd -
93                                 fi
94                         fi
95                 fi
96         done
97 done
98 done
99
100 cd .. && rm -rf ./temp