aboutsummaryrefslogtreecommitdiff
path: root/src/cpt-lib
diff options
context:
space:
mode:
authormerakor <cem@ckyln.com>2020-08-03 15:52:29 +0000
committermerakor <cem@ckyln.com>2020-08-03 15:52:29 +0000
commitc060d828bfde3cc13dd79efcbb55aadfdcce4ecc (patch)
tree5c8ee2ff63ba6b107d5529d8ee70007ad2476ff1 /src/cpt-lib
parentc6d00eaff2188ce651945a79fae7d4aafcf050ec (diff)
downloadcpt-c060d828bfde3cc13dd79efcbb55aadfdcce4ecc.tar.gz
cpt: create caches manually for each script that needs it
This makes sure we don't create unnecessary cache directories. We can source the library without creating directories now. FossilOrigin-Name: 8d9a38a33265e7a597375bb2ef4aa2263e110fb06c9b5df948d46a64c9b23e95
Diffstat (limited to 'src/cpt-lib')
-rw-r--r--src/cpt-lib35
1 files changed, 19 insertions, 16 deletions
diff --git a/src/cpt-lib b/src/cpt-lib
index eaf87cc..9f1a5b8 100644
--- a/src/cpt-lib
+++ b/src/cpt-lib
@@ -1420,6 +1420,25 @@ pkg_clean() {
"$CPT_TMPDIR/$pid-c" "$CPT_TMPDIR/$pid-m"
}
+create_cache() {
+ # A temporary directory can be specified apart from the cache
+ # directory in order to build in a user specified directory.
+ # /tmp could be used in order to build on ram, useful on SSDs.
+ # The user can specify CPT_TMPDIR for this.
+ #
+ # Create the required temporary directories and set the variables
+ # which point to them.
+ mkdir -p "${cac_dir:=${CPT_CACHE:=${XDG_CACHE_HOME:-$HOME/.cache}/cpt}}" \
+ "${CPT_TMPDIR:=$cac_dir}" \
+ "${mak_dir:=$CPT_TMPDIR/build-$pid}" \
+ "${pkg_dir:=$CPT_TMPDIR/pkg-$pid}" \
+ "${tar_dir:=$CPT_TMPDIR/extract-$pid}" \
+ "${src_dir:=$cac_dir/sources}" \
+ "${log_dir:=$cac_dir/logs}" \
+ "${bin_dir:=$cac_dir/bin}"
+
+}
+
main() {
set -ef
@@ -1489,22 +1508,6 @@ main() {
# Set a value for CPT_COMPRESS if it isn't set.
: "${CPT_COMPRESS:=gz}"
- # A temporary directory can be specified apart from the cache
- # directory in order to build in a user specified directory.
- # /tmp could be used in order to build on ram, useful on SSDs.
- # The user can specify CPT_TMPDIR for this.
- #
- # Create the required temporary directories and set the variables
- # which point to them.
- mkdir -p "${cac_dir:=${CPT_CACHE:=${XDG_CACHE_HOME:-$HOME/.cache}/cpt}}" \
- "${CPT_TMPDIR:=$cac_dir}" \
- "${mak_dir:=$CPT_TMPDIR/build-$pid}" \
- "${pkg_dir:=$CPT_TMPDIR/pkg-$pid}" \
- "${tar_dir:=$CPT_TMPDIR/extract-$pid}" \
- "${src_dir:=$cac_dir/sources}" \
- "${log_dir:=$cac_dir/logs}" \
- "${bin_dir:=$cac_dir/bin}"
-
}
main "$@"