summaryrefslogtreecommitdiffstats
path: root/libopkg
diff options
context:
space:
mode:
Diffstat (limited to 'libopkg')
-rw-r--r--libopkg/pkg.c42
-rw-r--r--libopkg/pkg.h2
2 files changed, 27 insertions, 17 deletions
diff --git a/libopkg/pkg.c b/libopkg/pkg.c
index 9d48576..bf39b10 100644
--- a/libopkg/pkg.c
+++ b/libopkg/pkg.c
@@ -79,6 +79,7 @@ pkg_init(pkg_t *pkg)
pkg->epoch = 0;
pkg->version = NULL;
pkg->revision = NULL;
+ pkg->force_reinstall = 0;
pkg->dest = NULL;
pkg->src = NULL;
pkg->architecture = NULL;
@@ -170,6 +171,8 @@ pkg_deinit(pkg_t *pkg)
/* revision shares storage with version, so don't free */
pkg->revision = NULL;
+ pkg->force_reinstall = 0;
+
/* owned by opkg_conf_t */
pkg->dest = NULL;
/* owned by opkg_conf_t */
@@ -937,29 +940,34 @@ verrevcmp(const char *val, const char *ref) {
}
int
-pkg_compare_versions(const pkg_t *pkg, const pkg_t *ref_pkg)
+pkg_compare_versions_no_reinstall(const pkg_t *pkg, const pkg_t *ref_pkg)
{
- int r;
+ int r;
- if (pkg->epoch > ref_pkg->epoch) {
- return 1;
- }
+ r = pkg->epoch - ref_pkg->epoch;
+ if (r)
+ return r;
- if (pkg->epoch < ref_pkg->epoch) {
- return -1;
- }
+ r = verrevcmp(pkg->version, ref_pkg->version);
+ if (r)
+ return r;
- r = verrevcmp(pkg->version, ref_pkg->version);
- if (r) {
- return r;
- }
+ r = verrevcmp(pkg->revision, ref_pkg->revision);
+ return r;
+}
- r = verrevcmp(pkg->revision, ref_pkg->revision);
- if (r) {
- return r;
- }
+int
+pkg_compare_versions(const pkg_t *pkg, const pkg_t *ref_pkg)
+{
+ int r;
+
+ r = pkg_compare_versions_no_reinstall(pkg, ref_pkg);
+ if (r)
+ return r;
- return r;
+ /* Compare force_reinstall flags. */
+ r = pkg->force_reinstall - ref_pkg->force_reinstall;
+ return r;
}
diff --git a/libopkg/pkg.h b/libopkg/pkg.h
index 1e3dd3f..45fe890 100644
--- a/libopkg/pkg.h
+++ b/libopkg/pkg.h
@@ -123,6 +123,7 @@ struct pkg
unsigned long epoch;
char *version;
char *revision;
+ int force_reinstall;
pkg_src_t *src;
pkg_dest_t *dest;
char *architecture;
@@ -203,6 +204,7 @@ int pkg_merge(pkg_t *oldpkg, pkg_t *newpkg);
char *pkg_version_str_alloc(pkg_t *pkg);
int pkg_compare_versions(const pkg_t *pkg, const pkg_t *ref_pkg);
+int pkg_compare_versions_no_reinstall(const pkg_t *pkg, const pkg_t *ref_pkg);
int pkg_name_version_and_architecture_compare(const void *a, const void *b);
int abstract_pkg_name_compare(const void *a, const void *b);