|
|
#!/bin/sh # --- SDE-COPYRIGHT-NOTE-BEGIN --- # This copyright note is auto-generated by ./scripts/Create-CopyPatch. # # Filename: bin/sde-reschedule-new # Copyright (C) 2008 The OpenSDE Project # # More information can be found in the files COPYING and README. # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; version 2 of the License. A copy of the # GNU General Public License can be found in the file COPYING. # --- SDE-COPYRIGHT-NOTE-END ---
#Description: Reschedule updated packages from the builds
[ -n "$SDEROOT" ] || export SDEROOT=$( cd "${0%/*}/.."; pwd -P )
. "$SDEROOT/lib/libsde.in"
reschedule_usage() { local progname=${0##*/} cat <<EOT Usage: ${progname//-/ } [<options>] <config_1> ...
Supported Options: --deps|-D every package depending on the others
--any|-A process any available config
--dry-run|-n don't really reschedule --soft|-s don't remove the packages when rescheduling EOT }
shortopts='DAns' longopts='help,deps,any,soft,dry-run' options=$( getopt -o "$shortopts" -l "$longopts" -- "$@" ) if [ $? -ne 0 ]; then reschedule_usage exit -1 fi
# load new arguments list eval set -- "$options"
reschedule_dependers= reschedule_any= reschedule_soft= reschedule_dry=
reschedule_configs=
while [ $# -gt 0 ]; do case "$1" in --help) reschedule_usage exit 0 ;;
--deps|-D) reschedule_dependers=yes ;; --any|-A) reschedule_any=yes ;; --soft|-s) reschedule_soft=yes ;; --dry-run|-n) reschedule_dry=yes ;;
--) shift; break ;; *) echo_abort 1 "$1: Unknown argument, aborting." esac shift done
. "$SDEROOT/lib/sde-config.in" . "$SDEROOT/lib/sde-package.in"
# receives a list of sandboxes, and returns a list of unique packages involved reschedule_packages_list() { local x= for x; do ( cd "$SDEROOT/$x/var/adm/packages" && ls -1d * ) 2> /dev/null done | sort -u }
# compares the package's chksum on a given config/sandbox to the current # and reschedule if it's different # reschedule_new() { local pkg="$1" cksum1="$2" cksum2= config="$3" sandbox="$4" local pkgfile="$SDEROOT/$sandbox/var/adm/packages/$pkg"
if [ -s "$pkgfile" ]; then cksum2=$( grep -R '^\(ROCK Linux\|T2\|OpenSDE\) Package Source Checksum: ' \ "$pkgfile" | cut -d: -f2 )
if [ " $cksum1" != "$cksum2" ]; then "$SDEROOT/bin/sde-reschedule-package" \ ${reschedule_dry:+--dry-run} \ ${reschedule_soft:+--soft} \ ${reschedule_dependers:+--deps} \ -c "$config" "$pkg" fi fi }
# which configs? # if [ "$reschedule_any" = "yes" ]; then reschedule_configs=$( config_list )
[ -n "$reschedule_configs" ] || echo_abort 1 "No config found." elif [ $# -eq 0 ]; then # try default
y="$( config_id default )"
if [ -z "$y" ]; then echo_abort 1 "No config found." elif [ -d "$SDEROOT/build/$y/" ]; then reschedule_configs=default else exit 0 fi else for x; do y=$( config_id "$x" ) if [ -z "$y" ]; then echo_warning "$x: Invalid config." elif [ -d "$SDEROOT/build/$y/" ]; then reschedule_configs="$reschedule_configs $x" fi done fi
[ -n "$reschedule_configs" ] || exit 0
tuples= sandboxes= for x in $reschedule_configs; do y=$( config_id "$x" ) if [ -z "$y" ]; then echo_warning "$x: Broken config." elif [ -d "$SDEROOT/build/$y/" ]; then tuples="$tuples $x:build/$y" sandboxes="$sandboxes build/$y" fi done
for pkg in $( reschedule_packages_list $sandboxes ); do cksum=$( sh "$SDEROOT/lib/sde-package/pkgchksum.sh" \ `package_confdir $pkg` )
for x in $tuples; do ( reschedule_new $pkg $cksum ${x/:/ } ) & done wait done
|