From owner-freebsd-ports@FreeBSD.ORG Wed Jan 4 11:02:03 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 3982B106566C for ; Wed, 4 Jan 2012 11:02:03 +0000 (UTC) (envelope-from utisoft@gmail.com) Received: from mail-iy0-f182.google.com (mail-iy0-f182.google.com [209.85.210.182]) by mx1.freebsd.org (Postfix) with ESMTP id F21EB8FC1B for ; Wed, 4 Jan 2012 11:02:02 +0000 (UTC) Received: by iadj38 with SMTP id j38so40788266iad.13 for ; Wed, 04 Jan 2012 03:02:02 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=GzUyLdX7Losa0N6CjIGNftOJobEpeFx2MwrftFMVWHw=; b=ro2SKF5gJr1St9w7gEZYJbKmaeKJlzfBQGogwfr5RWKEBSeDRSa3q5q+UOCazoRsWb qXZ3fMQjt80PptOicNBI3OKcpPEU3ny4x3X3ofHhCrledU/nmPsvCGsco7/gJI0jt4pb 7PIFSi7Q/qRNgit2lpCH7mFzIK/6mErdpMn4Q= MIME-Version: 1.0 Received: by 10.42.176.66 with SMTP id bd2mr9777962icb.32.1325674922439; Wed, 04 Jan 2012 03:02:02 -0800 (PST) Received: by 10.231.207.7 with HTTP; Wed, 4 Jan 2012 03:02:02 -0800 (PST) Received: by 10.231.207.7 with HTTP; Wed, 4 Jan 2012 03:02:02 -0800 (PST) In-Reply-To: <4F0414E0.9030206@infracaninophile.co.uk> References: <4F036A7F.1000908@FreeBSD.org> <4F0414E0.9030206@infracaninophile.co.uk> Date: Wed, 4 Jan 2012 11:02:02 +0000 Message-ID: From: Chris Rees To: Matthew Seaman Content-Type: text/plain; charset=ISO-8859-1 X-Content-Filtered-By: Mailman/MimeDel 2.1.5 Cc: freebsd-ports@freebsd.org 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 11:02:03 -0000 On 4 Jan 2012 08:59, "Matthew Seaman" wrote: > > On 03/01/2012 23:41, Paul Schmehl wrote: > > This returns the installed package: > > > > 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? > > > > JSON_VER=`pkg_info -qa | grep "p5-JSON-RPC" | sort | uniq | cut -d'-' -f4` > > JSON_VER=$( pkg_info -Ex p5-JSON-RPC | sed -e 's/^.*-//' ) $$( It's a Makefile, don't forget ;) > > > .if ${JSON_VER} >= 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 that: > > BUILD_DEPENDS = p5-JSON-RPC>=1.01:${PORTSDIR}/devel/p5-JSON-RPC > > Should you have some program that requires JSON::RPC <= 0.96, then > create a p5-JSON-RPC-096 port to provide exactly that. > > Cheers, > > Matthew > > -- > 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 >