aboutsummaryrefslogtreecommitdiff
path: root/leg-cloud-image
diff options
context:
space:
mode:
authorFathi Boudra <fathi.boudra@linaro.org>2016-11-24 21:09:58 +0200
committerFathi Boudra <fathi.boudra@linaro.org>2016-11-24 21:09:58 +0200
commitea23bcbdea87d82df196d18ff58663cde5853933 (patch)
tree93181c18f9fbb1aa2ae1b54654206402835fd0b4 /leg-cloud-image
parent6fec3350a6943cd1edcabc04af944d27efa7f6ae (diff)
downloadconfigs-ea23bcbdea87d82df196d18ff58663cde5853933.tar.gz
leg-cloud-image: separate shell step into an included builder.sh script
* use include-raw to include builders.sh script * split d-i preseed and anaconde kickstart configuration in plain text file * publish into a separate step to avoid token timeout * configure libvirt uri_default at runtime * fix shell expansion syntax in centos ks (dracut call) Change-Id: I12b9f765210174ce1b92313770c34ceca40c9f41 Signed-off-by: Fathi Boudra <fathi.boudra@linaro.org>
Diffstat (limited to 'leg-cloud-image')
-rwxr-xr-xleg-cloud-image/centos/builders.sh60
-rw-r--r--leg-cloud-image/centos/centos7-aarch64.ks95
-rwxr-xr-xleg-cloud-image/debian/builders.sh60
-rw-r--r--leg-cloud-image/debian/preseed.cfg50
4 files changed, 265 insertions, 0 deletions
diff --git a/leg-cloud-image/centos/builders.sh b/leg-cloud-image/centos/builders.sh
new file mode 100755
index 000000000..1b3f06456
--- /dev/null
+++ b/leg-cloud-image/centos/builders.sh
@@ -0,0 +1,60 @@
+#!/bin/bash
+
+export image_name=centos7-cloud-image
+
+sudo apt-get -q=2 update
+sudo apt-get -q=2 install -y --no-install-recommends qemu-utils virtinst libguestfs-tools libvirt-bin
+
+default_gw=$(ip route show default 0.0.0.0/0 | cut -d' ' -f3)
+sudo sed -i "/^uri_default/d" /etc/libvirt/libvirt.conf
+echo "uri_default = \"qemu+tcp://${default_gw}/system\"" | sudo tee -a /etc/libvirt/libvirt.conf
+
+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 destroy ${image_name} || true
+ sudo virsh undefine ${image_name} || true
+ sudo rm -f /var/lib/libvirt/images/${image_name}.qcow2 ${image_name}.qcow2
+}
+
+wget -q https://git.linaro.org/ci/job/configs.git/blob_plain/HEAD:/leg-cloud-image/centos/centos7-aarch64.ks -O centos7-aarch64.ks
+
+sudo virt-install \
+ --name ${image_name} \
+ --initrd-inject centos7-aarch64.ks \
+ --extra-args "ks=file:/centos7-aarch64.ks" \
+ --disk=pool=default,size=10,format=qcow2,bus=virtio \
+ --memory 2048 \
+ --location http://mirror.centos.org/altarch/7/os/aarch64/ \
+ --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
+sudo virsh pool-list --all
+sudo virsh net-list --all
+
+mkdir out
+mv centos7-aarch64.ks out/
+sudo cp -a /var/lib/libvirt/images/${image_name}.qcow2 .
+sudo qemu-img convert -c -O qcow2 ${image_name}.qcow2 out/${image_name}.qcow2
+# extract kernel and initramfs from image
+# --unversioned-names may be handy to get vmlinuz/initrd.img names if needed
+sudo LIBGUESTFS_BACKEND=direct virt-copy-out -a ${image_name}.qcow2 /boot/ .
+sudo cp -a boot/*-reference.*.aarch64* out/
+sudo chown -R buildslave:buildslave out
diff --git a/leg-cloud-image/centos/centos7-aarch64.ks b/leg-cloud-image/centos/centos7-aarch64.ks
new file mode 100644
index 000000000..078c6d7d3
--- /dev/null
+++ b/leg-cloud-image/centos/centos7-aarch64.ks
@@ -0,0 +1,95 @@
+reboot
+eula --agreed
+text
+firstboot --disable
+ignoredisk --only-use=vda
+keyboard --vckeymap=us --xlayouts='us'
+lang en_GB.UTF-8
+network --bootproto=dhcp --device=eth0 --onboot=off --ipv6=auto --hostname=localhost.localdomain
+repo --name=os --baseurl=http://mirror.centos.org/altarch/7/os/aarch64/
+repo --name=extras --baseurl=http://mirror.centos.org/altarch/7/extras/aarch64/
+repo --name=updates --baseurl=http://mirror.centos.org/altarch/7/updates/aarch64/
+rootpw --plaintext root
+user --name centos --plaintext --password centos --homedir /home/centos --groups wheel
+timezone Europe/Warsaw --isUtc
+bootloader --boot-drive=vda
+autopart --type=plain
+clearpart --all --initlabel --drives=vda
+
+%packages
+@core
+cloud-init
+chrony
+nfs-utils
+rsync
+tar
+yum-utils
+dracut-config-generic
+dracut-norescue
+-aic94xx-firmware
+-alsa-firmware
+-alsa-lib
+-alsa-tools-firmware
+-iprutils
+-ivtv-firmware
+-iwl100-firmware
+-iwl1000-firmware
+-iwl105-firmware
+-iwl135-firmware
+-iwl2000-firmware
+-iwl2030-firmware
+-iwl3160-firmware
+-iwl3945-firmware
+-iwl4965-firmware
+-iwl5000-firmware
+-iwl5150-firmware
+-iwl6000-firmware
+-iwl6000g2a-firmware
+-iwl6000g2b-firmware
+-iwl6050-firmware
+-iwl7260-firmware
+%end
+
+%post
+# Needed for install, not so much for cloud.
+yum -C -y remove firewalld --setopt="clean_requirements_on_remove=1"
+yum -C -y remove avahi\* Network\*
+
+cat > /etc/sysconfig/network << EO
+NETWORKING=yes
+NOZEROCONF=yes
+EO
+
+# Ensure we're not backing in a mac addr.
+cat > /etc/sysconfig/network-scripts/ifcfg-eth0 << EO
+DEVICE="eth0"
+BOOTPROTO="dhcp"
+ONBOOT="yes"
+TYPE="Ethernet"
+USERCTL="yes"
+PEERDNS="yes"
+IPV6INIT="no"
+PERSISTENT_DHCLIENT="1"
+EO
+
+# Let mirrors know it's cloud
+echo 'genclo' > /etc/yum/vars/infra
+
+# Fix selinux context
+echo "Fixing SELinux contexts."
+touch /var/log/cron
+touch /var/log/boot.log
+mkdir -p /var/cache/yum
+/usr/sbin/fixfiles -R -a restore
+
+# make sure firstboot doesn't start
+echo "RUN_FIRSTBOOT=NO" > /etc/sysconfig/firstboot
+
+# install updates (including kernel) from Linaro overlay
+curl http://repo.linaro.org/rpm/linaro-overlay/centos-7/linaro-overlay.repo > /etc/yum.repos.d/linaro-overlay.repo
+yum update -y --nogpgcheck
+
+# make sure that resulting initramfs will have virtio storage drivers
+echo 'add_drivers+="virtio-blk virtio-scsi"' > /etc/dracut.conf.d/add-virtio-modules.conf
+dracut -f /boot/initramfs-$(rpm -qa kernel|sed -e "s/kernel-//g").img $(rpm -qa kernel|sed -e "s/kernel-//g")
+%end \ No newline at end of file
diff --git a/leg-cloud-image/debian/builders.sh b/leg-cloud-image/debian/builders.sh
new file mode 100755
index 000000000..1392b73d9
--- /dev/null
+++ b/leg-cloud-image/debian/builders.sh
@@ -0,0 +1,60 @@
+#!/bin/bash
+
+export image_name=debian-cloud-image
+
+sudo apt-get -q=2 update
+sudo apt-get -q=2 install -y --no-install-recommends qemu-utils virtinst libguestfs-tools libvirt-bin
+
+default_gw=$(ip route show default 0.0.0.0/0 | cut -d' ' -f3)
+sudo sed -i "/^uri_default/d" /etc/libvirt/libvirt.conf
+echo "uri_default = \"qemu+tcp://${default_gw}/system\"" | sudo tee -a /etc/libvirt/libvirt.conf
+
+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 destroy ${image_name} || true
+ sudo virsh undefine ${image_name} || true
+ sudo rm -f /var/lib/libvirt/images/${image_name}.qcow2 ${image_name}.qcow2
+}
+
+wget -q https://git.linaro.org/ci/job/configs.git/blob_plain/HEAD:/leg-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=10,format=qcow2,bus=virtio \
+ --memory 2048 \
+ --location http://ftp.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
+sudo virsh pool-list --all
+sudo virsh net-list --all
+
+mkdir out
+mv preseed.cfg out/debian-jessie-arm64-preseed.cfg
+sudo cp -a /var/lib/libvirt/images/${image_name}.qcow2 .
+sudo qemu-img convert -c -O qcow2 ${image_name}.qcow2 out/${image_name}.qcow2
+# extract kernel and initramfs from image
+# --unversioned-names may be handy to get vmlinuz/initrd.img names if needed
+sudo LIBGUESTFS_BACKEND=direct virt-copy-out -a ${image_name}.qcow2 /boot/ .
+sudo cp -a boot/*-arm64 out/
+sudo chown -R buildslave:buildslave out
diff --git a/leg-cloud-image/debian/preseed.cfg b/leg-cloud-image/debian/preseed.cfg
new file mode 100644
index 000000000..8e2c2c60d
--- /dev/null
+++ b/leg-cloud-image/debian/preseed.cfg
@@ -0,0 +1,50 @@
+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 ftp.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-auto/choose_recipe select atomic
+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/confirm_nooverwrite boolean true
+d-i apt-setup/services-select multiselect security, updates, backports
+d-i apt-setup/local0/repository string http://repo.linaro.org/ubuntu/linaro-overlay jessie main
+d-i apt-setup/local0/comment string Linaro Overlay
+d-i apt-setup/local0/source boolean true
+d-i apt-setup/local0/key string http://repo.linaro.org/ubuntu/linarorepo.key
+d-i pkgsel/upgrade select full-upgrade
+tasksel tasksel/first multiselect standard
+d-i pkgsel/include string openssh-server cloud-init cloud-utils/jessie-backports 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 true
+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 \ No newline at end of file