aboutsummaryrefslogtreecommitdiff
path: root/kiss-new
diff options
context:
space:
mode:
authordylan.araps@gmail.com <dylan.araps@gmail.com>2019-06-29 06:40:03 +0000
committerdylan.araps@gmail.com <dylan.araps@gmail.com>2019-06-29 06:40:03 +0000
commit61547a5323e653bbdba07dc9e6808c9d13f869fa (patch)
treef784922b3bd7d5d7a8c9a4dcfa3b2b956417c9c3 /kiss-new
parent3e95cba8930d2655b6b432c651e4c4f9bffe1c88 (diff)
downloadcpt-61547a5323e653bbdba07dc9e6808c9d13f869fa.tar.gz
kiss-new: Catch errors.
FossilOrigin-Name: e54ccf952183296304ff32ee368641259ae59fc2ce093f5174d41c40f3a75fe0
Diffstat (limited to 'kiss-new')
-rwxr-xr-xkiss-new33
1 files changed, 23 insertions, 10 deletions
diff --git a/kiss-new b/kiss-new
index 47ef685..f9df047 100755
--- a/kiss-new
+++ b/kiss-new
@@ -41,10 +41,10 @@ pkg_lint() {
cd "$pkg_location" || die "'$pkg_location' not accessible"
- [ -f sources ] || die "Sources file not found."
- [ -x build ] || die "Build file not found or not executable."
- [ -f licenses ] || die "License file not found or empty."
- [ -f version ] || die "Version file not found or empty."
+ [ -f sources ] || die "Sources file not found."
+ [ -x build ] || die "Build file not found or not executable."
+ [ -f licenses ] || die "License file not found or empty."
+ [ -f version ] || die "Version file not found or empty."
}
pkg_search() {
@@ -208,20 +208,30 @@ setup_caching() {
die "Couldn't create cache directory ($cac_dir)."
# Build directory.
- mkdir -p "${mak_dir:=$cac_dir/build-$$}" ||
+ mkdir -p "${mak_dir:=$cac_dir/build-$pid}" ||
die "Couldn't create build directory ($mak_dir)."
- # Binary directory.
- mkdir -p "${bin_dir:=$cac_dir/bin}" ||
- die "Couldn't create binary directory ($bin_dir)."
+ # Package directory.
+ mkdir -p "${pkg_dir:=$cac_dir/pkg-$pid}" ||
+ die "Couldn't create package directory ($pkg_dir)."
# Tar directory.
- mkdir -p "${tar_dir:=$cac_dir/extract-$$}" ||
+ mkdir -p "${tar_dir:=$cac_dir/extract-$pid}" ||
die "Couldn't create tar directory ($tar_dir)."
# Source directory.
mkdir -p "${src_dir:=$cac_dir/sources}" ||
die "Couldn't create source directory ($src_dir)."
+
+ # Binary directory.
+ mkdir -p "${bin_dir:=$cac_dir/bin}" ||
+ die "Couldn't create binary directory ($bin_dir)."
+}
+
+pkg_clean() {
+ # Clean up on exit or error. This removes everything related
+ # to the build.
+ rm -rf -- "$mak_dir" "$pkg_dir" "$tar_dir"
}
args() {
@@ -288,8 +298,11 @@ main() {
# that it doesn't change beneath us.
pid=$$
- setup_caching
+ # Catch errors and ensure that build files and directories are cleaned
+ # up before we die. This occurs on 'Ctrl+C' as well as sucess and error.
+ trap pkg_clean EXIT INT
+ setup_caching
args "$@"
}