mirror of
https://codeberg.org/kiss-community/kiss
synced 2024-12-25 08:30:05 -07:00
kiss: clean up
This commit is contained in:
parent
f4d061b22d
commit
f6e47939d0
31
kiss
31
kiss
@ -928,42 +928,39 @@ pkg_swap() {
|
|||||||
die "Alternative '$1 $2' doesn't exist"
|
die "Alternative '$1 $2' doesn't exist"
|
||||||
|
|
||||||
if [ -f "$2" ]; then
|
if [ -f "$2" ]; then
|
||||||
# Figure out which package owns the file we are going to
|
# Figure out which package owns the file we are going to swap for
|
||||||
# swap for another package's.
|
# another package's. Print the full path to the manifest file which
|
||||||
#
|
# contains the match to our search.
|
||||||
# Print the full path to the manifest file which contains
|
|
||||||
# the match to our search.
|
|
||||||
pkg_owns=$(set +f; grep -lFx "$2" "$sys_db/"*/manifest) ||:
|
pkg_owns=$(set +f; grep -lFx "$2" "$sys_db/"*/manifest) ||:
|
||||||
|
|
||||||
# Extract the package name from the path above.
|
# Extract the package name from the path above.
|
||||||
pkg_owns=${pkg_owns%/*}
|
pkg_owns=${pkg_owns%/*}
|
||||||
pkg_owns=${pkg_owns##*/}
|
pkg_owns=${pkg_owns##*/}
|
||||||
|
|
||||||
[ "$pkg_owns" ] ||
|
# Ensure that the file we're going to swap is actually owned by a
|
||||||
die "File '$2' exists on filesystem but isn't owned"
|
# package. If it is not, we have to die here.
|
||||||
|
[ "$pkg_owns" ] || die "File '$2' exists on filesystem but isn't owned"
|
||||||
|
|
||||||
log "Swapping '$2' from '$pkg_owns' to '$1'"
|
log "Swapping '$2' from '$pkg_owns' to '$1'"
|
||||||
|
|
||||||
# Convert the current owner to an alternative and rewrite
|
# Convert the current owner to an alternative and rewrite its manifest
|
||||||
# its manifest file to reflect this.
|
# file to reflect this.
|
||||||
cp -Pf "$KISS_ROOT/$2" "$pkg_owns>${alt#*>}"
|
cp -Pf "$KISS_ROOT/$2" "$pkg_owns>${alt#*>}"
|
||||||
|
|
||||||
# The separator is the ASCII unit separator which should
|
# The separator is the ASCII unit separator which should be safe to
|
||||||
# be safe to use as files should never contain this character
|
# use as files should never contain this character (I hope to god)..
|
||||||
# (I hope to god)..
|
|
||||||
sed "s^$2$${PWD#$KISS_ROOT}/$pkg_owns>${alt#*>}" \
|
sed "s^$2$${PWD#$KISS_ROOT}/$pkg_owns>${alt#*>}" \
|
||||||
"../installed/$pkg_owns/manifest" | sort -r > "$mak_dir/.$1"
|
"../installed/$pkg_owns/manifest" | sort -r > "$mak_dir/.$1"
|
||||||
|
|
||||||
mv -f "$mak_dir/.$1" "../installed/$pkg_owns/manifest"
|
mv -f "$mak_dir/.$1" "../installed/$pkg_owns/manifest"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Convert the desired alternative to a real file and rewrite
|
# Convert the desired alternative to a real file and rewrite the manifest
|
||||||
# the manifest file to reflect this. The reverse of above.
|
# file to reflect this. The reverse of above.
|
||||||
mv -f "$alt" "$KISS_ROOT/$2"
|
mv -f "$alt" "$KISS_ROOT/$2"
|
||||||
|
|
||||||
# The separator is the ASCII unit separator which should
|
# The separator is the ASCII unit separator which should be safe to use
|
||||||
# be safe to use as files should never contain this character
|
# as files should never contain this character (I hope to god).
|
||||||
# (I hope to god)..
|
|
||||||
sed "s${PWD#$KISS_ROOT}/$alt$2" \
|
sed "s${PWD#$KISS_ROOT}/$alt$2" \
|
||||||
"../installed/$1/manifest" | sort -r > "$mak_dir/.$1"
|
"../installed/$1/manifest" | sort -r > "$mak_dir/.$1"
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user