commit: 9042539165dbeb4854af01dd8c58dc753408528b
parent 9179f4bd013fbd323d11d861a0c15f37a94f8c5b
Author: Eduardo Sánchez Muñoz <eduardosm-dev@e64.io>
Date: Thu, 21 Dec 2023 17:24:33 +0100
Avoid deleting sources that will be needed in future builds
Diffstat:
4 files changed, 44 insertions(+), 23 deletions(-)
diff --git a/steps/improve/clean_ram.sh b/steps/improve/clean_ram.sh
@@ -1,15 +0,0 @@
-# SPDX-FileCopyrightText: 2023 fosslinux <fosslinux@aussies.space>
-#
-# SPDX-License-Identifier: GPL-3.0-or-later
-
-# Save because linux deletes all distfiles to save space
-cp "${DISTFILES}"/musl-1.2.4.tar.gz /tmp
-cp "${DISTFILES}"/curl-7.88.1.tar.bz2 /tmp
-
-# Clear up some RAM space
-grep --no-filename '^build' "${SOURCES}"/run*.sh | grep -v musl-1.2.4 | sed "s/build //" | sed "s/ .*$//" | while read -r p ; do
- rm -rf "${SOURCES:?}/${p:?}"
-done
-
-mv /tmp/musl-1.2.4.tar.gz "${DISTFILES}"
-mv /tmp/curl-7.88.1.tar.bz2 "${DISTFILES}"
diff --git a/steps/improve/clean_sources.sh b/steps/improve/clean_sources.sh
@@ -0,0 +1,43 @@
+# SPDX-FileCopyrightText: 2023 Eduardo Sánchez Muñoz <eduardosm-dev@e64.io>
+#
+# SPDX-License-Identifier: GPL-3.0-or-later
+
+# Delete sources of packages before linux kernel
+
+get_source_filename() {
+ local url="${1}"
+ local fname="${3}"
+ # Default to basename of url if not given
+ echo "${fname:-$(basename "${url}")}"
+}
+
+# List all packages from linux kernel onwards
+# Ideally, we would use arrays here, but they are not supported by
+# the bash version we have at this point.
+pkgs="$(awk '/^build:/ { print $2 }' "${SRCDIR}/manifest" | awk '/^linux-[0-9]/,EOF { print $0 }')"
+
+# Gather source names for all packages in pkgs, which we want to keep
+keep_sources=""
+for pkg in ${pkgs}; do
+ while read line; do
+ keep_sources="${keep_sources} $(get_source_filename ${line})"
+ done < "${SRCDIR}/${pkg}/sources"
+done
+
+for source in "${DISTFILES}/"*; do
+ source_name="$(basename "${source}")"
+ for keep_source in ${keep_sources}; do
+ if [ "${keep_source}" = "${source_name}" ]; then
+ # Countinue the outer loop to skip deletion
+ continue 2
+ fi
+ done
+
+ # Delete this source
+ rm "${source}"
+done
+
+unset get_source_filename
+unset pkgs pkg line
+unset keep_sources keep_source
+unset source source_name
diff --git a/steps/linux-4.9.10/pass1.sh b/steps/linux-4.9.10/pass1.sh
@@ -6,14 +6,6 @@
# XXX: Fix package after builder-hex0
src_unpack() {
- # Remove all previous source tarballs
- mkdir /tmp/keep
- for keep in deblob-4.9 ${pkg}.tar.gz musl-1.2.4.tar.gz curl-7.88.1.tar.bz2; do
- mv "${DISTFILES}/${keep}" /tmp/keep
- done
- rm -r "${DISTFILES}/"*
- mv /tmp/keep/* "${DISTFILES}"
-
mkdir "${pkg}"
mv "${DISTFILES}/deblob-4.9" "${pkg}/"
default || true # Predictable link errors - not a problem
diff --git a/steps/manifest b/steps/manifest
@@ -114,6 +114,7 @@ build: bc-1.07.1
define: BUILD_LINUX = ( CHROOT == False || BUILD_KERNELS == True )
build: kexec-linux-1.0.0 ( BUILD_LINUX == True )
build: kexec-tools-2.0.22 ( BUILD_LINUX == True )
+improve: clean_sources
build: linux-4.9.10 ( BUILD_LINUX == True )
jump: break ( INTERNAL_CI == pass1 )
jump: linux ( CHROOT == False )