ALT Linux Team development discussions
 help / color / mirror / Atom feed
* Re: [devel] gb-task-repo-vercheck (vercheck): Use rpmevrcmp
@ 2009-02-16  8:16 Alexey Tourbin
  2009-02-16 12:23 ` Dmitry V. Levin
  0 siblings, 1 reply; 7+ messages in thread
From: Alexey Tourbin @ 2009-02-16  8:16 UTC (permalink / raw)
  To: devel

[-- Attachment #1: Type: text/plain, Size: 1747 bytes --]

On Sun, Jan 11, 2009 at 11:33:11PM +0000, Dmitry V. Levin wrote:
> ---
>  gb-task-repo-vercheck |   39 ++++-----------------------------------
>  1 files changed, 4 insertions(+), 35 deletions(-)
> 
> diff --git a/gb-task-repo-vercheck b/gb-task-repo-vercheck
> index 10a6eaf..8fbcb18 100755
> --- a/gb-task-repo-vercheck
> +++ b/gb-task-repo-vercheck
> @@ -6,41 +6,10 @@
>  vercheck()
>  {
>  	local EVR1="${1:?}" EVR2="${2:?}"
> -	local IFS=:
> -	set -- $EVR1
> -	local E1= VR1=
> -	if [ $# -eq 2 ] && [ -n "$1" ] && [ -n "$2" ]; then
> -		E1="$1" VR1="$2"
> -	elif [ $# -eq 1 ] && [ -n "$1" ]; then
> -		VR1="$1"
> -	else
> -		echo " *** bad EVR: $EVR1"
> -		return 1
> -	fi >&2
> -	set -- $EVR2
> -	local E2= VR2=
> -	if [ $# -eq 2 ] && [ -n "$1" ] && [ -n "$2" ]; then
> -		E2="$1" VR2="$2"
> -	elif [ $# -eq 1 ] && [ -n "$1" ]; then
> -		VR2="$1"
> -	else
> -		echo " *** bad EVR: $EVR2"
> -		return 1
> -	fi >&2
> -	if [ -n "$E1" ] && [ -z "$E2" ]; then
> -		return 1
> -	elif [ -z "$E1" ] && [ -n "$E2" ]; then
> -		return 0
> -	elif [ -n "$E1" ] && [ -n "$E2" ]; then
> -		if [ "$E1" -gt "$E2" ]; then
> -			return 1
> -		elif [ "$E1" -lt "$E2" ]; then
> -			return 0
> -		fi
> -	fi
> -	local cmp
> -	cmp=$(rpmvercmp "$VR1" "$VR2")
> -	[ "$cmp" = -1 ] || return 1
> +	# add zero epoch if EVRn does not have epoch
> +	[ -z "${EVR1##*:*}" ] || EVR1="0:$EVR1"
> +	[ -z "${EVR2##*:*}" ] || EVR2="0:$EVR2"
> +	[ "$(rpmevrcmp "$EVR1" "$EVR2")" = -1 ] || return 1
>  }

This can be WRONG.
0:1.0-alt1 cmp 1.0-alt2 should yield 1.
Zero serial is greater than no serial.

I fail to see why you choose remove the code wich does the right thing
and replace it with the code which is wrong.

[-- Attachment #2: Type: application/pgp-signature, Size: 197 bytes --]

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [devel] gb-task-repo-vercheck (vercheck): Use rpmevrcmp
  2009-02-16  8:16 [devel] gb-task-repo-vercheck (vercheck): Use rpmevrcmp Alexey Tourbin
@ 2009-02-16 12:23 ` Dmitry V. Levin
  2009-02-16 13:05   ` Alexey Tourbin
  0 siblings, 1 reply; 7+ messages in thread
From: Dmitry V. Levin @ 2009-02-16 12:23 UTC (permalink / raw)
  To: ALT Devel discussion list

[-- Attachment #1: Type: text/plain, Size: 189 bytes --]

On Mon, Feb 16, 2009 at 11:16:51AM +0300, Alexey Tourbin wrote:
[...]
> 0:1.0-alt1 cmp 1.0-alt2 should yield 1.

Why?

> Zero serial is greater than no serial.

Why?


-- 
ldv

[-- Attachment #2: Type: application/pgp-signature, Size: 197 bytes --]

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [devel] gb-task-repo-vercheck (vercheck): Use rpmevrcmp
  2009-02-16 12:23 ` Dmitry V. Levin
@ 2009-02-16 13:05   ` Alexey Tourbin
  2009-02-16 23:29     ` Dmitry V. Levin
  0 siblings, 1 reply; 7+ messages in thread
