From 94413eb36fb609eab7873f97926c3ee5c634ea8e Mon Sep 17 00:00:00 2001 From: Colin Guthrie Date: Tue, 29 Jul 2014 01:33:36 +0100 Subject: move: Rename mga-move-update to mga-move-pkg The -update suffix was no longer relevant since support for other subsections than 'updates' was added. Also install it :) --- Makefile | 1 + mga-move-pkg | 200 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ mga-move-update | 200 -------------------------------------------------------- 3 files changed, 201 insertions(+), 200 deletions(-) create mode 100755 mga-move-pkg delete mode 100755 mga-move-update diff --git a/Makefile b/Makefile index 8a0953f..2a44b07 100644 --- a/Makefile +++ b/Makefile @@ -14,6 +14,7 @@ install: $(ALL) install mga-hdlists-cauldron $(DESTDIR)/usr/bin install mga-hdlists-updates $(DESTDIR)/usr/bin install mga-hdlists-backports $(DESTDIR)/usr/bin + install mga-move-pkg $(DESTDIR)/usr/bin install -d $(DESTDIR)/$(PERL_VENDORLIB)/MGATools for i in rpmsrate.pm iso.pm; do install pm/MGATools/$$i $(DESTDIR)/$(PERL_VENDORLIB)/MGATools/; done diff --git a/mga-move-pkg b/mga-move-pkg new file mode 100755 index 0000000..3bfcae3 --- /dev/null +++ b/mga-move-pkg @@ -0,0 +1,200 @@ +#!/bin/sh + +set -e + +. /usr/share/mgatools/functions + +if [ "$1" = "--dry-run" ]; then + dryrun=echo + shift +fi + +sync= +if [ "$1" = "--sync" ]; then + sync=yes + shift +fi + +noconfirm= +if [ "$1" = "--no-confirm" ]; then + noconfirm=yes + shift +fi + +backport= +if [ "$1" = "--backports" ]; then + shift + backport=$1 + shift +fi + +if [ $# != 3 ]; then + echo "Usage: $0 [--dry-run] [--sync] [--no-confirm] [--backport ]
" >&2 + exit 1 +fi + +valid_release "$1" +valid_section "$2" + +release="$1" +section="$2" +srcname="$3" + +exactsrpm= +sourcesubsection='updates_testing' +destinationsubsection='updates' +if [ 'cauldron' = "$release" ]; then + if [ -n "$backport" ]; then + echo "Error: Cannot use --backport with cauldron" >&2 + exit 1 + fi + destinationsubsection='release' +fi + +if [ -n "$backport" ]; then + sourcesubsection='backports_testing' + destinationsubsection='backports' +fi + +for file in "$distribdir/$release/SRPMS/$section/$sourcesubsection/"*.rpm; do + pkg=$(rpm -qp --qf '%{NAME}' "$file") + + # Check exact match + bfile=$(basename "$file") + if [ "$bfile" = "$srcname" ]; then + exactsrpm=y + srcname=$pkg + srcpkg=$bfile + break + fi + + # Check for src package name + if [ "$pkg" = "$srcname" ]; then + srcpkg=$bfile + break + fi +done + +if [ -z "$srcpkg" ]; then + echo "The package '$srcname' could not be found in the '$release/$section/$sourcesubsection' repository." >&2 + exit 2 +fi + +oldsrcpkg= +if [ 'release' = "$destinationsubsection" ]; then + # In cauldron we also have to move the old version from release to ~schedbot/old/ + # We know srcname is a %{name} now. + for file in "$distribdir/$release/SRPMS/$section/release/"*.rpm; do + pkg=$(rpm -qp --qf '%{NAME}' "$file") + if [ "$pkg" = "$srcname" ]; then + oldsrcpkg=$bfile + break + fi + done + + # (cg) Is this a valid check? What if it's a new package introduced first into testing + # Ultimately this is not very likely, so ignore it for now. + if [ -z "$oldsrcpkg" ]; then + echo "The package '$srcname' could not be found in the '$release/$section/$sourcesubsection' repository." >&2 + exit 2 + fi +fi + + +# Safety check +if [ -n "$exactsrpm" -a -z "$noconfirm" -o 'release' = "$destinationsubsection" ]; then + echo "This SRPM (and matching binaries) will be moved from '$sourcesubsection' to '$destinationsubsection':" + echo "- $srcpkg" + echo + if [ 'release' = "$destinationsubsection" ]; then + echo "This SRPM (and matching binaries) will be moved from 'release' to '\~schedbot/old':" + echo "- $oldsrcpkg" + echo + fi + + read -p "Are you sure? [Y/n] " yn + [ -z "$yn" ] yn=y + case $yn in + [Yy]*) continue;; + *) exit;; + esac +fi + +function movepkg() +{ + srcdir="$1" + destdir="$2" + srcpkg="$3" + content="$4" + commands="$5" + + for file in "$srcdir/"*.rpm; do + srpm=$(rpm -qp --qf '%{SOURCERPM}' "$file") + if [ "$srpm" = "$srcpkg" ]; then + echo " $(basename $file)" | tee -a "$content" + $dryrun mv -v -f "$file" "$destdir" >>"$commands" 2>&1 + fi + done +} + +mailcontent=$(mktemp) +mailcommands=$(mktemp) + +if [ 'release' = "$destinationsubsection" ]; then + echo "" + echo "Moving binary and source rpms:" | tee -a "$mailcontent" + for arch in $arches; do + echo "- $arch:" | tee -a "$mailcontent" + movepkg "$distribdir/$release/$arch/media/$section/release" "/var/lib/schedbot/old/" "$oldsrcpkg" "$mailcontent" "$mailcommands" + movepkg "$distribdir/$release/$arch/media/debug/$section/release" "/var/lib/schedbot/old/" "$oldsrcpkg" "$mailcontent" "$mailcommands" + done + echo "- source:" | tee -a "$mailcontent" + echo " $oldsrcpkg" | tee -a "$mailcontent" + echo >> "$mailcontent" + echo >> "$mailcontent" + $dryrun mv -v -f "$distribdir/$release/SRPMS/$section/release/$oldsrcpkg" "/var/lib/schedbot/old/" >>"$mailcommands" 2>&1 +fi + +echo "" +echo "Moving binary and source rpms:" | tee -a "$mailcontent" +for arch in $arches; do + echo "- $arch:" | tee -a "$mailcontent" + movepkg "$distribdir/$release/$arch/media/$section/$sourcesubsection" "$distribdir/$release/$arch/media/$section/$destinationsubsection/" "$srcpkg" "$mailcontent" "$mailcommands" + movepkg "$distribdir/$release/$arch/media/debug/$section/$sourcesubsection" "$distribdir/$release/$arch/media/debug/$section/$destinationsubsection/" "$srcpkg" "$mailcontent" "$mailcommands" +done +echo "- source:" | tee -a "$mailcontent" +echo " $srcpkg" | tee -a "$mailcontent" +echo >> "$mailcontent" +echo >> "$mailcontent" +$dryrun mv -v -f "$distribdir/$release/SRPMS/$section/$sourcesubsection/$srcpkg" "$distribdir/$release/SRPMS/$section/$destinationsubsection/" >>"$mailcommands" 2>&1 + +if [ -n "$dryrun" ]; then + cat "$mailcontent" "$mailcommands" +else + if [ -z "$sync" ]; then + echo >>"$mailcontent" + echo "Warning: hdlist update+sync was not performed during this move" >>"$mailcontent" + echo >>"$mailcontent" + echo >>"$mailcontent" + fi + + if [ -n "$backport" ]; then + export SIG="https://bugs.mageia.org/show_bug.cgi?id=$backport" + $dryrun mutt -e 'set from="Mageia Backports "' \ + -e 'set signature="echo $SIG|"' \ + -e 'set sig_dashes=no' \ + backports-announce@ml.mageia.org -s "Package Backport: MGA $release/$section: $srcname" \ + -i "$mailcontent" + fi + + cat "$mailcommands" >>"$mailcontent" + /usr/bin/mailx -s "$0 $release $section $srcname" -S "from=$moveupdate_mailfrom" "$moveupdate_mailto" < "$mailcontent" + + if [ -n "$sync" ]; then + update_distro_hdlist "$release" "$section" "$sourcesubsection" + update_distro_hdlist "$release" "$section" "$destinationsubsection" + update_common_MD5SUM "$release" + mirror_repository "$release" + fi +fi +rm -f "$mailcontent" "$mailcommands" diff --git a/mga-move-update b/mga-move-update deleted file mode 100755 index b8529c1..0000000 --- a/mga-move-update +++ /dev/null @@ -1,200 +0,0 @@ -#!/bin/sh - -set -e - -. /usr/share/mgatools/functions - -if [ "$1" = "--dry-run" ]; then - dryrun=echo - shift -fi - -sync= -if [ "$1" = "--sync" ]; then - sync=yes - shift -fi - -noconfirm= -if [ "$1" = "--no-confirm" ]; then - noconfirm=yes - shift -fi - -backport= -if [ "$1" = "--backports" ]; then - shift - backport=$1 - shift -fi - -if [ $# != 3 ]; then - echo "Usage: $0 [--dry-run] [--sync] [--no-confirm] [--backport ]
" >&2 - exit 1 -fi - -valid_release "$1" -valid_section "$2" - -release="$1" -section="$2" -srcname="$3" - -exactsrpm= -sourcesubsection='updates_testing' -destinationsubsection='updates' -if [ 'cauldron' = "$release" ]; then - if [ -n "$backport" ]; then - echo "Error: Cannot use --backport with cauldron" >&2 - exit 1 - fi - destinationsubsection='release' -fi - -if [ -n "$backport" ]; then - sourcesubsection='backports_testing' - destinationsubsection='backports' -fi - -for file in "$distribdir/$release/SRPMS/$section/$sourcesubsection/"*.rpm; do - pkg=$(rpm -qp --qf '%{NAME}' "$file") - - # Check exact match - bfile=$(basename "$file") - if [ "$bfile" = "$srcname" ]; then - exactsrpm=y - srcname=$pkg - srcpkg=$bfile - break - fi - - # Check for src package name - if [ "$pkg" = "$srcname" ]; then - srcpkg=$bfile - break - fi -done - -if [ -z "$srcpkg" ]; then - echo "The package '$srcname' could not be found in the '$release/$section/$sourcesubsection' repository." >&2 - exit 2 -fi - -oldsrcpkg= -if [ 'release' = "$destinationsubsection" ]; then - # In cauldron we also have to move the old version from release to ~schedbot/old/ - # We know srcname is a %{name} now. - for file in "$distribdir/$release/SRPMS/$section/release/"*.rpm; do - pkg=$(rpm -qp --qf '%{NAME}' "$file") - if [ "$pkg" = "$srcname" ]; then - oldsrcpkg=$bfile - break - fi - done - - # (cg) Is this a valid check? What if it's a new package introduced first into testing - # Ultimately this is not very likely, so ignore it for now. - if [ -z "$oldsrcpkg" ]; then - echo "The package '$srcname' could not be found in the '$release/$section/$sourcesubsection' repository." >&2 - exit 2 - fi -fi - - -# Safety check -if [ -n "$exactsrpm" -a -z "$noconfirm" -o 'release' = "$destinationsubsection" ]; then - echo "This SRPM (and matching binaries) will be moved from '$sourcesubsection' to '$destinationsubsection':" - echo "- $srcpkg" - echo - if [ 'release' = "$destinationsubsection" ]; then - echo "This SRPM (and matching binaries) will be moved from 'release' to '\~schedbot/old':" - echo "- $oldsrcpkg" - echo - fi - - read -p "Are you sure? [Y/n] " yn - [ -z "$yn" ] yn=y - case $yn in - [Yy]*) continue;; - *) exit;; - esac -fi - -function movepkg() -{ - srcdir="$1" - destdir="$2" - srcpkg="$3" - content="$4" - commands="$5" - - for file in "$srcdir/"*.rpm; do - srpm=$(rpm -qp --qf '%{SOURCERPM}' "$file") - if [ "$srpm" = "$srcpkg" ]; then - echo " $(basename $file)" | tee -a "$content" - $dryrun mv -v -f "$file" "$destdir" >>"$commands" 2>&1 - fi - done -} - -mailcontent=$(mktemp) -mailcommands=$(mktemp) - -if [ 'release' = "$destinationsubsection" ]; then - echo "" - echo "Moving binary and source rpms:" | tee -a "$mailcontent" - for arch in $arches; do - echo "- $arch:" | tee -a "$mailcontent" - movepkg "$distribdir/$release/$arch/media/$section/release" "/var/lib/schedbot/old/" "$oldsrcpkg" "$mailcontent" "$mailcommands" - movepkg "$distribdir/$release/$arch/media/debug/$section/release" "/var/lib/schedbot/old/" "$oldsrcpkg" "$mailcontent" "$mailcommands" - done - echo "- source:" | tee -a "$mailcontent" - echo " $oldsrcpkg" | tee -a "$mailcontent" - echo >> "$mailcontent" - echo >> "$mailcontent" - $dryrun mv -v -f "$distribdir/$release/SRPMS/$section/release/$oldsrcpkg" "/var/lib/schedbot/old/" >>"$mailcommands" 2>&1 -fi - -echo "" -echo "Moving binary and source rpms:" | tee -a "$mailcontent" -for arch in $arches; do - echo "- $arch:" | tee -a "$mailcontent" - movepkg "$distribdir/$release/$arch/media/$section/$sourcesubsection" "$distribdir/$release/$arch/media/$section/$destinationsubsection/" "$srcpkg" "$mailcontent" "$mailcommands" - movepkg "$distribdir/$release/$arch/media/debug/$section/$sourcesubsection" "$distribdir/$release/$arch/media/debug/$section/$destinationsubsection/" "$srcpkg" "$mailcontent" "$mailcommands" -done -echo "- source:" | tee -a "$mailcontent" -echo " $srcpkg" | tee -a "$mailcontent" -echo >> "$mailcontent" -echo >> "$mailcontent" -$dryrun mv -v -f "$distribdir/$release/SRPMS/$section/$sourcesubsection/$srcpkg" "$distribdir/$release/SRPMS/$section/$destinationsubsection/" >>"$mailcommands" 2>&1 - -if [ -n "$dryrun" ]; then - cat "$mailcontent" "$mailcommands" -else - if [ -z "$sync" ]; then - echo >>"$mailcontent" - echo "Warning: hdlist update+sync was not performed during this move" >>"$mailcontent" - echo >>"$mailcontent" - echo >>"$mailcontent" - fi - - if [ -n "$backport" ]; then - export SIG="https://bugs.mageia.org/show_bug.cgi?id=$backport" - $dryrun mutt -e 'set from="Mageia Backports "' \ - -e 'set signature="echo $SIG|"' \ - -e 'set sig_dashes=no' \ - backports-announce@ml.mageia.org -s "Package Backport: MGA $release/$section: $srcname" \ - -i "$mailcontent" - fi - - cat "$mailcommands" >>"$mailcontent" - /usr/bin/mailx -s "mga-move-update $release $section $srcname" -S "from=$moveupdate_mailfrom" "$moveupdate_mailto" < "$mailcontent" - - if [ -n "$sync" ]; then - update_distro_hdlist "$release" "$section" "$sourcesubsection" - update_distro_hdlist "$release" "$section" "$destinationsubsection" - update_common_MD5SUM "$release" - mirror_repository "$release" - fi -fi -rm -f "$mailcontent" "$mailcommands" -- cgit v1.2.1