]> git.pld-linux.org Git - projects/pld-ftp-admin.git/blob - bin/move.sh
06760fff00beef04dbbbf6aec1317387ce8d93ac
[projects/pld-ftp-admin.git] / bin / move.sh
1 #!/bin/sh
2
3 . ~/pld-ftp-admin/scripts/functions
4
5 if [ "$#" -lt "3" ]; then
6         echo "Not enough parameters given"
7         echo "move.sh from-tree to-tree package1 [package2...]"
8         exit
9 fi
10
11 if [ ! -d "$FTP_DIR/$1" ]; then
12         echo "$FTP_DIR/$1 does not exit"
13         exit
14 fi
15
16 if [ ! -d "$FTP_DIR/$2" ]; then
17         echo "$FTP_DIR/$2 does not exit"
18         exit
19 fi
20
21
22 # we set $from, $to and $files
23 from=$1
24 to=$2
25 files=""
26
27 waserror=0
28 shift 2
29 while test "$#" -gt "0"
30 do
31         file=`echo $1|sed -e 's,.src.rpm$,,'`
32         if [ ! -f "$FTP_DIR/$from/SRPMS/.metadata/$file.src.rpm.info" ]; then
33                 waserror=$(($waserror+1))
34                 echo "$file was not found in source tree"
35         fi
36         if [ -f "$FTP_DIR/$to/SRPMS/.metadata/$file.src.rpm.info" ]; then
37                 waserror=$(($waserror+1))
38                 echo "$file is already present in destination tree"
39         fi
40         files="$files $file"
41         shift
42 done
43
44 if [ "$waserror" != "0" ]; then
45         echo "$waserror error(s) encountered... aborting"
46         exit
47 fi
48
49 # Remove old packages
50 cd "$FTP_DIR/$to/SRPMS/.metadata/"
51 for srcfile in $files; do
52         basename=`echo $srcfile|sed -e 's,-[^-]*-[^-]*$,,'`
53         for oldinfofile in $basename*; do
54                 if [ "$oldinfofile" == "$basename*" ]; then
55                         # No previous files
56                         continue
57                 fi
58                 # Remove all files connected to the old src.rpm (+ the src.rpm itself)
59                 for i in `cat $oldinfofile|grep '^file:'`; do
60                         arch=`echo $i|cut -d: -f 2`
61                         file=`echo $i|cut -d: -f 3`
62                         rm "$FTP_DIR/$to/$arch/RPMS/$file"
63                 done
64                 # And finally remove the .info file
65                 rm $oldinfofile
66         done
67 done
68
69 # Move the new packages
70 cd "$FTP_DIR/$from/SRPMS/.metadata/"
71 for srcfile in $files; do
72         # Move the rpms
73         for i in `cat "$srcfile.src.rpm.info"|grep '^file:'`; do
74                 arch=`echo $i|cut -d: -f 2`
75                 file=`echo $i|cut -d: -f 3`
76                 mv "$FTP_DIR/$from/$arch/RPMS/$file" "$FTP_DIR/$to/$arch/RPMS/"
77         done
78         # And move the .info file
79         mv "$srcfile.src.rpm.info" "$FTP_DIR/$to/SRPMS/.metadata/"
80 done
81
This page took 0.02691 seconds and 2 git commands to generate.