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.

155 lines
3.3 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-dependers
  6. # Copyright (C) 2008 - 2009 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 which depend on those given
  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. --cfg|-c <config> process a given config (multiple supported)
  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. -t use theoric dependers (from .cache at \$confdir)
  29. EOT
  30. }
  31. shortopts='c:Asnt'
  32. longopts='help,cfg:,any,soft,dry-run'
  33. options=$( getopt -o "$shortopts" -l "$longopts" -- "$@" )
  34. if [ $? -ne 0 ]; then
  35. reschedule_usage
  36. exit -1
  37. fi
  38. # load new arguments list
  39. eval set -- "$options"
  40. reschedule_any=
  41. reschedule_soft=
  42. reschedule_dry=
  43. reschedule_theoric=
  44. reschedule_configs=
  45. while [ $# -gt 0 ]; do
  46. case "$1" in
  47. --help)
  48. reschedule_usage
  49. exit 0 ;;
  50. --any|-A) reschedule_any=yes ;;
  51. --soft|-s) reschedule_soft=yes ;;
  52. --dry-run|-n) reschedule_dry=yes ;;
  53. -t) reschedule_theoric=yes ;;
  54. --cfg|-c) reschedule_configs="$reschedule_configs $2"
  55. shift ;;
  56. --) shift; break ;;
  57. *) echo_abort 1 "$1: Unknown argument, aborting."
  58. esac
  59. shift
  60. done
  61. . "$SDEROOT/lib/sde-config.in"
  62. . "$SDEROOT/lib/sde-package.in"
  63. reschedule_dependers()
  64. {
  65. local config="$1" pattern= sandbox=
  66. local x= y=
  67. shift
  68. if [ $# -eq 0 ]; then
  69. return
  70. elif [ $# -eq 1 ]; then
  71. pattern="$1"
  72. else
  73. pattern="$*"
  74. pattern="\(${pattern// /\|}\)"
  75. fi
  76. sandbox="$SDEROOT/build/$( config_id "$config" )"
  77. pattern="^\[DEP\].* $pattern\( .*\)\?$"
  78. if config_iscross "$config" || [ "$reschedule_theoric" = "yes" ]; then
  79. (cd "$sandbox/var/adm/packages" && ls -1 .) |
  80. while read x; do
  81. y=$( package_confdir "$x" )
  82. if [ -s "$y/$x.cache" ]; then
  83. if grep -q "$pattern" "$y/$x.cache"; then
  84. echo $x
  85. fi
  86. fi
  87. done
  88. else
  89. (cd "$sandbox/var/adm/cache" && grep -l "$pattern" *)
  90. fi 2> /dev/null
  91. }
  92. # which configs?
  93. #
  94. if [ "$reschedule_any" = "yes" ]; then
  95. reschedule_configs=$( config_list )
  96. [ -n "$reschedule_configs" ] || echo_abort 1 "No config found."
  97. elif [ -z "$reschedule_configs" ]; then
  98. # try default
  99. y="$( config_id default )"
  100. if [ -z "$y" ]; then
  101. echo_abort 1 "No config found."
  102. elif [ -d "$SDEROOT/build/$y/" ]; then
  103. reschedule_configs=default
  104. fi
  105. fi
  106. [ -n "$reschedule_configs" ] || exit 0
  107. y=
  108. for x; do
  109. if package_exists "$x"; then
  110. y="$y $x"
  111. else
  112. echo_warning "$x: Invalid package"
  113. fi
  114. done
  115. set -- $y
  116. [ $# -gt 0 ] || exit 0
  117. for x in $reschedule_configs; do
  118. y=$( reschedule_dependers "$x" "$@" )
  119. if [ -n "$y" ]; then
  120. "$SDEROOT/bin/sde-reschedule-package" \
  121. ${reschedule_dry:+--dry-run} \
  122. ${reschedule_soft:+--soft} \
  123. -c "$x" $y
  124. fi
  125. done