diff options
author | Maxim Uvarov <maxim.uvarov@linaro.org> | 2019-07-26 15:11:39 +0300 |
---|---|---|
committer | Milosz Wasilewski <milosz.wasilewski@linaro.org> | 2019-07-29 10:16:19 +0000 |
commit | ba719f3a33ffd3c8e978d67554dd8552612d9605 (patch) | |
tree | 5b6c8de34148a7d8d3f12716bacbc1de0b442415 /fedora-iot | |
parent | 8d3129f284cddcd9736baa99ddd9ff7f6cd3c872 (diff) |
fedora-iot: use libguestfs to prepare bootable image
under docker loop devices have some issues to use, so
plan is to use fuse fs with libguestfs.
Signed-off-by: Maxim Uvarov <maxim.uvarov@linaro.org>
Change-Id: I986c7f06d8ee87a90e4ce8249a9d8f3b0543bd0b
Diffstat (limited to 'fedora-iot')
-rwxr-xr-x | fedora-iot/build_fiot.sh | 24 | ||||
-rwxr-xr-x | fedora-iot/builders.sh | 2 | ||||
-rwxr-xr-x | fedora-iot/create_fedora.py | 77 | ||||
-rwxr-xr-x | fedora-iot/guestfish_x86.sh | 26 | ||||
-rwxr-xr-x | fedora-iot/run_fedora_iot.sh | 7 |
5 files changed, 28 insertions, 108 deletions
diff --git a/fedora-iot/build_fiot.sh b/fedora-iot/build_fiot.sh index d960d9c6..7f6387a6 100755 --- a/fedora-iot/build_fiot.sh +++ b/fedora-iot/build_fiot.sh @@ -7,29 +7,7 @@ URL="https://dl.fedoraproject.org/pub/alt/iot/30/IoT/x86_64/images" wget -c ${URL}/${IMG} xz -d ${IMG} -sudo losetup -sudo losetup -P -f ${IMG} - -LOOP="losetup |grep ${IMG} |cut -d " " -f 1" -sudo mkdir ./mnt -sudo mount /dev/${LOOP}p1 ./mnt/ -sudo sed -i 's/options/options console=ttyS0,115200/' ./mnt/loader/entries/ostree-1-fedora-iot.conf - -sudo mkdir ./deploy -sudo find ./mnt -name vmlinu* -exec cp '{}' ./deploy/ \; -sudo find ./mnt -name initramf*.img -exec cp '{}' ./deploy/ \; -sudo umount ./mnt - - -sudo mount /dev/${LOOP}p2 ./mnt/ -cd ./mnt -sudo tar -cpzf ../deploy/fiot-rootfs.tar.gz . -cd - -sudo losetup -d ${LOOP} - -export FIMG="${IMG}" -sudo python ./create_fedora.py -sudo xz -c ${IMG} > ./deploy/${IMG}.xz +sudo ./guestfish_x86.sh echo "build complete" diff --git a/fedora-iot/builders.sh b/fedora-iot/builders.sh index 31ab4c9c..320d98e2 100755 --- a/fedora-iot/builders.sh +++ b/fedora-iot/builders.sh @@ -21,7 +21,7 @@ if ! sudo DEBIAN_FRONTEND=noninteractive apt-get -q=2 update; then sudo DEBIAN_FRONTEND=noninteractive apt-get -q=2 update || true fi -pkg_list="python-pexpect qemu-system-x86 makedev" +pkg_list="libguestfs-tools" if ! sudo DEBIAN_FRONTEND=noninteractive apt-get -q=2 install -y ${pkg_list}; then echo "INFO: apt install error - try again in a moment" sleep 15 diff --git a/fedora-iot/create_fedora.py b/fedora-iot/create_fedora.py deleted file mode 100755 index a32522c5..00000000 --- a/fedora-iot/create_fedora.py +++ /dev/null @@ -1,77 +0,0 @@ -#!/usr/bin/python -import pexpect - -child = pexpect.spawn('./run_fedora_iot.sh', timeout=120) - -child.logfile = open("/dev/tty", "w") -def init_login(): - child.expect(".*Please make a selection from the above.", timeout=120) - child.sendline("2") - - child.expect(".*Create user") - child.expect("]:") - child.sendline("1") - - child.expect(".*User name") - child.expect("]:") - child.sendline("3") - - child.expect("and press ENTER:") - child.sendline("ledge") - - child.expect("]:") - child.sendline("4") - - child.expect("]:") - child.sendline("5") - child.expect("Password:") - child.sendline("ledge2019") - child.expect("Password \(confirm\):") - child.sendline("ledge2019") - - child.expect("]:") - child.sendline("6") - - child.expect("]:") - child.sendline("c") - - child.expect("]:") - child.sendline("q") - - child.expect("Please respond") - child.expect(":") - child.sendline("yes") - -def login(): - child.expect("localhost login:") - child.send("ledge\n") - - child.expect("Password:") - child.send("ledge2019\n") - child.expect("ledge.*$") - child.send("sudo su\n") - child.expect("password for ledge:") - child.send("ledge2019\n") - child.expect("ledge.*$") - -def grub_serial(): - child.sendline("""echo -e GRUB_TERMINAL=\\\"serial\\\" >> /etc/default/grub""") - child.expect("ledge.*$") - - child.sendline("""echo -e GRUB_SERIAL_COMMAND=\\\"serial --speed=115200 --unit=0 --word=8 --parity=no --stop=1\\\" >> /etc/default/grub""") - child.expect("ledge.*$") - - child.sendline('cat /etc/default/grub\n') - child.expect("ledge.*$") - child.send("grub2-mkconfig -o /boot/grub2/grub.cfg\n") - child.expect("ledge.*$") - -def power_off(): - child.send("poweroff\n") - -init_login() -login() -grub_serial() -power_off() - -child.expect(pexpect.EOF) diff --git a/fedora-iot/guestfish_x86.sh b/fedora-iot/guestfish_x86.sh new file mode 100755 index 00000000..e271bd8a --- /dev/null +++ b/fedora-iot/guestfish_x86.sh @@ -0,0 +1,26 @@ +#!/bin/bash + +# requirements: +# apt install libguestfs-tools + +sudo guestfish --rw -a Fedora-IoT-30-20190515.1.x86_64.raw << 'EOF' + run + list-filesystems + mount /dev/sda1 / + cat /loader.0/entries/ostree-1-fedora-iot.conf | sed 's/options/options gconsole=ttyS0,115200/' > /tmp/ostree-1-fedora-iot.conf + copy-in /tmp/ostree-1-fedora-iot.conf /loader.0/entries/ + cat /loader.0/entries/ostree-1-fedora-iot.conf + + !mkdir -p deploy + tar-out / - | gzip > deploy/boot.tar.gz + umount / + + mount /dev/sda2 / + tar-out / - | gzip > deploy/rootfs.tar.gz + umount / +EOF + +cd deploy +tar -xzf boot.tar.gz --strip-components=3 --wildcards --no-anchored 'vmlinuz*' +tar -xzf boot.tar.gz --strip-components=3 --wildcards --no-anchored 'initramfs*' +cd - diff --git a/fedora-iot/run_fedora_iot.sh b/fedora-iot/run_fedora_iot.sh deleted file mode 100755 index ae5dd177..00000000 --- a/fedora-iot/run_fedora_iot.sh +++ /dev/null @@ -1,7 +0,0 @@ -#!/bin/sh - -DRIVE="${FIMG:-Fedora-IoT-30-20190515.1.x86_64.raw}" - -qemu-system-x86_64 -cpu host -enable-kvm \ - -net nic,model=virtio,macaddr=DE:AD:BE:EF:28:01 -net user \ - -m 1024 -boot d -serial mon:stdio -serial null -nographic -drive format=raw,file=${DRIVE} |