kiss: fix install bug with multiple packages

If a cp fails, the file's contents is still that of the previous
package. This ensures they are truncated where applicable.
This commit is contained in:
Dylan Araps 2021-07-05 13:47:45 +03:00
parent 9c89761268
commit 6ef9a98ee3
No known key found for this signature in database
GPG Key ID: 13295DAC2CF13B5C

8
kiss
View File

@ -1204,7 +1204,7 @@ pkg_remove() {
fi
# Make a backup of the etcsums file (if it exists).
cp -f "$sys_db/$1/etcsums" "$mak_dir/c" 2>/dev/null || :
cp -f "$sys_db/$1/etcsums" "$mak_dir/c" 2>/dev/null || : > "$mak_dir/c"
log "$1" "Removing package"
pkg_remove_files < "$sys_db/$1/manifest"
@ -1320,8 +1320,10 @@ pkg_install() {
# If the package is already installed (and this is an upgrade) make a
# backup of the manifest and etcsums files.
cp -f "$sys_db/$pkg_name/manifest" "$mak_dir/m" 2>/dev/null || :
cp -f "$sys_db/$pkg_name/etcsums" "$mak_dir/c" 2>/dev/null || :
cp -f "$sys_db/$pkg_name/manifest" "$mak_dir/m" 2>/dev/null ||
: > "$mak_dir/m"
cp -f "$sys_db/$pkg_name/etcsums" "$mak_dir/c" 2>/dev/null ||
: > "$mak_dir/c"
# Install the package's files by iterating over its manifest.
pkg_install_files -z "$tar_dir/$pkg_name"