mirror of
https://github.com/crosstool-ng/crosstool-ng.git
synced 2024-12-21 13:47:48 +00:00
Implement an option to store downloads in subdirs
... following the buildroot model. Signed-off-by: Alexey Neyman <stilor@att.net>
This commit is contained in:
parent
2da27758a9
commit
2219aab336
@ -2,7 +2,7 @@
|
||||
|
||||
## select CC_SUPPORT_CXX if !LIBC_NONE
|
||||
## select CC_SUPPORT_FORTRAN
|
||||
## select CC_SUPPORT_JAVA if !GCC_7_or_later
|
||||
## select CC_SUPPORT_JAVA if !GCC_7_or_later && OBSOLETE
|
||||
## select CC_SUPPORT_ADA
|
||||
## select CC_SUPPORT_OBJC
|
||||
## select CC_SUPPORT_OBJCXX
|
||||
|
@ -19,6 +19,17 @@ config SAVE_TARBALLS
|
||||
If you say 'y' here, new downloaded tarballs will be saved in the
|
||||
directory you entered above.
|
||||
|
||||
config TARBALLS_BUILDROOT_LAYOUT
|
||||
bool "Prefer buildroot-style layout of the downloads"
|
||||
help
|
||||
Buildroot switched the layout of its downloads directory to place
|
||||
files for each package into a subdirectory named after that package.
|
||||
Enable this option to have crosstool-NG create similar layout.
|
||||
If this option is set and the required archive is located in
|
||||
the directory with a legacy, flat layout, the archive will be moved
|
||||
into a subdirectory. If this is option is not set, subdirectories
|
||||
will neither be checked nor used to store the downloads.
|
||||
|
||||
config WORK_DIR
|
||||
string
|
||||
prompt "Working directory"
|
||||
|
@ -14,8 +14,8 @@ do_cc_get() {
|
||||
# GCC source tree, which will not be there unless we get it and
|
||||
# put it there ourselves
|
||||
if [ "${CT_CC_LANG_JAVA_USE_ECJ}" = "y" ]; then
|
||||
if ! CT_GetFile package=ecj basename=ecj-latest extensions=.jar \
|
||||
mirrors=$(CT_Mirrors sourceware java); then
|
||||
if ! CT_GetFile package=ecj basename=ecj-latest extensions=.jar dir_name=gcc \
|
||||
mirrors="$(CT_Mirrors sourceware java)"; then
|
||||
# Should be a package, too - but with Java retirement in GCC,
|
||||
# it may not make sense.
|
||||
CT_Abort "Failed to download ecj-latest.jar"
|
||||
|
@ -761,29 +761,34 @@ CT_DoGetFile()
|
||||
# and if so, symlinks it for later usage. This function is called from
|
||||
# the `if' condition (via the CT_GetFile) and therefore must return
|
||||
# on error rather than relying on the shell's ERR trap to catch it.
|
||||
# Usage: CT_SaveLocal </full/path/file.name>
|
||||
# Usage: CT_SaveLocal </full/path/file.name> <subdirectory>
|
||||
CT_SaveLocal()
|
||||
{
|
||||
local file="$1"
|
||||
local savedir="${CT_LOCAL_TARBALLS_DIR}${CT_TARBALLS_BUILDROOT_LAYOUT:+/$2}"
|
||||
local basename="${file##*/}"
|
||||
|
||||
if [ "${CT_SAVE_TARBALLS}" = "y" ]; then
|
||||
CT_DoLog EXTRA "Saving '${basename}' to local storage"
|
||||
# The subdirectory for this package may not exist yet; create it
|
||||
if [ ! -d "${savedir}" ]; then
|
||||
CT_DoExecLog ALL mkdir -p "${savedir}"
|
||||
fi
|
||||
# The file may already exist if downloads are forced: remove it first
|
||||
if ! CT_DoExecLog ALL rm -f "${CT_LOCAL_TARBALLS_DIR}/${basename}"; then
|
||||
if ! CT_DoExecLog ALL rm -f "${savedir}/${basename}"; then
|
||||
return 1
|
||||
fi
|
||||
if ! CT_DoExecLog ALL mv -f "${file}" "${CT_LOCAL_TARBALLS_DIR}"; then
|
||||
if ! CT_DoExecLog ALL mv -f "${file}" "${savedir}"; then
|
||||
# Move may have failed if the local tarball storage is on a different
|
||||
# filesystem. Fallback to copy+delete.
|
||||
if ! CT_DoExecLog ALL cp -f "${file}" "${CT_LOCAL_TARBALLS_DIR}"; then
|
||||
if ! CT_DoExecLog ALL cp -f "${file}" "${savedir}"; then
|
||||
return 1
|
||||
fi
|
||||
if ! CT_DoExecLog ALL rm -f "${file}"; then
|
||||
return 1
|
||||
fi
|
||||
fi
|
||||
if ! CT_DoExecLog ALL ln -s "${CT_LOCAL_TARBALLS_DIR}/${basename}" "${file}"; then
|
||||
if ! CT_DoExecLog ALL ln -s "${savedir}/${basename}" "${file}"; then
|
||||
return 1
|
||||
fi
|
||||
fi
|
||||
@ -854,7 +859,7 @@ CT_ZCat()
|
||||
|
||||
# Verify the file against a detached signature.
|
||||
# Fetched from the URL, or obtained from the package directory.
|
||||
# Usage: CT_DoVerifySignature <local-file-path> <URL-used-for-download> <signature-format>
|
||||
# Usage: CT_DoVerifySignature <local-file-path> <URL-used-for-download> <signature-format> <save-subdirectory>
|
||||
CT_DoVerifySignature()
|
||||
{
|
||||
local path="$1"
|
||||
@ -865,6 +870,7 @@ CT_DoVerifySignature()
|
||||
local format="$3"
|
||||
local method="${format%/*}"
|
||||
local ext="${format#*/}"
|
||||
local save_subdir="$4"
|
||||
local sigfile
|
||||
local cat
|
||||
|
||||
@ -908,7 +914,7 @@ CT_DoVerifySignature()
|
||||
CT_Popd
|
||||
|
||||
# If we get here, verification succeeded.
|
||||
if ! CT_SaveLocal "${CT_TARBALLS_DIR}/${sigfile}${ext}"; then
|
||||
if ! CT_SaveLocal "${CT_TARBALLS_DIR}/${sigfile}${ext}" "${save_subdir}"; then
|
||||
CT_Popd
|
||||
return 1
|
||||
fi
|
||||
@ -922,12 +928,14 @@ CT_GetFile()
|
||||
local -a argnames=(
|
||||
package # Name of the package
|
||||
pkg_dir # Directory with package's auxiliary files
|
||||
dir_name # Package's directory name in downloads dir
|
||||
basename # Base name of file/archive
|
||||
extensions # Extension(s) for the file/archive
|
||||
digest # If 'y', verify the digest
|
||||
signature_format # Format of the signature
|
||||
mirrors # Mirrors to download from
|
||||
)
|
||||
local dl_dir
|
||||
local -a URLS
|
||||
local ext url
|
||||
|
||||
@ -935,6 +943,9 @@ CT_GetFile()
|
||||
eval "local ${arg//[[:space:]]/\\ }"
|
||||
done
|
||||
|
||||
CT_TestOrAbort "Internal error: dir_name not set" -n "${dir_name}"
|
||||
dl_dir="${CT_LOCAL_TARBALLS_DIR:+${CT_LOCAL_TARBALLS_DIR}${CT_TARBALLS_BUILDROOT_LAYOUT:+/${dir_name}}}"
|
||||
|
||||
# Does any of the requested files exist localy?
|
||||
for ext in ${extensions}; do
|
||||
# Do we already have it in *our* tarballs dir?
|
||||
@ -943,12 +954,24 @@ CT_GetFile()
|
||||
return 0
|
||||
fi
|
||||
|
||||
if [ -n "${CT_LOCAL_TARBALLS_DIR}" -a "${CT_FORCE_DOWNLOAD}" != "y" -a \
|
||||
-r "${CT_LOCAL_TARBALLS_DIR}/${basename}${ext}" ]; then
|
||||
CT_DoLog DEBUG "Got '${basename}' from local storage"
|
||||
CT_DoExecLog ALL ln -s "${CT_LOCAL_TARBALLS_DIR}/${basename}${ext}" \
|
||||
"${CT_TARBALLS_DIR}/${basename}${ext}"
|
||||
return 0
|
||||
if [ "${CT_FORCE_DOWNLOAD}" != "y" ]; then
|
||||
if [ -n "${dl_dir}" -a -r "${dl_dir}/${basename}${ext}" ]; then
|
||||
CT_DoLog DEBUG "Got '${basename}' from local storage"
|
||||
CT_DoExecLog ALL ln -s "${dl_dir}/${basename}${ext}" \
|
||||
"${CT_TARBALLS_DIR}/${basename}${ext}"
|
||||
return 0
|
||||
elif [ -n "${CT_LOCAL_TARBALLS_DIR}" -a -r "${CT_LOCAL_TARBALLS_DIR}/${basename}${ext}" ]; then
|
||||
# Only different if we're using new buildroot layout
|
||||
CT_DoLog DEBUG "Got '${basename}' from local storage"
|
||||
CT_DoLog INFO "Moving the ${basename}${ext} into ${dir_name}/${basename}${ext}"
|
||||
if [ ! -d "${dl_dir}" ]; then
|
||||
CT_DoExecLog ALL mkdir -p "${dl_dir}"
|
||||
fi
|
||||
CT_DoExecLog ALL mv "${CT_LOCAL_TARBALLS_DIR}/${basename}${ext}" "${dl_dir}/${basename}${ext}"
|
||||
CT_DoExecLog ALL ln -s "${dl_dir}/${basename}${ext}" \
|
||||
"${CT_TARBALLS_DIR}/${basename}${ext}"
|
||||
return 0
|
||||
fi
|
||||
fi
|
||||
done
|
||||
|
||||
@ -998,7 +1021,7 @@ CT_GetFile()
|
||||
CT_DoExecLog ALL rm "${CT_TARBALLS_DIR}/${basename}${ext}"
|
||||
return 1
|
||||
fi
|
||||
if ! CT_SaveLocal "${CT_TARBALLS_DIR}/${basename}${ext}"; then
|
||||
if ! CT_SaveLocal "${CT_TARBALLS_DIR}/${basename}${ext}" "${dir_name}"; then
|
||||
return 1
|
||||
fi
|
||||
return 0
|
||||
@ -2055,7 +2078,7 @@ CT_DoFetch()
|
||||
basename="${pkg_name}-${version}"
|
||||
fi
|
||||
pkg_dir="${pkg_name}/${version}"
|
||||
if ! CT_GetFile package="${pkg_name}" pkg_dir="${pkg_dir}" \
|
||||
if ! CT_GetFile package="${pkg_name}" pkg_dir="${pkg_dir}" dir_name="${dir_name}" \
|
||||
basename="${archive_filename}" extensions="${archive_formats}" \
|
||||
digest="${CT_VERIFY_DOWNLOAD_DIGEST}" \
|
||||
signature_format="${CT_VERIFY_DOWNLOAD_SIGNATURE:+${signature_format}}" \
|
||||
@ -2090,7 +2113,7 @@ CT_DoFetch()
|
||||
# attempt getting it from local storage or from the mirror if configured.
|
||||
# Bzip2 offers a reasonable compromise between compression speed and size.
|
||||
if [ "${unique_id}" != "to.be.determined" ] && \
|
||||
CT_GetFile package="${pkg_name}" \
|
||||
CT_GetFile package="${pkg_name}" dir_name="${dir_name}" \
|
||||
basename="${basename}" extensions='.tar.bz2'; then
|
||||
return 0
|
||||
fi
|
||||
@ -2112,7 +2135,7 @@ CT_DoFetch()
|
||||
|
||||
CT_DoExecLog ALL mv "${pkg_name}${devel_subdir:+/${devel_subdir}}" "${basename}"
|
||||
CT_DoExecLog ALL tar cjf "${CT_TARBALLS_DIR}/${basename}.tar.bz2" "${basename}"
|
||||
if ! CT_SaveLocal "${CT_TARBALLS_DIR}/${basename}.tar.bz2"; then
|
||||
if ! CT_SaveLocal "${CT_TARBALLS_DIR}/${basename}.tar.bz2" "${dir_name}"; then
|
||||
CT_Abort "${pkg_name}: failed to save to local storage"
|
||||
fi
|
||||
CT_Popd
|
||||
|
Loading…
Reference in New Issue
Block a user