-# Note: all functions expect to get N-V-R strings as file arguments (unless
+# Note: all functions expect to get N-V-R strings as pkg arguments (unless
# it's obvious they shouldn't get them of course)
# Read config
echo `date "+%F %T"` "[$scriptname]" "--" "$@" >>~/pld-ftp-admin/log
}
+# Wrapper so that we can test stuff without actually doing (allmost) anything
if [ "$DEBUG" == "yes" ]; then
rm()
{
# Get just the name without the version tag
basename=`echo $1|sed -e 's,-[^-]*-[^-]*$,,'`
# Find packages beginning with that name
- allfiles=`echo $basename*`
- if [ "$allfiles" == "$basename*" ]; then
+ allpkgs=`echo $basename*`
+ if [ "$allpkgs" == "$basename*" ]; then
# No files found
return
fi
- allfiles=`echo "$allfiles"|sed -e 's, ,\n,g' -e 's,.src.rpm.info,,g'`
- # Filter out files that just begin with basename, but ain't other
+ allpkgs=`echo "$allpkgs"|sed -e 's, ,\n,g' -e 's,.src.rpm.info,,g'`
+ # Filter out pkgs that just begin with basename, but ain't other
# versions of that package
- allfiles=`echo "$allfiles"|grep "$basename-[^-]*-[^-]*$"`
- echo "$allfiles"
+ allpkgs=`echo "$allpkgs"|grep "$basename-[^-]*-[^-]*$"`
+ echo "$allpkgs"
}
# Generate a list of older packages
{
cd "$FTP_DIR/$1/SRPMS/.metadata/"
list=""
- for file in $2; do
- # "Glob" for other files
- allfiles=`glob_packages $file`
+ for pkg in $2; do
+ # "Glob" for other pkgs
+ allpkgs=`glob_packages $pkg`
# Get just the name without the version tag (we need it)
- basename=`echo $file|sed -e 's,-[^-]*-[^-]*$,,'`
+ basename=`echo $pkg|sed -e 's,-[^-]*-[^-]*$,,'`
# Get only versions
- allfiles=`echo "$allfiles"|sed -e "s,^$basename-,,"`
+ allpkgs=`echo "$allpkgs"|sed -e "s,^$basename-,,"`
# Sort (note - this ain't perfect sorting)
- allfiles=`echo "$allfiles"|sort -n`
+ allpkgs=`echo "$allpkgs"|sort -n`
# Readd names
- allfiles=`echo "$allfiles"|sed -e "s,^,$basename-,"`
+ allpkgs=`echo "$allpkgs"|sed -e "s,^,$basename-,"`
# Grep packages < current package
- allfiles=`echo "$allfiles"|grep -B 999 "$file"|grep -v "^$file$"`
+ allpkgs=`echo "$allpkgs"|grep -B 999 "$pkg"|grep -v "^$pkg$"`
# Add to the list
- allfiles=`echo $allfiles`
- list="$list $allfiles"
+ allpkgs=`echo $allpkgs`
+ list="$list $allpkgs"
done
echo $list
}
{
cd "$FTP_DIR/$1/SRPMS/.metadata/"
list=""
- for file in $2; do
- # "Glob" for other files
- allfiles=`glob_packages $file`
+ for pkg in $2; do
+ # "Glob" for other pkgs
+ allpkgs=`glob_packages $pkg`
# Cut out our own package
- allfiles=`echo "$allfiles"|grep -v "^$file$"`
+ allpkgs=`echo "$allpkgs"|grep -v "^$pkg$"`
# Add to the list
- allfiles=`echo $allfiles`
- list="$list $allfiles"
+ allpkgs=`echo $allpkgs`
+ list="$list $allpkgs"
done
echo $list
}
# Remove packages in given tree
# Args: $1 - ftp tree
-# $2 - list of packages (info files) to remove
+# $2 - list of packages to remove
# $3 - force option
remove_pkgs() {
cd "$FTP_DIR/$1/SRPMS/.metadata/"
if [ "$3" == "force" ]; then
rmopt="-f"
fi
- for srcfile in $2; do
+ for pkg in $2; do
# Remove all files connected to the old src.rpm
# (+ the src.rpm itself)
- for i in `grep '^file:' $srcfile.src.rpm.info`; do
+ for i in `grep '^file:' $pkg.src.rpm.info`; do
arch=`echo $i|cut -d: -f 2`
file=`echo $i|cut -d: -f 3`
rm $rmopt "$FTP_DIR/$1/$arch/RPMS/$file"
done
# And finally remove the .info file
- rm $rmopt $srcfile.src.rpm.info
+ rm $rmopt $pkg.src.rpm.info
done
}
exit
fi
-# we set $tree and $files
+# we set $tree and $pkglist
tree=$1
-files=""
+pkglist=""
waserror=0
shift 1
while test "$#" -gt "0"
do
- file=`echo $1|sed -e 's,.src.rpm$,,'`
- if [ ! -f "$FTP_DIR/$tree/SRPMS/.metadata/$file.src.rpm.info" ]; then
+ pkg=`echo $1|sed -e 's,.src.rpm$,,'`
+ if [ ! -f "$FTP_DIR/$tree/SRPMS/.metadata/$pkg.src.rpm.info" ]; then
waserror=$(($waserror+1))
- echo "$file was not found in source tree"
+ echo "$pkg was not found in source tree"
fi
- files="$files $file"
+ pkglist="$pkglist $pkg"
shift
done
if [ "$REMOVEOLDER" == "yes" ]; then
# Remove packages older than the ones we're removing
- olderpkgs=`find_older_pkgs "$tree" "$files"`
+ olderpkgs=`find_older_pkgs "$tree" "$pkglist"`
remove_pkgs "$tree" "$olderpkgs"
fi
# Remove given packages
-remove_pkgs "$tree" "$files"
+remove_pkgs "$tree" "$pkglist"