From 8faa9c5400711c9687e4a4396f8a6dd1eb8a2634 Mon Sep 17 00:00:00 2001 From: udeved Date: Thu, 25 Feb 2016 18:37:29 +0100 Subject: [PATCH] [util-iso*] some code simplification --- lib/util-iso-aufs.sh | 2 +- lib/util-iso-boot.sh | 4 ++-- lib/util-iso-calamares.sh | 8 ++++---- lib/util-iso-image.sh | 10 +++++----- lib/util-iso-log.sh | 2 +- lib/util-iso-overlayfs.sh | 2 +- lib/util-iso.sh | 24 ++++++++---------------- lib/util-publish.sh | 2 +- 8 files changed, 23 insertions(+), 31 deletions(-) diff --git a/lib/util-iso-aufs.sh b/lib/util-iso-aufs.sh index c920ee3..d56a91d 100644 --- a/lib/util-iso-aufs.sh +++ b/lib/util-iso-aufs.sh @@ -17,7 +17,7 @@ mount_image(){ mount_image_custom(){ msg2 "%s mount: %s" "${iso_fs}" "${1##*/}" - mount -t aufs -o br="$1":${work_dir}/${custom}-image=ro:${work_dir}/root-image=ro none "$1" + mount -t aufs -o br="$1":${work_dir}/${profile}-image=ro:${work_dir}/root-image=ro none "$1" } # $1: image path diff --git a/lib/util-iso-boot.sh b/lib/util-iso-boot.sh index 7716c9c..c5d86ef 100644 --- a/lib/util-iso-boot.sh +++ b/lib/util-iso-boot.sh @@ -277,8 +277,8 @@ write_isomounts(){ echo "${arch}/mhwd-image.sqfs ${arch} / squashfs" >> ${file} fi if [[ -f "${packages_custom}" ]] ; then - msg2 "Writing %s entry ..." "${custom}" - echo "${arch}/${custom}-image.sqfs ${arch} / squashfs" >> ${file} + msg2 "Writing %s entry ..." "${profile}" + echo "${arch}/${profile}-image.sqfs ${arch} / squashfs" >> ${file} fi msg2 "Writing root entry ..." echo "${arch}/root-image.sqfs ${arch} / squashfs" >> ${file} diff --git a/lib/util-iso-calamares.sh b/lib/util-iso-calamares.sh index 382d825..e89a1eb 100644 --- a/lib/util-iso-calamares.sh +++ b/lib/util-iso-calamares.sh @@ -137,7 +137,7 @@ write_calamares_unpack_conf(){ echo " - source: \"/bootmnt/${iso_name}/${arch}/root-image.sqfs\"" >> "$conf" echo " sourcefs: \"squashfs\"" >> "$conf" echo " destination: \"\"" >> "$conf" - echo " - source: \"/bootmnt/${iso_name}/${arch}/${custom}-image.sqfs\"" >> "$conf" + echo " - source: \"/bootmnt/${iso_name}/${arch}/${profile}-image.sqfs\"" >> "$conf" echo " sourcefs: \"squashfs\"" >> "$conf" echo " destination: \"\"" >> "$conf" } @@ -160,8 +160,8 @@ write_calamares_users_conf(){ brand_calamares_settings_conf(){ local conf="$1/usr/share/calamares/settings.conf" if [[ -f $conf ]];then - if [[ -d $1/usr/share/calamares/branding/${iso_name}-${custom} ]];then - sed -i -e "s|^.*branding:.*|branding: ${iso_name}-${custom}|" "$conf" + if [[ -d $1/usr/share/calamares/branding/${iso_name}-${profile} ]];then + sed -i -e "s|^.*branding:.*|branding: ${iso_name}-${profile}|" "$conf" elif [[ -d $1/usr/share/calamares/branding/${iso_name} ]];then sed -i -e "s|^.*branding:.*|branding: ${iso_name}|" "$conf" fi @@ -201,7 +201,7 @@ configure_thus(){ echo "SHORT_NAME = \"${dist_name}\"" >> "$conf" echo "[install]" >> "$conf" echo "LIVE_MEDIA_SOURCE = \"/bootmnt/${iso_name}/${arch}/root-image.sqfs\"" >> "$conf" - echo "LIVE_MEDIA_DESKTOP = \"/bootmnt/${iso_name}/${arch}/${custom}-image.sqfs\"" >> "$conf" + echo "LIVE_MEDIA_DESKTOP = \"/bootmnt/${iso_name}/${arch}/${profile}-image.sqfs\"" >> "$conf" echo "LIVE_MEDIA_TYPE = \"squashfs\"" >> "$conf" echo "LIVE_USER_NAME = \"${username}\"" >> "$conf" echo "KERNEL = \"${kernel}\"" >> "$conf" diff --git a/lib/util-iso-image.sh b/lib/util-iso-image.sh index 9b84b87..cd8e141 100644 --- a/lib/util-iso-image.sh +++ b/lib/util-iso-image.sh @@ -21,8 +21,8 @@ copy_overlay(){ write_profile_conf_entries(){ local conf=$1/profile.conf echo '' >> ${conf} - echo '# custom image name' >> ${conf} - echo "custom=${custom}" >> ${conf} + echo '# profile image name' >> ${conf} + echo "profile=${profile}" >> ${conf} echo '' >> ${conf} echo '# iso_name' >> ${conf} echo "iso_name=${iso_name}" >> ${conf} @@ -78,7 +78,7 @@ add_svc_sd(){ } # $1: chroot configure_environment(){ - case ${custom} in + case ${profile} in cinnamon|gnome|i3|lxde|mate|netbook|openbox|pantheon|xfce|xfce-minimal) echo "QT_STYLE_OVERRIDE=gtk" >> $1/etc/environment ;; @@ -377,11 +377,11 @@ configure_root_image(){ } configure_custom_image(){ - msg "Configuring [%s-image]" "${custom}" + msg "Configuring [%s-image]" "${profile}" configure_displaymanager "$1" configure_services "$1" configure_environment "$1" - msg "Done configuring [%s-image]" "${custom}" + msg "Done configuring [%s-image]" "${profile}" } configure_live_image(){ diff --git a/lib/util-iso-log.sh b/lib/util-iso-log.sh index 5fcf64f..dff17b4 100644 --- a/lib/util-iso-log.sh +++ b/lib/util-iso-log.sh @@ -18,7 +18,7 @@ error_function() { error "A failure occurred in %s()." "$1" plain "Aborting..." fi - for mp in ${work_dir}/{root,${custom},live,mhwd,boot}-image;do + for mp in ${work_dir}/{root,${profile},live,mhwd,boot}-image;do umount_image "$mp" done exit 2 diff --git a/lib/util-iso-overlayfs.sh b/lib/util-iso-overlayfs.sh index 3958a98..609e553 100644 --- a/lib/util-iso-overlayfs.sh +++ b/lib/util-iso-overlayfs.sh @@ -19,7 +19,7 @@ mount_image(){ mount_image_custom(){ msg2 "%s mount: %s" "${iso_fs}" "${1##*/}" mkdir -p "${work_dir}/work" - mount -t overlay overlay -olowerdir="${work_dir}/${custom}-image":"${work_dir}/root-image",upperdir="$1",workdir="${work_dir}/work" "$1" + mount -t overlay overlay -olowerdir="${work_dir}/${profile}-image":"${work_dir}/root-image",upperdir="$1",workdir="${work_dir}/work" "$1" } umount_image(){ diff --git a/lib/util-iso.sh b/lib/util-iso.sh index 8ae9eee..4a13189 100644 --- a/lib/util-iso.sh +++ b/lib/util-iso.sh @@ -116,8 +116,8 @@ make_checksum(){ gen_iso_fn(){ local vars=() name vars+=("${iso_name}") - [[ -n ${custom} ]] && vars+=("${custom}") - [[ ${edition} == 'minimal' ]] && vars+=("${edition}") +# [[ -n ${profile} ]] && vars+=("${profile}") +# [[ ${edition} == 'minimal' ]] && vars+=("${edition}") [[ ${initsys} == 'openrc' ]] && vars+=("${initsys}") vars+=("${dist_release}") vars+=("${arch}") @@ -148,17 +148,17 @@ make_image_root() { make_image_custom() { if [[ ! -e ${work_dir}/build.${FUNCNAME} ]]; then - msg "Prepare [Desktop installation] (%s-image)" "${custom}" - local path="${work_dir}/${custom}-image" + msg "Prepare [Desktop installation] (%s-image)" "${profile}" + local path="${work_dir}/${profile}-image" mkdir -p ${path} mount_image "${path}" chroot_create "${path}" "${packages}" - pacman -Qr "${path}" > "${path}/${custom}-image-pkgs.txt" - cp "${path}/${custom}-image-pkgs.txt" ${iso_dir}/$(gen_iso_fn)-pkgs.txt - [[ -e ${profile_dir}/${custom}-overlay ]] && copy_overlay "${profile_dir}/${custom}-overlay" "${path}" + pacman -Qr "${path}" > "${path}/${profile}-image-pkgs.txt" + cp "${path}/${profile}-image-pkgs.txt" ${iso_dir}/$(gen_iso_fn)-pkgs.txt + [[ -e ${profile_dir}/${profile}-overlay ]] && copy_overlay "${profile_dir}/${profile}-overlay" "${path}" configure_custom_image "${path}" ${is_custom_pac_conf} && clean_pacman_conf "${path}" @@ -166,7 +166,7 @@ make_image_custom() { clean_up_image "${path}" : > ${work_dir}/build.${FUNCNAME} - msg "Done [Desktop installation] (%s-image)" "${custom}" + msg "Done [Desktop installation] (%s-image)" "${profile}" fi } @@ -461,12 +461,6 @@ check_custom_pacman_conf(){ fi } -get_custom(){ - local name=${1##*/} - name=${name#*-} - echo ${name,,} -} - check_profile(){ local keyfiles=("${profile_dir}/mkinitcpio.conf" "${profile_dir}/Packages-Root" @@ -504,8 +498,6 @@ check_profile(){ esac done - custom=$(get_custom "${packages_custom}") - [[ -f "${profile_dir}/Packages-Mhwd" ]] && packages_mhwd=${profile_dir}/Packages-Mhwd } diff --git a/lib/util-publish.sh b/lib/util-publish.sh index a05e9aa..6b1eb99 100644 --- a/lib/util-publish.sh +++ b/lib/util-publish.sh @@ -33,7 +33,7 @@ gen_iso_fn(){ local vars=() name vars+=("${iso_name}") [[ -n ${1} ]] && vars+=("${1}") - [[ ${edition} == 'minimal' ]] && vars+=("${edition}") + #[[ ${edition} == 'minimal' ]] && vars+=("${edition}") [[ ${initsys} == 'openrc' ]] && vars+=("${initsys}") vars+=("${dist_release}") vars+=("${arch}")