logo

live-bootstrap

Mirror of <https://github.com/fosslinux/live-bootstrap>

clean_sources.sh (1552B)


  1. # SPDX-FileCopyrightText: 2023 Eduardo Sánchez Muñoz <eduardosm-dev@e64.io>
  2. # SPDX-FileCopyrightText: 2024 fosslinux <fosslinux@aussies.space>
  3. #
  4. # SPDX-License-Identifier: GPL-3.0-or-later
  5. # Delete sources of packages before linux kernel
  6. get_source_filename() {
  7. local url="${1}"
  8. local fname="${3}"
  9. # Default to basename of url if not given
  10. echo "${fname:-$(basename "${url}")}"
  11. }
  12. # List all packages from linux kernel onwards
  13. # Ideally, we would use arrays here, but they are not supported by
  14. # the bash version we have at this point.
  15. pkgs="$(awk '/^build:/ { print $2 }' "${SRCDIR}/manifest" | awk '/^linux-[0-9]/,EOF { print $0 }')"
  16. # Gather source names for all packages in pkgs, which we want to keep
  17. keep_sources=""
  18. for pkg in ${pkgs}; do
  19. while read line; do
  20. keep_sources="${keep_sources} $(get_source_filename ${line})"
  21. done < "${SRCDIR}/${pkg}/sources"
  22. done
  23. for source in "${DISTFILES}/"*; do
  24. source_name="$(basename "${source}")"
  25. for keep_source in ${keep_sources}; do
  26. if [ "${keep_source}" = "${source_name}" ]; then
  27. # Countinue the outer loop to skip deletion
  28. continue 2
  29. fi
  30. done
  31. # Delete this source
  32. rm "${source}"
  33. done
  34. if [ -e "/external/repo-preseeded/linux-4.14.336_0.tar.bz2" ]; then
  35. # This is done in src_extract out of necessity usually -- I can't think of a better solution :(
  36. rm -f "${DISTFILES}/linux-4.14.336.tar.xz"
  37. fi
  38. unset get_source_filename
  39. unset pkgs pkg line
  40. unset keep_sources keep_source
  41. unset source source_name