From 9f16862acd7e7be02da72f63a03b4c0e256dabff Mon Sep 17 00:00:00 2001 From: fdupoux Date: Fri, 30 Oct 2020 21:20:05 +0000 Subject: Configure the image type and image creation options using profiles (#54) --- AUTHORS.rst | 1 + README.profile.rst | 5 +++++ archiso/mkarchiso | 53 ++++++++++++++++++++++++++--------------------------- 3 files changed, 32 insertions(+), 27 deletions(-) diff --git a/AUTHORS.rst b/AUTHORS.rst index 536c15c..cc2c3e0 100644 --- a/AUTHORS.rst +++ b/AUTHORS.rst @@ -15,6 +15,7 @@ Archiso Authors * Dieter Plaetinck * Eli Schwartz * Florian Pritz +* Francois Dupoux * Gerardo Exequiel Pozzi * Gerhard Brauer * James Sitegen diff --git a/README.profile.rst b/README.profile.rst index 94cecdd..70f0b30 100644 --- a/README.profile.rst +++ b/README.profile.rst @@ -44,6 +44,11 @@ The image file is constructed from some of the variables in **profiledef.sh**: ` file (e.g. `packages.x86_64`) * `pacman_conf`: The `pacman.conf` to use to install packages to the work directory when creating the image (defaults to the host's `/etc/pacman.conf`) +* `airootfs_image_type`: The image type to create. The following options are understood (defaults to `squashfs`): + - `squashfs`: Create a squashfs image directly from the airootfs work directory + - `ext4+squashfs`: Create an ext4 partition, copy the airootfs work directory to it and create a squashfs image from it +* `airootfs_image_tool_options`: An array of options to pass to the tool to create the airootfs image. Currently only + `mksquashfs` is supported - see `mksquashfs --help` for all possible options (defaults to `('-comp' 'xz')`). packages.arch ============= diff --git a/archiso/mkarchiso b/archiso/mkarchiso index 5bb042c..13cee6a 100755 --- a/archiso/mkarchiso +++ b/archiso/mkarchiso @@ -17,8 +17,6 @@ quiet="y" work_dir="work" out_dir="out" img_name="${app_name}.iso" -sfs_mode="sfs" -sfs_comp="xz" gpg_key="" override_gpg_key="" @@ -38,6 +36,8 @@ arch="$(uname -m)" pacman_conf="/etc/pacman.conf" override_pacman_conf="" bootmodes=() +airootfs_image_type="squashfs" +airootfs_image_tool_options=('-comp' 'xz') # Show an INFO message @@ -108,17 +108,11 @@ usage: ${app_name} [options] Default: '${iso_label}' -P Set the ISO publisher Default: '${iso_publisher}' - -c Set SquashFS compression type (gzip, lzma, lzo, xz, zstd) - Default: '${sfs_comp}' -g Set the GPG key to be used for signing the sqashfs image -h This message -o Set the output directory Default: '${out_dir}' -p PACKAGE(S) Package(s) to install, can be used multiple times - -s Set SquashFS image mode (img or sfs) - img: prepare airootfs.sfs for dm-snapshot usage - sfs: prepare airootfs.sfs for overlayfs usage - Default: '${sfs_mode}' -v Enable verbose output -w Set the working directory Default: '${work_dir}' @@ -201,6 +195,23 @@ _cleanup() { _msg_info "Done!" } +_mkairootfs_create_image() { + if (( $# < 1 )); then + _msg_error "Function '${FUNCNAME[0]}' requires at least one argument" 1 + fi + + image_path="${isofs_dir}/${install_dir}/${arch}/airootfs.sfs" + if [[ "${airootfs_image_type}" =~ .*squashfs ]] ; then + if [[ "${quiet}" == "y" ]]; then + mksquashfs "$@" "${image_path}" -noappend "${airootfs_image_tool_options[@]}" -no-progress > /dev/null + else + mksquashfs "$@" "${image_path}" -noappend "${airootfs_image_tool_options[@]}" + fi + else + _msg_error "Unsupported image type: '${airootfs_image_type}'" 1 + fi +} + # Makes a ext4 filesystem inside a SquashFS from a source directory. _mkairootfs_img() { if [[ ! -e "${airootfs_dir}" ]]; then @@ -223,13 +234,7 @@ _mkairootfs_img() { _umount_airootfs install -d -m 0755 -- "${isofs_dir}/${install_dir}/${arch}" _msg_info "Creating SquashFS image, this may take some time..." - if [[ "${quiet}" = "y" ]]; then - mksquashfs "${airootfs_dir}.img" "${isofs_dir}/${install_dir}/${arch}/airootfs.sfs" -noappend \ - -comp "${sfs_comp}" -no-progress > /dev/null - else - mksquashfs "${airootfs_dir}.img" "${isofs_dir}/${install_dir}/${arch}/airootfs.sfs" -noappend \ - -comp "${sfs_comp}" - fi + _mkairootfs_create_image "${airootfs_dir}.img" _msg_info "Done!" rm -- "${airootfs_dir}.img" } @@ -242,13 +247,7 @@ _mkairootfs_sfs() { install -d -m 0755 -- "${isofs_dir}/${install_dir}/${arch}" _msg_info "Creating SquashFS image, this may take some time..." - if [[ "${quiet}" = "y" ]]; then - mksquashfs "${airootfs_dir}" "${isofs_dir}/${install_dir}/${arch}/airootfs.sfs" -noappend \ - -comp "${sfs_comp}" -no-progress > /dev/null - else - mksquashfs "${airootfs_dir}" "${isofs_dir}/${install_dir}/${arch}/airootfs.sfs" -noappend \ - -comp "${sfs_comp}" - fi + _mkairootfs_create_image "${airootfs_dir}" _msg_info "Done!" } @@ -573,10 +572,12 @@ _make_boot_uefi-x64.systemd-boot.eltorito() { # Build airootfs filesystem image _make_prepare() { - if [[ "${sfs_mode}" == "sfs" ]]; then + if [[ "${airootfs_image_type}" == "squashfs" ]]; then # prepare airootfs.sfs for overlayfs usage (default) _run_once _mkairootfs_sfs - else + elif [[ "${airootfs_image_type}" == "ext4+squashfs" ]]; then # prepare airootfs.sfs for dm-snapshot usage _run_once _mkairootfs_img + else + _msg_error "Unsupported image type: '${airootfs_image_type}'" 1 fi _mkchecksum if [[ "${gpg_key}" ]]; then @@ -806,7 +807,7 @@ _build_profile() { _run_once _make_iso } -while getopts 'p:r:C:L:P:A:D:w:o:s:c:g:vh?' arg; do +while getopts 'p:r:C:L:P:A:D:w:o:g:vh?' arg; do case "${arg}" in p) read -r -a opt_pkg_list <<< "${OPTARG}" @@ -820,8 +821,6 @@ while getopts 'p:r:C:L:P:A:D:w:o:s:c:g:vh?' arg; do D) override_install_dir="${OPTARG}" ;; w) work_dir="$(realpath -- "${OPTARG}")" ;; o) out_dir="$(realpath -- "${OPTARG}")" ;; - s) sfs_mode="${OPTARG}" ;; - c) sfs_comp="${OPTARG}" ;; g) override_gpg_key="${OPTARG}" ;; v) quiet="n" ;; h|?) _usage 0 ;; -- cgit v1.2.3-70-g09d2