Browse code

Fix expect script in mkimage-arch

Docker-DCO-1.1-Signed-off-by: Zoltan Tombol <zoltan.tombol@gmail.com> (github: ztombol)

Zoltan Tombol authored on 2014/07/10 00:38:13
Showing 1 changed files
... ...
@@ -5,13 +5,13 @@
5 5
 set -e
6 6
 
7 7
 hash pacstrap &>/dev/null || {
8
-    echo "Could not find pacstrap. Run pacman -S arch-install-scripts"
9
-    exit 1
8
+	echo "Could not find pacstrap. Run pacman -S arch-install-scripts"
9
+	exit 1
10 10
 }
11 11
 
12 12
 hash expect &>/dev/null || {
13
-    echo "Could not find expect. Run pacman -S expect"
14
-    exit 1
13
+	echo "Could not find expect. Run pacman -S expect"
14
+	exit 1
15 15
 }
16 16
 
17 17
 ROOTFS=$(mktemp -d ${TMPDIR:-/var/tmp}/rootfs-archlinux-XXXXXXXXXX)
... ...
@@ -21,18 +21,19 @@ chmod 755 $ROOTFS
21 21
 PKGIGNORE=linux,jfsutils,lvm2,cryptsetup,groff,man-db,man-pages,mdadm,pciutils,pcmciautils,reiserfsprogs,s-nail,xfsprogs
22 22
 
23 23
 expect <<EOF
24
-  set timeout 60
25
-  set send_slow {1 1}
26
-  spawn pacstrap -C ./mkimage-arch-pacman.conf -c -d -G -i $ROOTFS base haveged --ignore $PKGIGNORE
27
-  expect {
28
-    "Install anyway?" { send n\r; exp_continue }
29
-    "(default=all)" { send \r; exp_continue }
30
-    "Proceed with installation?" { send "\r"; exp_continue }
31
-    "skip the above package" {send "y\r"; exp_continue }
32
-    "checking" { exp_continue }
33
-    "loading" { exp_continue }
34
-    "installing" { exp_continue }
35
-  }
24
+	set send_slow {1 .1}
25
+	proc send {ignore arg} {
26
+		sleep .1
27
+		exp_send -s -- \$arg
28
+	}
29
+	set timeout 60
30
+
31
+	spawn pacstrap -C ./mkimage-arch-pacman.conf -c -d -G -i $ROOTFS base haveged --ignore $PKGIGNORE
32
+	expect {
33
+		-exact "anyway? \[Y/n\] " { send -- "n\r"; exp_continue }
34
+		-exact "(default=all): " { send -- "\r"; exp_continue }
35
+		-exact "installation? \[Y/n\]" { send -- "y\r"; exp_continue }
36
+	}
36 37
 EOF
37 38
 
38 39
 arch-chroot $ROOTFS /bin/sh -c "haveged -w 1024; pacman-key --init; pkill haveged; pacman -Rs --noconfirm haveged; pacman-key --populate archlinux"