test.sh: Only build archiso when necessary

extramodules
Jesus Alvarez 6 years ago
parent 51545aa3e0
commit 231cc988da
  1. 2
      .gitignore
  2. 0
      archiso/README.rst
  3. 0
      archiso/airootfs/etc/fstab
  4. 0
      archiso/airootfs/etc/hostname
  5. 0
      archiso/airootfs/etc/locale.conf
  6. 0
      archiso/airootfs/etc/machine-id
  7. 0
      archiso/airootfs/etc/systemd/scripts/choose-mirror
  8. 0
      archiso/airootfs/etc/systemd/system/choose-mirror.service
  9. 0
      archiso/airootfs/etc/systemd/system/etc-pacman.d-gnupg.mount
  10. 0
      archiso/airootfs/etc/systemd/system/getty@tty1.service.d/autologin.conf
  11. 0
      archiso/airootfs/etc/systemd/system/pacman-init.service
  12. 0
      archiso/airootfs/etc/udev/rules.d/81-dhcpcd.rules
  13. 0
      archiso/airootfs/root/.automated_script.sh
  14. 0
      archiso/airootfs/root/.zlogin
  15. 0
      archiso/airootfs/root/customize_airootfs.sh
  16. 0
      archiso/airootfs/root/install.txt
  17. 0
      archiso/build.sh
  18. 0
      archiso/efiboot/loader/entries/archiso-x86_64.conf
  19. 0
      archiso/efiboot/loader/loader.conf
  20. 0
      archiso/isolinux/isolinux.cfg
  21. 0
      archiso/mkinitcpio.conf
  22. 0
      archiso/packages
  23. 0
      archiso/pacman.conf
  24. 0
      archiso/syslinux/splash.png
  25. 0
      archiso/syslinux/syslinux.cfg
  26. 2
      testing/.gitignore
  27. 67
      testing/test.sh
  28. 13
      testing/tests/archzfs-qemu-base/setup.sh
  29. 12
      testing/tests/archzfs-qemu-lts-test-01-root-bootfs/archiso.sh
  30. 1
      testing/tests/archzfs-qemu-lts-test-01-root-bootfs/fs.sh
  31. 16
      testing/tests/archzfs-qemu-lts-test-01-root-bootfs/hooks.sh

2
.gitignore vendored

