2 # Note: all functions expect to get N-V-R strings as pkg arguments (unless
3 # it's obvious they shouldn't get them of course)
6 if [ ! -f ~/.ftpadmrc ]; then
7 echo "Config not found"
14 scriptname=`basename $0`
16 # Log a message... useful for debugging
18 echo `date "+%F %T"` "[$scriptname]" "--" "$@" >>~/pld-ftp-admin/log
21 # Wrapper so that we can test stuff without actually doing (allmost) anything
22 if [ "$DEBUG" == "yes" ]; then
38 # Return a list of packages that differ only by version than the one given
39 # Args: $1 - the package we're intersted in (in N-V-R format)
40 # Note1: we assume we're in .metadata dir
41 # Note2: the list returned is newline, not space, separated
42 # Note3: sets $glob_basename to basename (without V-R) if anybody need's it
45 # Get just the name without the version tag
46 basename=`echo $1|sed -e 's,-[^-]*-[^-]*$,,'`
47 # Find packages beginning with that name
48 allpkgs=`echo $basename*`
49 if [ "$allpkgs" == "$basename*" ]; then
53 allpkgs=`echo "$allpkgs"|sed -e 's, ,\n,g' -e 's,.src.rpm.info,,g'`
54 # Filter out pkgs that just begin with basename, but ain't other
55 # versions of that package
56 allpkgs=`echo "$allpkgs"|grep "$basename-[^-]*-[^-]*$"`
60 # Generate a list of older packages
62 # $2 - packages we're interested in
65 cd "$FTP_DIR/$1/SRPMS/.metadata/"
68 # "Glob" for other pkgs
69 allpkgs=`glob_packages $pkg`
70 # Get just the name without the version tag (we need it)
71 basename=`echo $pkg|sed -e 's,-[^-]*-[^-]*$,,'`
73 allpkgs=`echo "$allpkgs"|sed -e "s,^$basename-,,"`
74 # Sort (note - this ain't perfect sorting)
75 allpkgs=`echo "$allpkgs"|sort -n`
77 allpkgs=`echo "$allpkgs"|sed -e "s,^,$basename-,"`
78 # Grep packages < current package
79 allpkgs=`echo "$allpkgs"|grep -B 999 "$pkg"|grep -v "^$pkg$"`
81 allpkgs=`echo $allpkgs`
87 # Generate a list of all packages (glob name-*) except the one given
89 # $2 - packages we're interested in
92 cd "$FTP_DIR/$1/SRPMS/.metadata/"
95 # "Glob" for other pkgs
96 allpkgs=`glob_packages $pkg`
97 # Cut out our own package
98 allpkgs=`echo "$allpkgs"|grep -v "^$pkg$"`
100 allpkgs=`echo $allpkgs`
101 list="$list $allpkgs"
106 # Remove packages in given tree
107 # Args: $1 - ftp tree
108 # $2 - list of packages to remove
111 cd "$FTP_DIR/$1/SRPMS/.metadata/"
113 if [ "$3" == "force" ]; then
117 # Remove all files connected to the old src.rpm
118 # (+ the src.rpm itself)
119 for i in `grep '^file:' $pkg.src.rpm.info`; do
120 arch=`echo $i|cut -d: -f 2`
121 file=`echo $i|cut -d: -f 3`
122 rm $rmopt "$FTP_DIR/$1/$arch/RPMS/$file"
124 # And finally remove the .info file
125 rm $rmopt $pkg.src.rpm.info