From owner-freebsd-ports@freebsd.org Wed Aug 15 13:17:55 2018 Return-Path: Delivered-To: freebsd-ports@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 593301084445 for ; Wed, 15 Aug 2018 13:17:55 +0000 (UTC) (envelope-from ros@bebik.net) Received: from smtp.osorio.me (smtp.osorio.me [5.196.94.126]) by mx1.freebsd.org (Postfix) with ESMTP id F36608C2A3 for ; Wed, 15 Aug 2018 13:17:54 +0000 (UTC) (envelope-from ros@bebik.net) Received: from [192.168.1.117] (unknown [78.194.61.125]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.osorio.me (Postfix) with ESMTPSA id E9A8F4E2DD for ; Wed, 15 Aug 2018 13:17:53 +0000 (UTC) From: Rodrigo Osorio Subject: Re: getting PKGNAME from CONFLICTS To: freebsd-ports@freebsd.org References: <286CAC11-E9C6-42C4-8D41-97F51EFF1596@yahoo.com> <9823D065-3FCC-4D69-9EB4-9C4CD01C7778@langille.org> <16f81513-5324-001f-d1c7-45536835ef15@FreeBSD.org> Message-ID: <106c6045-c2b3-7da6-5ceb-daa778e52286@bebik.net> Date: Wed, 15 Aug 2018 15:17:53 +0200 User-Agent: Mozilla/5.0 (X11; FreeBSD amd64; rv:52.0) Gecko/20100101 Thunderbird/52.9.1 MIME-Version: 1.0 In-Reply-To: <16f81513-5324-001f-d1c7-45536835ef15@FreeBSD.org> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit X-BeenThere: freebsd-ports@freebsd.org X-Mailman-Version: 2.1.27 Precedence: list List-Id: Porting software to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 15 Aug 2018 13:17:55 -0000 On 08/15/18 14:46, Matthew Seaman wrote: > On 15/08/2018 00:35, Dan Langille wrote: >>> On Aug 14, 2018, at 2:55 PM, Mark Millard via freebsd-ports wrote: >>> >>> >>> Dan Langille dan at langille.org wrote on >>> Tue Aug 14 17:54:01 UTC 2018 : >>> >>>> . . . >>>> At https://dev.freshports.org/www/p5-CGI/ you can see: >>>> >>>> CONFLICTS: p5-CGI.pm-[1-3]* >>>> . . . >>>> To extract the PKGNAME values from the CONFLICTS I will need to remove everything after the trailing dash. >>>> . . . >>> p5- >>> vs. >>> p5-CGI.pm- >>> vs. >>> p5-CGI.pm-[1- >>> >>> It looks to me like "trailing dash" probably has a >>> complicated definition where some "-"(s) may exist >>> that are to be ignored after the one of interest. >>> In the example I'm guessing that the middle >>> "-" is intended (so "p5-CGI.pm-"). >> Agreed. The hard part is identifying the regex and deleting it from consideration. >> > If you don't mind spawning a new process, you can just do: > > % pkg search -qg 'p5-CGI.pm-[1-3]*' > p5-CGI.pm-3.63_1,1 > > This does assume your pkg(8) is configured to use a repository with all > possible packages available. The default FreeBSD repositories are a > good choice in that regard. > > Or if you already have a database table with all of the package names > and versions, then you'll presumably want to change the glob expression > into a regex match (in this case something like '^p5-CGI\.pm-[1-3].*') > Unless there's a PG extension that allows using glob(3) to match > strings? I can't see one after a pretty cursory search. (sqlite has > glob(3) support, which is what the pkg(8) command above is using under > the hood.) > > Cheers, > > Matthew > Hi, Why do you uses regexp instead of evaluating them with fnmatch ? The function is available (at least) in php, python and ruby. Cheers, - rodrigo