-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
base: use a helper script for extracting tarballs.
Trivial tarball extraction leads to file ownership to be kept, which can cause permission problems with rootless container engines. This could be overcome by changing subuid and subgid ranges or ignoring ownership from the container filesystem in the installed machine. However, this leads to a more difficult setup for the IOC machines. Instead, file ownership is ignored during extraction in the build phase. This requirement of customizing extraction for all downloaded archives justifies having a dedicated helper script for both downloading and extracting archives. For convenience, a list of URLs can be defined. Tarball archives are downloaded to a dedicated temporary directory to avoid filename conflicts, since they might have arbitrary names. The extraction can be made either in the current directory or at the filesystem root. The latter is useful to extract to specific directories without any intervention. It should be used, for instance, to install custom packages to the /usr/local tree. Noisy output from commands are replaced by short messages to make the build progress more clean. Exceptionally, `wget` output is logged to stdout only when it fails.
- Loading branch information
1 parent
4ba9c44
commit 288d0da
Showing
4 changed files
with
29 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
#!/usr/bin/env bash | ||
# | ||
# Download and extract tarball archive from the network. | ||
|
||
set -eu | ||
|
||
case "$1" in | ||
-r) dest=/ ;; | ||
-l) dest=. ;; | ||
*) >&2 echo "Invalid extraction mode: must be either root (-r) or local (-l)." | ||
exit 1; | ||
;; | ||
esac | ||
|
||
shift | ||
|
||
for url; do | ||
download_dir=$(mktemp -d) | ||
|
||
echo Downloading "$url"... | ||
wget -P $download_dir -o /tmp/wget.log "$url" || (cat /tmp/wget.log && false) | ||
tar --no-same-owner -xf $download_dir/* -C $dest | ||
rm -rf $download_dir /tmp/wget.log | ||
done |