From 1573ed33df6e269124a878887b863e5e40c8c565 Mon Sep 17 00:00:00 2001 From: udeved Date: Mon, 11 May 2015 18:31:41 +0200 Subject: [PATCH] [util*] do some cleaning --- lib/util-iso-image.sh | 3 ++ lib/util-iso.sh | 65 ++++++++++++------------------------------- 2 files changed, 21 insertions(+), 47 deletions(-) diff --git a/lib/util-iso-image.sh b/lib/util-iso-image.sh index c5a099e..ab0e754 100644 --- a/lib/util-iso-image.sh +++ b/lib/util-iso-image.sh @@ -358,4 +358,7 @@ clean_up_image(){ 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 64312ae..be38c2f 100644 --- a/lib/util-iso.sh +++ b/lib/util-iso.sh @@ -151,53 +151,43 @@ download_to_cache(){ # $1: image path # $2: packages make_chroot(){ - #set locale.gen - local flag - if [ "$1" == "${work_dir}/root-image" ]; then - flag="-L" - fi - + [[ "$1" == "${work_dir}/root-image" ]] && local flag="-L" setarch "${ARCH}" \ mkchroot -C ${pacman_conf} \ -S ${mirrors_conf} \ ${flag} \ - "$1" $2 || die "Failed to retrieve one or more packages!" + "$1" "$2" || die "Failed to retrieve one or more packages!" fi - - # Cleanup - find "${work_dir}" -name *.pacnew -name *.pacsave -name *.pacorig -delete } # $1: image path squash_image_dir() { - if [ ! -d "$1" ]; then + if [[ ! -d "$1" ]]; then error "$1 is not a directory" return 1 fi - local sq_img="${work_dir}/iso/${INSTALL_DIR}/${ARCH}/$(basename ${1}).sqfs" + local timer=$(get_timer) + local sq_img="${work_dir}/iso/${iso_name}/${arch}/$(basename ${1}).sqfs" msg "Generating SquashFS image for '${1}'" - if [ -e "${sq_img}" ]; then - dirhaschanged=$(find ${1} -newer ${sqimg}) + if [[ -f "${sq_img}" ]]; then + local has_changed_dir=$(find ${1} -newer ${sq_img}) msg2 "Possible changes for ${1}..." >> /tmp/buildiso.debug - msg2 "${dirhaschanged}" >> /tmp/buildiso.debug - if [ ! -z "${dirhaschanged}" ]; then + msg2 "${has_changed_dir}" >> /tmp/buildiso.debug + if [[ -n "${has_changed_dir}" ]]; then msg2 "SquashFS image '${sq_img}' is not up to date, rebuilding..." - rm "${sqimg}" + rm "${sq_img}" else msg2 "SquashFS image '${sq_img}' is up to date, skipping." return fi fi - + local highcomp=" -b 256K -Xbcj x86" + [[ "${iso_compression}" != "xz" ]] && highcomp="" msg2 "Creating SquashFS image. This may take some time..." - start=$(date +%s) - - mksquashfs "${1}" "${sqimg}" -noappend -comp "${COMPRESSION}" ${HIGHCOMP} - - minutes=$(echo $start $(date +%s) | awk '{ printf "%0.2f",($2-$1)/60 }') - msg "Image creation done in $minutes minutes." + mksquashfs "${1}" "${sq_img}" -noappend -comp "${iso_compression}" "${highcomp}" + msg3 "Time ${FUNCNAME}: $(elapsed_time ${timer}) minutes" } # Build ISO @@ -214,28 +204,15 @@ make_iso() { squash_image_dir "$d" fi done - msg "Making bootable image" - # Sanity checks - [[ ! -d "${work_dir}/iso" ]] && die "${work_dir}/iso doesn't exist. What did you do?!" + [[ ! -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 -# if [[ ! -f ${work_dir}/iso/isolinux/isolinux.cfg ]]; then -# die "${work_dir}/iso/isolinux/isolinux.cfg, doesn't exist." -# fi -# -# if [ ! -f "${work_dir}/iso/isolinux/isolinux.bin" ]; then -# die "${work_dir}/iso/isolinux/isolinux.bin, doesn't exist." -# fi -# if [ ! -f "${work_dir}/iso/isolinux/isohdpfx.bin" ]; then -# die "${work_dir}/iso/isolinux/isohdpfx.bin, doesn't exist." -# fi - local efi_boot_args="" # If exists, add an EFI "El Torito" boot image (FAT filesystem) to ISO-9660 image. @@ -246,13 +223,7 @@ make_iso() { "-isohybrid-gpt-basdat" \ "-no-emul-boot") fi - msg "Creating ISO image..." - ## Generate the BIOS+ISOHYBRID CD image using xorriso (extra/libisoburn package) in mkisofs emulation mode - #_qflag="" -# if ${QUIET}; then -# _qflag="-quiet" -# fi xorriso -as mkisofs \ -iso-level 3 -rock -joliet \ -max-iso9660-filenames -omit-period \ @@ -330,7 +301,7 @@ make_image_root() { if [[ ! -e ${work_dir}/build.${FUNCNAME} ]]; then msg "Prepare [Base installation] (root-image)" local path="${work_dir}/root-image" -# mkiso ${create_args[*]} -p "${packages}" -i "root-image" create "${work_dir}" || mkiso_error_handler + make_chroot "${path}" "${packages}" pacman -Qr "${path}" > "${path}/root-image-pkgs.txt" configure_lsb "${path}" copy_overlay_root "${path}" @@ -347,7 +318,7 @@ make_image_custom() { mkdir -p ${path} umount_image_handler aufs_mount_root_image "${path}" -# mkiso ${create_args[*]} -i "${custom}-image" -p "${packages}" create "${work_dir}" || mkiso_error_handler + make_chroot "${path}" "${packages}" 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 @@ -372,7 +343,7 @@ make_image_livecd() { else aufs_mount_root_image "${path}" fi -# mkiso ${create_args[*]} -i "livecd-image" -p "${packages}" create "${work_dir}" || mkiso_error_handler + make_chroot "${path}" "${packages}" pacman -Qr "${path}" > "${path}/livecd-image-pkgs.txt" copy_overlay_livecd "${path}" # copy over setup helpers and config loader