From bd1f7bf8fae6e40e7bbb0e03db6b6d8b790fbc75 Mon Sep 17 00:00:00 2001 From: udeved Date: Mon, 11 May 2015 23:32:40 +0200 Subject: [PATCH] [buildiso] drop unused code; some cosmetics --- bin/buildiso.in | 18 ++------- lib/util-iso-image.sh | 24 ----------- lib/util-iso.sh | 92 ++++++++++++++++++++++++------------------- lib/util.sh | 8 ---- 4 files changed, 55 insertions(+), 87 deletions(-) diff --git a/bin/buildiso.in b/bin/buildiso.in index 0559d1a..be2126b 100755 --- a/bin/buildiso.in +++ b/bin/buildiso.in @@ -25,7 +25,6 @@ show_profile(){ load_profile "$1" msg2 "work_dir: ${work_dir}" msg2 "iso_file: ${iso_file}" - #msg2 "pacman_conf: ${pacman_conf}" msg2 "is_custom_pac_conf: ${is_custom_pac_conf}" msg2 "initsys: ${initsys}" @@ -88,7 +87,6 @@ display_settings(){ msg2 "clean_first: ${clean_first}" msg2 "clean_cache_xorg: ${clean_cache_xorg}" msg2 "clean_cache_lng: ${clean_cache_lng}" - msg2 "clean_cache_iso: ${clean_cache_iso}" msg2 "images_only: ${images_only}" msg2 "iso_only: ${iso_only}" @@ -107,6 +105,8 @@ display_settings(){ msg "ISO SETTINGS:" msg2 "iso_label: ${iso_label}" msg2 "iso_name: ${iso_name}" + msg2 "iso_publisher: ${iso_publisher}" + msg2 "iso_app_id: ${iso_app_id}" msg2 "iso_compression: ${iso_compression}" msg2 "iso_checksum: ${iso_checksum}" @@ -120,7 +120,6 @@ load_config "${USER_CONFIG}/manjaro-tools.conf" load_config "${SYSCONFDIR}/manjaro-tools.conf" clean_first=true -clean_cache_iso=true clean_cache_xorg=false clean_cache_lng=false @@ -137,9 +136,7 @@ usage() { echo " -a Arch [default: ${arch}]" echo " -b Branch [default: ${branch}]" echo ' -r Chroots directory' - echo ' -k Custom pacman repo to keep' echo " [default: ${chroots_iso}]" - echo ' -w Disable clean iso cache' echo ' -c Disable clean work dir' echo ' -x Clean xorg cache' echo ' -l Clean lng cache' @@ -155,7 +152,7 @@ usage() { orig_argv=("$@") -opts='p:a:b:r:k:cxlisqwLh' +opts='p:a:b:r:cxlisqh' while getopts "${opts}" arg; do case "${arg}" in @@ -165,7 +162,6 @@ while getopts "${opts}" arg; do r) chroots_iso="$OPTARG" ;; k) keep_repo="$OPTARG" ;; c) clean_first=false ;; - w) clean_cache_iso=false;; x) clean_cache_xorg=true ;; l) clean_cache_lng=true ;; i) images_only=true ;; @@ -190,15 +186,9 @@ cache_dir_iso="${cache_dir}/iso" mirrors_conf="${PKGDATADIR}/pacman-mirrors-${branch}.conf" -# create_args+=(-v -a ${arch} -D ${iso_name} -M ${mirrors_conf}) - -# iso_args+=(-v -x -a ${arch} -D ${iso_name} -L ${iso_label} -c ${iso_compression}) - -# ${clean_cache_iso} && iso_args+=(-f) - check_root "$0" "${orig_argv[@]}" -check_run_dir +#check_run_dir eval_buildset "${buildset_iso}" "${sets_dir_iso}" diff --git a/lib/util-iso-image.sh b/lib/util-iso-image.sh index ab0e754..af1fb39 100644 --- a/lib/util-iso-image.sh +++ b/lib/util-iso-image.sh @@ -338,27 +338,3 @@ configure_xorg_drivers(){ touch $1/var/lib/mhwd/db/pci/graphic_drivers/nvidia-340xx/MHWDCONFIG fi } - -# $1: image path -clean_up_image(){ - msg2 "Cleaning up [$1]" - if [ -d "$1/boot/" ]; then - # remove the initcpio images that were generated for the host system - find "$1/boot" -name 'initramfs*.img' -delete &>/dev/null - fi - - [[ -f "$1/etc/locale.gen.bak" ]] \ - && mv "$1/etc/locale.gen.bak" "$1/etc/locale.gen" - [[ -f "$1/etc/locale.conf.bak" ]] \ - && mv "$1/etc/locale.conf.bak" "$1/etc/locale.conf" - - find "$1/var/lib/pacman" -maxdepth 1 -type f -delete &>/dev/null - find "$1/var/lib/pacman/sync" -delete &>/dev/null - find "$1/var/cache/pacman/pkg" -type f -delete &>/dev/null - find "$1/var/log" -type f -delete &>/dev/null - find "$1/var/tmp" -mindepth 1 -delete &>/dev/null - find "$1/tmp" -mindepth 1 -delete &>/dev/null - -# find "${work_dir}" -name *.pacnew -name *.pacsave -name *.pacorig -delete - -} diff --git a/lib/util-iso.sh b/lib/util-iso.sh index 8a10530..62fe3d3 100644 --- a/lib/util-iso.sh +++ b/lib/util-iso.sh @@ -13,11 +13,11 @@ [[ -r ${LIBDIR}/util-iso-boot.sh ]] && source ${LIBDIR}/util-iso-boot.sh [[ -r ${LIBDIR}/util-iso-calamares.sh ]] && source ${LIBDIR}/util-iso-calamares.sh -check_run_dir(){ - if [[ ! -f shared/Packages-Systemd ]] || [[ ! -f shared/Packages-Openrc ]];then - die "${0##*/} is not run in a valid iso-profiles folder!" - fi -} +# check_run_dir(){ +# if [[ ! -f shared/Packages-Systemd ]] || [[ ! -f shared/Packages-Openrc ]];then +# die "${0##*/} is not run in a valid iso-profiles folder!" +# fi +# } copy_overlay_root(){ msg2 "Copying overlay ..." @@ -189,31 +189,8 @@ squash_image_dir() { msg3 "Time ${FUNCNAME}: $(elapsed_time ${timer}) minutes" } -make_squash(){ - -} - -# Build ISO -make_iso() { - msg "Start [Build ISO]" - touch "${work_dir}/iso/.buildiso" - for d in $(find "${work_dir}" -maxdepth 1 -type d -name '[^.]*'); do - if [[ "$d" != "${work_dir}/iso" ]] && \ - [[ "$(basename "$d")" != "iso" ]] && \ - [[ "$(basename "$d")" != "efiboot" ]] && \ - [[ "$d" != "${work_dir}" ]]; then - squash_image_dir "$d" || die "Exit ..." - fi - done - msg "Making bootable image" - # Sanity checks - [[ ! -d "${work_dir}/iso" ]] && die "[${work_dir}/iso] doesn't exist. What did you do?!" - - if [[ -f "${cache_dir_iso}/${iso_file}" ]]; then - msg2 "Removing existing bootable image..." - rm -rf "${cache_dir_iso}/${iso_file}" - fi - +run_xorriso(){ + msg "Creating ISO image..." local efi_boot_args="" if [[ -f "${work_dir}/iso/EFI/miso/${iso_name}.img" ]]; then msg2 "Setting efi args. El Torito detected." @@ -222,13 +199,7 @@ make_iso() { "-isohybrid-gpt-basdat" \ "-no-emul-boot") fi - msg "Creating ISO image..." - # test msg2 - msg2 "iso_label: ${iso_label}" - msg2 "iso_name: ${iso_name}" - msg2 "iso_publisher: ${iso_publisher}" - msg2 "iso_app_id: ${iso_app_id}" - msg2 "iso_file: ${iso_file}" + xorriso -as mkisofs \ -iso-level 3 -rock -joliet \ -max-iso9660-filenames -omit-period \ @@ -245,6 +216,30 @@ make_iso() { ${efi_boot_args[@]} \ -output "${cache_dir_iso}/${iso_file}" \ "${work_dir}/iso/" +} + +# Build ISO +make_iso() { + msg "Start [Build ISO]" + touch "${work_dir}/iso/.buildiso" + for d in $(find "${work_dir}" -maxdepth 1 -type d -name '[^.]*'); do + if [[ "$d" != "${work_dir}/iso" ]] && \ + [[ "$(basename "$d")" != "iso" ]] && \ + [[ "$(basename "$d")" != "efiboot" ]] && \ + [[ "$d" != "${work_dir}" ]]; then + squash_image_dir "$d" || die "Exit ..." + fi + done + + msg "Making bootable image" + # Sanity checks + [[ ! -d "${work_dir}/iso" ]] && die "[${work_dir}/iso] doesn't exist. What did you do?!" + if [[ -f "${cache_dir_iso}/${iso_file}" ]]; then + msg2 "Removing existing bootable image..." + rm -rf "${cache_dir_iso}/${iso_file}" + fi + + run_xorriso chown -R "${OWNER}:users" "${cache_dir_iso}" msg "Done [Build ISO]" @@ -296,10 +291,22 @@ umount_image_handler(){ aufs_remove_image "${work_dir}/boot-image" } -# mkiso_error_handler(){ -# umount_image_handler -# die "Exiting..." -# } +# $1: image path +clean_up_image(){ + msg2 "Cleaning up [$1]" + [[ -d "$1/boot/" ]] && find "$1/boot" -name 'initramfs*.img' -delete &>/dev/null + [[ -f "$1/etc/locale.gen.bak" ]] && mv "$1/etc/locale.gen.bak" "$1/etc/locale.gen" + [[ -f "$1/etc/locale.conf.bak" ]] && mv "$1/etc/locale.conf.bak" "$1/etc/locale.conf" + + find "$1/var/lib/pacman" -maxdepth 1 -type f -delete &>/dev/null + find "$1/var/lib/pacman/sync" -delete &>/dev/null + find "$1/var/cache/pacman/pkg" -type f -delete &>/dev/null + find "$1/var/log" -type f -delete &>/dev/null + find "$1/var/tmp" -mindepth 1 -delete &>/dev/null + find "$1/tmp" -mindepth 1 -delete &>/dev/null + +# find "${work_dir}" -name *.pacnew -name *.pacsave -name *.pacorig -delete +} # Base installation (root-image) make_image_root() { @@ -308,6 +315,7 @@ make_image_root() { local path="${work_dir}/root-image" mkdir -p ${path} make_chroot "${path}" "${packages}" + clean_up_image "${path}" pacman -Qr "${path}" > "${path}/root-image-pkgs.txt" configure_lsb "${path}" copy_overlay_root "${path}" @@ -325,6 +333,7 @@ make_image_custom() { umount_image_handler aufs_mount_root_image "${path}" make_chroot "${path}" "${packages}" + clean_up_image "${path}" pacman -Qr "${path}" > "${path}/${custom}-image-pkgs.txt" cp "${path}/${custom}-image-pkgs.txt" ${cache_dir_iso}/${iso_name}-${custom}-${dist_release}-${arch}-pkgs.txt [[ -d ${custom}-overlay ]] && copy_overlay_custom @@ -350,6 +359,7 @@ make_image_livecd() { aufs_mount_root_image "${path}" fi make_chroot "${path}" "${packages}" + clean_up_image "${path}" pacman -Qr "${path}" > "${path}/livecd-image-pkgs.txt" copy_overlay_livecd "${path}" # copy over setup helpers and config loader diff --git a/lib/util.sh b/lib/util.sh index 5c90f7f..2ba523b 100644 --- a/lib/util.sh +++ b/lib/util.sh @@ -323,14 +323,6 @@ load_config(){ buildset_iso='default' fi -# if [[ -z ${clean_cache_xorg} ]];then -# clean_cache_xorg='true' -# fi -# -# if [[ -z ${clean_cache_lng} ]];then -# clean_cache_lng='true' -# fi - ##### iso settings ##### if [[ -z ${dist_release} ]];then