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.

161 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. local dependers= x=
  77. if [ -s "$pkgfile" ]; then
  78. cksum2=$( grep -R '^\(ROCK Linux\|T2\|OpenSDE\) Package Source Checksum: ' \
  79. "$pkgfile" | cut -d: -f2 )
  80. if [ " $cksum1" != "$cksum2" ]; then
  81. if [ "$reschedule_dependers" = "yes" ]; then
  82. # TODO: Implement dependers detection
  83. dependers=
  84. fi
  85. for x in $pkg $dependers; do
  86. echo "$config: $x"
  87. if [ "$reschedule_dry" != "yes" ]; then
  88. if [ "$reschedule_soft" != "yes" ]; then
  89. mine -rf -R "$SDEROOT/$sandbox/" "$x"
  90. fi
  91. rm -f "$SDEROOT/$sandbox/var/adm"/*/?-$x.* 2> /dev/null
  92. fi
  93. done
  94. fi
  95. fi
  96. }
  97. # which configs?
  98. #
  99. if [ -n "$reschedule_any" ]; then
  100. reschedule_configs=$( config_list )
  101. [ -n "$reschedule_configs" ] || echo_abort 1 "No config found."
  102. elif [ $# -eq 0 ]; then
  103. # try default
  104. set -- 'default'
  105. fi
  106. if [ -z "$reschedule_configs" ]; then
  107. for x; do
  108. if config_exists "$x"; then
  109. reschedule_configs="$reschedule_configs $x"
  110. else
  111. echo_warning "$x: Invalid config."
  112. fi
  113. done
  114. fi
  115. tuples=
  116. sandboxes=
  117. for x in $reschedule_configs; do
  118. y=$( config_id "$x" )
  119. if [ -z "$y" ]; then
  120. echo_warning "$x: Broken config."
  121. elif [ -d "$SDEROOT/build/$y/" ]; then
  122. tuples="$tuples $x:build/$y"
  123. sandboxes="$sandboxes build/$y"
  124. fi
  125. done
  126. for pkg in $( reschedule_packages_list $sandboxes ); do
  127. cksum1=$( sh $SDEROOT/lib/sde-package/pkgchksum.sh \
  128. `package_confdir $pkg` )
  129. for x in $tuples; do
  130. ( reschedule_new $pkg $cksum1 ${x/:/ } ) &
  131. done
  132. wait
  133. done