summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Makefile4
-rwxr-xr-xsrc/parted-usb.sh3
-rwxr-xr-xsrc/usb.sh39
3 files changed, 33 insertions, 13 deletions
diff --git a/Makefile b/Makefile
index 633dc1e..453b315 100644
--- a/Makefile
+++ b/Makefile
@@ -167,9 +167,11 @@ FORCE:
167$(btrfs_images): FORCE 167$(btrfs_images): FORCE
168 $(MAKE) -C rootfs $(notdir $@) 168 $(MAKE) -C rootfs $(notdir $@)
169 169
170.PHONY: usb 170.PHONY: usb key
171usb: rootfs 171usb: rootfs
172 sudo ROOTFS=rootfs/$(rootfs) ./src/parted-usb.sh USB 172 sudo ROOTFS=rootfs/$(rootfs) ./src/parted-usb.sh USB
173key:
174 sudo ROOTFS= ./src/parted-usb.sh USB
173 175
174boot: rootfs 176boot: rootfs
175 sudo ./src/mkinitramfs-samizdat 177 sudo ./src/mkinitramfs-samizdat
diff --git a/src/parted-usb.sh b/src/parted-usb.sh
index 1c0219d..1a7ec7a 100755
--- a/src/parted-usb.sh
+++ b/src/parted-usb.sh
@@ -316,7 +316,8 @@ if [ "$1" ]
316then 316then
317 if [ "$1" = USB ] 317 if [ "$1" = USB ]
318 then 318 then
319 target=$(./src/usb.sh) || exit 1 319 [ "$DO_BUILD" ] && arg= || arg=-n
320 target=$(./src/usb.sh $arg) || exit 1
320 elif [ -f "$1" ] 321 elif [ -f "$1" ]
321 then 322 then
322 case "$1" in 323 case "$1" in
diff --git a/src/usb.sh b/src/usb.sh
index 991f553..a8fd5fb 100755
--- a/src/usb.sh
+++ b/src/usb.sh
@@ -17,20 +17,34 @@ whole_device()
17 esac 17 esac
18} 18}
19 19
20confirm_usb() 20confirm_usb_strict()
21{ 21{
22 local msg="This will completely overwrite device:\n\n\t%s\n\nType 'yes' to confirm.\nContinue? " 22 CONFIRM_MSG="This will completely overwrite device:\n\n\t%s\n\nType 'yes' to confirm.\nContinue? "
23 PRINTF "$msg" "$1" 23 CONFIRM_WITH_ONE_LETTER=
24 confirm_helper "$@"
25}
26
27confirm_usb_lax()
28{
29 CONFIRM_MSG="The device used will be:\n\n\t%s\n\nType 'y' to confirm.\nContinue? "
30 CONFIRM_WITH_ONE_LETTER=y
31 confirm_helper "$@"
32}
33
34confirm_helper()
35{
36 PRINTF "$CONFIRM_MSG" "$1"
24 read line 37 read line
25 case "$line" in 38 case "$line" in
26 [yY][eE][sS]) return ;; 39 [yY][eE][sS]) return ;;
27 *) die "Aborted by user." ;; 40 [yY]) [ "$CONFIRM_WITH_ONE_LETTER" ] && return || : ;;
28 esac 41 esac
42 die "Aborted by user."
29} 43}
30 44
31choose_usb() 45choose_usb()
32{ 46{
33 local devs maj 47 local devs maj USB
34 set -- /dev/disk/by-id/usb* 48 set -- /dev/disk/by-id/usb*
35 for dev; do 49 for dev; do
36 shift 50 shift
@@ -40,7 +54,8 @@ choose_usb()
40 if [ $# = 0 ]; then 54 if [ $# = 0 ]; then
41 die "no usb device found" 55 die "no usb device found"
42 elif [ $# = 1 ]; then 56 elif [ $# = 1 ]; then
43 confirm_usb "$1" || die impossible 57 [ "$NO_ACT" ] && confirm=confirm_usb_lax || confirm=confirm_usb_strict
58 $confirm "$1" || exit
44 USB=$1 59 USB=$1
45 else 60 else
46 ECHO 61 ECHO
@@ -60,14 +75,16 @@ choose_usb()
60 ;; 75 ;;
61 *) die "Invalid argument: $line" ;; 76 *) die "Invalid argument: $line" ;;
62 esac 77 esac
78 confirm_usb_lax
63 fi 79 fi
80 [ "$USB" ] && readlink -f "$USB"
64} 81}
65 82
66choose_cdrom() 83NO_ACT=
67{ 84case "$1" in
68 die 'choose_cdrom: unimplemented; specify cdrom device with --out' 85 -n) NO_ACT=y;;
69} 86 -*) exit 1;;
87esac
70 88
71choose_usb 89choose_usb
72[ "$USB" ] && readlink -f "$USB"
73 90