Date: Wed, 04 Jan 2012 08:59:12 +0000 From: Matthew Seaman <m.seaman@infracaninophile.co.uk> To: freebsd-ports@freebsd.org Subject: Re: How to detect the version of a installed perl module during portbuild Message-ID: <4F0414E0.9030206@infracaninophile.co.uk> In-Reply-To: <CE503C49DD251ECD02D0F7E1@utd71538.utdallas.edu> References: <4F036A7F.1000908@FreeBSD.org> <CE503C49DD251ECD02D0F7E1@utd71538.utdallas.edu>
next in thread | previous in thread | raw e-mail | index | archive | help
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--
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?4F0414E0.9030206>