Adding two more scripts to perform post-install

01-reconfigure-net.expect works around a problem with the pre-configured
network driver

02-setup.expect updates the pkg database and installs install vim cscope openssh gcc44 scmgit
* run netconf and restart to prevent qemu from not getting an ip address
* set the password (dev)
* pkgin update
* pkgin install vim cscope openssh gcc44 scmgit
This commit is contained in:
Kees Jongenburger
2012-06-06 16:56:38 +02:00
parent 5aa5dd23a4
commit ea6f7338c5
4 changed files with 244 additions and 1 deletions

View File

@@ -16,3 +16,11 @@ minix_R3.2.0-116fcea.iso.bz2:
minix.base.8g.img:script/02_qemu_minix_base.install.expect minix_R3.2.0-116fcea.iso
script/02_qemu_minix_base.install.expect
mv minix.tmp.img minix.base.8g.img
minix.postinst.8g.img:minix.base.8g.img
rm -f minix.postinst.8g.tmp.img minix.postinst.8g.img
cp minix.base.8g.img minix.postinst.8g.tmp.img
post-install/01-reconfigure-net.expect
post-install/02-setup.expect
mv minix.postinst.8g.tmp.img minix.postinst.8g.img

View File

@@ -0,0 +1,113 @@
#!/usr/bin/expect -f
#
# Script to perform unattended install of minix on qemu
#
#
# required: qemu , expect and minix_R3.2.0-116fcea.iso in the current directory
# sha1sum 127e79c76538b8066dbcf549b246be1f22a986e7
#
# Spawn qemu using the curses front-end and start interacting with it
#spawn qemu -hda minix.tmp.img -cdrom minix_R3.2.0-116fcea.iso -boot d -curses
spawn qemu-system-i386 -m 512 -hda minix.postinst.8g.tmp.img -curses
set timeout 5
puts "Performing post install"
#
#--- Welcome to MINIX 3. This is the boot monitor. ---
expect "\\-\\-\\- Welcome to MINIX 3. This is the boot monitor. \\-\\-\\-"
#
#Check we have a normal boot loader
#1. Start MINIX 3
expect "1. Start MINIX 3"
expect "Choose an option; RETURN for default; SPACE to stop countdown." {
send "\n"
}
# expect the boot to take very long as in the default image the network
# driver is not properly configured
set timeout 200
#
# the fist boot fails with a malloc problem in dhcpd
#Starting networking: dhcpd nonamed.
#assertion "(char *) NextSlot(p) <= next" failed: file "minix/malloc.c", line 245
#, function "free"
#PM: coredump signal 6 for 128 / dhcpd
# dhcpd 36668 0x806b5f1 0x806b49f 0x80836bd 0x80754b5 0x8063b50 0x80751d8 0x80
#65352 0x804eb6a 0x804ec55 0x804bf98 0x804c2a1 0x8048602 0x804813b 0x80480b5 0x1
#
for {} 1 {} {
puts "fix dhcp loop"
expect {
#minix login:
#but later if it worked ip-address login:
"login:" {
send "root\n"
break
}
"dirty, performing fsck" {puts "resetting timeout as the file system in dirty" }
#Starting networking: dhcpd nonamed.
"nonamed." {
#send a break signal
sleep 1
send "\003"
}
timeout {
puts "Failed to catch login command"
exit 1
}
}
}
set timeout 20
#
#
#
# netconf
# MINIX 3 currently supports the following Ethernet cards. PCI cards detected
# by MINIX are marked with *. Please choose:
#
# 0. No Ethernet card (no networking)
# 1. 3Com 501 or 3Com 509 based card
# 2. Realtek 8029 based card (also emulated by Qemu)
# 3. NE2000, 3com 503 or WD based card (also emulated by Bochs)
# 4. Attansic/Atheros L2 FastEthernet
# 5. DEC Tulip 21140A in VirtualPC
# 6. * Intel PRO/1000 Gigabit
# 7. Intel PRO/100
# 8. AMD LANCE (also emulated by VMWare and VirtualBox)
# 9. Realtek 8139 based card
# 10. Realtek 8169 based card
# 11. Different Ethernet card (no networking)
#
# Ethernet card? [6]
expect "#" {
send "netconf\n"
expect "Ethernet card?" {
send "\n"
}
# Configure network using DHCP or manually?
#
# 1. Automatically using DHCP
# 2. Manually
#
# Configure method? [1] ^[[V
expect "Configure method?" {
send "\n"
}
expect "You might have to reboot for the changes to take effect." {
puts "Network card reconfigured, reboot"
}
}
#shutdown
send "shutdown\n"
expect "Choose an option; RETURN for default; SPACE to stop countdown."

