mirror of the now-defunct rocklinux.org
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.

132 lines
3.1 KiB

  1. #!/bin/bash
  2. PATH="${PATH/:$INSTALL_WRAPPER_MYPATH:/:}"
  3. PATH="${PATH#$INSTALL_WRAPPER_MYPATH:}"
  4. PATH="${PATH%:$INSTALL_WRAPPER_MYPATH}"
  5. filter="${INSTALL_WRAPPER_FILTER:+|} $INSTALL_WRAPPER_FILTER"
  6. if [ "$INSTALL_WRAPPER_NOLOOP" = 1 ]; then
  7. echo "--"
  8. echo "Found loop in install_wrapper: $0 $*" >&2
  9. echo "INSTALL_WRAPPER_MYPATH=$INSTALL_WRAPPER_MYPATH"
  10. echo "PATH=$PATH"
  11. echo "--"
  12. exit 1
  13. fi
  14. export INSTALL_WRAPPER_NOLOOP=1
  15. logfile="${INSTALL_WRAPPER_LOGFILE:-/dev/null}"
  16. [ -z "${logfile##*/*}" -a ! -d "${logfile%/*}" ] && logfile=/dev/null
  17. command="${0##*/}"
  18. error=0
  19. echo "" >> $logfile
  20. echo "$PWD:" >> $logfile
  21. echo "* ${INSTALL_WRAPPER_FILTER:-No Filter.}" >> $logfile
  22. echo "- $command $*" >> $logfile
  23. case "$command" in
  24. chmod|chown)
  25. declare -a newparams
  26. newparams[0]="$command"
  27. actually_got_file_params=0
  28. newparams_c=0
  29. for p; do
  30. case "$p" in
  31. -*) newparams[newparams_c++]="$p" ;;
  32. *) f="$( eval "echo \"$p\" | tr -s '/' $filter" )"
  33. if [ -n "$f" ]; then
  34. newparams[newparams_c++]="$f"
  35. if [ -f "$f" -o -z "${f##*/*}" ]; then
  36. actually_got_file_params=1
  37. fi
  38. fi ;;
  39. esac
  40. done
  41. if [ $actually_got_file_params = 1 ]; then
  42. echo "+ $command ${newparams[*]}" >> $logfile
  43. $command "${newparams[@]}" || error=$?
  44. fi
  45. echo "===> Returncode: $error" >> $logfile
  46. exit $error
  47. ;;
  48. esac
  49. destination=""
  50. declare -a sources
  51. newcommand="$command"
  52. sources_counter=0
  53. if [ "${*/--target-directory//}" != "$*" ]; then
  54. echo "= $command $*" >> $logfile
  55. $command "$@"; exit $?
  56. fi
  57. while [ $# -gt 0 ]; do
  58. # Ignore any verbose option
  59. if [ "${1:0:1}" == "-" -a "${1:0:2}" != "--" ]; then
  60. if [ "$1" == "-v" ]; then shift; continue; fi
  61. param="${1//v/}"
  62. else
  63. param="$1"
  64. fi
  65. case "$param" in
  66. --verbose)
  67. ;;
  68. -g|-m|-o|-S|--group|--mode|--owner|--suffix)
  69. newcommand="$newcommand $param $2"
  70. shift 1
  71. ;;
  72. -s|--strip)
  73. if [ "$ROCKCFG_DEBUG" = 0 -a "$STRIP" = "strip" ] || [[ $command != *install ]]
  74. then
  75. newcommand="$newcommand $param"
  76. fi
  77. ;;
  78. -*)
  79. newcommand="$newcommand $param"
  80. ;;
  81. *)
  82. if [ -n "$destination" ]; then
  83. sources[sources_counter++]="$destination"
  84. fi
  85. destination="$param"
  86. ;;
  87. esac
  88. shift 1
  89. done
  90. unset param
  91. [ -z "${destination##/*}" ] || destination="$PWD/$destination"
  92. if [ "$filter" != " " ]; then
  93. destination="$( eval "echo \"$destination\" | tr -s '/' $filter" )"
  94. fi
  95. if [ -z "$destination" ]; then
  96. : do nothing
  97. elif [ $sources_counter -eq 0 ]; then
  98. echo "+ $newcommand $destination" >> $logfile
  99. $newcommand "$destination" || error=$?
  100. elif [ -d "$destination" ]; then
  101. for source in "${sources[@]}"; do
  102. thisdest="${destination}"
  103. [ ! -d "${source//\/\///}" ] && thisdest="$thisdest/${source##*/}"
  104. thisdest="${thisdest//\/\///}"
  105. [ "$filter" != " " ] && thisdest="$( eval "echo \"$thisdest\" $filter" )"
  106. if [ ! -z "$thisdest" ]; then
  107. echo "+ $newcommand $source $thisdest" >> $logfile
  108. $newcommand "$source" "$thisdest" || error=$?
  109. fi
  110. done
  111. else
  112. echo "+ $newcommand ${sources[*]} $destination" >> $logfile
  113. $newcommand "${sources[@]}" "$destination" || error=$?
  114. fi
  115. echo "===> Returncode: $error" >> $logfile
  116. exit $error