kiss: Fix pkg_swap failure. Closes #162

This commit is contained in:
Dylan Araps 2020-06-09 10:02:52 +03:00
parent d8beb34aa5
commit 4efddd0410
No known key found for this signature in database
GPG Key ID: 46D62DD9F1DE636E

28
kiss
View File

@ -875,10 +875,16 @@ pkg_swap() {
# 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 be safe to # Replace the matching line in the manifest with the desired replacement.
# use as files should never contain this character (I hope to god).. # This used to be a 'sed' call which turned out to be a little
sed "s^$2$${PWD#"$KISS_ROOT"}/$pkg_owns>${alt#*>}" \ # error-prone in some cases. This new method is a tad slower but ensures
"../installed/$pkg_owns/manifest" | sort -r > "$mak_dir/.$1" # we never wipe the file due to a command error.
while read -r line; do
case $line in
"$2") printf '%s\n' "${PWD#"$KISS_ROOT"}/$pkg_owns>${alt#*>}" ;;
*) printf '%s\n' "$line" ;;
esac
done < "../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
@ -887,10 +893,16 @@ pkg_swap() {
# 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 be safe to use # Replace the matching line in the manifest with the desired replacement.
# as files should never contain this character (I hope to god). # This used to be a 'sed' call which turned out to be a little error-prone
sed "s${PWD#"$KISS_ROOT"}/$alt$2" \ # in some cases. This new method is a tad slower but ensures we never wipe
"../installed/$1/manifest" | sort -r > "$mak_dir/.$1" # the file due to a command error.
while read -r line; do
case $line in
"${PWD#"$KISS_ROOT"}/$alt") printf '%s\n' "$2" ;;
*) printf '%s\n' "$line" ;;
esac
done < "../installed/$1/manifest" | sort -r > "$mak_dir/.$1"
mv -f "$mak_dir/.$1" "../installed/$1/manifest" mv -f "$mak_dir/.$1" "../installed/$1/manifest"
} }