diff options
author | Lyndon Brown <jnqnfe@gmail.com> | 2020-02-12 17:17:34 +0000 |
---|---|---|
committer | Luca Boccassi <bluca@debian.org> | 2020-03-05 22:13:57 +0000 |
commit | 4d0c3a1169760ec3c29ee756c13b37569d1deb94 (patch) | |
tree | 330bfc1984698337f3321c767806e12fc96b0b8c /functions | |
parent | 7867641fd0e23c290a5ae2b8f04f685948b917e3 (diff) | |
download | vyos-live-build-4d0c3a1169760ec3c29ee756c13b37569d1deb94.tar.gz vyos-live-build-4d0c3a1169760ec3c29ee756c13b37569d1deb94.zip |
firmware: enable caching for archive content file with firmware lists
the existing logic for obtaining a list of firmware packages always
downloaded a fresh copy of the archive content file, deleting the file
already in the cache. here we move to actually making use of the cache.
this helps when building multiple times, at least for the same distro. the
package list obtained is rarely going to change after all. it could of
course differ between distros, but the cache is per-distro, as it has
always been.
we of course here switch to caching each of the archive-area files
individually rather than having one file that gets overwritten (or
appended to in the case of when we kept the decompressed file).
Gbp-Dch: Short
Closes: #952911
Diffstat (limited to 'functions')
-rwxr-xr-x | functions/firmwarelists.sh | 25 |
1 files changed, 19 insertions, 6 deletions
diff --git a/functions/firmwarelists.sh b/functions/firmwarelists.sh index 3c1f9a936..fdd9d67ed 100755 --- a/functions/firmwarelists.sh +++ b/functions/firmwarelists.sh @@ -20,19 +20,32 @@ Firmware_List_From_Contents () { for _ARCHIVE_AREA in ${ARCHIVE_AREAS} do - local CONTENTS_FILE="cache/contents.chroot/contents.${DISTRO_CHROOT}.${LB_ARCHITECTURES}.gz" local CONTENTS_URL="${MIRROR_CHROOT}/dists/${DISTRO_CHROOT}/${_ARCHIVE_AREA}/Contents-${LB_ARCHITECTURES}.gz" + local CONTENTS_FILEDIR="cache/contents.chroot/${DISTRO_CHROOT}/${_ARCHIVE_AREA}" + local CONTENTS_FILE="${CONTENTS_FILEDIR}/contents-${LB_ARCHITECTURES}.gz" - # Ensure fresh - rm -f "${CONTENTS_FILE}" + mkdir -p "${CONTENTS_FILEDIR}" - wget ${WGET_OPTIONS} "${CONTENTS_URL}" -O "${CONTENTS_FILE}" + # Purge from cache if not wanting to use from cache, ensuring fresh copy + if [ "${LB_CACHE}" != "true" ] + then + rm -f "${CONTENTS_FILE}" + fi + + # If not cached, download + if [ ! -e "${CONTENTS_FILE}" ] + then + wget ${WGET_OPTIONS} "${CONTENTS_URL}" -O "${CONTENTS_FILE}" + fi local PACKAGES PACKAGES="$(gunzip -c "${CONTENTS_FILE}" | awk '/^lib\/firmware/ { print $2 }' | sort -u )" FIRMWARE_PACKAGES="${FIRMWARE_PACKAGES} ${PACKAGES}" - # Don't waste disk space preserving since always getting fresh - rm -f "${CONTENTS_FILE}" + # Don't waste disk space, if not making use of caching + if [ "${LB_CACHE}" != "true" ] + then + rm -f "${CONTENTS_FILE}" + fi done } |