summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAndrew Cady <d@cryptonomic.net>2020-10-30 13:45:21 -0400
committerAndrew Cady <d@cryptonomic.net>2020-10-30 13:45:21 -0400
commit9931fd97d5f7dc6210a22ec0b7cc66fb56d1d17a (patch)
tree031c24424a0dd9527d33244a6f7412f68f625322 /src
parent2b2060df3cc0460128774b2c167c06f562cf77e2 (diff)
"make usb" target
Diffstat (limited to 'src')
-rwxr-xr-xsrc/parted-usb.sh81
1 files changed, 58 insertions, 23 deletions
diff --git a/src/parted-usb.sh b/src/parted-usb.sh
index fff003c..af56c8c 100755
--- a/src/parted-usb.sh
+++ b/src/parted-usb.sh
@@ -234,6 +234,38 @@ boot_vm()
234 -drive file="$installer_target",format=raw 234 -drive file="$installer_target",format=raw
235} 235}
236 236
237do_build()
238{
239 if [ -b "$target" ]
240 then
241 globalize
242 individualize
243 release_target_block_devices
244 elif [ -f "$target" -o ! -e "$target" ]
245 then
246 template=${target%.img}.template.img
247 final=$target
248 (
249 target=$target.tmp
250 if [ ! -e "$template" ]
251 then
252 target="$template".tmp globalize
253 release_target_block_devices
254 mv -T "$template".tmp "$template"
255 fi
256
257 cp -T --reflink=always "$template" "$target"
258 acquire_target_block_devices
259 individualize
260 release_target_block_devices
261
262 mv -T "$target" "$final"
263 )
264 else
265 die "Target must be a file or block device."
266 fi
267}
268
237. samizdat-paths.sh || die 'samizdat-paths.sh not found' 269. samizdat-paths.sh || die 'samizdat-paths.sh not found'
238samizdat_linux_dir=/ 270samizdat_linux_dir=/
239 271
@@ -270,33 +302,36 @@ fi
270sanity_checks 302sanity_checks
271set -e 303set -e
272 304
273if [ "$1" = boot ] 305if [ "$1" = -n ]
274then
275 boot_vm boot-disk.img
276elif [ "$1" ]
277then 306then
278 [ -b "$1" ] || die "Not a block device: $1" 307 shift
279 target=$1 308 DO_BUILD=
280 globalize
281 individualize
282 release_target_block_devices
283else 309else
284 template=boot-disk.template.img 310 DO_BUILD=y
285 if [ ! -e "$template" ] 311fi
312
313default_target=boot-disk.img
314
315if [ "$1" ]
316then
317
318 if [ "$1" = USB ]
286 then 319 then
287 target="$template".tmp globalize 320 target=$(./src/usb.sh) || exit 1
288 release_target_block_devices 321 elif [ -f "$1" ]
289 mv -T "$template".tmp "$template" 322 then
323 case "$1" in
324 *.img) ;;
325 *) die "Invalid image filename. Use *.img";;
326 esac
290 fi 327 fi
328 target=$1
329else
330 target=$default_target
331fi
291 332
292 target=boot-disk.img.tmp 333if [ "$DO_BUILD" ]
293 cp -T --reflink=always "$template" "$target" 334then
294 acquire_target_block_devices 335 do_build
295 individualize
296 release_target_block_devices
297
298 final=${target%.tmp}
299 mv -T "$target" "$final"
300 target=$final
301fi 336fi
302boot_vm "$target" 337boot_vm "$target"