summaryrefslogtreecommitdiffstats
path: root/data/meson-add-wants.sh
blob: c33d1b4ffcbef8035a8294cd8c301abad5bd097b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#!/bin/sh
set -eu

# Script copied from systemd

unitdir="$1"
target="$2"
unit="$3"

case "$target" in
    */?*) # a path, but not just a slash at the end
        dir="${DESTDIR:-}${target}"
        ;;
    *)
        dir="${DESTDIR:-}${unitdir}/${target}"
        ;;
esac

unitpath="${DESTDIR:-}${unitdir}/${unit}"

case "$target" in
    */)
        mkdir -vp -m 0755 "$dir"
        ;;
    *)
        mkdir -vp -m 0755 "$(dirname "$dir")"
        ;;
esac

ln -vfs --relative "$unitpath" "$dir"