From e73a8b728db8671e709daedbd7962427fbc521cf Mon Sep 17 00:00:00 2001 From: Dylan Araps Date: Mon, 17 Jun 2019 10:18:36 +0300 Subject: [PATCH 1/3] kiss: Added package conflicts. --- kiss | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) 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 From 560ac9ada1abaf2801def81bf02ca26036922b12 Mon Sep 17 00:00:00 2001 From: Dylan Araps Date: Tue, 18 Jun 2019 11:01:06 +0300 Subject: [PATCH 2/3] kiss: Fix pkg_conflicts --- kiss | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/kiss b/kiss index 997bae9..b789b8d 100755 --- a/kiss +++ b/kiss @@ -125,8 +125,11 @@ pkg_strip() { } pkg_manifest() { - (cd "$pkg_dir" && find ./*) | sed -e ss.ss -e '1!G;h;$!d' | - tee manifest > "$pkg_db/$name/manifest" + # Store the file and directory list of the package. + # Directories have a trailing '/' and the list is sorted in reverse. + (cd "$pkg_dir" && { + find ./* -type d -print | sed 's!$!/!'; find . \! -type d + }) | sort -r | sed -e ss.ss | tee manifest > "$pkg_db/$name/manifest" } pkg_tar() { @@ -139,9 +142,9 @@ pkg_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 + while read -r line; do + [ "${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 @@ -152,8 +155,6 @@ pkg_conflicts() { grep -Fxf "$cac_dir/manifest" "$db/manifest" && die "Package '$name' conflicts with '${db##*/}'." done - - rm "$cac_dir/manifest" } pkg_install() { @@ -261,7 +262,7 @@ args() { } main() { - trap 'rm -rf -- "$mak_dir" "$pkg_dir"' EXIT INT + trap 'rm -rf -- "$mak_dir" "$pkg_dir" "$cac_dir/manifest"' EXIT INT kiss=${0##*/} [ -z "$KISS_PATH" ] && From 8de5bd259480c4647dc4fd72d21857f73b91514f Mon Sep 17 00:00:00 2001 From: Dylan Araps Date: Tue, 18 Jun 2019 11:38:46 +0300 Subject: [PATCH 3/3] kiss: Simplify manifest find. --- kiss | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/kiss b/kiss index 5f3e440..ab7a5bb 100755 --- a/kiss +++ b/kiss @@ -131,9 +131,8 @@ pkg_strip() { pkg_manifest() { # Store the file and directory list of the package. # Directories have a trailing '/' and the list is sorted in reverse. - (cd "$pkg_dir" && { - find ./* -type d -print | sed 's!$!/!'; find . \! -type d - }) | sort -r | sed -e ss.ss | tee manifest > "$pkg_db/$name/manifest" + (cd "$pkg_dir" && find ./* -type d -exec printf '%s/\n' {} + -or -print) | + sort -r | sed -e ss.ss | tee manifest > "$pkg_db/$name/manifest" } pkg_tar() {