Commit 9f16862a authored by Francois Dupoux's avatar Francois Dupoux
Browse files

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

parent e369ade1
...@@ -15,6 +15,7 @@ Archiso Authors ...@@ -15,6 +15,7 @@ Archiso Authors
* Dieter Plaetinck <dieter@plaetinck.be> * Dieter Plaetinck <dieter@plaetinck.be>
* Eli Schwartz <eschwartz@archlinux.org> * Eli Schwartz <eschwartz@archlinux.org>
* Florian Pritz <bluewind@xinu.at> * Florian Pritz <bluewind@xinu.at>
* Francois Dupoux <fdupoux@users.sourceforge.net>
* Gerardo Exequiel Pozzi <vmlinuz386@gmail.com> * Gerardo Exequiel Pozzi <vmlinuz386@gmail.com>
* Gerhard Brauer <gerbra@archlinux.de> * Gerhard Brauer <gerbra@archlinux.de>
* James Sitegen <jamesm.sitegen@gmail.com> * James Sitegen <jamesm.sitegen@gmail.com>
......
...@@ -44,6 +44,11 @@ The image file is constructed from some of the variables in **profiledef.sh**: ` ...@@ -44,6 +44,11 @@ The image file is constructed from some of the variables in **profiledef.sh**: `
file (e.g. `packages.x86_64`) 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 * `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`) 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 packages.arch
============= =============
......
...@@ -17,8 +17,6 @@ quiet="y" ...@@ -17,8 +17,6 @@ quiet="y"
work_dir="work" work_dir="work"
out_dir="out" out_dir="out"
img_name="${app_name}.iso" img_name="${app_name}.iso"
sfs_mode="sfs"
sfs_comp="xz"
gpg_key="" gpg_key=""
override_gpg_key="" override_gpg_key=""
...@@ -38,6 +36,8 @@ arch="$(uname -m)" ...@@ -38,6 +36,8 @@ arch="$(uname -m)"
pacman_conf="/etc/pacman.conf" pacman_conf="/etc/pacman.conf"
override_pacman_conf="" override_pacman_conf=""
bootmodes=() bootmodes=()
airootfs_image_type="squashfs"
airootfs_image_tool_options=('-comp' 'xz')
# Show an INFO message # Show an INFO message
...@@ -108,17 +108,11 @@ usage: ${app_name} [options] <profile_dir> ...@@ -108,17 +108,11 @@ usage: ${app_name} [options] <profile_dir>
Default: '${iso_label}' Default: '${iso_label}'
-P <publisher> Set the ISO publisher -P <publisher> Set the ISO publisher
Default: '${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 -g <gpg_key> Set the GPG key to be used for signing the sqashfs image
-h This message -h This message
-o <out_dir> Set the output directory -o <out_dir> Set the output directory
Default: '${out_dir}' Default: '${out_dir}'
-p PACKAGE(S) Package(s) to install, can be used multiple times -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 -v Enable verbose output
-w <work_dir> Set the working directory -w <work_dir> Set the working directory
Default: '${work_dir}' Default: '${work_dir}'
...@@ -201,6 +195,23 @@ _cleanup() { ...@@ -201,6 +195,23 @@ _cleanup() {
_msg_info "Done!" _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. # Makes a ext4 filesystem inside a SquashFS from a source directory.
_mkairootfs_img() { _mkairootfs_img() {
if [[ ! -e "${airootfs_dir}" ]]; then if [[ ! -e "${airootfs_dir}" ]]; then
...@@ -223,13 +234,7 @@ _mkairootfs_img() { ...@@ -223,13 +234,7 @@ _mkairootfs_img() {
_umount_airootfs _umount_airootfs
install -d -m 0755 -- "${isofs_dir}/${install_dir}/${arch}" install -d -m 0755 -- "${isofs_dir}/${install_dir}/${arch}"
_msg_info "Creating SquashFS image, this may take some time..." _msg_info "Creating SquashFS image, this may take some time..."
if [[ "${quiet}" = "y" ]]; then _mkairootfs_create_image "${airootfs_dir}.img"
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
_msg_info "Done!" _msg_info "Done!"
rm -- "${airootfs_dir}.img" rm -- "${airootfs_dir}.img"
} }
...@@ -242,13 +247,7 @@ _mkairootfs_sfs() { ...@@ -242,13 +247,7 @@ _mkairootfs_sfs() {
install -d -m 0755 -- "${isofs_dir}/${install_dir}/${arch}" install -d -m 0755 -- "${isofs_dir}/${install_dir}/${arch}"
_msg_info "Creating SquashFS image, this may take some time..." _msg_info "Creating SquashFS image, this may take some time..."
if [[ "${quiet}" = "y" ]]; then _mkairootfs_create_image "${airootfs_dir}"
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
_msg_info "Done!" _msg_info "Done!"
} }
...@@ -573,10 +572,12 @@ _make_boot_uefi-x64.systemd-boot.eltorito() { ...@@ -573,10 +572,12 @@ _make_boot_uefi-x64.systemd-boot.eltorito() {
# Build airootfs filesystem image # Build airootfs filesystem image
_make_prepare() { _make_prepare() {
if [[ "${sfs_mode}" == "sfs" ]]; then if [[ "${airootfs_image_type}" == "squashfs" ]]; then # prepare airootfs.sfs for overlayfs usage (default)
_run_once _mkairootfs_sfs _run_once _mkairootfs_sfs
else elif [[ "${airootfs_image_type}" == "ext4+squashfs" ]]; then # prepare airootfs.sfs for dm-snapshot usage
_run_once _mkairootfs_img _run_once _mkairootfs_img
else
_msg_error "Unsupported image type: '${airootfs_image_type}'" 1
fi fi
_mkchecksum _mkchecksum
if [[ "${gpg_key}" ]]; then if [[ "${gpg_key}" ]]; then
...@@ -806,7 +807,7 @@ _build_profile() { ...@@ -806,7 +807,7 @@ _build_profile() {
_run_once _make_iso _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 case "${arg}" in
p) p)
read -r -a opt_pkg_list <<< "${OPTARG}" 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 ...@@ -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}" ;; D) override_install_dir="${OPTARG}" ;;
w) work_dir="$(realpath -- "${OPTARG}")" ;; w) work_dir="$(realpath -- "${OPTARG}")" ;;
o) out_dir="$(realpath -- "${OPTARG}")" ;; o) out_dir="$(realpath -- "${OPTARG}")" ;;
s) sfs_mode="${OPTARG}" ;;
c) sfs_comp="${OPTARG}" ;;
g) override_gpg_key="${OPTARG}" ;; g) override_gpg_key="${OPTARG}" ;;
v) quiet="n" ;; v) quiet="n" ;;
h|?) _usage 0 ;; h|?) _usage 0 ;;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment