diff options
author | Lucio Andrés Illanes Albornoz <lucio@lucioillanes.de> | 2021-04-05 11:10:57 +0100 |
---|---|---|
committer | Lucio Andrés Illanes Albornoz <lucio@lucioillanes.de> | 2021-04-05 11:10:57 +0100 |
commit | 10ff54eb9e65ad8b20b3903206a42c6a267696ab (patch) | |
tree | 56cb29023d679d6ca034eea69cb37d544e9cae1a | |
parent | 64409f500604636c649603c4f54339a957fc3aed (diff) | |
download | midipix_build-10ff54eb9e65ad8b20b3903206a42c6a267696ab.tar.bz2 midipix_build-10ff54eb9e65ad8b20b3903206a42c6a267696ab.tar.xz |
subr/pkg_fetch_{download,extract}.subr: download into & auto-cleanup ${BUILD_DLCACHEDIR}/${PKG_NAME}/ vs. ${BUILD_DLCACHEDIR}/.
vars/{gcc,python[23]{,_host}}.vars: updated.
-rw-r--r-- | subr/pkg_fetch_download.subr | 37 | ||||
-rw-r--r-- | subr/pkg_fetch_extract.subr | 10 | ||||
-rw-r--r-- | vars/gcc.vars | 32 | ||||
-rw-r--r-- | vars/python2.vars | 2 | ||||
-rw-r--r-- | vars/python2_host.vars | 2 | ||||
-rw-r--r-- | vars/python3.vars | 2 | ||||
-rw-r--r-- | vars/python3_host.vars | 2 |
7 files changed, 63 insertions, 24 deletions
diff --git a/subr/pkg_fetch_download.subr b/subr/pkg_fetch_download.subr index 43f4388c..188c7f7b 100644 --- a/subr/pkg_fetch_download.subr +++ b/subr/pkg_fetch_download.subr @@ -2,18 +2,47 @@ # set +o errexit -o noglob -o nounset is assumed. # +pkg_fetch_download_dlcache_subdir() { + if [ -n "${PKG_INHERIT_FROM:-}" ]\ + && ! [ -e "${BUILD_DLCACHEDIR}/${PKG_NAME}" ]\ + && ! rtl_fileop ln_symbolic "${PKG_INHERIT_FROM}" "${BUILD_DLCACHEDIR}/${PKG_NAME}"; then + return 1; + elif [ -z "${PKG_INHERIT_FROM:-}" ]\ + && ! [ -e "${BUILD_DLCACHEDIR}/${PKG_NAME}" ]\ + && ! rtl_fileop mkdir "${BUILD_DLCACHEDIR}/${PKG_NAME}"; then + return 1; + else + return 0; + fi; +}; + pkg_fetch_download() { + local _fname=""; + if [ "${ARG_FETCH_FORCE:-}" != "offline" ]; then if [ -n "${PKG_URL:-}" ]; then - if ! rtl_fetch_url_wget \ - "${PKG_URL}" "${PKG_SHA256SUM}" "${BUILD_DLCACHEDIR}"\ + if ! pkg_fetch_download_dlcache_subdir; then + return 1; + elif ! rtl_fetch_url_wget \ + "${PKG_URL}" "${PKG_SHA256SUM}" "${BUILD_DLCACHEDIR}/${PKG_NAME}"\ "${PKG_FNAME}" "${PKG_NAME}" "${PKG_MIRRORS:-}"; then return 1; + else + for _fname in $(find \ + "${BUILD_DLCACHEDIR}/${PKG_NAME}" \ + -type f \ + -not -name "${PKG_FNAME}" \ + -not -name "${PKG_FNAME}.fetched"); do + rtl_log_msg notice "Deleting redundant file \`%s' for package \`%s'." "${_fname}" "${PKG_NAME}"; + rtl_fileop rm "${_fname}"; + done; fi; fi; if [ -n "${PKG_URLS_GIT:-}" ]; then - if ! rtl_fetch_urls_git \ - "${BUILD_DLCACHEDIR}" "${DEFAULT_GIT_ARGS}" "${PKG_BASE_DIR}"\ + if ! pkg_fetch_download_dlcache_subdir; then + return 1; + elif ! rtl_fetch_urls_git \ + "${BUILD_DLCACHEDIR}/${PKG_NAME}" "${DEFAULT_GIT_ARGS}" "${PKG_BASE_DIR}"\ "${PKG_NAME}" "${PKG_MIRRORS_GIT:-}" ${PKG_URLS_GIT}; then return 1; fi; diff --git a/subr/pkg_fetch_extract.subr b/subr/pkg_fetch_extract.subr index e91e7a6a..b86c490a 100644 --- a/subr/pkg_fetch_extract.subr +++ b/subr/pkg_fetch_extract.subr @@ -19,11 +19,11 @@ pkg_fetch_extract() { rtl_fileop cd "${_oldpwd}"; return 1; else case "$(pkgp_fetch_extract_type "${PKG_NAME}")" in - bz2) bunzip2 -d < "${BUILD_DLCACHEDIR}/${PKG_FNAME}" | tar -C "${PKG_BASE_DIR}" -xf -; ;; - gz) gunzip -d < "${BUILD_DLCACHEDIR}/${PKG_FNAME}" | tar -C "${PKG_BASE_DIR}" -xf -; ;; - lz) lzip -d < "${BUILD_DLCACHEDIR}/${PKG_FNAME}" | tar -C "${PKG_BASE_DIR}" -xf -; ;; - xz) xz -d < "${BUILD_DLCACHEDIR}/${PKG_FNAME}" | tar -C "${PKG_BASE_DIR}" -xf -; ;; - *) tar -C "${PKG_BASE_DIR}" -xf "${BUILD_DLCACHEDIR}/${PKG_FNAME}"; ;; + bz2) bunzip2 -d < "${BUILD_DLCACHEDIR}/${PKG_NAME}/${PKG_FNAME}" | tar -C "${PKG_BASE_DIR}" -xf -; ;; + gz) gunzip -d < "${BUILD_DLCACHEDIR}/${PKG_NAME}/${PKG_FNAME}" | tar -C "${PKG_BASE_DIR}" -xf -; ;; + lz) lzip -d < "${BUILD_DLCACHEDIR}/${PKG_NAME}/${PKG_FNAME}" | tar -C "${PKG_BASE_DIR}" -xf -; ;; + xz) xz -d < "${BUILD_DLCACHEDIR}/${PKG_NAME}/${PKG_FNAME}" | tar -C "${PKG_BASE_DIR}" -xf -; ;; + *) tar -C "${PKG_BASE_DIR}" -xf "${BUILD_DLCACHEDIR}/${PKG_NAME}/${PKG_FNAME}"; ;; esac; if [ "${?}" -ne 0 ]; then rtl_fileop cd "${_oldpwd}"; return 1; diff --git a/vars/gcc.vars b/vars/gcc.vars index c7e094a9..50794c93 100644 --- a/vars/gcc.vars +++ b/vars/gcc.vars @@ -122,11 +122,16 @@ pkgp_gcc_stage1_all() { return 1; fi; if ! ex_pkg_state_test "${PKG_NAME}" fetch "${_restart_at}"; then - rtl_fetch_urls_git \ - "${BUILD_DLCACHEDIR}" "${DEFAULT_GIT_ARGS}" "${PKG_BASE_DIR}" \ - "${PKG_NAME}" "${PKG_MIRRORS_GIT:-}" \ - "cbb-gcc-${PKG_VERSION}=${PKG_GITROOT}/cbb/cbb-gcc-${PKG_VERSION}" || return 1; - pkgp_gcc_state_set "fetch" -"patch"; + if ! pkg_fetch_download_dlcache_subdir; then + return 1; + elif ! rtl_fetch_urls_git \ + "${BUILD_DLCACHEDIR}/${PKG_NAME}" "${DEFAULT_GIT_ARGS}" "${PKG_BASE_DIR}" \ + "${PKG_NAME}" "${PKG_MIRRORS_GIT:-}" \ + "cbb-gcc-${PKG_VERSION}=${PKG_GITROOT}/cbb/cbb-gcc-${PKG_VERSION}"; then + return 1; + else + pkgp_gcc_state_set "fetch" -"patch"; + fi; fi; if ! ex_pkg_state_test "${PKG_NAME}" patch "${_restart_at}"; then if [ -e "${MIDIPIX_BUILD_PWD}/patches/${PKG_NAME}.local.patch" ]; then @@ -213,12 +218,17 @@ pkg_gcc_full_all() { export MAKE="make LIBTOOL=slibtool ${_vis_hide}"; pkgp_gcc_build_dir "cbb-gcc-${PKG_VERSION}" native; if ! ex_pkg_state_test "${PKG_NAME}" fetch "${_restart_at}"; then - rtl_fetch_urls_git \ - "${BUILD_DLCACHEDIR}" "${DEFAULT_GIT_ARGS}" \ - "${PKG_BASE_DIR}" "${PKG_NAME}" \ - "${PKG_MIRRORS_GIT:-}" \ - "cbb-gcc-${PKG_VERSION}=${PKG_GITROOT}/cbb/cbb-gcc-${PKG_VERSION}" || return 1; - pkgp_gcc_state_set "fetch" -"patch"; + if ! pkg_fetch_download_dlcache_subdir; then + return 1; + elif ! rtl_fetch_urls_git \ + "${BUILD_DLCACHEDIR}/${PKG_NAME}" "${DEFAULT_GIT_ARGS}" \ + "${PKG_BASE_DIR}" "${PKG_NAME}" \ + "${PKG_MIRRORS_GIT:-}" \ + "cbb-gcc-${PKG_VERSION}=${PKG_GITROOT}/cbb/cbb-gcc-${PKG_VERSION}"; then + return 1; + else + pkgp_gcc_state_set "fetch" -"patch"; + fi; fi; if ! ex_pkg_state_test "${PKG_NAME}" patch "${_restart_at}"; then if [ -e "${MIDIPIX_BUILD_PWD}/patches/${PKG_NAME}.local.patch" ]; then diff --git a/vars/python2.vars b/vars/python2.vars index 7bdcd205..67a39d09 100644 --- a/vars/python2.vars +++ b/vars/python2.vars @@ -5,7 +5,7 @@ pkg_python2_fetch_download() { if ! pkg_fetch_download\ || ! rtl_fileop rm "${PKG_BASE_DIR}/sbpython2"\ - || ! rtl_fetch_urls_git "${BUILD_DLCACHEDIR}" "${DEFAULT_GIT_ARGS}" "${PKG_BASE_DIR}/build" "${PKG_NAME}" "${PKG_MIRRORS_GIT:-}" "sbpython2=${DEFAULT_GITROOT}/python/sbpython2@main"\ + || ! rtl_fetch_urls_git "${BUILD_DLCACHEDIR}/${PKG_NAME}" "${DEFAULT_GIT_ARGS}" "${PKG_BASE_DIR}/build" "${PKG_NAME}" "${PKG_MIRRORS_GIT:-}" "sbpython2=${DEFAULT_GITROOT}/python/sbpython2@main"\ || ! ex_pkg_state_set "${PKG_NAME}" "fetch_download" "-fetch_extract"; then return 1; fi; diff --git a/vars/python2_host.vars b/vars/python2_host.vars index 0cb83e2a..8222aac9 100644 --- a/vars/python2_host.vars +++ b/vars/python2_host.vars @@ -5,7 +5,7 @@ pkg_python2_host_fetch_download() { if ! pkg_fetch_download\ || ! rtl_fileop rm "${PKG_BASE_DIR}/sbpython2"\ - || ! rtl_fetch_urls_git "${BUILD_DLCACHEDIR}" "${DEFAULT_GIT_ARGS}" "${PKG_BASE_DIR}/build" "${PKG_NAME}" "${PKG_MIRRORS_GIT:-}" "sbpython2=${DEFAULT_GITROOT}/python/sbpython2@main"\ + || ! rtl_fetch_urls_git "${BUILD_DLCACHEDIR}/${PKG_NAME}" "${DEFAULT_GIT_ARGS}" "${PKG_BASE_DIR}/build" "${PKG_NAME}" "${PKG_MIRRORS_GIT:-}" "sbpython2=${DEFAULT_GITROOT}/python/sbpython2@main"\ || ! rtl_fileop cp "../sbpython2/project/config/cfgdefs.sh" "../sbpython2/project/config/cfgdefs.sh.orig"\ || ! sed -i"" -e"s/-ltinfo/&w/" -e"s/mb_ncurses_libs='\([^']*\)'/mb_ncurses_libs='\1 -ltinfow'/" ../sbpython2/project/config/cfgdefs.sh\ || ! sed -i"" -e'108a\ diff --git a/vars/python3.vars b/vars/python3.vars index a58325c1..3e3bd32f 100644 --- a/vars/python3.vars +++ b/vars/python3.vars @@ -5,7 +5,7 @@ pkg_python3_fetch_download() { if ! pkg_fetch_download\ || ! rtl_fileop rm "${PKG_BASE_DIR}/sbpython3"\ - || ! rtl_fetch_urls_git "${BUILD_DLCACHEDIR}" "${DEFAULT_GIT_ARGS}" "${PKG_BASE_DIR}/build" "${PKG_NAME}" "${PKG_MIRRORS_GIT:-}" "sbpython3=${DEFAULT_GITROOT}/python/sbpython3@main"\ + || ! rtl_fetch_urls_git "${BUILD_DLCACHEDIR}/${PKG_NAME}" "${DEFAULT_GIT_ARGS}" "${PKG_BASE_DIR}/build" "${PKG_NAME}" "${PKG_MIRRORS_GIT:-}" "sbpython3=${DEFAULT_GITROOT}/python/sbpython3@main"\ || ! ex_pkg_state_set "${PKG_NAME}" "fetch_download" "-fetch_extract"; then return 1; fi; diff --git a/vars/python3_host.vars b/vars/python3_host.vars index 05b58e2b..df70b7be 100644 --- a/vars/python3_host.vars +++ b/vars/python3_host.vars @@ -5,7 +5,7 @@ pkg_python3_host_fetch_download() { if ! pkg_fetch_download\ || ! rtl_fileop rm "${PKG_BASE_DIR}/sbpython3"\ - || ! rtl_fetch_urls_git "${BUILD_DLCACHEDIR}" "${DEFAULT_GIT_ARGS}" "${PKG_BASE_DIR}/build" "${PKG_NAME}" "${PKG_MIRRORS_GIT:-}" "sbpython3=${DEFAULT_GITROOT}/python/sbpython3@main"\ + || ! rtl_fetch_urls_git "${BUILD_DLCACHEDIR}/${PKG_NAME}" "${DEFAULT_GIT_ARGS}" "${PKG_BASE_DIR}/build" "${PKG_NAME}" "${PKG_MIRRORS_GIT:-}" "sbpython3=${DEFAULT_GITROOT}/python/sbpython3@main"\ || ! rtl_fileop cp "../sbpython3/project/config/cfgdefs.sh" "../sbpython3/project/config/cfgdefs.sh.orig"\ || ! sed -i"" -e"s/-ltinfo/&w/" -e"s/mb_ncurses_libs='\([^']*\)'/mb_ncurses_libs='\1 -ltinfow'/" "../sbpython3/project/config/cfgdefs.sh"\ || ! sed -i"" -e'108a\ |