test.sh: Only build archiso when necessary

extramodules
Jesus Alvarez 9 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.* */*.tar.*
*.log *.log
archiso/out/
archiso/work/

@ -1,4 +1,2 @@
*.qcow2 *.qcow2
packer_work/ 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" export base_image_output_dir="${script_dir}/files"
init_archiso_vars() { # Build the archiso with linux-lts if needed
if [[ ! -d ${test_mode}/archiso ]]; then archiso_build() {
export archiso_baseurl="http://mirrors.kernel.org/archlinux/iso/latest" msg "Building the archiso if required"
debug "archiso_baseurl=${archiso_baseurl}" local build_archiso=0
export archiso_iso_name=$(curl -s ${archiso_baseurl}/ | grep -o "\".*dual.iso\"" | tr -d '"') # Check the linux-lts version last used in the archiso
export archiso_sha=$(curl -s ${archiso_baseurl}/sha1sums.txt | grep ${archiso_iso_name} | awk '{ print $1 }') 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-).*$'"
export archiso_url="${packer_work_dir}/${archiso_iso_name}" 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 else
export archiso_iso_name=$(find files/packer_work/ -iname "archlinux*.iso" | xargs basename) current_archiso_lts_vers="${run_cmd_output}"
export archiso_sha=$(sha1sum ${packer_work_dir}/${archiso_iso_name} | awk '{ print $1 }') debug "current_archiso_lts_vers: ${current_archiso_lts_vers}"
export archiso_url="${packer_work_dir}/${archiso_iso_name}" 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 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_iso_name=${archiso_iso_name}"
debug "archiso_sha=${archiso_sha}" debug "archiso_sha=${archiso_sha}"
debug "archiso_url=${archiso_url}" debug "archiso_url=${archiso_url}"
} }
gen_base_image_name() { base_image_name() {
export base_image_basename="$(basename ${test_mode})-archiso-${archiso_iso_name:10:-9}" export base_image_basename="$(basename ${test_mode})-archiso-${archiso_iso_name:10:-4}"
debug "base_image_basename=${base_image_basename}" 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) run_cmd_output=$(find ${script_dir} -iname "*$(basename ${test_mode})-*" -printf "%P\\n" | sort -r | head -n 1)
if [[ ${run_cmd_output} == "" ]]; then if [[ ${run_cmd_output} == "" ]]; then
@ -65,8 +89,8 @@ usage() {
echo " -h: Show help information." echo " -h: Show help information."
echo " -n: Dryrun; Output commands, but don't do anything." echo " -n: Dryrun; Output commands, but don't do anything."
echo " -d: Show debug info." echo " -d: Show debug info."
echo " -R: Re-use existing archzfs test packages." # echo " -R: Re-use existing archzfs test packages."
echo # echo
# echo "Modes:" # echo "Modes:"
# echo # echo
# for ml in "${mode_list[@]}"; do # 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 for (( a = 0; a < $#; a++ )); do
if [[ ${args[$a]} == "-R" ]]; then # if [[ ${args[$a]} == "-R" ]]; then
commands+=("reuse") # commands+=("reuse")
elif [[ ${args[$a]} == "-n" ]]; then if [[ ${args[$a]} == "-n" ]]; then
dry_run=1 dry_run=1
elif [[ ${args[$a]} == "-d" ]]; then elif [[ ${args[$a]} == "-d" ]]; then
debug_flag=1 debug_flag=1
@ -155,8 +179,6 @@ if [[ "${test_mode}" != "" ]]; then
msg2 "Using packer to build the base image ..." msg2 "Using packer to build the base image ..."
gen_base_image_name
# Base files # 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/packer.json' '${packer_work_dir}/packer.json'"
run_cmd "check_symlink '${script_dir}/tests/archzfs-qemu-base/base.sh' '${packer_work_dir}/base.sh'" 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 # 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 ." 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" archiso_build
source_safe "${test_mode}/conf.sh" && source_safe "${test_mode}/archiso.sh" && test_build_archiso archiso_init_vars
base_image_name
init_archiso_vars
# Uncomment to enable packer debug # Uncomment to enable packer debug
export PACKER_LOG=1 export PACKER_LOG=1

@ -60,8 +60,15 @@ test_bootloader_install
test_fs_config_root_postinstall test_fs_config_root_postinstall
exit 0 # Reboot!
test_setup_exit
# Reboot! # TODO: Manage packer output here. We need to boot the built base image and run tests on it.
setup_exit
# 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 # We need an archiso with the lts kernel used by default
test_build_archiso() { test_build_archiso() {
msg "Building archiso" msg "Building archiso"
cd ${test_root_dir}/archiso/ &> /dev/null cd ${test_root_dir}/../../../archiso/ &> /dev/null
# if [[ -d ${packer_work_dir}/out ]] && [[ $(ls -1 | wc -l) -gt 0 ]]; then if [[ -d ${packer_work_dir}/out ]] && [[ $(ls -1 | wc -l) -gt 0 ]]; then
# run_cmd "rm -rf ${test_root_dir}/archiso/out/archlinux*" run_cmd "rm -rf ${test_root_dir}/archiso/out/archlinux*"
# fi fi
# run_cmd "./build.sh -v" run_cmd "./build.sh -v"
msg2 "Coping archiso to packer_work_dir" 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 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 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 mountpoint=none zroot/data"
run_cmd "zfs create -o compression=lz4 -o mountpoint=${test_target_dir}/ROOT/home zroot/data/home" 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" msg2 "Mounting /home"
run_cmd "mount -t zfs -o default,noatime zroot/data/home ${test_target_dir}/ROOT/home" run_cmd "mount -t zfs -o default,noatime zroot/data/home ${test_target_dir}/ROOT/home"

@ -1,12 +1,12 @@
#!/bin/bash #!/bin/bash
setup_exit() {
test_setup_exit() {
msg "Installation complete!" msg "Installation complete!"
/usr/bin/sleep 10 systemctl reboot
/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 test_met_acceptance_criteria() {
/usr/bin/umount /repo return 1
/usr/bin/systemctl reboot
} }

Loading…
Cancel
Save