summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/xorriso-usb.sh120
1 files changed, 73 insertions, 47 deletions
diff --git a/src/xorriso-usb.sh b/src/xorriso-usb.sh
index a42764b..0adbb70 100644
--- a/src/xorriso-usb.sh
+++ b/src/xorriso-usb.sh
@@ -80,6 +80,74 @@ try_mount()
80 mount -r "$1" /mnt && trap 'umount -l /mnt' EXIT 80 mount -r "$1" /mnt && trap 'umount -l /mnt' EXIT
81} 81}
82 82
83xorriso_cmd()
84{
85 # input variables:
86
87 # INPUT_DEVICE
88 # NEED_STDIO
89 # SILENT
90 # volid
91 # INPUT_DEVICE_COPIES
92 # REMOVE_BTRFS
93 # ADD_BTRFS
94 # vmlinuz_dir
95 # gpg_iso_path
96 # gnupghome
97 # efi_dir
98
99 # $@ = btrfs filesystems
100
101 ([ "$SHOW_CMD" ] && set -x;
102 ${NO_ACT:+ :} \
103 xorriso \
104 ${INPUT_DEVICE:+ -indev "$INPUT_DEVICE" } \
105 -outdev ${NEED_STDIO:+stdio:}"$outdev" \
106 -blank as_needed \
107 ${SILENT:+ -report_about mishap} \
108 -return_with sorry 0 \
109 -volid "$volid" \
110 -pathspecs on \
111 \
112 \
113 ${INPUT_DEVICE_COPIES} \
114 \
115 \
116 -rm_r linux -- -add linux="${vmlinuz_dir}" -- \
117 ${REMOVE_BTRFS:+ -rm_r rootfs -- } \
118 ${ADD_BTRFS:+ -follow link -add "$@" -- -follow default } \
119 \
120 \
121 -rm_r "${gpg_iso_path}" -- \
122 -add "${gpg_iso_path}=${gnupghome}" -- \
123 \
124 \
125 -chown_r 0 / -- \
126 -chgrp_r 0 / -- \
127 -chmod_r go-rwx "${gpg_iso_path}" -- \
128 \
129 \
130 -as mkisofs -graft-points \
131 -b grub/i386-pc/eltorito.img \
132 -no-emul-boot -boot-info-table \
133 --embedded-boot "${efi_dir}"/embedded.img \
134 --protective-msdos-label \
135 grub="${efi_dir}"/grub
136 )
137}
138
139run_xorriso()
140{
141 xorriso_cmd "$@" || die "xorriso exited $?"
142
143 case "$outdev" in
144 *~) [ -f "$outdev" ] && mv "$outdev" "${outdev%\~}" ;;
145 esac
146
147 if [ "$USB" -a "$DETACH" -a $? = 0 ]; then
148 udisks --detach "$outdev"
149 fi
150}
83 151
84. samizdat-paths.sh || exit 1 152. samizdat-paths.sh || exit 1
85 153
@@ -158,12 +226,12 @@ fi
158if [ "$INPUT_DEVICE" ]; then 226if [ "$INPUT_DEVICE" ]; then
159 if [ "$INPUT_DEVICE" = /dev/md55 ]; then 227 if [ "$INPUT_DEVICE" = /dev/md55 ]; then
160 if mountpoint -q /cdrom; then 228 if mountpoint -q /cdrom; then
161 XORRISO_IS_DRIVING_ME_INSANE='-add /=/cdrom --' 229 INPUT_DEVICE_COPIES='-add /=/cdrom --'
162 fi 230 fi
163 elif [ -d "$INPUT_DEVICE" ]; then 231 elif [ -d "$INPUT_DEVICE" ]; then
164 XORRISO_IS_DRIVING_ME_INSANE="-add /=$INPUT_DEVICE --" # TODO: escape 232 INPUT_DEVICE_COPIES="-add /=$INPUT_DEVICE --" # TODO: escape
165 elif try_mount "$INPUT_DEVICE"; then 233 elif try_mount "$INPUT_DEVICE"; then
166 XORRISO_IS_DRIVING_ME_INSANE='-add /=/mnt --' 234 INPUT_DEVICE_COPIES='-add /=/mnt --'
167 else 235 else
168 REPLACE_INITRD= 236 REPLACE_INITRD=
169 REMOVE_BTRFS= 237 REMOVE_BTRFS=
@@ -198,48 +266,6 @@ if [ "$REPLACE_INITRD" ]; then
198fi 266fi
199 267
200SILENT= 268SILENT=
269SHOW_CMD=y
201 270
202(set -x 271run_xorriso "$@"
203xorriso \
204 ${INPUT_DEVICE:+ -indev "$INPUT_DEVICE" } \
205 -outdev ${NEED_STDIO:+stdio:}"$outdev" \
206 -blank as_needed \
207 ${SILENT:+ -report_about mishap} \
208 -return_with sorry 0 \
209 -volid "$volid" \
210 -pathspecs on \
211 \
212 \
213 ${XORRISO_IS_DRIVING_ME_INSANE} \
214 \
215 \
216 -rm_r linux -- -add linux="${vmlinuz_dir}" -- \
217 ${REMOVE_BTRFS:+ -rm_r rootfs -- } \
218 ${ADD_BTRFS:+ -follow link -add "$@" -- -follow default } \
219 \
220 \
221 -rm_r "${gpg_iso_path}" -- \
222 -add "${gpg_iso_path}=${gnupghome}" -- \
223 \
224 \
225 -chown_r 0 / -- \
226 -chgrp_r 0 / -- \
227 -chmod_r go-rwx "${gpg_iso_path}" -- \
228 \
229 \
230 -as mkisofs -graft-points \
231 -b grub/i386-pc/eltorito.img \
232 -no-emul-boot -boot-info-table \
233 --embedded-boot "${efi_dir}"/embedded.img \
234 --protective-msdos-label \
235 grub="${efi_dir}"/grub
236
237) || die "xorriso exited $?"
238
239case "$outdev" in
240 *~) [ -f "$outdev" ] && mv "$outdev" "${outdev%\~}" ;;
241esac
242
243if [ "$USB" -a "$DETACH" -a $? = 0 ]; then
244 udisks --detach "$outdev"
245fi