Added basic support to update a single package via "xbps-bin update foo".

--HG--
extra : convert_revision : 7214ab270ccb57a327afeed94f6a2efc4738442d
This commit is contained in:
Juan RP 2009-04-02 02:46:36 +02:00
parent 7db36bf9e0
commit 54b6d87809
7 changed files with 174 additions and 65 deletions

View file

@ -35,11 +35,12 @@
#include <xbps_api.h>
static int unpack_archive_init(prop_dictionary_t, const char *);
static int unpack_archive_fini(struct archive *, prop_dictionary_t);
static int unpack_archive_init(prop_dictionary_t, const char *, bool);
static int unpack_archive_fini(struct archive *, prop_dictionary_t, bool);
int
xbps_unpack_binary_pkg(prop_dictionary_t repo, prop_dictionary_t pkg)
xbps_unpack_binary_pkg(prop_dictionary_t repo, prop_dictionary_t pkg,
bool update)
{
prop_string_t filename, repoloc, arch;
char *binfile, *path;
@ -69,14 +70,14 @@ xbps_unpack_binary_pkg(prop_dictionary_t repo, prop_dictionary_t pkg)
}
free(path);
rv = unpack_archive_init(pkg, binfile);
rv = unpack_archive_init(pkg, binfile, update);
free(binfile);
return rv;
}
static int
unpack_archive_init(prop_dictionary_t pkg, const char *binfile)
unpack_archive_init(prop_dictionary_t pkg, const char *binfile, bool update)
{
struct archive *ar;
int pkg_fd, rv;
@ -104,7 +105,7 @@ unpack_archive_init(prop_dictionary_t pkg, const char *binfile)
return rv;
}
rv = unpack_archive_fini(ar, pkg);
rv = unpack_archive_fini(ar, pkg, update);
/*
* If installation of package was successful, make sure the package
* is really on storage (if possible).
@ -121,10 +122,10 @@ unpack_archive_init(prop_dictionary_t pkg, const char *binfile)
/*
* Flags for extracting files in binary packages.
*/
#define EXTRACT_FLAGS ARCHIVE_EXTRACT_SECURE_NODOTDOT | \
ARCHIVE_EXTRACT_SECURE_SYMLINKS | \
ARCHIVE_EXTRACT_NO_OVERWRITE | \
#define INSTALL_EFLAGS ARCHIVE_EXTRACT_NO_OVERWRITE | \
ARCHIVE_EXTRACT_NO_OVERWRITE_NEWER
#define EXTRACT_FLAGS ARCHIVE_EXTRACT_SECURE_NODOTDOT | \
ARCHIVE_EXTRACT_SECURE_SYMLINKS
#define FEXTRACT_FLAGS ARCHIVE_EXTRACT_OWNER | ARCHIVE_EXTRACT_PERM | \
ARCHIVE_EXTRACT_TIME | EXTRACT_FLAGS
@ -133,7 +134,7 @@ unpack_archive_init(prop_dictionary_t pkg, const char *binfile)
* the consumer.
*/
static int
unpack_archive_fini(struct archive *ar, prop_dictionary_t pkg)
unpack_archive_fini(struct archive *ar, prop_dictionary_t pkg, bool update)
{
struct archive_entry *entry;
size_t len;
@ -165,6 +166,9 @@ unpack_archive_fini(struct archive *ar, prop_dictionary_t pkg)
else
lflags = EXTRACT_FLAGS;
if (update == false)
lflags |= INSTALL_EFLAGS;
/*
* This length is '.%s/metadata/%s/INSTALL' + NULL.
*/