-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmake-system-root.sh
More file actions
executable file
·49 lines (39 loc) · 1.27 KB
/
make-system-root.sh
File metadata and controls
executable file
·49 lines (39 loc) · 1.27 KB
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
40
41
42
43
44
45
46
47
48
49
# Modified from: https://github.com/NixOS/nixpkgs/blob/5d20a2b99a586c6611b30b12a684df96f8f95c1c/nixos/lib/make-system-tarball.sh#L1
source $stdenv/setup
sources_=($sources)
targets_=($targets)
sources_nl_=($sources_nl)
targets_nl_=($targets_nl)
objects=($objects)
symlinks=($symlinks)
# Remove the initial slash from a path, since genisofs likes it that way.
stripSlash() {
res="$1"
if test "${res:0:1}" = /; then res=${res:1}; fi
}
# Add the individual files.
for ((i = 0; i < ${#targets_[@]}; i++)); do
stripSlash "${targets_[$i]}"
mkdir -p "$(dirname "$res")"
cp -a "${sources_[$i]}" "$res"
done
# Add the individual files (without following symlinks).
for ((i = 0; i < ${#targets_nl_[@]}; i++)); do
stripSlash "${targets_nl_[$i]}"
mkdir -p "$(dirname "$res")"
cp --dereference "${sources_nl_[$i]}" "$res"
done
# Add symlinks to the top-level store objects.
for ((n = 0; n < ${#objects[*]}; n++)); do
object=${objects[$n]}
symlink=${symlinks[$n]}
if test "$symlink" != "none"; then
mkdir -p "$(dirname -- ./"$symlink")"
ln -s "$object" ./"$symlink"
fi
done
mkdir -p proc sys dev sbin
ln -sf /nix/var/nix/profiles/system/init sbin/init
mkdir -p "$out"/root
cp -r --no-dereference ./* "$out"/root/
rm -f "$out"/root/env-vars