]> git.pld-linux.org Git - projects/pld-ftp-admin.git/blame - bin/move.sh
- more changes
[projects/pld-ftp-admin.git] / bin / move.sh
CommitLineData
cf864f0d
MM
1#!/bin/sh
2
f87a6239 3. ~/pld-ftp-admin/scripts/functions
cf864f0d
MM
4
5if [ "$#" -lt "3" ]; then
6 echo "Not enough parameters given"
7 echo "move.sh from-tree to-tree package1 [package2...]"
8 exit
9fi
10
11if [ ! -d "$FTP_DIR/$1" ]; then
12 echo "$FTP_DIR/$1 does not exit"
13 exit
14fi
15
16if [ ! -d "$FTP_DIR/$2" ]; then
17 echo "$FTP_DIR/$2 does not exit"
18 exit
19fi
20
21
22# we set $from, $to and $files
23from=$1
24to=$2
25files=""
26
27waserror=0
28shift 2
29while test "$#" -gt "0"
30do
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
42done
43
44if [ "$waserror" != "0" ]; then
40063693 45 echo "$waserror error(s) encountered... aborting"
cf864f0d
MM
46 exit
47fi
48
49# Remove old packages
50cd "$FTP_DIR/$to/SRPMS/.metadata/"
51for 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)
2086e467 59 for i in `cat $oldinfofile|grep '^file:'`; do
cf864f0d
MM
60 arch=`echo $i|cut -d: -f 2`
61 file=`echo $i|cut -d: -f 3`
da382ebe 62 rm "$FTP_DIR/$to/$arch/RPMS/$file"
cf864f0d
MM
63 done
64 # And finally remove the .info file
65 rm $oldinfofile
66 done
67done
68
69# Move the new packages
70cd "$FTP_DIR/$from/SRPMS/.metadata/"
71for srcfile in $files; do
72 # Move the rpms
2086e467 73 for i in `cat "$srcfile.src.rpm.info"|grep '^file:'`; do
cf864f0d
MM
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/"
80done
81
This page took 0.042782 seconds and 4 git commands to generate.