From owner-freebsd-ports@FreeBSD.ORG Wed Jan 4 08:59:31 2012 Return-Path: Delivered-To: freebsd-ports@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id F2FA5106564A for ; Wed, 4 Jan 2012 08:59:30 +0000 (UTC) (envelope-from m.seaman@infracaninophile.co.uk) Received: from smtp.infracaninophile.co.uk (smtp6.infracaninophile.co.uk [IPv6:2001:8b0:151:1:3cd3:cd67:fafa:3d78]) by mx1.freebsd.org (Postfix) with ESMTP id 786628FC12 for ; Wed, 4 Jan 2012 08:59:30 +0000 (UTC) Received: from seedling.black-earth.co.uk (seedling.black-earth.co.uk [IPv6:2001:8b0:151:1:fa1e:dfff:feda:c0bb]) (authenticated bits=0) by smtp.infracaninophile.co.uk (8.14.5/8.14.5) with ESMTP id q048xKKQ072784 (version=TLSv1/SSLv3 cipher=DHE-RSA-CAMELLIA256-SHA bits=256 verify=NO) for ; Wed, 4 Jan 2012 08:59:26 GMT (envelope-from m.seaman@infracaninophile.co.uk) X-DKIM: OpenDKIM Filter v2.4.1 smtp.infracaninophile.co.uk q048xKKQ072784 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=infracaninophile.co.uk; s=201001-infracaninophile; t=1325667566; bh=GUcilW/9I7sDB/gwSv56mxWd9uVApQqk52S59/5aSuM=; h=Message-ID:Date:From:MIME-Version:To:Subject:References: In-Reply-To:Content-Type:Cc; b=Mw0UMrjETPSjssU1B8LzejhxZCcV1abJeBQ+PAMgGU2JoXJEiYeATLK0kpVBZqcfv lSvm+15BBP8EAiM9B/GYF/AK4hLSbWnnMhI/vMj0FdY7tgqIE6oPrLUfWSIbia6Lii 80x7LLUlyN27b3VbTg6Rtlw7uGhmtdkrUEjSgjjY= Message-ID: <4F0414E0.9030206@infracaninophile.co.uk> Date: Wed, 04 Jan 2012 08:59:12 +0000 From: Matthew Seaman User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.6; rv:9.0) Gecko/20111222 Thunderbird/9.0.1 MIME-Version: 1.0 To: freebsd-ports@freebsd.org References: <4F036A7F.1000908@FreeBSD.org> In-Reply-To: X-Enigmail-Version: 1.3.4 OpenPGP: id=60AE908C Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="------------enigB63D2355EFDDDD375001ED8D" X-Virus-Scanned: clamav-milter 0.97.3 at lucid-nonsense.infracaninophile.co.uk X-Virus-Status: Clean X-Spam-Status: No, score=-2.4 required=5.0 tests=ALL_TRUSTED,AWL,BAYES_00, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU autolearn=ham version=3.3.2 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on lucid-nonsense.infracaninophile.co.uk Subject: Re: How to detect the version of a installed perl module during portbuild X-BeenThere: freebsd-ports@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Porting software to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 04 Jan 2012 08:59:31 -0000 This is an OpenPGP/MIME signed message (RFC 2440 and 3156) --------------enigB63D2355EFDDDD375001ED8D Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable On 03/01/2012 23:41, Paul Schmehl wrote: > This returns the installed package: >=20 > pkg_info -qa | grep "p5-JSON-RPC" | sort | uniq Woah! Try it like this: pkg_info -Ex p5-JSON-RPC > so maybe you could do something like? >=20 > JSON_VER=3D`pkg_info -qa | grep "p5-JSON-RPC" | sort | uniq | cut -d'-'= -f4` JSON_VER=3D$( pkg_info -Ex p5-JSON-RPC | sed -e 's/^.*-//' ) > .if ${JSON_VER} >=3D 1 > do this > .else > do this > .endif case ${JSON_VER) in 1.*) do_stuff ;; 0.*) do_something_else ;; esac case does a string comparison using standard shell globbing rules -- it's a lot more flexible than trying to do maths on version numbers. Using perl to generate the version number is also viable as suggested by Jason: perl -MJSON::RPC -le 'print $JSON::RPC::VERSION' but it strikes me as slightly wasteful to fire up an entire perl interpreter just to print out the value of one variable. However, if the object is to create a port that has a BUILD_DEPENDS on devel/p5-JSON-RPC then you only need to support what is already in the ports -- and that's version 1.01. The BUILD_DEPENDS line can enforce tha= t: BUILD_DEPENDS =3D p5-JSON-RPC>=3D1.01:${PORTSDIR}/devel/p5-JSON-RPC Should you have some program that requires JSON::RPC <=3D 0.96, then create a p5-JSON-RPC-096 port to provide exactly that. Cheers, Matthew --=20 Dr Matthew J Seaman MA, D.Phil. 7 Priory Courtyard Flat 3 PGP: http://www.infracaninophile.co.uk/pgpkey Ramsgate JID: matthew@infracaninophile.co.uk Kent, CT11 9PW --------------enigB63D2355EFDDDD375001ED8D Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG/MacGPG2 v2.0.16 (Darwin) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/ iEYEARECAAYFAk8EFOgACgkQ8Mjk52CukIxIwwCeOYSsiytHoKJbcscAnM4elNqy 7wAAoI4Udlp8NKSUCXg0rNEE+x2asDG3 =8WQ9 -----END PGP SIGNATURE----- --------------enigB63D2355EFDDDD375001ED8D--