From 002758b4f2893c2cb1fa75b9e61ea967ab3eddc6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Per=20=C3=98yvind=20Karlsen?= Date: Sat, 11 Dec 2010 20:29:19 +0000 Subject: real fix for previous commit which were due to disttag & distepoch being added to files in synthesis, but not becoming part of NVRA at beginning of @info --- URPM.xs | 36 ++++++++++++++++++++++++++---------- 1 file changed, 26 insertions(+), 10 deletions(-) diff --git a/URPM.xs b/URPM.xs index d2a45aa..5e053b8 100644 --- a/URPM.xs +++ b/URPM.xs @@ -272,7 +272,7 @@ get_evr(URPM__Package pkg) { */ static int get_fullname_parts(URPM__Package pkg, char **name, int *epoch, char **version, char **release, char **disttag, char **distepoch, char **arch, char **eos) { - char *_version = NULL, *_release = NULL, *_disttag = NULL, *_distepoch = NULL, *_arch = NULL, *_eos = NULL, *tmp = NULL; + char *_version = NULL, *_release = NULL, *_disttag = NULL, *_distepoch = NULL, *_arch = NULL, *_eos = NULL, *tmp = NULL, *tmp2 = NULL; /* XXX: Could've probably be written in a more generic way, only thing we * really want to do is to check for arch field, which will be missing in * the case of gpg-pubkey at least.. @@ -282,26 +282,42 @@ get_fullname_parts(URPM__Package pkg, char **name, int *epoch, char **version, c if(pkg->info) { if ((_eos = strchr(pkg->info, '@')) != NULL) { if (epoch != NULL) *epoch = isdigit(_eos[1]) ? atoi(_eos+1) : 0; - if(name != NULL || version != NULL || release != NULL || disttag != NULL || distepoch != NULL || arch != NULL) { + if (name != NULL || version != NULL || release != NULL || disttag != NULL || distepoch != NULL || arch != NULL) { backup_char(_eos); if (eos != NULL) *eos = _eos+1; if ((pubkey = !strncmp(pkg->info, "gpg-pubkey", 10)) || (_arch = strrchr(pkg->info, '.')) != NULL) { - if(!pubkey) + if (!pubkey) backup_char(_arch); if (arch != NULL) *arch = pubkey ? "" : _arch + 1; if (distepoch != NULL || disttag != NULL || release != NULL || version != NULL || name != NULL) { - if((_distepoch = strchr(strrchr(pkg->provides, '-'), ':')) != NULL) { - if((tmp = strrchr(_distepoch+1, ']'))) { + if ((_distepoch = strchr(strrchr(pkg->provides, '-'), ':')) != NULL) { + if ((tmp = strrchr(_distepoch+1, ']'))) { backup_char(tmp); - if((tmp = strstr(pkg->info, _distepoch+1))) + if ((tmp = strstr(pkg->info, _distepoch+1))) backup_char(tmp); + else { + /* If synthesis is generated with older versions, disttag & distepoch will + * not be part of NVRA at beginning of line, but as it'll still be part of + * filename which is located at end of line, we can live with it as long + * as we're aware of it and take the necessary precautions to cope. + */ + if ((tmp = strrchr(_eos+1, '-'))) { + if ((tmp2 = strstr(tmp, _distepoch+1))) { + backup_char(tmp2); + _disttag = tmp; + } + } + } } } - if(distepoch != NULL) *distepoch = _distepoch ? _distepoch+1 : NULL; + if (distepoch != NULL) *distepoch = _distepoch ? _distepoch+1 : NULL; if (disttag != NULL || release != NULL || version != NULL || name != NULL) { - if ((_disttag = strrchr(pkg->info, '-')) != NULL && (strstr(pkg->provides, _disttag)) == NULL) { - backup_char(_disttag); - } else _disttag = NULL; + if (_disttag == NULL) { + /* XXX: re-verify this logic, see comment above.. */ + if ((_disttag = strrchr(pkg->info, '-')) != NULL && (strstr(pkg->provides, _disttag)) == NULL) { + backup_char(_disttag); + } else _disttag = NULL; + } if (disttag != NULL) *disttag = _disttag ? _disttag + 1: NULL; if ((release != NULL || version != NULL || name != NULL) && (_release = strrchr(pkg->info, '-')) != NULL) { backup_char(_release); -- cgit v1.2.1