mirror of
https://codeberg.org/kiss-community/kiss
synced 2024-12-25 00:20:05 -07:00
Merge pull request #12 from kissx/pkg_conflicts
kiss: Added package conflicts.
This commit is contained in:
commit
3f38626e30
37
kiss
37
kiss
@ -19,6 +19,10 @@ source_type() {
|
|||||||
[ -z "${1##*://*}" ] && return 5 # Remote file.
|
[ -z "${1##*://*}" ] && return 5 # Remote file.
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pkg_clean() {
|
||||||
|
rm -rf -- "$mak_dir" "$pkg_dir" "$cac_dir/manifest" "$cac_dir/tar"
|
||||||
|
}
|
||||||
|
|
||||||
pkg_search() {
|
pkg_search() {
|
||||||
set -f
|
set -f
|
||||||
# shellcheck disable=2086,2046
|
# shellcheck disable=2086,2046
|
||||||
@ -126,8 +130,10 @@ pkg_strip() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pkg_manifest() {
|
pkg_manifest() {
|
||||||
(cd "$pkg_dir" && find ./*) | sed -e ss.ss -e '1!G;h;$!d' |
|
# Store the file and directory list of the package.
|
||||||
sort | tee manifest > "$pkg_db/$name/manifest"
|
# Directories have a trailing '/' and the list is sorted in reverse.
|
||||||
|
(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() {
|
pkg_tar() {
|
||||||
@ -135,16 +141,39 @@ pkg_tar() {
|
|||||||
log "Use '$kiss install $name' to install the package."
|
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
|
||||||
|
[ "${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
|
||||||
|
}
|
||||||
|
|
||||||
pkg_install() {
|
pkg_install() {
|
||||||
[ -f "$bin_dir/$pkg" ] || args b "$name"
|
[ -f "$bin_dir/$pkg" ] || args b "$name"
|
||||||
|
|
||||||
|
pkg_conflicts
|
||||||
|
|
||||||
# Create a backup of 'tar' so it isn't removed during
|
# Create a backup of 'tar' so it isn't removed during
|
||||||
# package installation.
|
# package installation.
|
||||||
cp "$(command -v tar)" "$cac_dir"
|
cp "$(command -v tar)" "$cac_dir"
|
||||||
|
|
||||||
|
log "Removing previous version of package if it exists."
|
||||||
pkg_remove "$name"
|
pkg_remove "$name"
|
||||||
"$cac_dir/tar" kpxvf "$bin_dir/$pkg" -C "$sys_dir/" 2>/dev/null
|
|
||||||
|
|
||||||
|
"$cac_dir/tar" kpxf "$bin_dir/$pkg" -C "$sys_dir/"
|
||||||
"$sys_db/$name/post-install" 2>/dev/null
|
"$sys_db/$name/post-install" 2>/dev/null
|
||||||
|
|
||||||
log "Installed ${pkg%.tar.gz}"
|
log "Installed ${pkg%.tar.gz}"
|
||||||
@ -235,7 +264,7 @@ args() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
main() {
|
main() {
|
||||||
trap 'rm -rf -- "$mak_dir" "$pkg_dir" "$cac_dir/tar"' EXIT INT
|
trap pkg_clean EXIT INT
|
||||||
kiss=${0##*/}
|
kiss=${0##*/}
|
||||||
|
|
||||||
[ -z "$KISS_PATH" ] &&
|
[ -z "$KISS_PATH" ] &&
|
||||||
|
Loading…
Reference in New Issue
Block a user