summaryrefslogtreecommitdiffstats
path: root/mga-move-pkg
diff options
context:
space:
mode:
authorColin Guthrie <colin@mageia.org>2014-07-29 01:33:36 +0100
committerColin Guthrie <colin@mageia.org>2014-07-29 01:42:38 +0100
commit94413eb36fb609eab7873f97926c3ee5c634ea8e (patch)
treeed64acd82f0d77b6a5ee532aa7ea7af690978700 /mga-move-pkg
parenta6432c73f660cfa196fa4ad061f789a93cd81bf4 (diff)
downloadmgatools-94413eb36fb609eab7873f97926c3ee5c634ea8e.tar
mgatools-94413eb36fb609eab7873f97926c3ee5c634ea8e.tar.gz
mgatools-94413eb36fb609eab7873f97926c3ee5c634ea8e.tar.bz2
mgatools-94413eb36fb609eab7873f97926c3ee5c634ea8e.tar.xz
mgatools-94413eb36fb609eab7873f97926c3ee5c634ea8e.zip
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 :)
Diffstat (limited to 'mga-move-pkg')
-rwxr-xr-xmga-move-pkg200
1 files changed, 200 insertions, 0 deletions
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 <bug>] <release> <section> <src-rpm-name>" >&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 <buildsystem-daemon@mageia.org>"' \
+ -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"