View File

@@ -0,0 +1,121 @@
#!/usr/bin/expect -f
#
spawn qemu-system-i386 -m 512 -hda minix.postinst.8g..tmp.img -curses
set timeout 5
puts "Performing post install"
#
#--- Welcome to MINIX 3. This is the boot monitor. ---
expect "\\-\\-\\- Welcome to MINIX 3. This is the boot monitor. \\-\\-\\-"
#
#Check we have a normal boot loader
#1. Start MINIX 3
expect "1. Start MINIX 3"
expect "Choose an option; RETURN for default; SPACE to stop countdown." {
send "\n"
}
# expect the boot to take very long as in the default image the network
# driver is not properly configured
set timeout 60
#
for {} 1 {} {
puts "Waiting for a prompt"
expect {
#minix login:
#but later if it worked ip-address login:
"login:" {
send "root\n"
break
}
"dirty, performing fsck" {puts "resetting timeout as the file system in dirty" }
timeout {
puts "Failed to catch login command"
exit 1
}
}
}
set timeout 5
expect "#"
expect -re $
#
# put a run command in /tmp that echoes RESULT-OK or RESULT-FAIL based on the
# return value of the command launched
#
set send_human {.1 .3 1 .05 2}
# the shell can't handle all this output at once so sending it as "human"
send -h "echo '#/bin/sh' > /tmp/runcmd.sh ; echo 'if $* ; then echo RESULT-OK ; else echo RESULT-FAIL ; fi' >> /tmp/runcmd.sh ; chmod +x /tmp/runcmd.sh\n"
expect "#"
#read the full buffer so the next line does not match RESULT-FAIL
set timeout 60
expect -re $
send "/tmp/runcmd.sh pkgin update\n"
expect {
"RESULT-FAIL" {
puts "Failed to update package database"
interact
exit 1
}
"RESULT-OK" {
puts "Updated the package database"
}
timeout {
puts "Failed to update pkg database"
interact
exit 1
}
}
set timeout 120
expect -re $
send "/tmp/runcmd.sh pkgin upgrade\n"
expect {
"RESULT-FAIL" {
puts "Failed to upgrade packages"
interact
exit 1
}
"RESULT-OK" {
puts "Updated the package upgraded"
}
timeout {
puts "Failed to update pkg packages"
interact
exit 1
}
}
#
# installing takes quite some time
#
set timeout 500
expect -re $
send "/tmp/runcmd.sh pkgin -y install vim cscope openssh gcc44 scmgit\n"
expect {
"RESULT-FAIL" {
puts "Failed to install needed packages"
interact
exit 1
}
"RESULT-OK" {
puts "Updated the needed packages"
}
timeout {
puts "Failed to install selected packages"
interact
exit 1
}
}
#shutdown
send "shutdown\n"
expect "Choose an option; RETURN for default; SPACE to stop countdown."

View File

@@ -17,7 +17,8 @@ exec qemu-img create minix.tmp.img 8G
# Spawn qemu using the curses front-end and start interacting with it
spawn qemu -hda minix.tmp.img -cdrom minix_R3.2.0-116fcea.iso -boot d -curses
#spawn qemu -hda minix.tmp.img -cdrom minix_R3.2.0-116fcea.iso -boot d -curses
spawn qemu-system-i386 -hda minix.tmp.img -cdrom minix_R3.2.0-116fcea.iso -boot d -curses
#pass past the bootloader
expect "1. Regular MINIX 3" {