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.

93 lines
2.3 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. -s|--strip)
  38. if [ "$ROCKCFG_DEBUG" = 0 -a "$STRIP" = "strip" ] || [[ $command != *install ]]
  39. then
  40. newcommand="$newcommand $1"
  41. fi
  42. ;;
  43. -*)
  44. newcommand="$newcommand $1"
  45. ;;
  46. *)
  47. if [ -n "$destination" ]; then
  48. sources[sources_counter++]="$destination"
  49. fi
  50. destination="$1"
  51. ;;
  52. esac
  53. shift 1
  54. done
  55. [ -z "${destination##/*}" ] || destination="$PWD/$destination"
  56. if [ "$filter" != " " ]; then
  57. destination="$( eval "echo \"$destination\" | tr -s '/' $filter" )"
  58. fi
  59. if [ -z "$destination" ]; then
  60. : do nothing
  61. elif [ $sources_counter -eq 0 ]; then
  62. echo "+ $newcommand $destination" >> $logfile
  63. $newcommand "$destination" || error=$?
  64. elif [ -d "$destination" ]; then
  65. for source in "${sources[@]}"; do
  66. thisdest="${destination}"
  67. [ ! -d "${source//\/\///}" ] && thisdest="$thisdest/${source##*/}"
  68. thisdest="${thisdest//\/\///}"
  69. [ "$filter" != " " ] && thisdest="$( eval "echo \"$thisdest\" $filter" )"
  70. if [ ! -z "$thisdest" ]; then
  71. echo "+ $newcommand $source $thisdest" >> $logfile
  72. $newcommand "$source" "$thisdest" || error=$?
  73. fi
  74. done
  75. else
  76. echo "+ $newcommand ${sources[*]} $destination" >> $logfile
  77. $newcommand "${sources[@]}" "$destination" || error=$?
  78. fi
  79. echo "===> Returncode: $error" >> $logfile
  80. exit $error