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.

87 lines
2.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. destination=""
  19. declare -a sources
  20. newcommand="$command"
  21. sources_counter=0
  22. error=0
  23. echo "" >> $logfile
  24. echo "$PWD:" >> $logfile
  25. echo "* ${INSTALL_WRAPPER_FILTER:-No Filter.}" >> $logfile
  26. echo "- $command $*" >> $logfile
  27. if [ "${*/--target-directory//}" != "$*" ]; then
  28. echo "= $command $*" >> $logfile
  29. $command "$@"; exit $?
  30. fi
  31. while [ $# -gt 0 ]; do
  32. case "$1" in
  33. -g|-m|-o|-S|--group|--mode|--owner|--suffix)
  34. newcommand="$newcommand $1 $2"
  35. shift 1
  36. ;;
  37. -*)
  38. newcommand="$newcommand $1"
  39. ;;
  40. *)
  41. if [ -n "$destination" ]; then
  42. sources[sources_counter++]="$destination"
  43. fi
  44. destination="$1"
  45. ;;
  46. esac
  47. shift 1
  48. done
  49. [ -z "${destination##/*}" ] || destination="$PWD/$destination"
  50. if [ "$filter" != " " ]; then
  51. destination="$( eval "echo \"$destination\" | tr -s '/' $filter" )"
  52. fi
  53. if [ -z "$destination" ]; then
  54. : do nothing
  55. elif [ $sources_counter -eq 0 ]; then
  56. echo "+ $newcommand $destination" >> $logfile
  57. $newcommand "$destination" || error=$?
  58. elif [ -d "$destination" ]; then
  59. for source in "${sources[@]}"; do
  60. thisdest="${destination}"
  61. [ ! -d "${source//\/\///}" ] && thisdest="$thisdest/${source##*/}"
  62. thisdest="${thisdest//\/\///}"
  63. [ "$filter" != " " ] && thisdest="$( eval "echo \"$thisdest\" $filter" )"
  64. if [ ! -z "$thisdest" ]; then
  65. echo "+ $newcommand $source $thisdest" >> $logfile
  66. $newcommand "$source" "$thisdest" || error=$?
  67. fi
  68. done
  69. else
  70. echo "+ $newcommand ${sources[*]} $destination" >> $logfile
  71. $newcommand "${sources[@]}" "$destination" || error=$?
  72. fi
  73. echo "===> Returncode: $error" >> $logfile
  74. exit $error