aboutsummaryrefslogtreecommitdiff
path: root/src/cpt-lib.in
diff options
context:
space:
mode:
Diffstat (limited to 'src/cpt-lib.in')
-rw-r--r--src/cpt-lib.in26
1 files changed, 18 insertions, 8 deletions
diff --git a/src/cpt-lib.in b/src/cpt-lib.in
index 5416efe..d6fa0a4 100644
--- a/src/cpt-lib.in
+++ b/src/cpt-lib.in
@@ -43,8 +43,11 @@ trap_set() {
trap pkg_clean EXIT
trap 'pkg_clean; exit 1' INT
;;
- block) trap '' INT ;;
- unset) trap - EXIT INT ;;
+ handle-int)
+ trap pkg_clean INT
+ ;;
+ block) trap '' INT ;;
+ unset) trap - EXIT INT ;;
esac
}
@@ -703,11 +706,18 @@ pkg_sources() {
elif [ -z "${src##*://*}" ]; then
log "$1" "Downloading $src"
+ # We don't want our trap to exit immediately here if we receive an
+ # interrupt, we handle this ourselves.
+ trap_set handle-int
+
curl "$src" -fLo "${src##*/}" || {
rm -f "${src##*/}"
die "$1" "Failed to download $src"
}
+ # Restore original trap value.
+ trap_set cleanup
+
# Local source.
elif [ -f "$repo_dir/$src" ]; then
log "$1" "Found local file '$src'"
@@ -1979,6 +1989,12 @@ create_cache() {
eval set -- "$REST"
}
+ # The PID of the current shell process is used to isolate directories
+ # to each specific CPT instance. This allows multiple package manager
+ # instances to be run at once. Store the value in another variable so
+ # that it doesn't change beneath us.
+ pid=${CPT_PID:-$$}
+
# Create the cache directories for CPT and set the variables which point
# to them. This is seperate from temporary directories created in
# create_cache(). That's because we need these variables set on most
@@ -1998,12 +2014,6 @@ create_cache() {
# Set the location to the repository and package database.
pkg_db=var/db/cpt/installed
- # The PID of the current shell process is used to isolate directories
- # to each specific CPT instance. This allows multiple package manager
- # instances to be run at once. Store the value in another variable so
- # that it doesn't change beneath us.
- pid=${CPT_PID:-$$}
-
# Force the C locale to speed up things like 'grep' which disable unicode
# etc when this is set. We don't need unicode and a speed up is always
# welcome.