[util*] do some cleaning

This commit is contained in:
udeved 2015-05-11 18:31:41 +02:00 committed by Ramon Buldó
parent d4913d1134
commit 84c20f14d7
2 changed files with 21 additions and 47 deletions

View file

@ -358,4 +358,7 @@ clean_up_image(){
find "$1/var/log" -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/var/tmp" -mindepth 1 -delete &>/dev/null
find "$1/tmp" -mindepth 1 -delete &>/dev/null find "$1/tmp" -mindepth 1 -delete &>/dev/null
# find "${work_dir}" -name *.pacnew -name *.pacsave -name *.pacorig -delete
} }

View file

@ -151,53 +151,43 @@ download_to_cache(){
# $1: image path # $1: image path
# $2: packages # $2: packages
make_chroot(){ make_chroot(){
#set locale.gen [[ "$1" == "${work_dir}/root-image" ]] && local flag="-L"
local flag
if [ "$1" == "${work_dir}/root-image" ]; then
flag="-L"
fi
setarch "${ARCH}" \ setarch "${ARCH}" \
mkchroot -C ${pacman_conf} \ mkchroot -C ${pacman_conf} \
-S ${mirrors_conf} \ -S ${mirrors_conf} \
${flag} \ ${flag} \
"$1" $2 || die "Failed to retrieve one or more packages!" "$1" "$2" || die "Failed to retrieve one or more packages!"
fi fi
# Cleanup
find "${work_dir}" -name *.pacnew -name *.pacsave -name *.pacorig -delete
} }
# $1: image path # $1: image path
squash_image_dir() { squash_image_dir() {
if [ ! -d "$1" ]; then if [[ ! -d "$1" ]]; then
error "$1 is not a directory" error "$1 is not a directory"
return 1 return 1
fi 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}'" msg "Generating SquashFS image for '${1}'"
if [ -e "${sq_img}" ]; then if [[ -f "${sq_img}" ]]; then
dirhaschanged=$(find ${1} -newer ${sqimg}) local has_changed_dir=$(find ${1} -newer ${sq_img})
msg2 "Possible changes for ${1}..." >> /tmp/buildiso.debug msg2 "Possible changes for ${1}..." >> /tmp/buildiso.debug
msg2 "${dirhaschanged}" >> /tmp/buildiso.debug msg2 "${has_changed_dir}" >> /tmp/buildiso.debug
if [ ! -z "${dirhaschanged}" ]; then if [[ -n "${has_changed_dir}" ]]; then
msg2 "SquashFS image '${sq_img}' is not up to date, rebuilding..." msg2 "SquashFS image '${sq_img}' is not up to date, rebuilding..."
rm "${sqimg}" rm "${sq_img}"
else else
msg2 "SquashFS image '${sq_img}' is up to date, skipping." msg2 "SquashFS image '${sq_img}' is up to date, skipping."
return return
fi fi
fi fi
local highcomp=" -b 256K -Xbcj x86"
[[ "${iso_compression}" != "xz" ]] && highcomp=""
msg2 "Creating SquashFS image. This may take some time..." msg2 "Creating SquashFS image. This may take some time..."
start=$(date +%s) mksquashfs "${1}" "${sq_img}" -noappend -comp "${iso_compression}" "${highcomp}"
msg3 "Time ${FUNCNAME}: $(elapsed_time ${timer}) minutes"
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."
} }
# Build ISO # Build ISO
@ -214,28 +204,15 @@ make_iso() {
squash_image_dir "$d" squash_image_dir "$d"
fi fi
done done
msg "Making bootable image" msg "Making bootable image"
# Sanity checks # 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 if [[ -f "${cache_dir_iso}/${iso_file}" ]]; then
msg2 "Removing existing bootable image..." msg2 "Removing existing bootable image..."
rm -rf "${cache_dir_iso}/${iso_file}" rm -rf "${cache_dir_iso}/${iso_file}"
fi 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="" local efi_boot_args=""
# If exists, add an EFI "El Torito" boot image (FAT filesystem) to ISO-9660 image. # If exists, add an EFI "El Torito" boot image (FAT filesystem) to ISO-9660 image.
@ -246,13 +223,7 @@ make_iso() {
"-isohybrid-gpt-basdat" \ "-isohybrid-gpt-basdat" \
"-no-emul-boot") "-no-emul-boot")
fi fi
msg "Creating ISO image..." 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 \ xorriso -as mkisofs \
-iso-level 3 -rock -joliet \ -iso-level 3 -rock -joliet \
-max-iso9660-filenames -omit-period \ -max-iso9660-filenames -omit-period \
@ -330,7 +301,7 @@ make_image_root() {
if [[ ! -e ${work_dir}/build.${FUNCNAME} ]]; then if [[ ! -e ${work_dir}/build.${FUNCNAME} ]]; then
msg "Prepare [Base installation] (root-image)" msg "Prepare [Base installation] (root-image)"
local path="${work_dir}/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" pacman -Qr "${path}" > "${path}/root-image-pkgs.txt"
configure_lsb "${path}" configure_lsb "${path}"
copy_overlay_root "${path}" copy_overlay_root "${path}"
@ -347,7 +318,7 @@ make_image_custom() {
mkdir -p ${path} mkdir -p ${path}
umount_image_handler umount_image_handler
aufs_mount_root_image "${path}" 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" 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 cp "${path}/${custom}-image-pkgs.txt" ${cache_dir_iso}/${iso_name}-${custom}-${dist_release}-${arch}-pkgs.txt
[[ -d ${custom}-overlay ]] && copy_overlay_custom [[ -d ${custom}-overlay ]] && copy_overlay_custom
@ -372,7 +343,7 @@ make_image_livecd() {
else else
aufs_mount_root_image "${path}" aufs_mount_root_image "${path}"
fi 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" pacman -Qr "${path}" > "${path}/livecd-image-pkgs.txt"
copy_overlay_livecd "${path}" copy_overlay_livecd "${path}"
# copy over setup helpers and config loader # copy over setup helpers and config loader