diff options
author | Andrew Cady <d@jerkface.net> | 2016-04-29 23:09:57 -0400 |
---|---|---|
committer | Andrew Cady <d@jerkface.net> | 2016-04-29 23:09:57 -0400 |
commit | 12a53f4d71572d62a7c4fef197d2d77347911797 (patch) | |
tree | db0be3675e63c93d647c873ff4a76e09784c9826 | |
parent | 15189dabed41fb16c6f22336ff6003ed41321820 (diff) |
fix problems with xorriso-usb related to creating a grandchild
-rw-r--r-- | src/xorriso-usb.sh | 47 |
1 files changed, 38 insertions, 9 deletions
diff --git a/src/xorriso-usb.sh b/src/xorriso-usb.sh index 6cada5e..100288d 100644 --- a/src/xorriso-usb.sh +++ b/src/xorriso-usb.sh | |||
@@ -12,7 +12,7 @@ efi_dir=$samizdat_grub_efi_dir | |||
12 | 12 | ||
13 | die() { printf "%s: Error: %s\n" "$0" "$*" >&2; exit 1; } | 13 | die() { printf "%s: Error: %s\n" "$0" "$*" >&2; exit 1; } |
14 | 14 | ||
15 | TEMP="$(getopt -o '' --long adam,usb,detach,out:,test -n "$0" -- "$@")" || | 15 | TEMP="$(getopt -o '' --long adam,usb,detach,in:,out:,test -n "$0" -- "$@")" || |
16 | die 'getopt error' | 16 | die 'getopt error' |
17 | eval set -- "$TEMP" | 17 | eval set -- "$TEMP" |
18 | 18 | ||
@@ -24,13 +24,18 @@ while [ $# -gt 0 ]; do | |||
24 | --detach) shift; DETACH=y;; | 24 | --detach) shift; DETACH=y;; |
25 | --test) shift; QUICK_TEST=y;; | 25 | --test) shift; QUICK_TEST=y;; |
26 | --out) CMDLINE_OUTDEV="$2"; shift 2;; | 26 | --out) CMDLINE_OUTDEV="$2"; shift 2;; |
27 | --in) INPUT_DEVICE="$2"; shift 2;; | ||
27 | --) shift; break;; | 28 | --) shift; break;; |
28 | *) die 'getopt error';; | 29 | *) die 'getopt error';; |
29 | esac | 30 | esac |
30 | done | 31 | done |
31 | 32 | ||
32 | if [ $# = 0 ]; then | 33 | if [ -z "$INPUT_DEVICE" -a $# = 0 ]; then |
33 | set -- debian-live-8.4.0-amd64-standard.btrfs layer.btrfs | 34 | if [ -e debian-live-8.4.0-amd64-standard.btrfs -a -e layer.btrfs ]; then |
35 | set -- debian-live-8.4.0-amd64-standard.btrfs layer.btrfs | ||
36 | else | ||
37 | die "no input device and no input btrfs layers: aborting." | ||
38 | fi | ||
34 | fi | 39 | fi |
35 | 40 | ||
36 | for fs; do | 41 | for fs; do |
@@ -125,10 +130,28 @@ choose_outdev | |||
125 | 130 | ||
126 | generate_keys | 131 | generate_keys |
127 | 132 | ||
133 | try_mount() | ||
134 | { | ||
135 | # TODO: don't use /mnt | ||
136 | # Ofc the real solution is to get help with xorriso. | ||
137 | NEED_UNMOUNT="$1" | ||
138 | mount -r "$1" /mnt && trap 'umount -l /mnt' EXIT | ||
139 | } | ||
140 | |||
128 | if [ "$INPUT_DEVICE" ]; then | 141 | if [ "$INPUT_DEVICE" ]; then |
129 | REPLACE_INITRD= | 142 | if [ "$INPUT_DEVICE" = /dev/md55 ]; then |
130 | REMOVE_BTRFS= | 143 | if mountpoint -q /cdrom; then |
131 | ADD_BTRFS= | 144 | XORRISO_IS_DRIVING_ME_INSANE='-add /=/cdrom --' |
145 | fi | ||
146 | elif [ -d "$INPUT_DEVICE" ]; then | ||
147 | XORRISO_IS_DRIVING_ME_INSANE="-add /=$INPUT_DEVICE --" # TODO: escape | ||
148 | elif try_mount "$INPUT_DEVICE"; then | ||
149 | XORRISO_IS_DRIVING_ME_INSANE='-add /=/mnt --' | ||
150 | else | ||
151 | REPLACE_INITRD= | ||
152 | REMOVE_BTRFS= | ||
153 | ADD_BTRFS= | ||
154 | fi | ||
132 | else | 155 | else |
133 | REPLACE_INITRD=y | 156 | REPLACE_INITRD=y |
134 | REMOVE_BTRFS=y | 157 | REMOVE_BTRFS=y |
@@ -144,19 +167,24 @@ if [ "$REPLACE_INITRD" ]; then | |||
144 | initrd.sh || die 'initrd.sh failed' | 167 | initrd.sh || die 'initrd.sh failed' |
145 | fi | 168 | fi |
146 | 169 | ||
170 | SILENT= | ||
171 | |||
147 | (set -x | 172 | (set -x |
148 | xorriso \ | 173 | xorriso \ |
149 | ${INPUT_DEVICE:+ -indev "$INPUT_DEVICE" } \ | 174 | ${disable____INPUT_DEVICE:+ -indev "$INPUT_DEVICE" } \ |
150 | -outdev ${NEED_STDIO:+stdio:}"$outdev" \ | 175 | -outdev ${NEED_STDIO:+stdio:}"$outdev" \ |
151 | -blank as_needed \ | 176 | -blank as_needed \ |
152 | -report_about mishap \ | 177 | ${SILENT:+ -report_about mishap} \ |
153 | -return_with sorry 0 \ | 178 | -return_with sorry 0 \ |
154 | -volid "$volid" \ | 179 | -volid "$volid" \ |
155 | -pathspecs on \ | 180 | -pathspecs on \ |
156 | \ | 181 | \ |
157 | \ | 182 | \ |
183 | ${XORRISO_IS_DRIVING_ME_INSANE} \ | ||
184 | \ | ||
185 | \ | ||
158 | ${REPLACE_INITRD:+ -rm_r linux -- -add linux="${vmlinuz_dir}" -- } \ | 186 | ${REPLACE_INITRD:+ -rm_r linux -- -add linux="${vmlinuz_dir}" -- } \ |
159 | ${REMOVE_BTRFS:+ -rm_r btrfs -- } \ | 187 | ${REMOVE_BTRFS:+ -rm_r rootfs -- } \ |
160 | ${ADD_BTRFS:+ -follow link -add "$@" -- -follow default } \ | 188 | ${ADD_BTRFS:+ -follow link -add "$@" -- -follow default } \ |
161 | \ | 189 | \ |
162 | \ | 190 | \ |
@@ -175,6 +203,7 @@ xorriso \ | |||
175 | --embedded-boot "${efi_dir}"/embedded.img \ | 203 | --embedded-boot "${efi_dir}"/embedded.img \ |
176 | --protective-msdos-label \ | 204 | --protective-msdos-label \ |
177 | grub="${efi_dir}"/grub | 205 | grub="${efi_dir}"/grub |
206 | |||
178 | ) || die "xorriso exited $?" | 207 | ) || die "xorriso exited $?" |
179 | 208 | ||
180 | case "$outdev" in | 209 | case "$outdev" in |