summaryrefslogtreecommitdiff
path: root/src/xorriso-layer.sh
blob: 7ce4776a5aaf3b67dfc47b215d7fa986a03044c6 (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
31
32
33
34
35
36
37
38
#!/bin/bash

outdev=debian-live-8.4.0-amd64-standard.btrfs.layered.iso
indev=debian-live-8.4.0-amd64-standard.btrfs.iso
volid=SamizdatLive
btrfs_layer_iso_path=live/layer%s.btrfs
btrfs_layer_filesystem="$1"

die() { printf '%s\n' "$*"; exit 1; }

[ -f "$btrfs_layer_filesystem" ] || die "Usage: $0 <layer.btrfs> [layer2.btrfs ...]"

i=0
while [ $i -lt $# ]; do
    arg=$1
    [ $i -eq 0 ] && n='' || n=$((i + 1))
    arg=$(printf "${btrfs_layer_iso_path}=%s" "$n" "$arg")
    shift
    set -- "$@" "$arg"
    i=$((i + 1))
done

for arg; do echo "a=$arg"; done; exit;

set -ex

cp --reflink "$indev" "$outdev"~
time xorriso \
        -drive_class clear_list all \
        -outdev "$outdev"~ -indev "$outdev"~ \
        -report_about mishap \
        -volid "$volid" \
        -return_with sorry 0 \
        -pathspecs on -overwrite on \
        -add_plainly any \
        "$@"

mv -f "$outdev"~ "$outdev"