@ -1,3 +1,5 @@
*!
*/*.tar.*
*.log
archiso/out/
archiso/work/

@ -1,4 +1,2 @@
*.qcow2
packer_work/
out/
work/

@ -23,26 +23,50 @@ export packer_work_dir="${script_dir}/files/packer_work"
export base_image_output_dir="${script_dir}/files"
init_archiso_vars() {
if [[ ! -d ${test_mode}/archiso ]]; then
export archiso_baseurl="http://mirrors.kernel.org/archlinux/iso/latest"
debug "archiso_baseurl=${archiso_baseurl}"
export archiso_iso_name=$(curl -s ${archiso_baseurl}/ | grep -o "\".*dual.iso\"" | tr -d '"')
export archiso_sha=$(curl -s ${archiso_baseurl}/sha1sums.txt | grep ${archiso_iso_name} | awk '{ print $1 }')
export archiso_url="${packer_work_dir}/${archiso_iso_name}"
# Build the archiso with linux-lts if needed
archiso_build() {
msg "Building the archiso if required"
local build_archiso=0
# Check the linux-lts version last used in the archiso
run_cmd_no_output "cat ${script_dir}/../archiso/work/iso/arch/pkglist.x86_64.txt 2> /dev/null | grep linux-lts | grep -Po '(?<=core/linux-lts-).*$'"
if [[ ${run_cmd_return} -ne 0 ]]; then
build_archiso=1
elif [[ ! -f "${packer_work_dir}/archlinux*.iso" ]]; then
msg2 "archzfs archiso does not exist!"
build_archiso=1
else
export archiso_iso_name=$(find files/packer_work/ -iname "archlinux*.iso" | xargs basename)
export archiso_sha=$(sha1sum ${packer_work_dir}/${archiso_iso_name} | awk '{ print $1 }')
export archiso_url="${packer_work_dir}/${archiso_iso_name}"
current_archiso_lts_vers="${run_cmd_output}"
debug "current_archiso_lts_vers: ${current_archiso_lts_vers}"
if ! check_webpage "https://www.archlinux.org/packages/core/x86_64/linux-lts/" "(?<=<h2>linux-lts )[\d\.-]+(?=</h2>)" "${current_archiso_lts_vers}"; then
debug "Setting build_archiso to 1"
build_archiso=1
fi
fi
if [[ ${build_archiso} -eq 0 ]]; then
msg2 "archiso is up-to-date!"
return
fi
# Delete the working directories since we are out-of-date
run_cmd_no_output "rm -rf ${script_dir}/archiso/{out,work} ${packer_work_dir}/*.iso"
source_safe "${test_mode}/conf.sh" && source_safe "${test_mode}/archiso.sh" && test_build_archiso
}
archiso_init_vars() {
export archiso_iso_name=$(find ${packer_work_dir}/ -iname "archlinux*.iso" | xargs basename)
export archiso_sha=$(sha1sum ${packer_work_dir}/${archiso_iso_name} | awk '{ print $1 }')
export archiso_url="${packer_work_dir}/${archiso_iso_name}"
debug "archiso_iso_name=${archiso_iso_name}"
debug "archiso_sha=${archiso_sha}"
debug "archiso_url=${archiso_url}"
}
gen_base_image_name() {
export base_image_basename="$(basename ${test_mode})-archiso-${archiso_iso_name:10:-9}"
base_image_name() {
export base_image_basename="$(basename ${test_mode})-archiso-${archiso_iso_name:10:-4}"
debug "base_image_basename=${base_image_basename}"
run_cmd_output=$(find ${script_dir} -iname "*$(basename ${test_mode})-*" -printf "%P\\n" | sort -r | head -n 1)
if [[ ${run_cmd_output} == "" ]]; then
@ -65,8 +89,8 @@ usage() {
echo " -h: Show help information."
echo " -n: Dryrun; Output commands, but don't do anything."
echo " -d: Show debug info."
echo " -R: Re-use existing archzfs test packages."
echo
# echo " -R: Re-use existing archzfs test packages."
# echo
# echo "Modes:"
# echo
# for ml in "${mode_list[@]}"; do
@ -93,9 +117,9 @@ debug_print_array "test_commands_list" "${test_commands_list[@]}"
for (( a = 0; a < $#; a++ )); do
if [[ ${args[$a]} == "-R" ]]; then
commands+=("reuse")
elif [[ ${args[$a]} == "-n" ]]; then
# if [[ ${args[$a]} == "-R" ]]; then
# commands+=("reuse")
if [[ ${args[$a]} == "-n" ]]; then
dry_run=1
elif [[ ${args[$a]} == "-d" ]]; then
debug_flag=1
@ -155,8 +179,6 @@ if [[ "${test_mode}" != "" ]]; then
msg2 "Using packer to build the base image ..."
gen_base_image_name
# Base files
run_cmd "check_symlink '${script_dir}/tests/archzfs-qemu-base/packer.json' '${packer_work_dir}/packer.json'"
run_cmd "check_symlink '${script_dir}/tests/archzfs-qemu-base/base.sh' '${packer_work_dir}/base.sh'"
@ -179,10 +201,9 @@ if [[ "${test_mode}" != "" ]]; then
# Make it easy to get the files into the archiso environment
run_cmd "tar --exclude='*.iso' --exclude=packer_cache --exclude=b.tar -C ${packer_work_dir} -cvhf ${packer_work_dir}/b.tar ."
msg "Building the archiso if required"
source_safe "${test_mode}/conf.sh" && source_safe "${test_mode}/archiso.sh" && test_build_archiso
init_archiso_vars
archiso_build
archiso_init_vars
base_image_name
# Uncomment to enable packer debug
export PACKER_LOG=1

@ -60,8 +60,15 @@ test_bootloader_install
test_fs_config_root_postinstall
exit 0
# Reboot!
test_setup_exit
# Reboot!
setup_exit
# TODO: Manage packer output here. We need to boot the built base image and run tests on it.
# Check acceptance criteria
if ! test_met_acceptance_criteria; then
error "Test failed!"
exit 1
fi

@ -5,12 +5,12 @@
# We need an archiso with the lts kernel used by default
test_build_archiso() {
msg "Building archiso"
cd ${test_root_dir}/archiso/ &> /dev/null
# if [[ -d ${packer_work_dir}/out ]] && [[ $(ls -1 | wc -l) -gt 0 ]]; then
# run_cmd "rm -rf ${test_root_dir}/archiso/out/archlinux*"
# fi
# run_cmd "./build.sh -v"
cd ${test_root_dir}/../../../archiso/ &> /dev/null
if [[ -d ${packer_work_dir}/out ]] && [[ $(ls -1 | wc -l) -gt 0 ]]; then
run_cmd "rm -rf ${test_root_dir}/archiso/out/archlinux*"
fi
run_cmd "./build.sh -v"
msg2 "Coping archiso to packer_work_dir"
run_cmd "cp ${test_root_dir}/archiso/out/archlinux* ${packer_work_dir} && rm -rf ${test_root_dir}/archiso/work"
run_cmd "cp ${test_root_dir}/../../../archiso/out/archlinux* ${packer_work_dir} && rm -rf ${test_root_dir}/archiso/work"
cd - &> /dev/null
}

@ -46,6 +46,7 @@ test_fs_config_root_preinstall() {
run_cmd "zfs create -o compression=lz4 -o mountpoint=${test_target_dir}/ROOT zroot/ROOT/default"
run_cmd "zfs create -o mountpoint=none zroot/data"
run_cmd "zfs create -o compression=lz4 -o mountpoint=${test_target_dir}/ROOT/home zroot/data/home"
run_cmd "zfs set mountpoint=legacy zroot/data/home"
msg2 "Mounting /home"
run_cmd "mount -t zfs -o default,noatime zroot/data/home ${test_target_dir}/ROOT/home"

@ -1,12 +1,12 @@
#!/bin/bash
setup_exit() {
test_setup_exit() {
msg "Installation complete!"
/usr/bin/sleep 10
/usr/bin/umount /mnt/repo
/usr/bin/umount /mnt/var/cache/pacman/pkg
/usr/bin/umount ${arch_target_dir}
/usr/bin/umount /var/cache/pacman/pkg
/usr/bin/umount /repo
/usr/bin/systemctl reboot
systemctl reboot
}
test_met_acceptance_criteria() {
return 1
}

Loading…
Cancel
Save