-#!/bin/sh -eu
+#!/bin/sh
+set -eu
unitdir="$1"
target="$2"
case "$target" in
*/?*) # a path, but not just a slash at the end
- dir="${DESTDIR}${target}"
+ dir="${DESTDIR:-}${target}"
;;
*)
- dir="${DESTDIR}${unitdir}/${target}"
+ dir="${DESTDIR:-}${unitdir}/${target}"
;;
esac
-unitpath="${DESTDIR}${unitdir}/${unit}"
+unitpath="${DESTDIR:-}${unitdir}/${unit}"
case "$target" in
*/)
- mkdir -p -m 0755 "$dir"
+ mkdir -vp -m 0755 "$dir"
;;
*)
- mkdir -p -m 0755 "$(basename "$dir")"
+ mkdir -vp -m 0755 "$(dirname "$dir")"
;;
esac