Skip to content

Commit db1d7c8

Browse files
committed
tools/download-sources: proof of concept
Signed-off-by: Ian Leonard <[email protected]>
1 parent b7eed89 commit db1d7c8

File tree

1 file changed

+45
-0
lines changed

1 file changed

+45
-0
lines changed

tools/download-sources

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
#!/bin/bash
2+
3+
# SPDX-License-Identifier: GPL-2.0
4+
# Copyright (C) 2019-present Team LibreELEC (https://libreelec.tv)
5+
6+
# Download all packages listed in the build plan to SOURCES_DIR
7+
8+
unset _CACHE_PACKAGE_LOCAL _CACHE_PACKAGE_GLOBAL _DEBUG_DEPENDS_LIST _DEBUG_PACKAGE_LIST
9+
10+
. config/options ""
11+
12+
THREADCOUNT="${THREADCOUNT:-$(nproc)}"
13+
14+
# function to enable use of parallel
15+
download_package_tarball() {
16+
local package_name="${1}"
17+
18+
"${SCRIPTS}/get" "${package_name}"
19+
}
20+
21+
# Packages listed in the build plan
22+
PACKAGE_LIST=$( \
23+
"${SCRIPTS}/pkgjson" | \
24+
"${SCRIPTS}/genbuildplan.py" --hide-header --list-packages --build ${@:-image} ${GENFLAGS} || \
25+
die "FAILURE: Unable to generate plan"
26+
)
27+
28+
# drop :target, :host, :init, and now repeated package entries
29+
UNIQUE_PACKAGES=$(
30+
for package in ${PACKAGE_LIST}; do
31+
echo "${package}" | cut -d ":" -f 1
32+
done | awk '!seen[$0]++'
33+
)
34+
35+
# Package downloading
36+
if command -v parallel > /dev/null; then
37+
export -f download_package_tarball
38+
export SCRIPTS
39+
40+
parallel --jobs "${THREADCOUNT}" download_package_tarball <<< "${UNIQUE_PACKAGES}"
41+
else
42+
for package in ${UNIQUE_PACKAGES}; do
43+
download_package_tarball "${package}"
44+
done
45+
fi

0 commit comments

Comments
 (0)