Call curtin installer from subiquity

Hacky method, but in welcome controller, use subprocess to
call a script which invokes curtin at a known location with
a specific set of parameters.

Modify the installer configuration and start-up scripts to
ensure Subiquity runs on tty1 and keeps the service running.

Upon hitting 'Confirm' Subiquity will exec curtin_wrap.sh
which calls the *real* curtin.  Cloud-init user-data has been
modified to unpack the curtin archive embedded.

When complete, the target.img file is bootable.

Signed-off-by: Ryan Harper <ryan.harper@canonical.com>
This commit is contained in:
Ryan Harper 2015-06-16 18:56:22 -05:00
parent a80d6b16d0
commit 8fa43b57ea
4 changed files with 21 additions and 9 deletions

14
bin/curtin_wrap.sh Executable file
View File

@ -0,0 +1,14 @@
#!/bin/bash
CMD="-v --showtrace install cp:///"
CURTIN="/usr/local/curtin/bin/curtin"
OUTPUT="/tmp/.curtin_wrap_ran"
if [ -e $CURTIN ]; then
$CURTIN $CMD | tee -a $OUTPUT
else
echo "$CURTIN not found" > $OUTPUT
echo $CURTIN $CMD | tee -a $OUTPUT
fi
echo "Shutting down after running $CURTIN $CMD"
telinit 0

View File

@ -302,7 +302,7 @@ generate_seed() {
# append the curtin-cmd file
rm -f ${seed}/user-data &&
cp $installer_user_data $seed/user-data &&
userdata_write_file "/usr/local/bin/curtin" \
userdata_write_file "/usr/local/bin/curtin-archive" \
"root:root" "0755" "none" \
"$curtin_cmd" >> $seed/user-data || {
log "Failed to embed curtin into $seed";

View File

@ -6,24 +6,20 @@ output: {all: '| tee -a /var/log/cloud-init-output.log'}
packages:
- python-urwid
- python3-urwid
power_state:
mode: poweroff
message: Bye Bye
timeout: 30
runcmd:
- cp /usr/share/doc/python-urwid/examples/input_test.py /tmp/installer.py
- tar -C /usr/local -xf /tmp/subiquity.tar
- chmod +x /tmp/installer.py /usr/local/bin/subiquity
- (cd /usr/local && bin/curtin-archive extract --no-execute)
- systemctl enable subiquity.service
- systemctl stop getty@tty1.service
# - systemctl stop serial-getty@ttyS0.service
- /tmp/installer.sh
- telinit 0
write_files:
- content: |
#!/bin/bash
chvt 2
chvt 1
systemctl start subiquity
# restart getty service after exiting "installer"
# systemctl stop serial-getty@ttyS0.service
@ -51,4 +47,4 @@ write_files:
WantedBy=default.target
path: /lib/systemd/system/subiquity.service
owner: root:root
permissions: '0755'
permissions: '0644'

View File

@ -15,6 +15,7 @@
from subiquity.controllers import BaseController
from subiquity.views.welcome import WelcomeView
import subprocess
class WelcomeController(BaseController):
@ -25,4 +26,5 @@ class WelcomeController(BaseController):
return WelcomeView(self.finish)
def finish(self, code, val):
subprocess.check_call("/usr/local/bin/curtin_wrap.sh")
raise SystemExit("Saw res: {}, val: {}".format(code, val))