summaryrefslogtreecommitdiff
path: root/bin/cpa
blob: 210019140409844be1b9548cdd0ed8c389eea181 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
#!/bin/sh -e

test "$#" -ge 3 || { echo "cpa: fatal: too few arguments" 1>&2 ; exit 100 ; }

output="$1"
source=$($output/build-build/command/s6-linkname -f -- $2)
dest="$3"


srcname=$(basename "$source")
destdir="$output"/$(dirname "$dest")
destname=$(basename "$dest")

{ cd $(dirname "$source") && tar c "$srcname" ; } | { cd "$destdir" && tar x ; }
if test "$srcname" != "$destname" ; then
  mv -f "$destdir/$srcname" "$destdir/$destname"
fi