OpenSDE Framework (without history before r20070)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

159 lines
3.6 KiB

  1. #!/bin/sh
  2. # --- SDE-COPYRIGHT-NOTE-BEGIN ---
  3. # This copyright note is auto-generated by ./scripts/Create-CopyPatch.
  4. #
  5. # Filename: bin/sde-reschedule-new
  6. # Copyright (C) 2008 The OpenSDE Project
  7. #
  8. # More information can be found in the files COPYING and README.
  9. #
  10. # This program is free software; you can redistribute it and/or modify
  11. # it under the terms of the GNU General Public License as published by
  12. # the Free Software Foundation; version 2 of the License. A copy of the
  13. # GNU General Public License can be found in the file COPYING.
  14. # --- SDE-COPYRIGHT-NOTE-END ---
  15. #Description: Reschedule updated packages from the builds
  16. [ -n "$SDEROOT" ] ||
  17. export SDEROOT=$( cd "${0%/*}/.."; pwd -P )
  18. . "$SDEROOT/lib/libsde.in"
  19. reschedule_usage() {
  20. local progname=${0##*/}
  21. cat <<EOT
  22. Usage: ${progname//-/ } [<options>] <config_1> ...
  23. Supported Options:
  24. --deps|-D every package depending on the others
  25. --any|-A process any available config
  26. --dry-run|-n don't really reschedule
  27. --soft|-s don't remove the packages when rescheduling
  28. EOT
  29. }
  30. shortopts='DAns'
  31. longopts='help,deps,any,soft,dry-run'
  32. options=$( getopt -o "$shortopts" -l "$longopts" -- "$@" )
  33. if [ $? -ne 0 ]; then
  34. reschedule_usage
  35. exit -1
  36. fi
  37. # load new arguments list
  38. eval set -- "$options"
  39. reschedule_dependers=
  40. reschedule_any=
  41. reschedule_soft=
  42. reschedule_dry=
  43. reschedule_configs=
  44. while [ $# -gt 0 ]; do
  45. case "$1" in
  46. --help)
  47. reschedule_usage
  48. exit 0 ;;
  49. --deps|-D) reschedule_dependers=yes ;;
  50. --any|-A) reschedule_any=yes ;;
  51. --soft|-s) reschedule_soft=yes ;;
  52. --dry-run|-n) reschedule_dry=yes ;;
  53. --) shift; break ;;
  54. *) echo_abort 1 "$1: Unknown argument, aborting."
  55. esac
  56. shift
  57. done
  58. . "$SDEROOT/lib/sde-config.in"
  59. . "$SDEROOT/lib/sde-package.in"
  60. # receives a list of sandboxes, and returns a list of unique packages involved
  61. reschedule_packages_list()
  62. {
  63. local x=
  64. for x; do
  65. ( cd "$SDEROOT/$x/var/adm/packages" &&
  66. ls -1d * ) 2> /dev/null
  67. done | sort -u
  68. }
  69. # compares the package's chksum on a given config/sandbox to the current
  70. # and reschedule if it's different
  71. #
  72. reschedule_new()
  73. {
  74. local pkg="$1" cksum1="$2" cksum2= config="$3" sandbox="$4"
  75. local pkgfile="$SDEROOT/$sandbox/var/adm/packages/$pkg"
  76. if [ -s "$pkgfile" ]; then
  77. cksum2=$( grep -R '^\(ROCK Linux\|T2\|OpenSDE\) Package Source Checksum: ' \
  78. "$pkgfile" | cut -d: -f2 )
  79. if [ " $cksum1" != "$cksum2" ]; then
  80. "$SDEROOT/bin/sde-reschedule-package" \
  81. ${reschedule_dry:+--dry-run} \
  82. ${reschedule_soft:+--soft} \
  83. ${reschedule_dependers:+--deps} \
  84. -c "$config" "$pkg"
  85. fi
  86. fi
  87. }
  88. # which configs?
  89. #
  90. if [ "$reschedule_any" = "yes" ]; then
  91. reschedule_configs=$( config_list )
  92. [ -n "$reschedule_configs" ] || echo_abort 1 "No config found."
  93. elif [ $# -eq 0 ]; then
  94. # try default
  95. y="$( config_id default )"
  96. if [ -z "$y" ]; then
  97. echo_abort 1 "No config found."
  98. elif [ -d "$SDEROOT/build/$y/" ]; then
  99. reschedule_configs=default
  100. else
  101. exit 0
  102. fi
  103. else
  104. for x; do
  105. y=$( config_id "$x" )
  106. if [ -z "$y" ]; then
  107. echo_warning "$x: Invalid config."
  108. elif [ -d "$SDEROOT/build/$y/" ]; then
  109. reschedule_configs="$reschedule_configs $x"
  110. fi
  111. done
  112. fi
  113. [ -n "$reschedule_configs" ] || exit 0
  114. tuples=
  115. sandboxes=
  116. for x in $reschedule_configs; do
  117. y=$( config_id "$x" )
  118. if [ -z "$y" ]; then
  119. echo_warning "$x: Broken config."
  120. elif [ -d "$SDEROOT/build/$y/" ]; then
  121. tuples="$tuples $x:build/$y"
  122. sandboxes="$sandboxes build/$y"
  123. fi
  124. done
  125. for pkg in $( reschedule_packages_list $sandboxes ); do
  126. cksum=$( sh "$SDEROOT/lib/sde-package/pkgchksum.sh" \
  127. `package_confdir $pkg` )
  128. for x in $tuples; do
  129. ( reschedule_new $pkg $cksum ${x/:/ } ) &
  130. done
  131. wait
  132. done