summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xmga-move-update149
1 files changed, 91 insertions, 58 deletions
diff --git a/mga-move-update b/mga-move-update
index d9bf11a..cd9138a 100755
--- a/mga-move-update
+++ b/mga-move-update
@@ -1,91 +1,124 @@
#!/bin/sh
+set -e
+
. /usr/share/mgatools/functions
-if [ $# != 3 ]
-then
- echo 'Usage: mga-move-update distrorelease section srcname' >&2
- exit 1
+if [ "$1" = "--dry-run" ]; then
+ dryrun=echo
+ shift
fi
-distrorelease="$1"
-section="$2"
-srcname="$3"
+nosync=
+if [ "$1" = "--no-sync" ]; then
+ nosync=yes
+ shift
+fi
-if ! inlist "$distrorelease" "$distroreleases"
-then
- echo "Incorrect distrorelease $distrorelease" >&2
- exit 1
+noconfirm=
+if [ "$1" = "--no-confirm" ]; then
+ noconfirm=yes
+ shift
fi
-if ! inlist "$section" "$distrosections"
-then
- echo "Incorrect section $section" >&2
+if [ $# != 3 ]; then
+ echo "Usage: $0 [--dry-run] [--no-sync] [--no-confirm] <release> <section> <src-rpm-name>" >&2
exit 1
fi
-for file in "$distribdir/$distrorelease/SRPMS/$section/updates_testing/"*.rpm
-do
+valid_release "$1"
+valid_section "$2"
+
+release="$1"
+section="$2"
+srcname="$3"
+
+for file in "$distribdir/$release/SRPMS/$section/updates_testing/"*.rpm; do
+ # Check exact match
+ bfile=$(basename "$file")
+ if [ "$bfile" = "$srcname" ]; then
+ srcpkg=$bfile
+ break
+ fi
+
+ # Check for src package name
fname=$(rpm -qp --qf '%{NAME}' "$file")
- if [ a"$fname" = a"$srcname" ]
- then
- srcpkg=$(basename "$file")
- break
+ if [ "$fname" = "$srcname" ]; then
+ srcpkg=$bfile
+ break
fi
done
-if [ -z $srcpkg ]
-then
- echo "The package $srcname could not be found in $distrorelease/$section/updates_testing repository." >&2
+if [ -z "$srcpkg" ]; then
+ echo "The package '$srcname' could not be found in the '$release/$section/updates_testing' repository." >&2
exit 2
fi
+# Safety check
+if [ "$srcname" != "$srcpkg" -a -z "$noconfirm" ]; then
+ echo "This SRPM (and matching binaries) will be moved from 'updates_testing' to 'updates':"
+ echo
+ echo " $srcpkg"
+ echo
+
+ 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"
- output="$4"
-
- for file in "$srcdir/"*.rpm
- do
- fname=$(rpm -qp --qf '%{SOURCERPM}' "$file")
- if [ a"$fname" = a"$srcpkg" ]
- then
- $dryrun mv -v -f "$file" "$destdir" >> "$output"
- fi
- done
-}
+ content="$4"
+ commands="$5"
-function post()
-{
- for arch in $arches
- do
- update_hdlist "$distribdir/$distrorelease/$arch/media/$section/updates_testing"
- update_hdlist "$distribdir/$distrorelease/$arch/media/$section/updates"
- update_hdlist "$distribdir/$distrorelease/$arch/media/debug/$section/updates_testing"
- update_hdlist "$distribdir/$distrorelease/$arch/media/debug/$section/updates"
+ for file in "$srcdir/"*.rpm; do
+ fname=$(rpm -qp --qf '%{SOURCERPM}' "$file")
+ if [ "$fname" = "$srcpkg" ]; then
+ echo " $(basename $file)" | tee -a "$content"
+ $dryrun mv -v -f "$file" "$destdir" >>"$commands" 2>&1
+ fi
done
- update_hdlist "$distribdir/$distrorelease/SRPMS/$section/updates_testing"
- update_hdlist "$distribdir/$distrorelease/SRPMS/$section/updates"
- update_common_MD5SUM $distrorelease
- mirror_repository $distrorelease
}
mailcontent=$(mktemp)
-for arch in $arches
-do
- movepkg "$distribdir/$distrorelease/$arch/media/$section/updates_testing" "$distribdir/$distrorelease/$arch/media/$section/updates/" "$srcpkg" "$mailcontent"
- movepkg "$distribdir/$distrorelease/$arch/media/debug/$section/updates_testing" "$distribdir/$distrorelease/$arch/media/debug/$section/updates/" "$srcpkg" "$mailcontent"
+mailcommands=$(mktemp)
+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/updates_testing" "$distribdir/$release/$arch/media/$section/updates/" "$srcpkg" "$mailcontent" "$mailcommands"
+ movepkg "$distribdir/$release/$arch/media/debug/$section/updates_testing" "$distribdir/$release/$arch/media/debug/$section/updates/" "$srcpkg" "$mailcontent" "$mailcommands"
done
-$dryrun mv -v -f "$distribdir/$distrorelease/SRPMS/$section/updates_testing/$srcpkg" "$distribdir/$distrorelease/SRPMS/$section/updates/" >> "$output"
+echo "- source:" | tee -a "$mailcontent"
+echo " $srcpkg" | tee -a "$mailcontent"
+echo >> "$mailcontent"
+echo >> "$mailcontent"
+$dryrun mv -v -f "$distribdir/$release/SRPMS/$section/updates_testing/$srcpkg" "$distribdir/$release/SRPMS/$section/updates/" >>"$mailcommands" 2>&1
-if [ -n "$dryrun" ]
-then
- cat "$mailcontent"
+if [ -n "$dryrun" ]; then
+ cat "$mailcontent" "$mailcommands"
else
- /usr/bin/mailx -s "mga-move-update $distrorelease $section $srcname" -S "from=$moveupdate_mailfrom" "$moveupdate_mailto" < "$mailcontent"
- post
-fi
-rm -f "$mailcontent"
+ if [ -n "$nosync" ]; then
+ echo >>"$mailcontent"
+ echo "Warning: hdlist update+sync was not performed during this move" >>"$mailcontent"
+ echo >>"$mailcontent"
+ echo >>"$mailcontent"
+ fi
+ cat "$mailcommands" >>"$mailcontent"
+
+ /usr/bin/mailx -s "mga-move-update $release $section $srcname" -S "from=$moveupdate_mailfrom" "$moveupdate_mailto" < "$mailcontent"
+ if [ -z "$nosync" ]; then
+ update_distro_hdlist "$release" "$section" "updates_testing"
+ update_distro_hdlist "$release" "$section" "updates"
+ update_common_MD5SUM "$release"
+ mirror_repository "$release"
+ fi
+fi
+rm -f "$mailcontent" "$mailcommands"