From c060d828bfde3cc13dd79efcbb55aadfdcce4ecc Mon Sep 17 00:00:00 2001 From: merakor Date: Mon, 3 Aug 2020 15:52:29 +0000 Subject: 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 --- src/cpt-lib | 35 +++++++++++++++++++---------------- 1 file changed, 19 insertions(+), 16 deletions(-) (limited to 'src/cpt-lib') 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 "$@" -- cgit v1.2.3