Commit 803c76b5 authored by Bernhard Link's avatar Bernhard Link

Change dpkgversion_isNewer to dpkgversion_cmp to allow checking for equal versions

parent 5dee85bb
......@@ -132,10 +132,9 @@ int versioncompare(const struct versionrevision *version,
/* now own code */
retvalue dpkgversions_isNewer(const char *first,const char *second) {
retvalue dpkgversions_cmp(const char *first,const char *second,int *result) {
struct versionrevision v1,v2;
const char *m;
int r;
if( (m = parseversion(&v1,first)) != NULL ) {
fprintf(stderr,"Error while parsing '%s' as version: %s\n",first,m);
......@@ -145,11 +144,8 @@ retvalue dpkgversions_isNewer(const char *first,const char *second) {
fprintf(stderr,"Error while parsing '%s' as version: %s\n",second,m);
return RET_ERROR;
}
r = versioncompare(&v1,&v2);
*result = versioncompare(&v1,&v2);
free((char*)v1.version);
free((char*)v2.version);
if( r > 0 )
return RET_OK;
else
return RET_NOTHING;
return RET_OK;
}
......@@ -6,8 +6,8 @@
#warning wth?
#endif
/* return RET_OK, if first >> second, RET_NOTHING if not,
* return error if those are not proper versions */
retvalue dpkgversions_isNewer(const char *first,const char *second);
/* return error if those are not proper versions,
* otherwise RET_OK and result is <0, ==0 or >0, if first is smaller, equal or larger */
retvalue dpkgversions_cmp(const char *first,const char *second,int *result);
#endif
......@@ -205,7 +205,9 @@ retvalue target_addpackage(struct target *target,DB *references,const char *name
return r;
}
if( RET_IS_OK(r) ) {
r = dpkgversions_isNewer(version,oldversion);
int versioncmp;
r = dpkgversions_cmp(version,oldversion,&versioncmp);
if( RET_WAS_ERROR(r) ) {
fprintf(stderr,"Parse errors processing versions of %s.\n",name);
if( !force ) {
......@@ -214,7 +216,7 @@ retvalue target_addpackage(struct target *target,DB *references,const char *name
return r;
}
} else {
if( r == RET_NOTHING ) {
if( versioncmp <= 0 ) {
/* new Version is not newer than old version */
if( downgrade ) {
fprintf(stderr,"Warning: downgrading '%s' from '%s' to '%s' in '%s'!\n",name,oldversion,version,target->identifier);
......
......@@ -313,33 +313,35 @@ static retvalue upgradelist_trypackage(void *data,const char *chunk){
} else {
/* The package already exists: */
char *control;struct strlist files,md5sums,origfiles;
int versioncmp;
upgrade->last = current;
r = dpkgversions_isNewer(version,current->version);
r = dpkgversions_cmp(version,current->version,&versioncmp);
if( RET_WAS_ERROR(r) ) {
free(packagename);
free(version);
return r;
}
if( r == RET_NOTHING ) {
if( verbose > 30 )
fprintf(stderr,"Ignoring '%s' from '%s' as not newer than '%s'\n",
version,packagename,current->version);
if( versioncmp <= 0 ) {
/* there already is a newer version, so
* doing nothing but perhaps updating what
* versions are around, when we are newer
* than yet known candidates... */
if( current->new_version == NULL ||
( current->new_version != current->version &&
dpkgversions_isNewer(version,
current->new_version) == RET_OK ) ) {
int c = 0;
if( current->new_version == current->version )
c =versioncmp;
else if( current->new_version == NULL )
c = 1;
else (void)dpkgversions_cmp(version,
current->new_version,&c);
if( c > 0 ) {
free(current->new_version);
current->new_version = version;
} else {
} else
free(version);
}
free(packagename);
return RET_NOTHING;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment