Skip to content

Commit a790e0c

Browse files
authored
Fetch base in cache (#147)
* Store base.txz in POT_CACHE instead of /tmp * tests: fix fetch related tests
1 parent 4527f5c commit a790e0c

File tree

5 files changed

+11
-9
lines changed

5 files changed

+11
-9
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
2828
- info: -B instead of -b for private bridge information
2929
- copy-in: copy is executed in the jail environment, to avoid soft-link related issues in the destination path
3030
- copy-in: with running pots, a -F flag is needed to force the copy, an operation that is discouraged for security reasons
31+
- fetch base.txz: the base FreeBSD tarball used to be temporarily stored in /tmp. While a POT_CACHE folder is available, use that instead.
3132

3233
### Removed
3334
- create-dns: remove this already deprecated command, leaving the user to create a dns for the public bridge

share/pot/common.sh

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -855,7 +855,7 @@ _fetch_freebsd()
855855
if ! _fetch_freebsd_internal "$1" "$_archpath"; then
856856
# remove artifact and retry only once
857857
_rel="$( _get_freebsd_release_name "$1" )"
858-
rm -f /tmp/"${_rel}"_base.txz
858+
rm -f "${POT_CACHE}/${_rel}"_base.txz
859859
if ! _fetch_freebsd_internal "$1" "$_archpath"; then
860860
return 1 # false
861861
fi
@@ -872,15 +872,15 @@ _fetch_freebsd_internal()
872872
_rel="$( _get_freebsd_release_name "$1" )"
873873
_archpath="$( echo "$2" | sed -e 's:-:/:' )"
874874

875-
if [ ! -r /tmp/"${_rel}"_base.txz ]; then
876-
fetch -m https://ftp.freebsd.org/pub/FreeBSD/releases/"$_archpath"/"${_rel}"/base.txz -o /tmp/"${_rel}"_base.txz
875+
if [ ! -r "${POT_CACHE}/${_rel}"_base.txz ]; then
876+
fetch -m https://ftp.freebsd.org/pub/FreeBSD/releases/"$_archpath"/"${_rel}"/base.txz -o "${POT_CACHE}/${_rel}"_base.txz
877877
fi
878878

879-
if [ ! -r /tmp/"${_rel}"_base.txz ]; then
879+
if [ ! -r "${POT_CACHE}/${_rel}"_base.txz ]; then
880880
return 1 # false
881881
fi
882882
if [ -r /usr/local/share/freebsd/MANIFESTS/"$2"-"${_rel}" ]; then
883-
_sha=$( sha256 -q /tmp/"${_rel}"_base.txz )
883+
_sha=$( sha256 -q "${POT_CACHE}/${_rel}"_base.txz )
884884
# shellcheck disable=SC2002
885885
_sha_m=$( cat /usr/local/share/freebsd/MANIFESTS/"$2"-"${_rel}" | awk '/^base.txz/ { print $2 }' )
886886
# This version would remove the useless cat, but the testability of this function is compromised

share/pot/create-base.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ _cb_tar_dir()
5858
(
5959
set -e
6060
cd "$_mnt"
61-
tar xkf /tmp/"${_rel}"_base.txz
61+
tar xkf "${POT_CACHE}/${_rel}"_base.txz
6262
# add release information
6363
echo "$_rel" > .osrelease
6464
cp -a root opt/custom/

share/pot/create.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -435,16 +435,16 @@ _cj_single_install()
435435
else
436436
_rel="$_base"-RELEASE
437437
fi
438-
if [ ! -r "/tmp/${_rel}_base.txz" ]; then
439-
_error "FreeBSD base tarball /tmp/${_rel}_base.txz is missing"
438+
if [ ! -r "${POT_CACHE}/${_rel}_base.txz" ]; then
439+
_error "FreeBSD base tarball ${POT_CACHE}/${_rel}_base.txz is missing"
440440
_cj_undo_create
441441
return 1 # falase
442442
fi
443443
(
444444
set -e
445445
cd "$_proot"
446446
_info "Extract the tarball"
447-
tar xkf "/tmp/${_rel}_base.txz"
447+
tar xkf "${POT_CACHE}/${_rel}_base.txz"
448448
if [ ! -d usr/home ]; then
449449
mkdir -p usr/home
450450
fi

tests/common5.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,7 @@ setUp()
207207
__arch="amd64"
208208
__didfetch="1"
209209
common_setUp
210+
POT_CACHE="/tmp"
210211
FETCH_CALLS=0
211212
RM_CALLS=0
212213
}

0 commit comments

Comments
 (0)