logo

live-bootstrap

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

clean_sources.sh (1610B)


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