From f820ab32d44e72512dfe499c56b05cba87d74dcb Mon Sep 17 00:00:00 2001 From: stevleibelt Date: Thu, 21 Nov 2024 10:50:41 +0100 Subject: [PATCH] Add first try to reduce iso size plus add todo --- CHANGELOG.md | 13 +++++++++---- build.sh | 37 ++++++++++++++++++++++++++++++++++++- 2 files changed, 45 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1277e22..f0d6939 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -15,13 +15,15 @@ and this project adheres to [Semantic Versioning](http://semver.org/). * [Link](https://end.re/blog/ebp036_archzfs-repo-for-kernels/) * [Source](https://github.com/archzfs/archzfs/issues/467#issuecomment-1332029677) * Add flag `-c|--cleanup` for `build.sh` -* Add an arch installer like: - * [archinstall](https://github.com/archlinux/archinstall) - * [anarchy installer](https://anarchyinstaller.gitlab.io/) - * [alci](https://alci.online/) ### To Change +* Reduce the iso size since this is way about 2 GiB while the official image has a size of 1.1 GiB by checking: + * Compare installed packages (mount/start official iso and run `pacman -Qq` and do the same on our build) + * Check if we can remove HOOKS in `airootfs/etc/mkinitcpio.conf` + * Check if official image also has that high amount of firmware + * Check if lts image contains non-lts kernel by mistake + * Check `releng/packages.x86_64` if we really need all in there * Apply [shellcheck](https://github.com/koalaman/shellcheck) to all scripts * Manipulate `dynamic_dat/releng/profiledef.sh` before running the iso build process * [issue/9](https://github.com/stevleibelt/arch-linux-live-cd-iso-with-zfs/issues/9) @@ -41,6 +43,9 @@ and this project adheres to [Semantic Versioning](http://semver.org/). ### Added in unreleased +* Add removal of `.git` directories for all "batteries included" scripts +* Add cleanup section in build process to reduce iso size + ### Changed in unreleased * Update build section diff --git a/build.sh b/build.sh index ce6fb01..ec7a7c9 100755 --- a/build.sh +++ b/build.sh @@ -16,6 +16,34 @@ set -o history -o histexpand # copy all command output to a log file exec &> >(tee "build.sh.log") +#### +# @param +#### +function remove_files () +{ + _echo_if_be_verbose ":: Starting removing files" + + #bo: variable + local PATH_TO_THE_ARCHLIVE_ROOT + + PATH_TO_THE_ARCHLIVE_ROOT=${1:-""} + + if [[ ! -d ${PATH_TO_THE_ARCHLIVE_ROOT} ]]; + then + echo " Invalid path to the archlive provided >>${PATH_TO_THE_ARCHLIVE_ROOT}<< is not a directory." + + exit 1 + else + _echo_if_be_verbose " PATH_TO_THE_ARCHLIVE_ROOT >>${PATH_TO_THE_ARCHLIVE_ROOT}<<." + fi + #bo: variable + + rm -fr "${PATH_TO_THE_ARCHLIVE_ROOT}/var/lib/pacman/local/*" + rm -fr "${PATH_TO_THE_ARCHLIVE_ROOT}/var/lib/pacman/sync/*" + rm -fr "${PATH_TO_THE_ARCHLIVE_ROOT}/var/log/*.log" + + _echo_if_be_verbose ":: Finished removing files" +} #### # @param - this is not >>/<< but >>/root<< #### @@ -62,14 +90,17 @@ function add_files () _echo_if_be_verbose " Adding repository >>arch-linux-configuration<< " git clone https://github.com/stevleibelt/arch-linux-configuration "${PATH_TO_THE_ARCHLIVE_ROOT_USER}/software/arch-linux-configuration/" exit_if_last_exit_code_is_not_zero ${?} "Checkout and creation of directory >>${PATH_TO_THE_ARCHLIVE_ROOT_USER}/software/arch-linux-configuration<< failed." + rm -fr "${PATH_TO_THE_ARCHLIVE_ROOT_USER}/software/arch-linux-configuration/.git" _echo_if_be_verbose " Adding repository >>arch-linux-live-cd-zfs-setup<< " git clone https://github.com/stevleibelt/arch-linux-live-cd-zfs-setup "${PATH_TO_THE_ARCHLIVE_ROOT_USER}/software/arch-linux-live-cd-zfs-setup/" exit_if_last_exit_code_is_not_zero ${?} "Checkout and creation of directory >>${PATH_TO_THE_ARCHLIVE_ROOT_USER}/software/arch-linux-live-cd-zfs-setup<< failed." + rm -fr "${PATH_TO_THE_ARCHLIVE_ROOT_USER}/software/arch-linux-live-cd-zfs-setup/.git" _echo_if_be_verbose " Adding repository >>downgrade<< " git clone https://github.com/archlinux-downgrade/downgrade "${PATH_TO_THE_ARCHLIVE_ROOT_USER}/software/downgrade/" exit_if_last_exit_code_is_not_zero ${?} "Checkout and creation of directory >>${PATH_TO_THE_ARCHLIVE_ROOT_USER}/software/downgrade<< failed." + rm -fr "${PATH_TO_THE_ARCHLIVE_ROOT_USER}/software/downgrade/.git" _echo_if_be_verbose " Adding directory >>zfsbootmenu<< with latest EFI file " # ref: https://docs.zfsbootmenu.org/en/v2.2.x/guides/general/portable.html @@ -81,16 +112,19 @@ function add_files () _echo_if_be_verbose " Adding repository >>archinstall<< " git clone https://github.com/archlinux/archinstall "${PATH_TO_THE_ARCHLIVE_ROOT_USER}/software/archinstall/" exit_if_last_exit_code_is_not_zero ${?} "Checkout and creation of directory >>${PATH_TO_THE_ARCHLIVE_ROOT_USER}/software/archinstall<< failed." + rm -fr "${PATH_TO_THE_ARCHLIVE_ROOT_USER}/software/archinstall/.git" cp "${PATH_TO_THIS_SCRIPT}/source/start_archinstall.sh" "${PATH_TO_THE_ARCHLIVE_ROOT_USER}/software/archinstall/" exit_if_last_exit_code_is_not_zero ${?} "Copy of >>${PATH_TO_THIS_SCRIPT}/source/start_archinstall.sh<< to >>${PATH_TO_THE_ARCHLIVE_ROOT_USER}/software/archinstall/<< failed." _echo_if_be_verbose " Adding repository >>bulk_hdd_testing<< " git clone https://github.com/ezonakiusagi/bht "${PATH_TO_THE_ARCHLIVE_ROOT_USER}/software/bulk_hdd_testing/" exit_if_last_exit_code_is_not_zero ${?} "Checkout and creation of directory >>${PATH_TO_THE_ARCHLIVE_ROOT_USER}/software/bulk_hdd_testing<< failed." + rm -fr "${PATH_TO_THE_ARCHLIVE_ROOT_USER}/software/bulk_hdd_testing/.git" _echo_if_be_verbose " Adding repository >>general_howtos<< " git clone https://github.com/stevleibelt/general_howtos "${PATH_TO_THE_ARCHLIVE_ROOT_USER}/document/general_howtos/" exit_if_last_exit_code_is_not_zero ${?} "Checkout and creation of directory >>${PATH_TO_THE_ARCHLIVE_ROOT_USER}/document/general_howtos<< failed." + rm -fr "${PATH_TO_THE_ARCHLIVE_ROOT_USER}/document/general_howtos/.git" _echo_if_be_verbose " Adding script >>create_efibootmgr_entry.sh<< " cp "${PATH_TO_THIS_SCRIPT}/source/create_efibootmgr_entry.sh" "${PATH_TO_THE_ARCHLIVE_ROOT_USER}/software/" @@ -1079,7 +1113,6 @@ function _main () add_packages_and_repository "${PATH_TO_THE_PROFILE_DIRECTORY}" "${REPO_INDEX}" fi - #@todo add_files "${PATH_TO_THE_PROFILE_DIRECTORY}/airootfs/root" if [[ ${KERNEL} != 'linux' ]]; @@ -1137,6 +1170,8 @@ function _main () PATH_TO_PROFILEDEF="${PATH_TO_THE_PROFILE_DIRECTORY}/profiledef.sh" sed -i "s/iso_name=\"archlinux\"/iso_name=\"${BUILD_FILE_NAME}\"/" "${PATH_TO_PROFILEDEF}" # eo: profiledef adaptation + + remove_files "${PATH_TO_THE_PROFILE_DIRECTORY}/airootfs" build_archiso "${PATH_TO_THE_DYNAMIC_DATA_DIRECTORY}/work" "${PATH_TO_THE_OUTPUT_DIRECTORY}" "${PATH_TO_THE_PROFILE_DIRECTORY}" "${ISO_FILE_PATH}" "${SHA512_FILE_PATH}"