diff options
-rw-r--r-- | NEWS | 3 | ||||
-rw-r--r-- | URPM.xs | 72 | ||||
-rw-r--r-- | t/synthesis.t | 22 |
3 files changed, 54 insertions, 43 deletions
@@ -1,5 +1,8 @@ Version 3.33.1 - 9 March 2011, by Per Øyvind Karlsen +- support getting disttag & distepoch from synthesis +- fix URPM::Package->distepoch to actually work +- add disttag & distepoch at end of @ - add support for doing comparision against provides with distepoch to allow fresh install of newer releases into chroots - convert suggests to compatible tags when loading package headers @@ -157,36 +157,24 @@ newSVpv_utf8(const char *s, STRLEN len) static void get_fullname_parts(URPM__Package pkg, char **name, char **version, char **release, char **arch, char **eos) { char *_version = NULL, *_release = NULL, *_arch = NULL, *_eos = NULL; - int distepoch = 0; - char *tmp; - /* search through provides for distepoch */ - if ((tmp = pkg->provides)) { - do { - if((_eos = strchr(tmp, '@'))) - *_eos = 0; - - if((tmp = strchr(tmp, '[')) && - (tmp = strchr(tmp, '-')) && - (tmp = strchr(tmp, ':'))) - distepoch = 1; - if(_eos) { - *_eos++ = '@'; - tmp = _eos; - } - } while(!distepoch && _eos != NULL); - /* XXX: filename at end of line, don't bother to support it, just make sure - * for it not to cause crash... - */ - if ((tmp = strrchr(pkg->info, '.')) && !strcmp(tmp, ".rpm")) - distepoch = 0; - } + int i, disttag = 0; + char *tmp = pkg->info; + for (i = 0; i < 4 && tmp != NULL; i++) + tmp = strchr(++tmp, '@'); + if (tmp++ != NULL && *tmp != '@') + disttag = 1; + /* XXX: filename at end of line, don't bother to support it, just make sure + * for it not to cause crash... + */ + if ((tmp = strrchr(pkg->info, '.')) && !strcmp(tmp, ".rpm")) + disttag = 0; if ((_eos = strchr(pkg->info, '@')) != NULL) { *_eos = 0; /* mark end of string to enable searching backwards */ if ((_arch = strrchr(pkg->info, '.')) != NULL) { *_arch = 0; if ((release != NULL || version != NULL || name != NULL) && (_release = strrchr(pkg->info, '-')) != NULL) { - if (distepoch) { + if (disttag) { tmp = _release; while(tmp != _arch) { backup_char(tmp++); @@ -1736,7 +1724,7 @@ Pkg_release(pkg) get_fullname_parts(pkg, NULL, NULL, &release, &arch, NULL); if (arch - release < 1) croak("invalid fullname"); - XPUSHs(sv_2mortal(newSVpv(release, arch-release-1))); + XPUSHs(sv_2mortal(newSVpv(release, arch[-2] ? arch-release-1 : 0))); restore_chars(); } else if (pkg->h) { XPUSHs(sv_2mortal(newSVpv(get_name(pkg->h, RPMTAG_RELEASE), 0))); @@ -1968,7 +1956,7 @@ Pkg_fullname(pkg) EXTEND(SP, 4); PUSHs(sv_2mortal(newSVpv(name, version-name-1))); PUSHs(sv_2mortal(newSVpv(version, release-version-1))); - PUSHs(sv_2mortal(newSVpv(release, arch-release-1))); + PUSHs(sv_2mortal(newSVpv(release, arch[-2] ? arch-release-1 : 0))); PUSHs(sv_2mortal(newSVpv(arch == eos ? "" : arch, eos-arch))); restore_chars(); } @@ -2160,7 +2148,7 @@ Pkg_compare(pkg, evr) _epoch = get_int(pkg->h, RPMTAG_EPOCH); } else croak("undefined package"); if (!compare) { - char *epoch, *version, *release; + char *epoch, *version, *release, *distepoch; /* extract epoch and version from evr */ version = evr; @@ -2182,6 +2170,10 @@ Pkg_compare(pkg, evr) /* continue extracting release if any */ if ((release = strrchr(version, '-')) != NULL) { *release++ = 0; + /* XXX: compare distepoch rather than just ignoring? */ + if ((distepoch = strrchr(release, ':')) != NULL) + *distepoch++ = 0; + compare = rpmvercmp(_version, version); if (!compare) { /* need to compare with release here */ @@ -2190,6 +2182,8 @@ Pkg_compare(pkg, evr) compare = rpmvercmp(_release, release); } release[-1] = '-'; /* restore in memory modification */ + if (distepoch != NULL) + distepoch[-1] = ':'; } else { compare = rpmvercmp(_version, version); } @@ -2516,18 +2510,30 @@ Pkg_dirnames(pkg) void Pkg_distepoch(pkg) URPM::Package pkg PPCODE: -#ifdef RPMTAG_DISTEPOCH - if (pkg->h) { + if (pkg->info) { + int i; + char *tmp = pkg->info, *eos = NULL; + for (i = 0; i < 5 && tmp != NULL; i++) + tmp = strchr(++tmp, '@'); + if (tmp != NULL && *tmp) + eos = strchr(++tmp, '@'); + XPUSHs(sv_2mortal(newSVpv((tmp && *tmp != '@') ? tmp : "", eos ? eos-tmp : 0))); + } else if (pkg->h) { XPUSHs(sv_2mortal(newSVpv(get_name(pkg->h, RPMTAG_DISTEPOCH), 0))); } -#else - croak("distepoch isn't available with this rpm version"); -#endif void Pkg_disttag(pkg) URPM::Package pkg PPCODE: - if (pkg->h) { + if (pkg->info) { + int i; + char *tmp = pkg->info, *eos = NULL; + for (i = 0; i < 4 && tmp != NULL; i++) + tmp = strchr(++tmp, '@'); + if (tmp != NULL && *tmp) + eos = strchr(++tmp, '@'); + XPUSHs(sv_2mortal(newSVpv((tmp && *tmp != '@') ? tmp : "", eos ? eos-tmp : 0))); + } else if (pkg->h) { XPUSHs(sv_2mortal(newSVpv(get_name(pkg->h, RPMTAG_DISTTAG), 0))); } diff --git a/t/synthesis.t b/t/synthesis.t index 6729b3b..ca870aa 100644 --- a/t/synthesis.t +++ b/t/synthesis.t @@ -2,7 +2,7 @@ use strict ; use warnings ; -use Test::More tests => 94; +use Test::More tests => 96; use URPM; chdir 't' if -d 't'; @@ -10,11 +10,11 @@ my $file1 = 'synthesis.sample.cz'; open my $f, "| gzip -9 >$file1"; print $f <<'EOF'; -@provides@glibc-devel == 6:2.2.4-25mdk +@provides@glibc-devel == 6:2.2.4-25:2011.0 @requires@/sbin/install-info@glibc == 2.2.4@kernel-headers@kernel-headers >= 2.2.1@/bin/sh@/bin/sh@/bin/sh@rpmlib(PayloadFilesHavePrefix) <= 4.0-1@rpmlib(CompressedFileNames) <= 3.0.4-1 @conflicts@texinfo < 3.11@gcc < 2.96-0.50mdk @obsoletes@libc-debug@libc-headers@libc-devel@linuxthreads-devel@glibc-debug -@info@glibc-devel-2.2.4-25mdk.i586@6@45692097@Development/C +@info@glibc-devel-2.2.4-25-mdv2011.0.i586@6@45692097@Development/C@mdv@2011.0 EOF close $f; @@ -44,9 +44,11 @@ my $pkg = $a->{depslist}[0]; ok($pkg); ok($pkg->name eq 'glibc-devel'); ok($pkg->version eq '2.2.4'); -ok($pkg->release eq '25mdk'); +ok($pkg->release eq '25'); +ok($pkg->disttag eq 'mdv'); +ok($pkg->distepoch eq '2011.0'); ok($pkg->arch eq 'i586'); -ok($pkg->fullname eq 'glibc-devel-2.2.4-25mdk.i586'); +ok($pkg->fullname eq 'glibc-devel-2.2.4-25-mdv2011.0.i586'); ok(!defined $pkg->buildarchs); ok(!defined $pkg->buildhost); is($pkg->buildtime,0); @@ -58,13 +60,13 @@ my ($name, $version, $release, $arch, @l) = $pkg->fullname; ok(@l == 0); ok($name eq 'glibc-devel'); ok($version eq '2.2.4'); -ok($release eq '25mdk'); +ok($release eq '25'); ok($arch eq 'i586'); ok($pkg->epoch == 6); ok($pkg->size == 45692097); ok($pkg->group eq 'Development/C'); -ok($pkg->filename eq 'glibc-devel-2.2.4-25mdk.i586.rpm'); +ok($pkg->filename eq 'glibc-devel-2.2.4-25-mdv2011.0.i586.rpm'); ok(defined $pkg->id); ok($pkg->id == 0); ok($pkg->set_id(6) == 0); @@ -92,13 +94,13 @@ ok($requires[8] eq 'rpmlib(CompressedFileNames) <= 3.0.4-1'); my @provides = $pkg->provides; ok(@provides == 1); -ok($provides[0] eq 'glibc-devel == 6:2.2.4-25mdk'); +ok($provides[0] eq 'glibc-devel == 6:2.2.4-25:2011.0'); my @files = $pkg->files; ok(@files == 0); -ok($pkg->compare("6:2.2.4-25mdk") == 0); -ok($pkg->compare("2.2.4-25mdk") > 0); +ok($pkg->compare("6:2.2.4-25:2011.0") == 0); +ok($pkg->compare("2.2.4-25") > 0); ok($pkg->compare("6:2.2.4") == 0); ok($pkg->compare("2.2.3") > 0); ok($pkg->compare("2.2") > 0); |