|
#!/bin/bash
|
|
#
|
|
# PURPOSE:
|
|
#
|
|
# For all packages from comps files it retags from SOURCE to TARGET. It skips
|
|
# all packages starting with "foreman". Also, it understand special comment in
|
|
# comps-foreman-rhel6.xml and it is able to switch to nonscl tag when
|
|
# necessary.
|
|
#
|
|
# EXAMPLE:
|
|
#
|
|
# tag-latest-builds nightly 1.3
|
|
#
|
|
# REQUIREMENTS:
|
|
#
|
|
# - rpmdevtools
|
|
# - koji
|
|
# - and config for katello koji in ~/.koji/katello-config
|
|
#
|
|
|
|
SOURCE=${1:-nightly}
|
|
TARGET=${2:-1.3}
|
|
|
|
KJ="koji -c ~/.koji/katello-config"
|
|
for COMPS_FILE in comps-foreman-rhel*.xml comps-foreman-fedora*.xml; do
|
|
PLATFORM=$(echo $COMPS_FILE | sed 's/comps-foreman-\(.*\)\.xml/\1/')
|
|
SOURCE_TAG=foreman-$SOURCE-$PLATFORM
|
|
TARGET_TAG=foreman-$TARGET-$PLATFORM
|
|
echo -e "\nWorking $SOURCE_TAG -> $TARGET_TAG"
|
|
|
|
for PACKAGE in $(
|
|
cat $COMPS_FILE | awk '/packagereq/ { print $2 }' | sed 's/.*>\(.*\)<.*/\1/g'); do
|
|
|
|
# when special comment is found, switch over to nonscl mode
|
|
if [[ "$PACKAGE" == foreman-*-nonscl-rhel6 ]]; then
|
|
SOURCE_TAG="foreman-$SOURCE-nonscl-rhel6"
|
|
TARGET_TAG="foreman-$TARGET-nonscl-rhel6"
|
|
echo -e "\nWorking $SOURCE_TAG -> $TARGET_TAG"; continue
|
|
fi
|
|
# and skip other foreman packages
|
|
[[ "$PACKAGE" == foreman* ]] && continue
|
|
|
|
LATEST_BUILD=$($KJ latest-build --quiet $SOURCE_TAG $PACKAGE | awk '{ print $1 }')
|
|
|
|
# if there is no build then it is probably subpackage, just skip it, otherwise do:
|
|
if [ -n "$LATEST_BUILD" ]; then
|
|
TARGET_LATEST_BUILD=$($KJ latest-build --quiet $TARGET_TAG $PACKAGE | awk '{ print $1 }')
|
|
rpmdev-vercmp "$LATEST_BUILD" "$TARGET_LATEST_BUILD" >/dev/null
|
|
CMP_RESULT=$? # 11 is >, 12 is <, 0 is ==
|
|
if [ "$LATEST_BUILD" != "$TARGET_LATEST_BUILD" -a 0$CMP_RESULT -eq 11 ]; then
|
|
# uncomment to add package prior tagging (if you start from scratch)
|
|
#$KJ add-pkg --owner=lzapleta $TARGET_TAG $PACKAGE
|
|
echo Tagging $LATEST_BUILD into $TARGET_TAG
|
|
$KJ tag-build --nowait $TARGET_TAG $LATEST_BUILD >/dev/null
|
|
fi
|
|
# uncomment to remove old tags for $PACKAGE in $TARGET_TAG for clarity
|
|
#$KJ untag-build --non-latest $TARGET_TAG $PACKAGE >/dev/null
|
|
else
|
|
echo "No build of $PACKAGE found in $SOURCE_TAG"
|
|
fi
|
|
done
|
|
done
|