From: Alexey Tourbin @ 2009-02-16 13:05 UTC (permalink / raw)
  To: ALT Devel discussion list

[-- Attachment #1: Type: text/plain, Size: 2098 bytes --]

On Mon, Feb 16, 2009 at 03:23:12PM +0300, Dmitry V. Levin wrote:
> On Mon, Feb 16, 2009 at 11:16:51AM +0300, Alexey Tourbin wrote:
> [...]
> > 0:1.0-alt1 cmp 1.0-alt2 should yield 1.
> 
> Why?
> 
> > Zero serial is greater than no serial.
> 
> Why?

This is because how rpm-4.0 works.

lib/psm.c:
    72  int rpmVersionCompare(Header first, Header second)
    73  {
    74      const char * one, * two;
    75      int_32 * epochOne, * epochTwo;
    76      int rc;
    77  
    78      if (!headerGetEntry(first, RPMTAG_EPOCH, NULL, (void **) &epochOne, NULL))
    79          epochOne = NULL;
    80      if (!headerGetEntry(second, RPMTAG_EPOCH, NULL, (void **) &epochTwo,
    81                          NULL))
    82          epochTwo = NULL;
    83  
    84      if (epochOne && !epochTwo)
    85          return 1;
    86      else if (!epochOne && epochTwo)
    87          return -1;
    88      else if (epochOne && epochTwo) {
    89          if (*epochOne < *epochTwo)
    90              return -1;
    91          else if (*epochOne > *epochTwo)
    92              return 1;
    93      }
    94  
    95      rc = headerGetEntry(first, RPMTAG_VERSION, NULL, (void **) &one, NULL);
    96      rc = headerGetEntry(second, RPMTAG_VERSION, NULL, (void **) &two, NULL);
    97  
    98      rc = rpmvercmp(one, two);
    99      if (rc)
   100          return rc;
   101  
   102      (void) headerGetEntry(first, RPMTAG_RELEASE, NULL, (void **) &one, NULL);
   103      (void) headerGetEntry(second, RPMTAG_RELEASE, NULL, (void **) &two, NULL);
   104  
   105      rc = rpmvercmp(one, two);
   106      if (rc)
   107          return rc;
   108  
   109      if (upgrade_honor_buildtime())
   110          return rpmBuildTimeCompare(first, second);
   111  
   112      return 0;
   113  }

Thus, rpm will not upgrade a package (by default), and apt-rpm will
not consider an upgrade, if zero serial gets removed (and, say,
release number is increased).

Let's try to remove zero serial from e.g. kbd and see what happens.

[-- Attachment #2: Type: application/pgp-signature, Size: 197 bytes --]

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [devel] gb-task-repo-vercheck (vercheck): Use rpmevrcmp
  2009-02-16 13:05   ` Alexey Tourbin
@ 2009-02-16 23:29     ` Dmitry V. Levin
  2009-02-28 14:17       ` Alexey Tourbin
  2009-02-28 17:36       ` Alexey Tourbin
  0 siblings, 2 replies; 7+ messages in thread
From: Dmitry V. Levin @ 2009-02-16 23:29 UTC (permalink / raw)
  To: ALT Devel discussion list

[-- Attachment #1: Type: text/plain, Size: 618 bytes --]

On Mon, Feb 16, 2009 at 04:05:08PM +0300, Alexey Tourbin wrote:
> On Mon, Feb 16, 2009 at 03:23:12PM +0300, Dmitry V. Levin wrote:
> > On Mon, Feb 16, 2009 at 11:16:51AM +0300, Alexey Tourbin wrote:
> > [...]
> > > 0:1.0-alt1 cmp 1.0-alt2 should yield 1.
> > 
> > Why?
> > 
> > > Zero serial is greater than no serial.
> > 
> > Why?
> 
> This is because how rpm-4.0 works.
> 
> lib/psm.c:
>     72  int rpmVersionCompare(Header first, Header second)

If rpmVersionCompare() works this way, why rpmEVRcmp() doesn't work the
same way?  Let's fix librpm rather than multiply workarounds.


-- 
ldv

[-- Attachment #2: Type: application/pgp-signature, Size: 197 bytes --]

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [devel] gb-task-repo-vercheck (vercheck): Use rpmevrcmp
  2009-02-16 23:29     ` Dmitry V. Levin
@ 2009-02-28 14:17       ` Alexey Tourbin
  2009-02-28 22:37         ` Dmitry V. Levin
  2009-02-28 17:36       ` Alexey Tourbin
  1 sibling, 1 reply; 7+ messages in thread
From: Alexey Tourbin @ 2009-02-28 14:17 UTC (permalink / raw)
  To: ALT Devel discussion list

[-- Attachment #1: Type: text/plain, Size: 2222 bytes --]

On Tue, Feb 17, 2009 at 02:29:39AM +0300, Dmitry V. Levin wrote:
> On Mon, Feb 16, 2009 at 04:05:08PM +0300, Alexey Tourbin wrote:
> > On Mon, Feb 16, 2009 at 03:23:12PM +0300, Dmitry V. Levin wrote:
> > > On Mon, Feb 16, 2009 at 11:16:51AM +0300, Alexey Tourbin wrote:
> > > [...]
> > > > 0:1.0-alt1 cmp 1.0-alt2 should yield 1.
> > > 
> > > Why?
> > > 
> > > > Zero serial is greater than no serial.
> > > 
> > > Why?
> > 
> > This is because how rpm-4.0 works.
> > 
> > lib/psm.c:
> >     72  int rpmVersionCompare(Header first, Header second)
> 
> If rpmVersionCompare() works this way, why rpmEVRcmp() doesn't work the
> same way?

That's because rpmEVRcmp() is botched.

rpmdb/rpmvercmp.c:
   155  /* Compare {A,B} [epoch:]version[-release] */
   156  int 
   157  rpmEVRcmp(const char * const aE, const char * const aV, const char * const aR,
   158            const char * const aDepend,
   159            const char * const bE, const char * const bV, const char * const bR,
   160            const char * const bDepend)
   161  {
   162      int sense = 0;
   163  
   164      rpmMessage(RPMMESS_DEBUG, "cmp e=%s, v=%s, r=%s\n and e=%s, v=%s, r=%s\n ",
   165                 aE, aV, aR, bE, bV, bR);
   166  
   167  
   168      if (aE && *aE && bE && *bE)
   169          sense = rpmvercmp(aE, bE);
   170      else if (aE && *aE && atol(aE) > 0) {
   171          /* XXX legacy epoch-less requires/conflicts compatibility */
   172          rpmMessage(RPMMESS_DEBUG, _("the \"B\" dependency needs an epoch (assuming same as \"A\")\n\tA %s\tB %s\n"),
   173                  aDepend, bDepend);
   174          sense = 0;
   175      } else if (bE && *bE && atol(bE) > 0)
   176          sense = -1;
   177  
   178      if (sense == 0) {
   179          sense = rpmvercmp(aV, bV);
   180          if (sense == 0 && aR && *aR && bR && *bR) {
   181              sense = rpmvercmp(aR, bR);
   182          }
   183      }
   184  
   185      return sense;
   186  }

That is, rpmEVRcmp() does not exercise quite the same logic as
rpmVersionCompare().

> Let's fix librpm rather than multiply workarounds.

Prepending zero serial was wrong anyway.

[-- Attachment #2: Type: application/pgp-signature, Size: 197 bytes --]

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [devel] gb-task-repo-vercheck (vercheck): Use rpmevrcmp
  2009-02-16 23:29     ` Dmitry V. Levin
  2009-02-28 14:17       ` Alexey Tourbin
@ 2009-02-28 17:36       ` Alexey Tourbin
  1 sibling, 0 replies; 7+ messages in thread
From: Alexey Tourbin @ 2009-02-28 17:36 UTC (permalink / raw)
  To: ALT Devel discussion list

[-- Attachment #1: Type: text/plain, Size: 2208 bytes --]

On Tue, Feb 17, 2009 at 02:29:39AM +0300, Dmitry V. Levin wrote:
> On Mon, Feb 16, 2009 at 04:05:08PM +0300, Alexey Tourbin wrote:
> > On Mon, Feb 16, 2009 at 03:23:12PM +0300, Dmitry V. Levin wrote:
> > > On Mon, Feb 16, 2009 at 11:16:51AM +0300, Alexey Tourbin wrote:
> > > [...]
> > > > 0:1.0-alt1 cmp 1.0-alt2 should yield 1.
> > > 
> > > Why?
> > > 
> > > > Zero serial is greater than no serial.
> > > 
> > > Why?
> > 
> > This is because how rpm-4.0 works.
> > 
> > lib/psm.c:
> >     72  int rpmVersionCompare(Header first, Header second)
> 
> If rpmVersionCompare() works this way, why rpmEVRcmp() doesn't work the
> same way?  Let's fix librpm rather than multiply workarounds.

apt-pkg/rpm/rpmversion.cc:
    94  // ---------------------------------------------------------------------
    95  /* This fragments the version into E:V-R triples and compares each 
    96     portion separately. */
    97  int rpmVersioningSystem::DoCmpVersion(const char *A,const char *AEnd,
    98                                        const char *B,const char *BEnd)
    99  {
   100     char *AE, *AV, *AR;
   101     char *BE, *BV, *BR;
   102     int rc = 0;
   103     ParseVersion(A, AEnd, &AE, &AV, &AR);
   104     ParseVersion(B, BEnd, &BE, &BV, &BR);
   105     if (AE && !BE)
   106         rc = 1;
   107     else if (!AE && BE)
   108         rc = -1;
   109     else if (AE && BE)
   110     {
   111        int AEi, BEi;
   112        AEi = atoi(AE);
   113        BEi = atoi(BE);
   114        if (AEi < BEi)
   115            rc = -1;
   116        else if (AEi > BEi)
   117            rc = 1;
   118     }
   119     if (rc == 0)
   120     {
   121        rc = rpmvercmp(AV, BV);
   122        if (rc == 0) {
   123            if (AR && !BR)
   124                rc = 1;
   125            else if (!AR && BR)
   126                rc = -1;
   127            else if (AR && BR)
   128                rc = rpmvercmp(AR, BR);
   129        }
   130     }
   131     free(AE);free(AV);free(AR);;
   132     free(BE);free(BV);free(BR);;
   133     return rc;
   134  }

vercmp seems to be reliable.
evrcmp is a "sdelai sam" thing.

[-- Attachment #2: Type: application/pgp-signature, Size: 197 bytes --]

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [devel] gb-task-repo-vercheck (vercheck): Use rpmevrcmp
  2009-02-28 14:17       ` Alexey Tourbin
@ 2009-02-28 22:37         ` Dmitry V. Levin
  0 siblings, 0 replies; 7+ messages in thread
From: Dmitry V. Levin @ 2009-02-28 22:37 UTC (permalink / raw)
  To: ALT Devel discussion list

[-- Attachment #1: Type: text/plain, Size: 866 bytes --]

On Sat, Feb 28, 2009 at 05:17:25PM +0300, Alexey Tourbin wrote:
> On Tue, Feb 17, 2009 at 02:29:39AM +0300, Dmitry V. Levin wrote:
> > On Mon, Feb 16, 2009 at 04:05:08PM +0300, Alexey Tourbin wrote:
> > > On Mon, Feb 16, 2009 at 03:23:12PM +0300, Dmitry V. Levin wrote:
> > > > On Mon, Feb 16, 2009 at 11:16:51AM +0300, Alexey Tourbin wrote:
> > > > [...]
> > > > > 0:1.0-alt1 cmp 1.0-alt2 should yield 1.
> > > > 
> > > > Why?
> > > > 
> > > > > Zero serial is greater than no serial.
> > > > 
> > > > Why?
> > > 
> > > This is because how rpm-4.0 works.
> > > 
> > > lib/psm.c:
> > >     72  int rpmVersionCompare(Header first, Header second)
> > 
> > If rpmVersionCompare() works this way, why rpmEVRcmp() doesn't work the
> > same way?
> 
> That's because rpmEVRcmp() is botched.

Let's fix it, that should be easy change.


-- 
ldv

[-- Attachment #2: Type: application/pgp-signature, Size: 197 bytes --]

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2009-02-28 22:37 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-02-16  8:16 [devel] gb-task-repo-vercheck (vercheck): Use rpmevrcmp Alexey Tourbin
2009-02-16 12:23 ` Dmitry V. Levin
2009-02-16 13:05   ` Alexey Tourbin
2009-02-16 23:29     ` Dmitry V. Levin
2009-02-28 14:17       ` Alexey Tourbin
2009-02-28 22:37         ` Dmitry V. Levin
2009-02-28 17:36       ` Alexey Tourbin

ALT Linux Team development discussions

This inbox may be cloned and mirrored by anyone:

	git clone --mirror http://lore.altlinux.org/devel/0 devel/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 devel devel/ http://lore.altlinux.org/devel \
		devel@altlinux.org devel@altlinux.ru devel@lists.altlinux.org devel@lists.altlinux.ru devel@linux.iplabs.ru mandrake-russian@linuxteam.iplabs.ru sisyphus@linuxteam.iplabs.ru
	public-inbox-index devel

Example config snippet for mirrors.
Newsgroup available over NNTP:
	nntp://lore.altlinux.org/org.altlinux.lists.devel


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git