-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathunpack
executable file
·39 lines (30 loc) · 874 Bytes
/
unpack
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
31
32
33
34
35
36
37
38
39
#!/usr/bin/env bash
err() {
echo $* >&2
}
abs() {
echo "$(cd "$(dirname "$1")"; pwd)/$(basename "$1")"
}
if test $# -ne 3
then
err "usage: $0 <target path> <tarball file> <dependencies file>"
exit 1
fi
targetPath=$(abs $1)
tarball=$(abs $2)
dependencies=$(abs $3)
fromPrefix=/nix/store
nixrewrite=$(pwd)/nixrewrite
if test ${#targetPath} -gt ${#fromPrefix}
then
err "error: the new prefix must have at most the same length as \"$fromPrefix\"."
exit 1
fi
############ TAR (doesn't work)
# mkdir -p $targetPath
# ./nixrewrite $fromPrefix $targetPath $dependencies < $tarball | tar -xC $targetPath
############ CPIO
mkdir -p $targetPath
(cd $targetPath && $nixrewrite $fromPrefix $targetPath $dependencies < $tarball | cpio -id)
############ NAR
# ./nixrewrite $fromPrefix $targetPath $dependencies < $tarball | nix-store --restore $targetPath