Skip to content

Commit

Permalink
cmd-build: don't use anaconda
Browse files Browse the repository at this point in the history
Also switch to BLS.
  • Loading branch information
Andrew Jeddeloh committed Jun 20, 2019
1 parent 7640c90 commit ef0450c
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 14 deletions.
12 changes: 11 additions & 1 deletion src/cmd-build
Original file line number Diff line number Diff line change
Expand Up @@ -242,9 +242,19 @@ img_base=tmp/${imageprefix}-base.qcow2
# forgive me for this sin
checksum_location=$(find /usr/lib/coreos-assembler-anaconda/ -name '*CHECKSUM' | head -1)

build_image() {
local size kargs
size="$(python3 -c 'import sys, yaml; print(yaml.load(sys.stdin)["size"])' < "$configdir/image.yaml")G"
kargs="$(python3 -c 'import sys, yaml; args = yaml.load(sys.stdin)["extra-kargs"]; print(" ".join(args))' < "$configdir/image.yaml")"
kargs="$kargs console=tty0 console=${VM_TERMINAL},115200n8"

qemu-img create -f qcow2 "$img_base" "$size"
runvm_with_disk "$img_base" /usr/lib/coreos-assembler/create_disk.sh /dev/vda "$tmprepo" "${ref-:${commit}}" /usr/lib/coreos-assembler/grub.cfg "$name" "\"$kargs\""
}

if [ -n "${build_qemu}" ]; then
img_qemu=${imageprefix}-qemu.qcow2
run_virtinstall "${tmprepo}" "${ref}" "${PWD}"/"${img_base}" --variant=cloud
build_image
/usr/lib/coreos-assembler/gf-platformid "$(pwd)"/"${img_base}" "$(pwd)"/"${img_qemu}" qemu
fi

Expand Down
15 changes: 14 additions & 1 deletion src/cmdlib.sh
Original file line number Diff line number Diff line change
Expand Up @@ -314,6 +314,12 @@ EOF
}

runvm() {
runvm_with_disk "" "$@"
}

runvm_with_disk() {
local disk="$1"
shift
local vmpreparedir=${workdir}/tmp/supermin.prepare
local vmbuilddir=${workdir}/tmp/supermin.build

Expand Down Expand Up @@ -381,6 +387,12 @@ EOF
arch_args='-bios /usr/share/AAVMF/AAVMF_CODE.fd'
fi

# if a disk image exists, attach it too
extradisk=()
if [ -n "$disk" ]; then
extradisk=("-drive" "if=virtio,id=target,format=qcow2,file=$disk")
fi

#shellcheck disable=SC2086
${QEMU_KVM} ${arch_args:-} \
-nodefaults -nographic -m 2048 -no-reboot -cpu host \
Expand All @@ -394,7 +406,8 @@ EOF
-device scsi-hd,bus=scsi0.0,channel=0,scsi-id=0,lun=0,drive=drive-scsi0-0-0-0,id=scsi0-0-0-0,bootindex=1 \
"${cachedisk[@]}" \
-virtfs local,id=workdir,path="${workdir}",security_model=none,mount_tag=workdir \
"${srcvirtfs[@]}" -serial stdio -append "root=/dev/sda console=${VM_TERMINAL} selinux=1 enforcing=0 autorelabel=1"
"${srcvirtfs[@]}" -serial stdio -append "root=/dev/sda console=${VM_TERMINAL} selinux=1 enforcing=0 autorelabel=1" \
"${extradisk[@]}"

if [ ! -f "${workdir}"/tmp/rc ]; then
fatal "Couldn't find rc file, something went terribly wrong!"
Expand Down
26 changes: 14 additions & 12 deletions src/gf-platformid
Original file line number Diff line number Diff line change
Expand Up @@ -41,19 +41,21 @@ coreos_gf_run_mount "${tmp_dest}"
# * grub config
# * BLS config (for subsequent config regeneration)
# First, the grub config.
if [ "$(coreos_gf exists '/boot/efi')" == 'true' ]; then
grubcfg_path=$(coreos_gf glob-expand /boot/efi/EFI/*/grub.cfg)
else
grubcfg_path=/boot/loader/grub.cfg
if [ "$arch" -ne "x86_64" ] || [ "$platformid" == "metal" ]; then
if [ "$(coreos_gf exists '/boot/efi')" == 'true' ]; then
grubcfg_path=$(coreos_gf glob-expand /boot/efi/EFI/*/grub.cfg)
else
grubcfg_path=/boot/loader/grub.cfg
fi
coreos_gf download "${grubcfg_path}" "${tmpd}"/grub.cfg
# Remove any platformid currently there
sed -i -e 's, ignition.platform.id=[a-zA-Z0-9]*,,g' "${tmpd}"/grub.cfg
# Insert our new platformid
# Match linux16, linux and linuxefi since only linux is available on aarch64
# and linuxefi is available in grub2.cfg for UEFI
sed -i -e 's,^\(linux\(16\|efi\)\? .*\),\1 ignition.platform.id='"${platformid}"',' "${tmpd}"/grub.cfg
coreos_gf upload "${tmpd}"/grub.cfg "${grubcfg_path}"
fi
coreos_gf download "${grubcfg_path}" "${tmpd}"/grub.cfg
# Remove any platformid currently there
sed -i -e 's, ignition.platform.id=[a-zA-Z0-9]*,,g' "${tmpd}"/grub.cfg
# Insert our new platformid
# Match linux16, linux and linuxefi since only linux is available on aarch64
# and linuxefi is available in grub2.cfg for UEFI
sed -i -e 's,^\(linux\(16\|efi\)\? .*\),\1 ignition.platform.id='"${platformid}"',' "${tmpd}"/grub.cfg
coreos_gf upload "${tmpd}"/grub.cfg "${grubcfg_path}"
# Now the BLS version
blscfg_path=$(coreos_gf glob-expand /boot/loader/entries/ostree-*.conf)
coreos_gf download "${blscfg_path}" "${tmpd}"/bls.conf
Expand Down

0 comments on commit ef0450c

Please sign in to comment.