Merge branch 'epoch-work'
This commit is contained in:
commit
51175f31c4
31 changed files with 318 additions and 178 deletions
|
@ -220,12 +220,6 @@ while read i; do
|
|||
%REPLACES%)
|
||||
echo "replaces = $i" >> .PKGINFO
|
||||
;;
|
||||
%EPOCH%)
|
||||
echo "epoch = $i" >> .PKGINFO
|
||||
;;
|
||||
%FORCE%)
|
||||
echo "force = true" >> .PKGINFO
|
||||
;;
|
||||
|
||||
# files
|
||||
%BACKUP%)
|
||||
|
|
1
doc/.gitignore
vendored
1
doc/.gitignore
vendored
|
@ -6,6 +6,7 @@ pacman.8
|
|||
pacman.conf.5
|
||||
repo-add.8
|
||||
repo-remove.8
|
||||
vercmp.8
|
||||
*.css
|
||||
*.html
|
||||
*.xml
|
||||
|
|
|
@ -7,6 +7,7 @@ ASCIIDOC_MANS = \
|
|||
pacman.8 \
|
||||
makepkg.8 \
|
||||
repo-add.8 \
|
||||
vercmp.8 \
|
||||
PKGBUILD.5 \
|
||||
makepkg.conf.5 \
|
||||
pacman.conf.5 \
|
||||
|
@ -18,6 +19,7 @@ HTML_MANPAGES = \
|
|||
pacman.8.html \
|
||||
makepkg.8.html \
|
||||
repo-add.8.html \
|
||||
vercmp.8.html \
|
||||
PKGBUILD.5.html \
|
||||
makepkg.conf.5.html \
|
||||
pacman.conf.5.html \
|
||||
|
@ -38,6 +40,7 @@ EXTRA_DIST = \
|
|||
pacman.8.txt \
|
||||
makepkg.8.txt \
|
||||
repo-add.8.txt \
|
||||
vercmp.8.txt \
|
||||
PKGBUILD.5.txt \
|
||||
PKGBUILD-example.txt \
|
||||
makepkg.conf.5.txt \
|
||||
|
@ -129,6 +132,7 @@ $(HTML_OTHER): asciidoc.conf
|
|||
pacman.8 pacman.8.html: pacman.8.txt
|
||||
makepkg.8 makepkg.8.html: makepkg.8.txt
|
||||
repo-add.8 repo-add.8.html: repo-add.8.txt
|
||||
vercmp.8 vercmp.8.html: vercmp.8.txt
|
||||
PKGBUILD.5 PKGBUILD.5.html: PKGBUILD.5.txt PKGBUILD-example.txt
|
||||
makepkg.conf.5 makepkg.conf.5.html: makepkg.conf.5.txt
|
||||
pacman.conf.5 pacman.conf.5.html: pacman.conf.5.txt
|
||||
|
|
|
@ -45,7 +45,7 @@ similar to `$_basekernver`.
|
|||
|
||||
*pkgver*::
|
||||
The version of the software as released from the author (e.g. '2.7.1').
|
||||
The variable is not allowed to contain hyphens.
|
||||
The variable is not allowed to contain colons or hyphens.
|
||||
|
||||
*pkgrel*::
|
||||
This is the release number specific to the Arch Linux release. This
|
||||
|
|
|
@ -18,13 +18,14 @@ Authors
|
|||
|
||||
Current maintainers:
|
||||
|
||||
* Allan McRae <allan@archlinux.org>
|
||||
* Dan McGee <dan@archlinux.org>
|
||||
* Xavier Chantry <shiningxc@gmail.com>
|
||||
* Aaron Griffin <aaron@archlinux.org>
|
||||
|
||||
Past contributors:
|
||||
|
||||
* Judd Vinet <jvinet@zeroflux.org>
|
||||
* Aurelien Foret <aurelien@archlinux.org>
|
||||
* Aaron Griffin <aaron@archlinux.org>
|
||||
|
||||
See the 'AUTHORS' file for additional contributors.
|
||||
|
|
|
@ -43,6 +43,7 @@ configuration files dealing with pacman.
|
|||
* linkman:pacman[8]
|
||||
* linkman:pacman.conf[5]
|
||||
* linkman:repo-add[8]
|
||||
* linkman:vercmp[8]
|
||||
|
||||
Changelog
|
||||
~~~~~~~~~
|
||||
|
|
|
@ -80,8 +80,10 @@ to determine which packages need upgrading. This behavior operates as follows:
|
|||
Numeric:
|
||||
1 < 1.0 < 1.1 < 1.1.1 < 1.2 < 2.0 < 3.0.0
|
||||
+
|
||||
Additionally, packages can have an 'epoch' value defined that will override any
|
||||
version comparison and force an upgrade.
|
||||
Additionally, version strings can have an 'epoch' value defined that will
|
||||
overrule any version comparison (unless the epoch values are equal). This is
|
||||
specified in an `epoch:version-rel` format. For example, `2:1.0-1` is always
|
||||
greater than `1:3.6-1`.
|
||||
|
||||
*-T, \--deptest*::
|
||||
Check dependencies; this is useful in scripts such as makepkg to check
|
||||
|
|
71
doc/vercmp.8.txt
Normal file
71
doc/vercmp.8.txt
Normal file
|
@ -0,0 +1,71 @@
|
|||
/////
|
||||
vim:set ts=4 sw=4 syntax=asciidoc noet:
|
||||
/////
|
||||
vercmp(8)
|
||||
=========
|
||||
|
||||
Name
|
||||
----
|
||||
vercmp - version comparsion utility
|
||||
|
||||
|
||||
Synopsis
|
||||
--------
|
||||
'vercmp' <version1> <version2>
|
||||
|
||||
|
||||
Description
|
||||
-----------
|
||||
'vercmp' is used to determine the relationship between two given version
|
||||
numbers. It outputs values as follows:
|
||||
|
||||
* < 0 : if ver1 < ver2
|
||||
* = 0 : if ver1 == ver2
|
||||
* > 0 : if ver1 > ver2
|
||||
|
||||
Version comparsion operates as follows:
|
||||
|
||||
Alphanumeric:
|
||||
1.0a < 1.0alpha < 1.0b < 1.0beta < 1.0p < 1.0pre < 1.0rc < 1.0
|
||||
Numeric:
|
||||
1 < 1.0 < 1.1 < 1.1.1 < 1.2 < 2.0 < 3.0.0
|
||||
|
||||
Additionally, version strings can have an 'epoch' value defined that will
|
||||
overrule any version comparison (unless the epoch values are equal). This is
|
||||
specified in an `epoch:version-rel` format. For example, `2:1.0-1` is always
|
||||
greater than `1:3.6-1`.
|
||||
|
||||
|
||||
Options
|
||||
-------
|
||||
*-h, \--help*::
|
||||
Display syntax for the given operation. If no operation was supplied
|
||||
then the general syntax is shown.
|
||||
|
||||
Examples
|
||||
--------
|
||||
|
||||
$ vercmp 1 2
|
||||
-1
|
||||
|
||||
$ vercmp 2 1
|
||||
1
|
||||
|
||||
$ vercmp 2.0-1 1.7-6
|
||||
1
|
||||
|
||||
$ vercmp 2.0 2.0-13
|
||||
0
|
||||
|
||||
$ vercmp 4.34 1:001
|
||||
-1
|
||||
|
||||
Configuration
|
||||
-------------
|
||||
There is none.
|
||||
|
||||
See Also
|
||||
--------
|
||||
linkman:pacman[8], linkman:makepkg[8], linkman:libalpm[3]
|
||||
|
||||
include::footer.txt[]
|
|
@ -238,7 +238,6 @@ size_t alpm_pkg_changelog_read(void *ptr, size_t size,
|
|||
/*int alpm_pkg_changelog_feof(const pmpkg_t *pkg, void *fp);*/
|
||||
int alpm_pkg_changelog_close(const pmpkg_t *pkg, void *fp);
|
||||
int alpm_pkg_has_scriptlet(pmpkg_t *pkg);
|
||||
int alpm_pkg_get_epoch(pmpkg_t *pkg);
|
||||
|
||||
off_t alpm_pkg_download_size(pmpkg_t *newpkg);
|
||||
alpm_list_t *alpm_pkg_unused_deltas(pmpkg_t *pkg);
|
||||
|
|
|
@ -156,12 +156,6 @@ static alpm_list_t *_cache_get_groups(pmpkg_t *pkg)
|
|||
return pkg->groups;
|
||||
}
|
||||
|
||||
static int _cache_get_epoch(pmpkg_t *pkg)
|
||||
{
|
||||
LAZY_LOAD(INFRQ_DESC, -1);
|
||||
return pkg->epoch;
|
||||
}
|
||||
|
||||
static int _cache_has_scriptlet(pmpkg_t *pkg)
|
||||
{
|
||||
ALPM_LOG_FUNC;
|
||||
|
@ -318,7 +312,6 @@ static struct pkg_operations local_pkg_ops = {
|
|||
.get_size = _cache_get_size,
|
||||
.get_isize = _cache_get_isize,
|
||||
.get_reason = _cache_get_reason,
|
||||
.get_epoch = _cache_get_epoch,
|
||||
.has_scriptlet = _cache_has_scriptlet,
|
||||
.get_licenses = _cache_get_licenses,
|
||||
.get_groups = _cache_get_groups,
|
||||
|
@ -606,11 +599,6 @@ int _alpm_local_db_read(pmdb_t *db, pmpkg_t *info, pmdbinfrq_t inforeq)
|
|||
STRDUP(linedup, _alpm_strtrim(line), goto error);
|
||||
info->replaces = alpm_list_add(info->replaces, linedup);
|
||||
}
|
||||
} else if(strcmp(line, "%EPOCH%") == 0) {
|
||||
if(fgets(line, sizeof(line), fp) == NULL) {
|
||||
goto error;
|
||||
}
|
||||
info->epoch = atoi(_alpm_strtrim(line));
|
||||
} else if(strcmp(line, "%DEPENDS%") == 0) {
|
||||
while(fgets(line, sizeof(line), fp) && strlen(_alpm_strtrim(line))) {
|
||||
pmdepend_t *dep = _alpm_splitdep(_alpm_strtrim(line));
|
||||
|
@ -767,10 +755,6 @@ int _alpm_local_db_write(pmdb_t *db, pmpkg_t *info, pmdbinfrq_t inforeq)
|
|||
}
|
||||
fprintf(fp, "\n");
|
||||
}
|
||||
if(info->epoch) {
|
||||
fprintf(fp, "%%EPOCH%%\n"
|
||||
"%d\n\n", info->epoch);
|
||||
}
|
||||
if(info->url) {
|
||||
fprintf(fp, "%%URL%%\n"
|
||||
"%s\n\n", info->url);
|
||||
|
|
|
@ -184,13 +184,6 @@ static int parse_descfile(struct archive *a, pmpkg_t *newpkg)
|
|||
STRDUP(newpkg->version, ptr, RET_ERR(PM_ERR_MEMORY, -1));
|
||||
} else if(strcmp(key, "pkgdesc") == 0) {
|
||||
STRDUP(newpkg->desc, ptr, RET_ERR(PM_ERR_MEMORY, -1));
|
||||
} else if(strcmp(key, "force") == 0) {
|
||||
/* For backward compatibility, like in sync_db_read */
|
||||
if(!newpkg->epoch) {
|
||||
newpkg->epoch = 1;
|
||||
}
|
||||
} else if(strcmp(key, "epoch") == 0) {
|
||||
newpkg->epoch = atoi(ptr);
|
||||
} else if(strcmp(key, "group") == 0) {
|
||||
newpkg->groups = alpm_list_add(newpkg->groups, strdup(ptr));
|
||||
} else if(strcmp(key, "url") == 0) {
|
||||
|
|
|
@ -340,15 +340,6 @@ static int sync_db_read(pmdb_t *db, struct archive *archive,
|
|||
READ_AND_STORE(pkg->md5sum);
|
||||
} else if(strcmp(line, "%REPLACES%") == 0) {
|
||||
READ_AND_STORE_ALL(pkg->replaces);
|
||||
} else if(strcmp(line, "%EPOCH%") == 0) {
|
||||
READ_NEXT(line);
|
||||
pkg->epoch = atoi(line);
|
||||
} else if(strcmp(line, "%FORCE%") == 0) {
|
||||
/* For backward compatibility, treat force as a non-zero epoch
|
||||
* but only if we didn't already have a known epoch value. */
|
||||
if(!pkg->epoch) {
|
||||
pkg->epoch = 1;
|
||||
}
|
||||
} else if(strcmp(line, "%DEPENDS%") == 0) {
|
||||
/* Different than the rest because of the _alpm_splitdep call. */
|
||||
while(1) {
|
||||
|
|
|
@ -110,7 +110,6 @@ static const char *_pkg_get_arch(pmpkg_t *pkg) { return pkg->arch; }
|
|||
static off_t _pkg_get_size(pmpkg_t *pkg) { return pkg->size; }
|
||||
static off_t _pkg_get_isize(pmpkg_t *pkg) { return pkg->isize; }
|
||||
static pmpkgreason_t _pkg_get_reason(pmpkg_t *pkg) { return pkg->reason; }
|
||||
static int _pkg_get_epoch(pmpkg_t *pkg) { return pkg->epoch; }
|
||||
static int _pkg_has_scriptlet(pmpkg_t *pkg) { return pkg->scriptlet; }
|
||||
|
||||
static alpm_list_t *_pkg_get_licenses(pmpkg_t *pkg) { return pkg->licenses; }
|
||||
|
@ -141,7 +140,6 @@ struct pkg_operations default_pkg_ops = {
|
|||
.get_size = _pkg_get_size,
|
||||
.get_isize = _pkg_get_isize,
|
||||
.get_reason = _pkg_get_reason,
|
||||
.get_epoch = _pkg_get_epoch,
|
||||
.has_scriptlet = _pkg_has_scriptlet,
|
||||
.get_licenses = _pkg_get_licenses,
|
||||
.get_groups = _pkg_get_groups,
|
||||
|
@ -223,11 +221,6 @@ pmpkgreason_t SYMEXPORT alpm_pkg_get_reason(pmpkg_t *pkg)
|
|||
return pkg->ops->get_reason(pkg);
|
||||
}
|
||||
|
||||
int SYMEXPORT alpm_pkg_get_epoch(pmpkg_t *pkg)
|
||||
{
|
||||
return pkg->ops->get_epoch(pkg);
|
||||
}
|
||||
|
||||
alpm_list_t SYMEXPORT *alpm_pkg_get_licenses(pmpkg_t *pkg)
|
||||
{
|
||||
return pkg->ops->get_licenses(pkg);
|
||||
|
@ -427,7 +420,6 @@ pmpkg_t *_alpm_pkg_dup(pmpkg_t *pkg)
|
|||
newpkg->size = pkg->size;
|
||||
newpkg->isize = pkg->isize;
|
||||
newpkg->scriptlet = pkg->scriptlet;
|
||||
newpkg->epoch = pkg->epoch;
|
||||
newpkg->reason = pkg->reason;
|
||||
|
||||
newpkg->licenses = alpm_list_strdup(pkg->licenses);
|
||||
|
@ -518,20 +510,8 @@ void _alpm_pkg_free_trans(pmpkg_t *pkg)
|
|||
/* Is spkg an upgrade for localpkg? */
|
||||
int _alpm_pkg_compare_versions(pmpkg_t *spkg, pmpkg_t *localpkg)
|
||||
{
|
||||
int spkg_epoch, localpkg_epoch;
|
||||
|
||||
ALPM_LOG_FUNC;
|
||||
|
||||
spkg_epoch = alpm_pkg_get_epoch(spkg);
|
||||
localpkg_epoch = alpm_pkg_get_epoch(localpkg);
|
||||
|
||||
if(spkg_epoch > localpkg_epoch) {
|
||||
return(1);
|
||||
} else if(spkg_epoch < localpkg_epoch) {
|
||||
return(-1);
|
||||
}
|
||||
|
||||
/* equal epoch values, move on to version comparison */
|
||||
return alpm_pkg_vercmp(alpm_pkg_get_version(spkg),
|
||||
alpm_pkg_get_version(localpkg));
|
||||
}
|
||||
|
|
|
@ -57,7 +57,6 @@ struct pkg_operations {
|
|||
off_t (*get_size) (pmpkg_t *);
|
||||
off_t (*get_isize) (pmpkg_t *);
|
||||
pmpkgreason_t (*get_reason) (pmpkg_t *);
|
||||
int (*get_epoch) (pmpkg_t *);
|
||||
int (*has_scriptlet) (pmpkg_t *);
|
||||
|
||||
alpm_list_t *(*get_licenses) (pmpkg_t *);
|
||||
|
@ -107,7 +106,6 @@ struct __pmpkg_t {
|
|||
off_t download_size;
|
||||
|
||||
int scriptlet;
|
||||
int epoch;
|
||||
|
||||
pmpkgreason_t reason;
|
||||
pmpkgfrom_t origin;
|
||||
|
|
|
@ -23,23 +23,66 @@
|
|||
/* libalpm */
|
||||
#include "util.h"
|
||||
|
||||
/** Compare two version strings and determine which one is 'newer'.
|
||||
* Returns a value comparable to the way strcmp works. Returns 1
|
||||
* if a is newer than b, 0 if a and b are the same version, or -1
|
||||
* if b is newer than a.
|
||||
*
|
||||
* This function has been adopted from the rpmvercmp function located
|
||||
* at lib/rpmvercmp.c, and was most recently updated against rpm
|
||||
* version 4.4.2.3. Small modifications have been made to make it more
|
||||
* consistent with the libalpm coding style.
|
||||
*
|
||||
* Keep in mind that the pkgrel is only compared if it is available
|
||||
* on both versions handed to this function. For example, comparing
|
||||
* 1.5-1 and 1.5 will yield 0; comparing 1.5-1 and 1.5-2 will yield
|
||||
* -1 as expected. This is mainly for supporting versioned dependencies
|
||||
* that do not include the pkgrel.
|
||||
/**
|
||||
* Some functions in this file have been adopted from the rpm source, notably
|
||||
* 'rpmvercmp' located at lib/rpmvercmp.c and 'parseEVR' located at
|
||||
* lib/rpmds.c. It was most recently updated against rpm version 4.8.1. Small
|
||||
* modifications have been made to make it more consistent with the libalpm
|
||||
* coding style.
|
||||
*/
|
||||
int SYMEXPORT alpm_pkg_vercmp(const char *a, const char *b)
|
||||
|
||||
/**
|
||||
* Split EVR into epoch, version, and release components.
|
||||
* @param evr [epoch:]version[-release] string
|
||||
* @retval *ep pointer to epoch
|
||||
* @retval *vp pointer to version
|
||||
* @retval *rp pointer to release
|
||||
*/
|
||||
static void parseEVR(char *evr, const char **ep, const char **vp,
|
||||
const char **rp)
|
||||
{
|
||||
const char *epoch;
|
||||
const char *version;
|
||||
const char *release;
|
||||
char *s, *se;
|
||||
|
||||
s = evr;
|
||||
/* s points to epoch terminator */
|
||||
while (*s && isdigit(*s)) s++;
|
||||
/* se points to version terminator */
|
||||
se = strrchr(s, '-');
|
||||
|
||||
if(*s == ':') {
|
||||
epoch = evr;
|
||||
*s++ = '\0';
|
||||
version = s;
|
||||
if(*epoch == '\0') {
|
||||
epoch = "0";
|
||||
}
|
||||
} else {
|
||||
/* different from RPM- always assume 0 epoch */
|
||||
epoch = "0";
|
||||
version = evr;
|
||||
}
|
||||
if(se) {
|
||||
*se++ = '\0';
|
||||
release = se;
|
||||
} else {
|
||||
release = NULL;
|
||||
}
|
||||
|
||||
if(ep) *ep = epoch;
|
||||
if(vp) *vp = version;
|
||||
if(rp) *rp = release;
|
||||
}
|
||||
|
||||
/**
|
||||
* Compare alpha and numeric segments of two versions.
|
||||
* return 1: a is newer than b
|
||||
* 0: a and b are the same version
|
||||
* -1: b is newer than a
|
||||
*/
|
||||
static int rpmvercmp(const char *a, const char *b)
|
||||
{
|
||||
char oldch1, oldch2;
|
||||
char *str1, *str2;
|
||||
|
@ -49,13 +92,6 @@ int SYMEXPORT alpm_pkg_vercmp(const char *a, const char *b)
|
|||
int isnum;
|
||||
int ret = 0;
|
||||
|
||||
/* libalpm added code. ensure our strings are not null */
|
||||
if(!a) {
|
||||
if(!b) return(0);
|
||||
return(-1);
|
||||
}
|
||||
if(!b) return(1);
|
||||
|
||||
/* easy comparison to see if versions are identical */
|
||||
if(strcmp(a, b) == 0) return(0);
|
||||
|
||||
|
@ -147,22 +183,6 @@ int SYMEXPORT alpm_pkg_vercmp(const char *a, const char *b)
|
|||
one = ptr1;
|
||||
*ptr2 = oldch2;
|
||||
two = ptr2;
|
||||
|
||||
/* libalpm added code. check if version strings have hit the pkgrel
|
||||
* portion. depending on which strings have hit, take correct action.
|
||||
* this is all based on the premise that we only have one dash in
|
||||
* the version string, and it separates pkgver from pkgrel. */
|
||||
if(*ptr1 == '-' && *ptr2 == '-') {
|
||||
/* no-op, continue comparing since we are equivalent throughout */
|
||||
} else if(*ptr1 == '-') {
|
||||
/* ptr1 has hit the pkgrel and ptr2 has not. continue version
|
||||
* comparison after stripping the pkgrel from ptr1. */
|
||||
*ptr1 = '\0';
|
||||
} else if(*ptr2 == '-') {
|
||||
/* ptr2 has hit the pkgrel and ptr1 has not. continue version
|
||||
* comparison after stripping the pkgrel from ptr2. */
|
||||
*ptr2 = '\0';
|
||||
}
|
||||
}
|
||||
|
||||
/* this catches the case where all numeric and alpha segments have */
|
||||
|
@ -179,7 +199,7 @@ int SYMEXPORT alpm_pkg_vercmp(const char *a, const char *b)
|
|||
* - if one is an alpha, two is newer.
|
||||
* - otherwise one is newer.
|
||||
* */
|
||||
if ( ( !*one && !isalpha((int)*two) )
|
||||
if ( (!*one && !isalpha((int)*two))
|
||||
|| isalpha((int)*one) ) {
|
||||
ret = -1;
|
||||
} else {
|
||||
|
@ -192,4 +212,61 @@ cleanup:
|
|||
return(ret);
|
||||
}
|
||||
|
||||
/** Compare two version strings and determine which one is 'newer'.
|
||||
* Returns a value comparable to the way strcmp works. Returns 1
|
||||
* if a is newer than b, 0 if a and b are the same version, or -1
|
||||
* if b is newer than a.
|
||||
*
|
||||
* Different epoch values for version strings will override any further
|
||||
* comparison. If no epoch is provided, 0 is assumed.
|
||||
*
|
||||
* Keep in mind that the pkgrel is only compared if it is available
|
||||
* on both versions handed to this function. For example, comparing
|
||||
* 1.5-1 and 1.5 will yield 0; comparing 1.5-1 and 1.5-2 will yield
|
||||
* -1 as expected. This is mainly for supporting versioned dependencies
|
||||
* that do not include the pkgrel.
|
||||
*/
|
||||
int SYMEXPORT alpm_pkg_vercmp(const char *a, const char *b)
|
||||
{
|
||||
char *full1, *full2;
|
||||
const char *epoch1, *ver1, *rel1;
|
||||
const char *epoch2, *ver2, *rel2;
|
||||
int ret;
|
||||
|
||||
/* ensure our strings are not null */
|
||||
if(!a && !b) {
|
||||
return(0);
|
||||
} else if(!a) {
|
||||
return(-1);
|
||||
} else if(!b) {
|
||||
return(1);
|
||||
}
|
||||
/* another quick shortcut- if full version specs are equal */
|
||||
if(strcmp(a, b) == 0) {
|
||||
return(0);
|
||||
}
|
||||
|
||||
/* Parse both versions into [epoch:]version[-release] triplets. We probably
|
||||
* don't need epoch and release to support all the same magic, but it is
|
||||
* easier to just run it all through the same code. */
|
||||
full1 = strdup(a);
|
||||
full2 = strdup(b);
|
||||
|
||||
/* parseEVR modifies passed in version, so have to dupe it first */
|
||||
parseEVR(full1, &epoch1, &ver1, &rel1);
|
||||
parseEVR(full2, &epoch2, &ver2, &rel2);
|
||||
|
||||
ret = rpmvercmp(epoch1, epoch2);
|
||||
if(ret == 0) {
|
||||
ret = rpmvercmp(ver1, ver2);
|
||||
if(ret == 0 && rel1 && rel2) {
|
||||
ret = rpmvercmp(rel1, rel2);
|
||||
}
|
||||
}
|
||||
|
||||
free(full1);
|
||||
free(full2);
|
||||
return(ret);
|
||||
}
|
||||
|
||||
/* vim: set ts=2 sw=2 noet: */
|
||||
|
|
|
@ -142,18 +142,20 @@ clean_up() {
|
|||
msg "$(gettext "Cleaning up...")"
|
||||
rm -rf "$pkgdir" "$srcdir"
|
||||
if [[ -n $pkgbase ]]; then
|
||||
# TODO: this wasn't properly fixed in commit 2020e629
|
||||
local fullver=$(get_full_version $epoch $pkgver $pkgrel)
|
||||
# Can't do this unless the BUILDSCRIPT has been sourced.
|
||||
if (( BUILDFUNC )); then
|
||||
rm -f "${pkgbase}-${pkgver}-${pkgrel}-${CARCH}-build.log"*
|
||||
rm -f "${pkgbase}-${fullver}-${CARCH}-build.log"*
|
||||
fi
|
||||
if (( CHECKFUNC )); then
|
||||
rm -f "${pkgbase}-${pkgver}-${pkgrel}-${CARCH}-check.log"*
|
||||
rm -f "${pkgbase}-${fullver}-${CARCH}-check.log"*
|
||||
fi
|
||||
if (( PKGFUNC )); then
|
||||
rm -f "${pkgbase}-${pkgver}-${pkgrel}-${CARCH}-package.log"*
|
||||
rm -f "${pkgbase}-${fullver}-${CARCH}-package.log"*
|
||||
elif (( SPLITPKG )); then
|
||||
for pkg in ${pkgname[@]}; do
|
||||
rm -f "${pkgbase}-${pkgver}-${pkgrel}-${CARCH}-package_${pkg}.log"*
|
||||
rm -f "${pkgbase}-${fullver}-${CARCH}-package_${pkg}.log"*
|
||||
done
|
||||
fi
|
||||
|
||||
|
@ -224,6 +226,19 @@ get_url() {
|
|||
echo "${1#*::}"
|
||||
}
|
||||
|
||||
##
|
||||
# usage : get_full_version( $epoch, $pkgver, $pkgrel )
|
||||
# return : full version spec, including epoch (if necessary), pkgver, pkgrel
|
||||
##
|
||||
get_full_version() {
|
||||
if [[ $1 -eq 0 ]]; then
|
||||
# zero epoch case, don't include it in version
|
||||
echo $2-$3
|
||||
else
|
||||
echo $1:$2-$3
|
||||
fi
|
||||
}
|
||||
|
||||
##
|
||||
# Checks to see if options are present in makepkg.conf or PKGBUILD;
|
||||
# PKGBUILD options always take precedence.
|
||||
|
@ -762,7 +777,8 @@ run_function() {
|
|||
local ret=0
|
||||
local restoretrap
|
||||
if (( LOGGING )); then
|
||||
local BUILDLOG="${startdir}/${pkgbase}-${pkgver}-${pkgrel}-${CARCH}-$pkgfunc.log"
|
||||
local fullver=$(get_full_version $epoch $pkgver $pkgrel)
|
||||
local BUILDLOG="${startdir}/${pkgbase}-${fullver}-${CARCH}-$pkgfunc.log"
|
||||
if [[ -f $BUILDLOG ]]; then
|
||||
local i=1
|
||||
while true; do
|
||||
|
@ -935,9 +951,8 @@ write_pkginfo() {
|
|||
echo "# $(LC_ALL=C date -u)"
|
||||
echo "pkgname = $1"
|
||||
(( SPLITPKG )) && echo pkgbase = $pkgbase
|
||||
echo "pkgver = $pkgver-$pkgrel"
|
||||
echo "pkgver = $(get_full_version $epoch $pkgver $pkgrel)"
|
||||
echo "pkgdesc = $pkgdesc"
|
||||
[[ $epoch ]] && echo "epoch = $epoch"
|
||||
echo "url = $url"
|
||||
echo "builddate = $builddate"
|
||||
echo "packager = $packager"
|
||||
|
@ -1049,7 +1064,8 @@ create_package() {
|
|||
"$PKGEXT" ; EXT=$PKGEXT ;;
|
||||
esac
|
||||
|
||||
local pkg_file="$PKGDEST/${nameofpkg}-${pkgver}-${pkgrel}-${PKGARCH}${PKGEXT}"
|
||||
local fullver=$(get_full_version $epoch $pkgver $pkgrel)
|
||||
local pkg_file="$PKGDEST/${nameofpkg}-${fullver}-${PKGARCH}${PKGEXT}"
|
||||
local ret=0
|
||||
|
||||
# when fileglobbing, we want * in an empty directory to expand to
|
||||
|
@ -1144,7 +1160,8 @@ create_srcpackage() {
|
|||
"$SRCEXT" ;;
|
||||
esac
|
||||
|
||||
local pkg_file="$SRCPKGDEST/${pkgbase}-${pkgver}-${pkgrel}${SRCEXT}"
|
||||
local fullver=$(get_full_version $epoch $pkgver $pkgrel)
|
||||
local pkg_file="$SRCPKGDEST/${pkgbase}-${fullver}${SRCEXT}"
|
||||
|
||||
# tar it up
|
||||
msg2 "$(gettext "Compressing source package...")"
|
||||
|
@ -1176,12 +1193,14 @@ install_package() {
|
|||
msg "$(gettext "Installing %s package group with %s -U...")" "$pkgbase" "$PACMAN"
|
||||
fi
|
||||
|
||||
local pkg pkglist
|
||||
local fullver pkg pkglist
|
||||
for pkg in ${pkgname[@]}; do
|
||||
if [[ -f $PKGDEST/${pkg}-${pkgver}-${pkgrel}-${CARCH}${PKGEXT} ]]; then
|
||||
pkglist+=" $PKGDEST/${pkg}-${pkgver}-${pkgrel}-${CARCH}${PKGEXT}"
|
||||
# TODO: this wasn't properly fixed in commit 2020e629
|
||||
fullver=$(get_full_version $epoch $pkgver $pkgrel)
|
||||
if [[ -f $PKGDEST/${pkg}-${fullver}-${CARCH}${PKGEXT} ]]; then
|
||||
pkglist+=" $PKGDEST/${pkg}-${fullver}-${CARCH}${PKGEXT}"
|
||||
else
|
||||
pkglist+=" $PKGDEST/${pkg}-${pkgver}-${pkgrel}-any${PKGEXT}"
|
||||
pkglist+=" $PKGDEST/${pkg}-${fullver}-any${PKGEXT}"
|
||||
fi
|
||||
done
|
||||
|
||||
|
@ -1803,7 +1822,7 @@ if (( ! ( ASROOT || INFAKEROOT ) && ( DEP_BIN || RMDEPS || INSTALL ) )); then
|
|||
fi
|
||||
fi
|
||||
|
||||
unset pkgname pkgbase pkgver pkgrel pkgdesc url license groups provides
|
||||
unset pkgname pkgbase pkgver pkgrel epoch pkgdesc url license groups provides
|
||||
unset md5sums replaces depends conflicts backup source install changelog build
|
||||
unset makedepends optdepends options noextract
|
||||
|
||||
|
@ -1840,6 +1859,7 @@ if (( GENINTEG )); then
|
|||
fi
|
||||
|
||||
pkgbase=${pkgbase:-${pkgname[0]}}
|
||||
epoch=${epoch:-0}
|
||||
|
||||
# check the PKGBUILD for some basic requirements
|
||||
check_sanity || exit 1
|
||||
|
@ -1877,8 +1897,9 @@ if [[ -n "${PKGLIST[@]}" ]]; then
|
|||
fi
|
||||
|
||||
if (( ! SPLITPKG )); then
|
||||
if [[ -f $PKGDEST/${pkgname}-${pkgver}-${pkgrel}-${CARCH}${PKGEXT} \
|
||||
|| -f $PKGDEST/${pkgname}-${pkgver}-${pkgrel}-any${PKGEXT} ]] \
|
||||
fullver=$(get_full_version $epoch $pkgver $pkgrel)
|
||||
if [[ -f $PKGDEST/${pkgname}-${fullver}-${CARCH}${PKGEXT} \
|
||||
|| -f $PKGDEST/${pkgname}-${fullver}-any${PKGEXT} ]] \
|
||||
&& ! (( FORCE || SOURCEONLY || NOBUILD )); then
|
||||
if (( INSTALL )); then
|
||||
warning "$(gettext "A package has already been built, installing existing package...")"
|
||||
|
@ -1893,8 +1914,10 @@ else
|
|||
allpkgbuilt=1
|
||||
somepkgbuilt=0
|
||||
for pkg in ${pkgname[@]}; do
|
||||
if [[ -f $PKGDEST/${pkg}-${pkgver}-${pkgrel}-${CARCH}${PKGEXT} \
|
||||
|| -f $PKGDEST/${pkg}-${pkgver}-${pkgrel}-any${PKGEXT} ]]; then
|
||||
# TODO: this wasn't properly fixed in commit 2020e629
|
||||
fullver=$(get_full_version $epoch $pkgver $pkgrel)
|
||||
if [[ -f $PKGDEST/${pkg}-${fullver}-${CARCH}${PKGEXT} \
|
||||
|| -f $PKGDEST/${pkg}-${fullver}-any${PKGEXT} ]]; then
|
||||
somepkgbuilt=1
|
||||
else
|
||||
allpkgbuilt=0
|
||||
|
@ -1946,11 +1969,12 @@ if (( INFAKEROOT )); then
|
|||
exit 0 # $E_OK
|
||||
fi
|
||||
|
||||
msg "$(gettext "Making package: %s")" "$pkgbase $pkgver-$pkgrel ($(date))"
|
||||
fullver=$(get_full_version $epoch $pkgver $pkgrel)
|
||||
msg "$(gettext "Making package: %s")" "$pkgbase $fullver ($(date))"
|
||||
|
||||
# if we are creating a source-only package, go no further
|
||||
if (( SOURCEONLY )); then
|
||||
if [[ -f $SRCPKGDEST/${pkgbase}-${pkgver}-${pkgrel}${SRCEXT} ]] \
|
||||
if [[ -f $SRCPKGDEST/${pkgbase}-${fullver}${SRCEXT} ]] \
|
||||
&& (( ! FORCE )); then
|
||||
error "$(gettext "A source package has already been built. (use -f to overwrite)")"
|
||||
exit 1
|
||||
|
@ -2082,7 +2106,8 @@ else
|
|||
fi
|
||||
fi
|
||||
|
||||
msg "$(gettext "Finished making: %s")" "$pkgbase $pkgver-$pkgrel ($(date))"
|
||||
fullver=$(get_full_version $epoch $pkgver $pkgrel)
|
||||
msg "$(gettext "Finished making: %s")" "$pkgbase $fullver ($(date))"
|
||||
|
||||
install_package
|
||||
|
||||
|
|
|
@ -190,7 +190,7 @@ db_write_entry()
|
|||
{
|
||||
# blank out all variables
|
||||
local pkgfile="$1"
|
||||
local pkgname pkgver pkgdesc epoch csize size md5sum url arch builddate packager force \
|
||||
local pkgname pkgver pkgdesc csize size md5sum url arch builddate packager \
|
||||
_groups _licenses _replaces _depends _conflicts _provides _optdepends
|
||||
|
||||
local OLDIFS="$IFS"
|
||||
|
@ -274,12 +274,6 @@ db_write_entry()
|
|||
[[ -n $builddate ]] && echo -e "%BUILDDATE%\n$builddate\n" >>desc
|
||||
[[ -n $packager ]] && echo -e "%PACKAGER%\n$packager\n" >>desc
|
||||
write_list_entry "REPLACES" "$_replaces" "desc"
|
||||
# remain backward-compatible for now; put a force entry in the database
|
||||
if [[ -n $epoch ]]; then
|
||||
echo -e "%EPOCH%\n#epoch\n" >>desc
|
||||
echo -e "%FORCE%\n" >>desc
|
||||
fi
|
||||
[[ -n $force ]] && echo -e "%FORCE%\n" >>desc
|
||||
|
||||
# create depends entry
|
||||
msg2 "$(gettext "Creating 'depends' db entry...")"
|
||||
|
|
|
@ -24,8 +24,8 @@
|
|||
|
||||
#define BASENAME "vercmp"
|
||||
|
||||
/* forward declaration, comes from vercmp.o in libalpm source that is linked in
|
||||
* directly so we don't have any library deps */
|
||||
/* forward declaration, comes from version.o in libalpm source that is linked
|
||||
* in directly so we don't have any library deps */
|
||||
int alpm_pkg_vercmp(const char *a, const char *b);
|
||||
|
||||
static void usage(void)
|
||||
|
|
|
@ -156,11 +156,6 @@ class pmdb:
|
|||
pkg.md5sum = fd.readline().strip("\n")
|
||||
elif line == "%REPLACES%":
|
||||
pkg.replaces = _getsection(fd)
|
||||
elif line == "%EPOCH%":
|
||||
pkg.epoch = int(fd.readline().strip("\n"))
|
||||
elif line == "%FORCE%":
|
||||
fd.readline()
|
||||
pkg.force = True
|
||||
elif line == "%DEPENDS%":
|
||||
pkg.depends = _getsection(fd)
|
||||
elif line == "%OPTDEPENDS%":
|
||||
|
@ -250,19 +245,10 @@ class pmdb:
|
|||
data.append(_mksection("SIZE", pkg.size))
|
||||
if pkg.reason:
|
||||
data.append(_mksection("REASON", pkg.reason))
|
||||
if pkg.epoch:
|
||||
data.append(_mksection("EPOCH", pkg.epoch))
|
||||
else:
|
||||
data.append(_mksection("FILENAME", pkg.filename()))
|
||||
if pkg.replaces:
|
||||
data.append(_mksection("REPLACES", pkg.replaces))
|
||||
if pkg.epoch:
|
||||
data.append(_mksection("EPOCH", pkg.epoch))
|
||||
# for backward compatibility
|
||||
if not pkg.force:
|
||||
data.append(_mksection("FORCE", ""))
|
||||
if pkg.force:
|
||||
data.append(_mksection("FORCE", ""))
|
||||
if pkg.csize:
|
||||
data.append(_mksection("CSIZE", pkg.csize))
|
||||
if pkg.md5sum:
|
||||
|
|
|
@ -49,8 +49,6 @@ class pmpkg:
|
|||
self.reason = 0
|
||||
self.md5sum = "" # sync only
|
||||
self.replaces = []
|
||||
self.force = False
|
||||
self.epoch = 0
|
||||
self.depends = []
|
||||
self.optdepends = []
|
||||
self.conflicts = []
|
||||
|
@ -132,10 +130,6 @@ class pmpkg:
|
|||
data.append("builddate = %s" % self.builddate)
|
||||
data.append("packager = %s" % self.packager)
|
||||
data.append("size = %s" % self.size)
|
||||
if self.force:
|
||||
data.append("force = true")
|
||||
if self.epoch:
|
||||
data.append("epoch = %d" % self.epoch)
|
||||
if self.arch:
|
||||
data.append("arch = %s" % self.arch)
|
||||
for i in self.license:
|
||||
|
|
|
@ -78,9 +78,6 @@ class pmrule:
|
|||
elif case == "VERSION":
|
||||
if value != newpkg.version:
|
||||
success = 0
|
||||
elif case == "EPOCH":
|
||||
if int(value) != newpkg.epoch:
|
||||
success = 0
|
||||
elif case == "DESC":
|
||||
if value != newpkg.desc:
|
||||
success = 0
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
self.description = "Sysupgrade with a sync package having higher epoch"
|
||||
|
||||
sp = pmpkg("dummy", "1.0-1")
|
||||
sp.epoch = 1
|
||||
sp = pmpkg("dummy", "1:1.0-1")
|
||||
self.addpkg2db("sync", sp)
|
||||
|
||||
lp = pmpkg("dummy", "1.1-1")
|
||||
|
@ -10,4 +9,4 @@ self.addpkg2db("local", lp)
|
|||
self.args = "-Su"
|
||||
|
||||
self.addrule("PACMAN_RETCODE=0")
|
||||
self.addrule("PKG_VERSION=dummy|1.0-1")
|
||||
self.addrule("PKG_VERSION=dummy|1:1.0-1")
|
|
@ -3,8 +3,7 @@ self.description = "Sysupgrade with an epoch and ignore on same package"
|
|||
lp = pmpkg("dummy", "1.0-1")
|
||||
self.addpkg2db("local", lp)
|
||||
|
||||
sp = pmpkg("dummy", "1.0-2")
|
||||
sp.epoch = 1
|
||||
sp = pmpkg("dummy", "1:1.0-2")
|
||||
self.addpkg2db("sync", sp)
|
||||
|
||||
self.args = "-Su --ignore %s" % lp.name
|
|
@ -1,14 +1,12 @@
|
|||
self.description = "Sysupgrade with an epoch package overriding a force package"
|
||||
|
||||
sp = pmpkg("dummy", "1.4-1")
|
||||
sp.epoch = 2
|
||||
sp = pmpkg("dummy", "2:1.4-1")
|
||||
self.addpkg2db("sync", sp)
|
||||
|
||||
lp = pmpkg("dummy", "2.0-1")
|
||||
lp.force = True
|
||||
lp = pmpkg("dummy", "1:2.0-1")
|
||||
self.addpkg2db("local", lp)
|
||||
|
||||
self.args = "-Su"
|
||||
|
||||
self.addrule("PACMAN_RETCODE=0")
|
||||
self.addrule("PKG_VERSION=dummy|1.4-1")
|
||||
self.addrule("PKG_VERSION=dummy|2:1.4-1")
|
|
@ -1,18 +1,16 @@
|
|||
self.description = "Sysupgrade with same version, different epochs"
|
||||
|
||||
sp = pmpkg("dummy", "2.0-1")
|
||||
sp = pmpkg("dummy", "2:2.0-1")
|
||||
sp.files = ["bin/dummynew"]
|
||||
sp.epoch = 2
|
||||
self.addpkg2db("sync", sp)
|
||||
|
||||
lp = pmpkg("dummy", "2.0-1")
|
||||
lp = pmpkg("dummy", "1:2.0-1")
|
||||
lp.files = ["bin/dummyold"]
|
||||
lp.force = True
|
||||
self.addpkg2db("local", lp)
|
||||
|
||||
self.args = "-Su"
|
||||
|
||||
self.addrule("PACMAN_RETCODE=0")
|
||||
self.addrule("PKG_VERSION=dummy|2.0-1")
|
||||
self.addrule("PKG_VERSION=dummy|2:2.0-1")
|
||||
self.addrule("FILE_EXIST=bin/dummynew")
|
||||
self.addrule("!FILE_EXIST=bin/dummyold")
|
12
test/pacman/tests/epoch010.py
Normal file
12
test/pacman/tests/epoch010.py
Normal file
|
@ -0,0 +1,12 @@
|
|||
self.description = "usbutils case study: force in new package"
|
||||
|
||||
sp = pmpkg("usbutils", "1:001-1")
|
||||
self.addpkg2db("sync", sp)
|
||||
|
||||
lp = pmpkg("usbutils", "0.91-4")
|
||||
self.addpkg2db("local", lp)
|
||||
|
||||
self.args = "-Su"
|
||||
|
||||
self.addrule("PACMAN_RETCODE=0")
|
||||
self.addrule("PKG_VERSION=usbutils|1:001-1")
|
12
test/pacman/tests/epoch011.py
Normal file
12
test/pacman/tests/epoch011.py
Normal file
|
@ -0,0 +1,12 @@
|
|||
self.description = "usbutils case study: force stays, epoch now in local db"
|
||||
|
||||
sp = pmpkg("usbutils", "1:002-1")
|
||||
self.addpkg2db("sync", sp)
|
||||
|
||||
lp = pmpkg("usbutils", "1:001-1")
|
||||
self.addpkg2db("local", lp)
|
||||
|
||||
self.args = "-Su"
|
||||
|
||||
self.addrule("PACMAN_RETCODE=0")
|
||||
self.addrule("PKG_VERSION=usbutils|1:002-1")
|
13
test/pacman/tests/epoch012.py
Normal file
13
test/pacman/tests/epoch012.py
Normal file
|
@ -0,0 +1,13 @@
|
|||
self.description = "usbutils case study: maintainer screws up and removes force"
|
||||
|
||||
sp = pmpkg("usbutils", "003-1")
|
||||
self.addpkg2db("sync", sp)
|
||||
|
||||
lp = pmpkg("usbutils", "1:002-1")
|
||||
self.addpkg2db("local", lp)
|
||||
|
||||
self.args = "-Su"
|
||||
|
||||
self.addrule("PACMAN_RETCODE=0")
|
||||
# remember, this is how we have to handle this- 003 will not be installed
|
||||
self.addrule("PKG_VERSION=usbutils|1:002-1")
|
|
@ -1,7 +1,6 @@
|
|||
self.description = "Sysupgrade with a sync package forcing a downgrade"
|
||||
|
||||
sp = pmpkg("dummy", "1.0-1")
|
||||
sp.force = True
|
||||
sp = pmpkg("dummy", "1:1.0-1")
|
||||
|
||||
self.addpkg2db("sync", sp)
|
||||
|
||||
|
@ -12,4 +11,4 @@ self.addpkg2db("local", lp)
|
|||
self.args = "-Su"
|
||||
|
||||
self.addrule("PACMAN_RETCODE=0")
|
||||
self.addrule("PKG_VERSION=dummy|1.0-1")
|
||||
self.addrule("PKG_VERSION=dummy|1:1.0-1")
|
||||
|
|
|
@ -4,8 +4,7 @@ lp = pmpkg("dummy", "1.0-1")
|
|||
|
||||
self.addpkg2db("local", lp)
|
||||
|
||||
sp = pmpkg("dummy", "1.0-2")
|
||||
sp.force = True
|
||||
sp = pmpkg("dummy", "1:1.0-2")
|
||||
self.addpkg2db("sync", sp)
|
||||
|
||||
self.args = "-Su --ignore %s" % lp.name
|
||||
|
|
|
@ -118,6 +118,25 @@ runtest 1.5.1 1.5.b 1
|
|||
runtest 1.5.b-1 1.5.b 0
|
||||
runtest 1.5-1 1.5.b -1
|
||||
|
||||
# epoch included version comparisons
|
||||
runtest 0:1.0 0:1.0 0
|
||||
runtest 0:1.0 0:1.1 -1
|
||||
runtest 1:1.0 0:1.0 1
|
||||
runtest 1:1.0 0:1.1 1
|
||||
runtest 1:1.0 2:1.1 -1
|
||||
|
||||
# epoch + sometimes present pkgrel
|
||||
runtest 1:1.0 0:1.0-1 1
|
||||
runtest 1:1.0-1 0:1.1-1 1
|
||||
|
||||
# epoch included on one version
|
||||
runtest 0:1.0 1.0 0
|
||||
runtest 0:1.0 1.1 -1
|
||||
runtest 0:1.1 1.0 1
|
||||
runtest 1:1.0 1.0 1
|
||||
runtest 1:1.0 1.1 1
|
||||
runtest 1:1.1 1.1 1
|
||||
|
||||
#END TESTS
|
||||
|
||||
echo
|
||||
|
|
Loading…
Add table
Reference in a new issue