cpt

[ARCHIVED] Carbs Packaging Tools
git clone git://git.ckyln.com/~cem/cpt.git
Log | Files | Refs | README | LICENSE

commit 07bd67baa9ab35fcf5d0b82838d5fdd9370ff37f
parent ce4d5b2b08f4c92a1bbcc933ce8a3dee77818e0e
Author: Cem Keylan <cem@ckyln.com>
Date:   Mon,  3 Aug 2020 18:52:29 +0300

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.

Diffstat:
Msrc/cpt-build | 2++
Msrc/cpt-checksum | 2++
Msrc/cpt-download | 1+
Msrc/cpt-install | 2++
Msrc/cpt-lib | 35+++++++++++++++++++----------------
Msrc/cpt-update | 2++
6 files changed, 28 insertions(+), 16 deletions(-)

diff --git 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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -22,4 +22,6 @@ while [ "$1" ]; do esac done +create_cache + pkg_updates