[util-iso*] some code simplification

This commit is contained in:
udeved 2016-02-25 18:37:29 +01:00
parent 61b06a4602
commit 8faa9c5400
8 changed files with 23 additions and 31 deletions

View file

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

View file

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

View file

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

View file

@ -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(){

View file

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

View file

@ -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(){

View file

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

View file

@ -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}")