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.

183 lines
4.1 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-package
  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 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>] <package_1> ...
  23. Supported Options:
  24. --all|-a every package
  25. --new|-N every package updated since it was built
  26. --deps|-D every package depending on the others
  27. --cfg|-c <config> process a given config (multiple supported)
  28. --any|-A process any available config
  29. --dry-run|-n don't really reschedule
  30. --soft|-s don't remove the packages when rescheduling
  31. EOT
  32. }
  33. shortopts='aNDc:Ans'
  34. longopts='help,all,new,deps,cfg:,any,soft,dry-run'
  35. options=$( getopt -o "$shortopts" -l "$longopts" -- "$@" )
  36. if [ $? -ne 0 ]; then
  37. reschedule_usage
  38. exit -1
  39. fi
  40. # load new arguments list
  41. eval set -- "$options"
  42. reschedule_all=
  43. reschedule_new=
  44. reschedule_dependers=
  45. reschedule_any=
  46. reschedule_soft=
  47. reschedule_dry=
  48. reschedule_configs=
  49. while [ $# -gt 0 ]; do
  50. case "$1" in
  51. --help)
  52. reschedule_usage
  53. exit 0 ;;
  54. --all|-a) reschedule_all=yes ;;
  55. --new|-N) reschedule_new=yes ;;
  56. --deps|-D) reschedule_dependers=yes ;;
  57. --any|-A) reschedule_any=yes ;;
  58. --soft|-s) reschedule_soft=yes ;;
  59. --dry-run|-n) reschedule_dry=yes ;;
  60. --cfg|-c) reschedule_configs="$reschedule_configs $2"
  61. shift ;;
  62. --) shift; break ;;
  63. *) echo_abort 1 "$1: Unknown argument, aborting."
  64. esac
  65. shift
  66. done
  67. . "$SDEROOT/lib/sde-config.in"
  68. . "$SDEROOT/lib/sde-package.in"
  69. reschedule_package()
  70. {
  71. local config="$1" pkg= sandbox=
  72. shift
  73. [ $# -gt 0 ] || return
  74. sandbox="$SDEROOT/build/$( config_id "$config" )"
  75. for pkg; do
  76. [ -s "$sandbox/var/adm/packages/$pkg" ] || continue
  77. echo "$config: Removing $pkg..."
  78. if [ "$reschedule_dry" != "yes" ]; then
  79. if [ "$reschedule_soft" != "yes" ]; then
  80. mine -rf -R "$sandbox" "$pkg"
  81. fi
  82. rm -f "$sandbox/var/adm/logs"/?-$pkg.* 2> /dev/null
  83. fi
  84. done
  85. }
  86. # which configs?
  87. #
  88. if [ "$reschedule_any" = "yes" ]; then
  89. reschedule_configs=$( config_list )
  90. [ -n "$reschedule_configs" ] || echo_abort 1 "No config found."
  91. elif [ -z "$reschedule_configs" ]; then
  92. # try default
  93. y="$( config_id default )"
  94. if [ -z "$y" ]; then
  95. echo_abort 1 "No config found."
  96. elif [ -d "$SDEROOT/build/$y/" ]; then
  97. reschedule_configs=default
  98. else
  99. exit 0
  100. fi
  101. else
  102. z="$reschedule_configs"
  103. reschedule_configs=
  104. for x in $z; 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. # any config ?
  114. [ -n "$reschedule_configs" ] || exit 0
  115. if [ "$reschedule_all" = "yes" ]; then
  116. # every single package
  117. #
  118. for x in $reschedule_configs; do
  119. y="$SDEROOT/build/$( config_id $x )/var/adm/logs"
  120. reschedule_package "$x" $( ls -1d "$y"/* 2> /dev/null |
  121. sed -e 's|.*/.-\(.*\)\..*|\1|' )
  122. done
  123. exit $?
  124. elif [ -n "$reschedule_new" ]; then
  125. # every modified package
  126. #
  127. $SDEROOT/bin/sde-reschedule-new \
  128. ${reschedule_dry:+--dry-run} \
  129. ${reschedule_dependers:+--deps} \
  130. ${reschedule_soft:+--soft} \
  131. $reschedule_configs
  132. fi
  133. reschedule_packages=
  134. for x; do
  135. if package_exists "$x"; then
  136. reschedule_packages="$reschedule_packages $x"
  137. else
  138. echo_warning "$x: Invalid package"
  139. fi
  140. done
  141. [ $UID -eq 0 -o "$reschedule_dry" = "yes" ] ||
  142. echo_abort 1 "You have to be superuser to proceed, sorry."
  143. set -- $reschedule_packages
  144. for x in $reschedule_configs; do
  145. reschedule_package "$x" "$@"
  146. if [ "$reschedule_dependers" = "yes" ]; then
  147. $SDEROOT/bin/sde-reschedule-dependers \
  148. ${reschedule_dry:+--dry-run} \
  149. ${reschedule_soft:+--soft} \
  150. -c "$x" "$@"
  151. fi
  152. done