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.

151 lines
3.2 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 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. EOT
  29. }
  30. shortopts='c:Ans'
  31. longopts='help,cfg:,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_any=
  40. reschedule_soft=
  41. reschedule_dry=
  42. reschedule_configs=
  43. while [ $# -gt 0 ]; do
  44. case "$1" in
  45. --help)
  46. reschedule_usage
  47. exit 0 ;;
  48. --any|-A) reschedule_any=yes ;;
  49. --soft|-s) reschedule_soft=yes ;;
  50. --dry-run|-n) reschedule_dry=yes ;;
  51. --cfg|-c) reschedule_configs="$reschedule_configs $2"
  52. shift ;;
  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. reschedule_dependers()
  61. {
  62. local config="$1" pattern= sandbox=
  63. local x= y=
  64. shift
  65. if [ $# -eq 0 ]; then
  66. return
  67. elif [ $# -eq 1 ]; then
  68. pattern="$1"
  69. else
  70. pattern="$*"
  71. pattern="\(${pattern// /\|}\)"
  72. fi
  73. sandbox="$SDEROOT/build/$( config_id "$config" )"
  74. pattern="^\[DEP\].* $pattern\( .*\)\?$"
  75. if config_iscross "$config"; then
  76. ls -1 "$sandbox/var/adm/packages"/* 2> /dev/null | sed -e 's|.*/||' |
  77. while read x; do
  78. y=$( package_confdir "$x" )
  79. if [ -s "$y/$x.cache" ]; then
  80. if grep -q "$pattern" "$y/$x.cache"; then
  81. echo $x
  82. fi
  83. fi
  84. done
  85. else
  86. grep -l "$pattern" "$sandbox/var/adm/cache"/* 2> /dev/null |
  87. sed -e 's|.*/||'
  88. fi
  89. }
  90. # which configs?
  91. #
  92. if [ "$reschedule_any" = "yes" ]; then
  93. reschedule_configs=$( config_list )
  94. [ -n "$reschedule_configs" ] || echo_abort 1 "No config found."
  95. elif [ -z "$reschedule_configs" ]; then
  96. # try default
  97. y="$( config_id default )"
  98. if [ -z "$y" ]; then
  99. echo_abort 1 "No config found."
  100. elif [ -d "$SDEROOT/build/$y/" ]; then
  101. reschedule_configs=default
  102. fi
  103. fi
  104. [ -n "$reschedule_configs" ] || exit 0
  105. y=
  106. for x; do
  107. if package_exists "$x"; then
  108. y="$y $x"
  109. else
  110. echo_warning "$x: Invalid package"
  111. fi
  112. done
  113. set -- $y
  114. [ $# -gt 0 ] || exit 0
  115. for x in $reschedule_configs; do
  116. y=$( reschedule_dependers "$x" "$@" )
  117. if [ -n "$y" ]; then
  118. "$SDEROOT/bin/sde-reschedule-package" \
  119. ${reschedule_dry:+--dry-run} \
  120. ${reschedule_soft:+--soft} \
  121. -c "$x" $y
  122. fi
  123. done