]> piware.de Git - bin.git/blob - vmdebdev
schrootbd: force new conffiles
[bin.git] / vmdebdev
1 #!/usr/bin/expect -f
2 # create a Debian/Ubuntu development VM based on a standard autopkgtest VM
3
4 set timeout -1
5
6 set prompt "(%|#|\\$) $"
7 set sshkey [read [open ".ssh/id_rsa.pub"]]
8
9 # Start the guest VM
10 set img [lrange $argv 0 0]
11 if { $img == "" } { set img "/srv/vm/autopkgtest-sid.img" }
12 spawn vm $img -nographic -snapshot -virtfs local,id=srv,path=/srv,security_model=none,mount_tag=srv,readonly \
13               -virtfs local,id=etcschroot,path=/etc/schroot,security_model=none,mount_tag=etcschroot,readonly
14
15 # Login, and get root shell
16 expect {
17     # autopkgtest Debian machine only has a root login
18     "Debian GNU" { set user "root"; set sudo ""; set getroot "" }
19     "Ubuntu" { set user "ubuntu"; set password "ubuntu"; set getroot "sudo -n -i" }
20 }
21
22 expect "login: "
23 send "$user\r"
24
25 expect {
26     "Password" { send "$password\r"; exp_continue }
27     -re $prompt
28 }
29
30 send "export TERM=xterm; $getroot\r"
31 expect -re $prompt
32
33 # install wanted packages
34 send "apt-get install -o Dpkg::Options::=--force-confnew -y sudo less bash-completion vim openssh-server locales git-buildpackage build-essential fakeroot lintian debhelper manpages-dev git dput pristine-tar schroot sbuild </dev/null\r"
35 expect -re $prompt
36
37 # set up user
38 send "deluser --remove-home test; adduser --disabled-password --gecos 'Martin Pitt' martin; echo 'martin:a' | chpasswd; adduser martin sbuild\r"
39 expect -re $prompt
40
41 send "echo 'martin ALL=(ALL) NOPASSWD:ALL' | tee /etc/sudoers.d/martin; update-locale LANG=C.UTF-8; touch /var/lib/sudo/lectured/martin\r"
42 expect -re $prompt
43 send "mkdir /home/martin/.ssh; echo '$sshkey' | tee /home/martin/.ssh/authorized_keys; chown -R martin:martin /home/martin/.ssh\r"
44 expect -re $prompt
45
46 # mount home, /srv, and schroot config from host; TODO: move to NFS?
47 send "mkdir /home/martin/h; printf 'home /home/martin/h 9p trans=virtio,access=any,nofail,ro 0 0\nsrv /srv 9p trans=virtio,access=any,nofail,ro 0 0\netcschroot /etc/schroot 9p trans=virtio,access=any,nofail,ro 0 0\n' | tee -a /etc/fstab; mount /home/martin/h; mount /srv; mount /etc/schroot\r"
48 expect -re $prompt
49 send "(cd /home/martin; ln -s h/.gbp.conf; ln -s h/.vimrc)\r"
50
51 # set up lxd if available (on Ubuntu)
52 # FIXME: lxd init invocation aborts expect/qemu
53 #send "apt-get install -y lxd </dev/null && adduser martin lxd && yes '' | lxd init || true\r"
54 send "apt-get install -y lxd </dev/null && adduser martin lxd || true\r"
55 expect -re $prompt
56
57 interact