aboutsummaryrefslogtreecommitdiff
path: root/ldcg-cloud-image
diff options
context:
space:
mode:
authorMarcin Juszkiewicz <marcin.juszkiewicz@linaro.org>2018-09-07 10:01:58 +0100
committerMarcin Juszkiewicz <marcin.juszkiewicz@linaro.org>2018-09-10 15:04:48 +0000
commit5c78283569ae0df2202afaee173338b1cf02af5a (patch)
treeeef6585fc877ee93eab832c343fed907590092a5 /ldcg-cloud-image
parentdd7bd73c5c837653a1af02772b649fb7aaed6ca6 (diff)
ldcg-cloud-image-debian: build ERP cloud image - LDCG-783
Change-Id: I3031898eb988f9b030bf07c485fb6418a75b07ed
Diffstat (limited to 'ldcg-cloud-image')
-rwxr-xr-xldcg-cloud-image/debian/builders.sh69
-rw-r--r--ldcg-cloud-image/debian/preseed.cfg72
2 files changed, 141 insertions, 0 deletions
diff --git a/ldcg-cloud-image/debian/builders.sh b/ldcg-cloud-image/debian/builders.sh
new file mode 100755
index 0000000000..0cfa8155f5
--- /dev/null
+++ b/ldcg-cloud-image/debian/builders.sh
@@ -0,0 +1,69 @@
+#!/bin/bash
+
+export image_name=$(mktemp -u -p'debian-cloud-image' | sed -e 's+/+-+g')
+export mountpoint=$(mktemp -d /tmp/${image_name}.XXXXXX)
+
+echo "deb http://obs.linaro.org/ERP:/18.06/Debian_9 ./" | sudo tee /etc/apt/sources.list.d/erp-18.06.list
+
+sudo apt-get -q=2 update
+sudo apt-get -q=2 install -y --no-install-recommends cpio qemu-utils virtinst libvirt-clients
+
+virt-host-validate
+
+sudo virsh pool-list --all
+sudo virsh net-list --all
+
+set -ex
+
+trap cleanup_exit INT TERM EXIT
+
+cleanup_exit()
+{
+ cd ${WORKSPACE}
+ sudo virsh vol-delete --pool default ${image_name}.img || true
+ sudo virsh destroy ${image_name} || true
+ sudo virsh undefine ${image_name} || true
+ sudo umount ${mountpoint} || true
+ sudo kpartx -dv ${image_name}.img || true
+ sudo rm -rf ${mountpoint} || true
+ sudo rm -f ${image_name}.img
+}
+
+wget -q https://git.linaro.org/ci/job/configs.git/blob_plain/HEAD:/ldcg-cloud-image/debian/preseed.cfg -O preseed.cfg
+
+sudo virt-install \
+ --name ${image_name} \
+ --initrd-inject preseed.cfg \
+ --extra-args "interface=auto noshell auto=true DEBIAN_FRONTEND=text" \
+ --disk=pool=default,size=2.0,format=raw \
+ --network=network=default, \
+ --memory 2048 \
+ --location http://deb.debian.org/debian/dists/stable/main/installer-arm64/ \
+ --noreboot
+
+set +ex
+while [ true ]; do
+ sleep 1
+ vm_running=$(sudo virsh list --name --state-running | grep "^${image_name}" | wc -l)
+ [ "${vm_running}" -eq "0" ] && break
+done
+set -ex
+
+sudo virsh list --all
+
+mkdir -p out
+cp preseed.cfg out/debian-stretch-arm64-preseed.cfg
+
+sudo cp -a /var/lib/libvirt/images/${image_name}.img .
+
+sudo virsh vol-download --pool default --vol ${image_name}.img --file ${image_name}.img
+
+for device in $(sudo kpartx -avs ${image_name}.img | cut -d' ' -f3); do
+ partition=$(echo ${device} | cut -d'p' -f3)
+ [ "${partition}" = "2" ] && sudo mount /dev/mapper/${device} ${mountpoint}
+done
+
+cp -a ${mountpoint}/boot/*-arm64 out/
+
+sudo qemu-img convert -c -O qcow2 ${image_name}.img out/debian-erp-cloud-image.qcow2
+sudo chown -R buildslave:buildslave out
diff --git a/ldcg-cloud-image/debian/preseed.cfg b/ldcg-cloud-image/debian/preseed.cfg
new file mode 100644
index 0000000000..69b240bf30
--- /dev/null
+++ b/ldcg-cloud-image/debian/preseed.cfg
@@ -0,0 +1,72 @@
+d-i debian-installer/locale string en_US.UTF-8
+d-i localechooser/supported-locales multiselect en_US.UTF-8, en_GB.UTF-8
+d-i keyboard-configuration/xkb-keymap select us
+d-i netcfg/choose_interface select auto
+d-i netcfg/get_hostname string unassigned-hostname
+d-i netcfg/get_domain string unassigned-domain
+d-i netcfg/wireless_wep string
+d-i mirror/country string manual
+d-i mirror/http/hostname string deb.debian.org
+d-i mirror/http/directory string /debian
+d-i mirror/http/proxy string
+d-i passwd/root-login boolean false
+d-i passwd/user-fullname string Debian User
+d-i passwd/username string debian
+d-i passwd/user-password password insecure
+d-i passwd/user-password-again password insecure
+d-i clock-setup/utc boolean true
+d-i time/zone string UTC
+d-i clock-setup/ntp boolean true
+d-i partman-auto/method string regular
+d-i partman-lvm/device_remove_lvm boolean true
+d-i partman-md/device_remove_md boolean true
+d-i partman-lvm/confirm boolean true
+d-i partman-lvm/confirm_nooverwrite boolean true
+d-i partman-partitioning/confirm_write_new_label boolean true
+d-i partman/choose_partition select finish
+d-i partman/confirm boolean true
+d-i partman/confirm_nooverwrite boolean true
+d-i partman-md/confirm boolean true
+d-i partman-partitioning/confirm_write_new_label boolean true
+d-i partman/choose_partition select finish
+d-i partman/confirm boolean true
+d-i partman-basicfilesystems/no_swap boolean false
+d-i partman/confirm_nooverwrite boolean true
+d-i partman-auto/expert_recipe string \
+ myroot :: \
+ 64 64 64 vfat \
+ $primary{ } \
+ format{ } \
+ filesystem{ vfat } \
+ method{ efi } \
+ mountpoint{ /boot/efi } \
+ . \
+ 800 50 -1 ext4 \
+ $primary{ } \
+ $bootable{ } \
+ method{ format } \
+ format{ } \
+ use_filesystem{ } \
+ filesystem{ ext4 } \
+ mountpoint{ / } \
+ .
+
+d-i partman-auto/choose_recipe select myroot
+d-i apt-setup/services-select multiselect security, updates, backports
+d-i apt-setup/local0/repository string http://obs.linaro.org/ERP:/18.06/Debian_9/ ./
+d-i apt-setup/local0/comment string Enterprise RP 18.06
+d-i apt-setup/local0/source boolean true
+d-i apt-setup/local0/key string http://obs.linaro.org/ERP:/18.06/Debian_9/Release.key
+d-i pkgsel/upgrade select full-upgrade
+tasksel tasksel/first multiselect standard
+d-i pkgsel/include string openssh-server cloud-init cloud-utils cloud-initramfs-growroot linux-image-reference-arm64
+popularity-contest popularity-contest/participate boolean false
+d-i grub-installer/only_debian boolean true
+d-i grub-installer/with_other_os boolean false
+d-i grub-installer/bootdev string default
+d-i finish-install/reboot_in_progress note
+d-i preseed/late_command string \
+ mkdir -p /target/boot/efi/EFI/BOOT ; \
+ cp /target/boot/efi/EFI/debian/grubaa64.efi /target/boot/efi/EFI/BOOT/BOOTAA64.EFI ; \
+ echo 'debian ALL = NOPASSWD: ALL' > /target/etc/sudoers.d/cloud ; \
+ chmod 440 /target/etc/sudoers.d/cloud