From d9149e9aa3631866cd72cc4769c3436ab0c7703c Mon Sep 17 00:00:00 2001 From: Alejandro Mery Date: Sat, 16 Aug 2008 23:22:20 +0000 Subject: [PATCH] bin/sde-reschedule-new: Implemented normal mode, soft and dry run. dependers and smarter config detection still missing --- bin/sde-reschedule-new | 67 +++++++++++++++++++++++++++++++++++++++++- 1 file changed, 66 insertions(+), 1 deletion(-) diff --git a/bin/sde-reschedule-new b/bin/sde-reschedule-new index c2f9c01..bf9b47b 100755 --- a/bin/sde-reschedule-new +++ b/bin/sde-reschedule-new @@ -71,6 +71,51 @@ while [ $# -gt 0 ]; do 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" + local dependers= x= + + if [ -s "$pkgfile" ]; then + cksum2=$( grep -R '^\(ROCK Linux\|T2\|OpenSDE\) Package Source Checksum: ' \ + "$pkgfile" | cut -d: -f2 ) + + if [ " $cksum1" != "$cksum2" ]; then + if [ "$reschedule_dependers" = "yes" ]; then + # TODO: Implement dependers detection + + dependers= + fi + + for x in $pkg $dependers; do + echo "$config: $x" + + if [ "$reschedule_dry" != "yes" ]; then + if [ "$reschedule_soft" != "yes" ]; then + mine -rf -R "$SDEROOT/$sandbox/" "$x" + fi + rm -f "$SDEROOT/$sandbox/var/adm"/*/?-$x.* 2> /dev/null + fi + done + fi + fi +} # which configs? # @@ -93,4 +138,24 @@ if [ -z "$reschedule_configs" ]; then done fi -echo_abort 2 'Not Implemented' +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 + cksum1=$( sh $SDEROOT/lib/sde-package/pkgchksum.sh \ + `package_confdir $pkg` ) + + for x in $tuples; do + ( reschedule_new $pkg $cksum1 ${x/:/ } ) & + done + wait +done