From c9d648bea36c2c13a9be55dabf1b83bdaba106f4 Mon Sep 17 00:00:00 2001 From: Mariusz Mazur Date: Tue, 21 Sep 2004 22:30:51 +0000 Subject: [PATCH] - support for 'updating' archs in a given tree; meaning I can build a package for eg. athlon and ppc, move it to main tree, then build it for athlon, ppc and amd64 and moving the newer package to main tree will result in only amd64 being really moved, and rest of the archs getting discarded (removed) (of course we're talking about same NVR for both the newer and older package sets) - to make a long story short - I can start building th for those archs I have builders for and update ftp with new arch once amd64 builder becomes available (and I plan to do so as soon as I finish these scripts) Changed files: bin/functions -> 1.3 bin/move.sh -> 1.8 --- bin/functions | 15 +++++++++++---- bin/move.sh | 45 +++++++++++++++++++++++++++++++-------------- 2 files changed, 42 insertions(+), 18 deletions(-) diff --git a/bin/functions b/bin/functions index cfc3eb6..53badf7 100644 --- a/bin/functions +++ b/bin/functions @@ -83,16 +83,18 @@ find_older_pkgs() echo $list } -# Generate a list of all packages +# Generate a list of all packages (glob name-*) except the one given # Args: $1 - ftp tree # $2 - packages we're interested in -find_all_pkgs() +find_other_pkgs() { cd "$FTP_DIR/$1/SRPMS/.metadata/" list="" for file in $2; do # "Glob" for other files allfiles=`glob_packages $file` + # Cut out our own package + allfiles=`echo "$allfiles"|grep -v "^$file$"` # Add to the list allfiles=`echo $allfiles` list="$list $allfiles" @@ -103,18 +105,23 @@ find_all_pkgs() # Remove packages in given tree # Args: $1 - ftp tree # $2 - list of packages (info files) to remove +# $3 - force option remove_pkgs() { cd "$FTP_DIR/$1/SRPMS/.metadata/" + rmopt="" + if [ "$3" == "force" ]; then + rmopt="-f" + fi for srcfile 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 arch=`echo $i|cut -d: -f 2` file=`echo $i|cut -d: -f 3` - rm "$FTP_DIR/$1/$arch/RPMS/$file" + rm $rmopt "$FTP_DIR/$1/$arch/RPMS/$file" done # And finally remove the .info file - rm $srcfile.src.rpm.info + rm $rmopt $srcfile.src.rpm.info done } diff --git a/bin/move.sh b/bin/move.sh index 5698f4f..7baf4fd 100755 --- a/bin/move.sh +++ b/bin/move.sh @@ -33,10 +33,6 @@ do waserror=$(($waserror+1)) echo "$file was not found in source tree" fi - if [ -f "$FTP_DIR/$to/SRPMS/.metadata/$file.src.rpm.info" ]; then - waserror=$(($waserror+1)) - echo "$file is already present in destination tree" - fi files="$files $file" shift done @@ -51,19 +47,40 @@ olderpkgs=`find_older_pkgs "$from" "$files"` remove_pkgs "$from" "$olderpkgs" # Remove old packages in destination tree -olderpkgs=`find_all_pkgs "$to" "$files"` +olderpkgs=`find_other_pkgs "$to" "$files"` remove_pkgs "$to" "$olderpkgs" # Move the new packages cd "$FTP_DIR/$from/SRPMS/.metadata/" -for srcfile in $files; do - # Move the rpms - for i in `grep '^file:' "$srcfile.src.rpm.info"`; do - arch=`echo $i|cut -d: -f 2` - file=`echo $i|cut -d: -f 3` - mv "$FTP_DIR/$from/$arch/RPMS/$file" "$FTP_DIR/$to/$arch/RPMS/" - done - # And move the .info file - mv "$srcfile.src.rpm.info" "$FTP_DIR/$to/SRPMS/.metadata/" +for pkg in $files; do + # First we check if the package is already there + dstinfo="$FTP_DIR/$to/SRPMS/.metadata/$pkg.src.rpm.info" + if [ -f "$dstinfo" ]; then + archs=`grep '^file:' "$pkg.src.rpm.info"|cut -d: -f 2|sort|uniq` + for arch in $archs; do + if [ -n "`grep ^file:$arch: $dstinfo`" ]; then + # This arch is already in dest tree + echo "Arch $arch for package $pkg is already present in tree $to; removing from $from" + continue + fi + # Add missing archs + for i in `grep "^file:$arch:" "$pkg.src.rpm.info"|cut -d: -f 3`; do + mv "$FTP_DIR/$from/$arch/RPMS/$i" "$FTP_DIR/$to/$arch/RPMS/" + echo "file:$arch:$i" >>$dstinfo + done + # Remove the 'old' package; we use 'force' option to ommit + # errors that would show up for already moved rpms + remove_pkgs "$from" "$pkg" "force" + done + else + # No previous file found; just move the rpms + for i in `grep '^file:' "$pkg.src.rpm.info"`; do + arch=`echo $i|cut -d: -f 2` + file=`echo $i|cut -d: -f 3` + mv "$FTP_DIR/$from/$arch/RPMS/$file" "$FTP_DIR/$to/$arch/RPMS/" + done + # And move the .info file + mv "$pkg.src.rpm.info" "$FTP_DIR/$to/SRPMS/.metadata/" + fi done -- 2.44.0