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.

137 lines
3.3 KiB

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