aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordylan.araps@gmail.com <dylan.araps@gmail.com>2019-06-17 07:18:36 +0000
committerdylan.araps@gmail.com <dylan.araps@gmail.com>2019-06-17 07:18:36 +0000
commit1674a88b9152a541aec9981d2cd93c94049a635b (patch)
tree38417cfbff6feaeaced6a07a085e95367477e19e
parent9edcdbaf602455d89578968f37716f7858c7bd7f (diff)
downloadcpt-1674a88b9152a541aec9981d2cd93c94049a635b.tar.gz
kiss: Added package conflicts.
FossilOrigin-Name: 28cc1e0d70d5f372219079e0fab18b36430f735278428fc2e7598a66dd0d93b0
-rwxr-xr-xkiss28
1 files changed, 27 insertions, 1 deletions
diff --git a/kiss b/kiss
index cbecbac..997bae9 100755
--- a/kiss
+++ b/kiss
@@ -134,15 +134,41 @@ pkg_tar() {
log "Use '$kiss install $name' to install the package."
}
+pkg_conflicts() {
+ log "Checking for package conflicts."
+
+ # Extract manifest from tarball and strip directories.
+ tar xf "$bin_dir/$pkg" "./var/db/$kiss/$name/manifest" -O |
+ while read -r line; do
+ [ -f "$line" ] && printf '%s\n' "$line" >> "$cac_dir/manifest"
+ done
+
+ # Compare extracted manifest to all installed manifests.
+ # If there are matching lines (files) there's a package
+ # conflict.
+ for db in "$sys_db"/*; do
+ [ "$name" = "${db##*/}" ] && continue
+
+ grep -Fxf "$cac_dir/manifest" "$db/manifest" &&
+ die "Package '$name' conflicts with '${db##*/}'."
+ done
+
+ rm "$cac_dir/manifest"
+}
+
pkg_install() {
[ -f "$bin_dir/$pkg" ] || args b "$name"
+ pkg_conflicts
+
# Create a backup of 'tar' so it isn't removed during
# package installation.
cp "$(command -v tar)" "$cac_dir"
+ log "Removing previous version of package if it exists."
pkg_remove "$name"
- "$cac_dir/tar" kpxvf "$bin_dir/$pkg" -C "$sys_dir/"
+
+ "$cac_dir/tar" kpxf "$bin_dir/$pkg" -C "$sys_dir/"
rm "$cac_dir/tar"
"$sys_db/$name/post-install" 2>/dev/null