Configure the image type and image creation options using profiles (#54)

This commit is contained in:
fdupoux 2020-10-30 21:20:05 +00:00
parent e369ade17d
commit 9f16862acd
3 changed files with 32 additions and 27 deletions

View File

@ -15,6 +15,7 @@ Archiso Authors
* Dieter Plaetinck <dieter@plaetinck.be>
* Eli Schwartz <eschwartz@archlinux.org>
* Florian Pritz <bluewind@xinu.at>
* Francois Dupoux <fdupoux@users.sourceforge.net>
* Gerardo Exequiel Pozzi <vmlinuz386@gmail.com>
* Gerhard Brauer <gerbra@archlinux.de>
* James Sitegen <jamesm.sitegen@gmail.com>

View File

@ -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
=============

View File

@ -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] <profile_dir>
Default: '${iso_label}'
-P <publisher> Set the ISO publisher
Default: '${iso_publisher}'
-c <comp_type> Set SquashFS compression type (gzip, lzma, lzo, xz, zstd)
Default: '${sfs_comp}'
-g <gpg_key> Set the GPG key to be used for signing the sqashfs image
-h This message
-o <out_dir> Set the output directory
Default: '${out_dir}'
-p PACKAGE(S) Package(s) to install, can be used multiple times
-s <sfs_mode> 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 <work_dir> 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 ;;