aboutsummaryrefslogtreecommitdiff
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
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
-rwxr-xr-xsrc/cpt-build2
-rwxr-xr-xsrc/cpt-checksum2
-rwxr-xr-xsrc/cpt-download1
-rwxr-xr-xsrc/cpt-install2
-rw-r--r--src/cpt-lib35
-rwxr-xr-xsrc/cpt-update2
6 files changed, 28 insertions, 16 deletions
diff --git a/src/cpt-build b/src/cpt-build
index b577176..a143b67 100755
--- a/src/cpt-build
+++ b/src/cpt-build
@@ -10,4 +10,6 @@ case "$1" in
--version|-v) version ;;
esac
+create_cache
+
pkg_build "$@"
diff --git a/src/cpt-checksum b/src/cpt-checksum
index 2d303d3..63a567b 100755
--- a/src/cpt-checksum
+++ b/src/cpt-checksum
@@ -10,6 +10,8 @@ case "$1" in
'') set -- "${PWD##*/}"; export CPT_PATH=${PWD%/*}:$CPT_PATH ;;
esac
+create_cache
+
for pkg; do pkg_lint "$pkg" c; done
for pkg; do pkg_sources "$pkg" c; done
diff --git a/src/cpt-download b/src/cpt-download
index da0a692..19c4732 100755
--- a/src/cpt-download
+++ b/src/cpt-download
@@ -13,4 +13,5 @@ case "$1" in
'') set -- "${PWD##*/}"; export CPT_PATH=${PWD%/*}:$CPT_PATH
esac
+create_cache
for pkg; do pkg_sources "$pkg"; done
diff --git a/src/cpt-install b/src/cpt-install
index e886ad4..d971974 100755
--- a/src/cpt-install
+++ b/src/cpt-install
@@ -31,6 +31,8 @@ done
pkg_order "$@"
+create_cache
+
# shellcheck disable=2154
for pkg in $order; do pkg_install "$pkg"; done
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 "$@"
diff --git a/src/cpt-update b/src/cpt-update
index 368b23e..417b0e3 100755
--- a/src/cpt-update
+++ b/src/cpt-update
@@ -22,4 +22,6 @@ while [ "$1" ]; do
esac
done
+create_cache
+
pkg_updates