summaryrefslogtreecommitdiff
path: root/xorriso.sh
blob: 784f2efae11088b9ad45c3a8c2b8ff1c8c68a232 (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
39
40
41
42
43
44
45
#!/bin/sh

outdev=debian-live-8.4.0-amd64-standard.btrfs.iso
indev=debian-live-8.4.0-amd64-standard.iso
volid=SamizdatLive
squashfs_iso_path=live/filesystem.squashfs
btrfs_iso_path=live/filesystem.btrfs
btrfs_filesystem=debian-live-8.4.0-amd64-standard.btrfs
gpg_iso_path=samizdat/gpg/gnupghome
gnupghome=gnupghome
secrets=secrets

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

make_gnupghome()
{
  [ -d "$gnupghome" ] && return
  local reset=$-
  set -e
  [ ! -d "$gnupghome".tmp ] || die "Error: refusing to overwrite $gnupghome.tmp"
  [ ! -d "$secrets".tmp   ] || die "Error: refusing to overwrite $secrets.tmp"
  mkdir -p "$gnupghome".tmp "$secrets".tmp
  local PATH="$HOME"/src/samizdat/src:"$PATH" NO_USE_RAMFS=y
  NEW_GNUPGHOME="$gnupghome".tmp SECRETS_DIRECTORY="$secrets".tmp ~/src/samizdat/src/samizdat-make-key --adam
  mv "$secrets".tmp "$secrets"
  mv "$gnupghome".tmp "$gnupghome"
  set -$reset
}

make_gnupghome

set -ex

xorriso \
        -drive_class clear_list all \
        -outdev "$outdev"~ -indev "$indev" \
        -report_about mishap \
        -volid "$volid" \
        -return_with sorry 0 \
        -pathspecs on -overwrite on \
        -rm "$squashfs_iso_path" -- \
        -add_plainly any \
        "${btrfs_iso_path}=${btrfs_filesystem}" \
        "${gpg_iso_path}=${gnupghome}"
mv -f "$outdev"~ "$outdev"