diff --git a/archiso/mkarchiso b/archiso/mkarchiso index df7ee05..1dca307 100755 --- a/archiso/mkarchiso +++ b/archiso/mkarchiso @@ -4,10 +4,13 @@ set -e -u -export LANG=C +# Control the environment +umask 0022 +export LANG="C" +export SOURCE_DATE_EPOCH="${SOURCE_DATE_EPOCH:-"$(date +%s)"}" -app_name=${0##*/} -arch=$(uname -m) +app_name="${0##*/}" +arch="$(uname -m)" pkg_list=() run_cmd="" quiet="y" @@ -20,13 +23,14 @@ work_dir="work" out_dir="out" sfs_mode="sfs" sfs_comp="xz" -gpg_key= +gpg_key="" # Show an INFO message # $1: message string _msg_info() { local _msg="${1}" - echo "[mkarchiso] INFO: ${_msg}" + [[ "${quiet}" == "y" ]] || printf '[%s] INFO: %s\n' "${app_name}" "${_msg}" + } # Show an ERROR message then exit with status @@ -35,83 +39,83 @@ _msg_info() { _msg_error() { local _msg="${1}" local _error=${2} - echo - echo "[mkarchiso] ERROR: ${_msg}" - echo - if [[ ${_error} -gt 0 ]]; then + printf '\n[%s] ERROR: %s\n\n' "${app_name}" "${_msg}" >&2 + if (( _error > 0 )); then exit "${_error}" fi } _chroot_init() { - mkdir -p ${work_dir}/airootfs + mkdir -p -- "${work_dir}/airootfs" _pacman base syslinux } _chroot_run() { - eval arch-chroot ${work_dir}/airootfs "${run_cmd}" + eval -- arch-chroot "${work_dir}/airootfs" "${run_cmd}" } _mount_airootfs() { trap "_umount_airootfs" EXIT HUP INT TERM - mkdir -p "${work_dir}/mnt/airootfs" + mkdir -p -- "${work_dir}/mnt/airootfs" _msg_info "Mounting '${work_dir}/airootfs.img' on '${work_dir}/mnt/airootfs'" - mount "${work_dir}/airootfs.img" "${work_dir}/mnt/airootfs" + mount -- "${work_dir}/airootfs.img" "${work_dir}/mnt/airootfs" _msg_info "Done!" } _umount_airootfs() { _msg_info "Unmounting '${work_dir}/mnt/airootfs'" - umount -d "${work_dir}/mnt/airootfs" + umount -d -- "${work_dir}/mnt/airootfs" _msg_info "Done!" - rmdir "${work_dir}/mnt/airootfs" + rmdir -- "${work_dir}/mnt/airootfs" trap - EXIT HUP INT TERM } # Show help usage, with an exit status. # $1: exit status number. -_usage () -{ - echo "usage ${app_name} [options] command " - echo " general options:" - echo " -p PACKAGE(S) Package(s) to install, can be used multiple times" - echo " -r Run inside airootfs" - echo " -C Config file for pacman." - echo " Default: '${pacman_conf}'" - echo " -L