Improve previous and only overwrite files while upgrading packages in the

unpack phase.

--HG--
extra : convert_revision : xtraeme%40gmail.com-20100128152108-vfs98fe3wvtort4s
This commit is contained in:
Juan RP
2010-01-28 16:21:08 +01:00
parent 61dde1ac02
commit df5b800366
2 changed files with 20 additions and 9 deletions

View File

@@ -65,13 +65,24 @@
*/
static void
set_extract_flags(int *flags)
set_extract_flags(int *flags, bool update)
{
*flags = 0;
int lflags = 0;
if (getuid() == 0)
*flags = FEXTRACT_FLAGS;
lflags = FEXTRACT_FLAGS;
else
*flags = EXTRACT_FLAGS;
lflags = EXTRACT_FLAGS;
if (!update) {
/*
* Only overwrite files while updating.
*/
lflags |= ARCHIVE_EXTRACT_NO_OVERWRITE;
lflags |= ARCHIVE_EXTRACT_NO_OVERWRITE_NEWER;
}
*flags = lflags;
}
/*
@@ -152,7 +163,7 @@ unpack_archive_fini(struct archive *ar, prop_dictionary_t pkg)
*/
while (archive_read_next_header(ar, &entry) == ARCHIVE_OK) {
entry_str = archive_entry_pathname(entry);
set_extract_flags(&lflags);
set_extract_flags(&lflags, update);
/*
* Run the pre INSTALL action if the file is there.
*/