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.

121 lines
2.9 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. case "$1" in
  59. -g|-m|-o|-S|--group|--mode|--owner|--suffix)
  60. newcommand="$newcommand $1 $2"
  61. shift 1
  62. ;;
  63. -s|--strip)
  64. if [ "$ROCKCFG_DEBUG" = 0 -a "$STRIP" = "strip" ] || [[ $command != *install ]]
  65. then
  66. newcommand="$newcommand $1"
  67. fi
  68. ;;
  69. -*)
  70. newcommand="$newcommand $1"
  71. ;;
  72. *)
  73. if [ -n "$destination" ]; then
  74. sources[sources_counter++]="$destination"
  75. fi
  76. destination="$1"
  77. ;;
  78. esac
  79. shift 1
  80. done
  81. [ -z "${destination##/*}" ] || destination="$PWD/$destination"
  82. if [ "$filter" != " " ]; then
  83. destination="$( eval "echo \"$destination\" | tr -s '/' $filter" )"
  84. fi
  85. if [ -z "$destination" ]; then
  86. : do nothing
  87. elif [ $sources_counter -eq 0 ]; then
  88. echo "+ $newcommand $destination" >> $logfile
  89. $newcommand "$destination" || error=$?
  90. elif [ -d "$destination" ]; then
  91. for source in "${sources[@]}"; do
  92. thisdest="${destination}"
  93. [ ! -d "${source//\/\///}" ] && thisdest="$thisdest/${source##*/}"
  94. thisdest="${thisdest//\/\///}"
  95. [ "$filter" != " " ] && thisdest="$( eval "echo \"$thisdest\" $filter" )"
  96. if [ ! -z "$thisdest" ]; then
  97. echo "+ $newcommand $source $thisdest" >> $logfile
  98. $newcommand "$source" "$thisdest" || error=$?
  99. fi
  100. done
  101. else
  102. echo "+ $newcommand ${sources[*]} $destination" >> $logfile
  103. $newcommand "${sources[@]}" "$destination" || error=$?
  104. fi
  105. echo "===> Returncode: $error" >> $logfile
  106. exit $error