From owner-freebsd-ports Sat Mar 31 20:43: 9 2001 Delivered-To: freebsd-ports@freebsd.org Received: from sj-msg-core-4.cisco.com (sj-msg-core-4.cisco.com [171.71.163.10]) by hub.freebsd.org (Postfix) with ESMTP id B29F437B71A; Sat, 31 Mar 2001 20:43:03 -0800 (PST) (envelope-from bmah@cisco.com) Received: from bmah-freebsd-0.cisco.com (bmah-freebsd-0.cisco.com [171.70.84.42]) by sj-msg-core-4.cisco.com (8.9.3/8.9.1) with ESMTP id UAA27727; Sat, 31 Mar 2001 20:43:06 -0800 (PST) Received: (from bmah@localhost) by bmah-freebsd-0.cisco.com (8.11.3/8.11.1) id f314h2J82423; Sat, 31 Mar 2001 20:43:02 -0800 (PST) (envelope-from bmah) Message-Id: <200104010443.f314h2J82423@bmah-freebsd-0.cisco.com> X-Mailer: exmh version 2.3.1 01/19/2001 with nmh-1.0.4 To: "Akinori MUSHA" Cc: "Bruce A. Mah" , freebsd-ports@freebsd.org, knu@freebsd.org Subject: Re: pkg_version comparison routine In-Reply-To: <86y9tqc4tj.wl@archon.local.idaemons.org> References: <200103280237.f2S2bUP02277@bmah-freebsd-0.cisco.com> <86y9tqc4tj.wl@archon.local.idaemons.org> Comments: In-reply-to "Akinori MUSHA" message dated "Thu, 29 Mar 2001 00:04:56 +0900." From: bmah@freebsd.org (Bruce A. Mah) Reply-To: bmah@freebsd.org X-Face: g~c`.{#4q0"(V*b#g[i~rXgm*w;:nMfz%_RZLma)UgGN&=j`5vXoU^@n5v4:OO)c["!w)nD/!!~e4Sj7LiT'6*wZ83454H""lb{CC%T37O!!'S$S&D}sem7I[A 2V%N&+ X-Image-Url: http://www.employees.org/~bmah/Images/bmah-cisco-small.gif X-Url: http://www.employees.org/~bmah/ Mime-Version: 1.0 Content-Type: multipart/signed; boundary="==_Exmh_2070676098P"; micalg=pgp-sha1; protocol="application/pgp-signature" Content-Transfer-Encoding: 7bit Date: Sat, 31 Mar 2001 20:43:02 -0800 Sender: owner-freebsd-ports@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.org --==_Exmh_2070676098P Content-Type: text/plain; charset=us-ascii If memory serves me right, "Akinori MUSHA" wrote: > I think something similar to this can be written in Bourne shell using > the `pkg_version -t' feature, so that we can always ensure the > correctness of its behavior. OK, I've got a little script (below) that we can run to test pkg_version. Maybe I can put it in the same directory as pkg_version.pl; we won't install it but at least if it is in CVS, we can use it when hacking on pkg_version. Thanks for the idea, with so many weird cases that these routines need to handle, it's good to have a program like this. Bruce. PS. I haven't committed the diffs I posted earlier because I'm still waiting for some feedback as to whether or not they work. I'm pretty happy with the new code, and in fact I've been using it on my workstations while testing some port-upgrading stuff. #!/bin/sh # # Copyright 2001 Bruce A. Mah # # All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions # are met: # 1. Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # 2. Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in the # documentation and/or other materials provided with the distribution. # # THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY EXPRESS OR # IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES # OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. # IN NO EVENT SHALL THE DEVELOPERS BE LIABLE FOR ANY DIRECT, INDIRECT, # INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT # NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF # THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. # # test-pkg_version.sh # # Regression testing for pkg_version # Originally from an idea by "Akinori MUSHA" # # $FreeBSD$ # ECHO=echo PKG_VERSION=./pkg_version.pl test-pv ( ) { \ setvar v1 $1 setvar answer $2 setvar v2 $3 setvar type $4 res=`${PKG_VERSION} -t ${v1} ${v2}` if [ ${res} != ${answer} ]; then \ ${ECHO} "${type} test failed (${v1} ${res} ${v2}, should have been ${answer})"; \ fi } # Test coercion of default PORTREVISION and PORTEPOCH test-pv 0.10 "=" 0.10_0 coercion test-pv 0.10 "=" 0.10,0 coercion test-pv 0.10 "=" 0.10_0,0 coercion # Test various comparisons test-pv 1.0 "=" 1.0 equality test-pv 2.15a "=" 2.15a equality test-pv 0.10 ">" 0.9 inequality test-pv 0.9 "<" 0.10 inequality test-pv 2.3p10 ">" 2.3p9 number/letter test-pv 1.6.0 ">" 1.6.0.p3 number/letter test-pv 1.0.b ">" 1.0.a3 number/letter test-pv 1.0a "<" 1.0 number/letter test-pv 5.0a "<" 5.0.b number/letter test-pv 1.5_1 ">" 1.5 portrevision test-pv 1.5_2 ">" 1.5_1 portrevision test-pv 00.01.01,1 ">" 99.12.31 portepoch test-pv 0.0.1_1,2 ">" 0.0.1,2 portrevision/portepoch test-pv 0.0.1_1,3 ">" 0.0.1_2,2 portrevision/portepoch --==_Exmh_2070676098P Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.0.4 (FreeBSD) Comment: Exmh version 2.2 06/23/2000 iD8DBQE6xrHW2MoxcVugUsMRAuDbAKDhIs6rkM7DTALzKds7U1VWvfoC7wCgup0E XWE6iyHY2A7/c/ewzAPUizA= =jKze -----END PGP SIGNATURE----- --==_Exmh_2070676098P-- To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-ports" in the body of the message