Date: Tue, 14 Aug 2018 17:02:59 -0400 From: Dan Langille <dan@langille.org> To: Adam Weinberger <adamw@adamw.org> Cc: freebsd-ports@freebsd.org Subject: Re: getting PKGNAME from CONFLICTS Message-ID: <29956974-76C3-4345-973D-18003128BEA1@langille.org> In-Reply-To: <CAP7rwcjUBYcts2si_UTXz7rbtBe%2B5PYUWCe-p67QXmJ558TdHg@mail.gmail.com> References: <ED883748-4CE1-4CEB-9830-224F253561E4@langille.org> <CAP7rwcgUfFyUedagXbKmWT7bFnbu=hsUAeR__%2B1f497AH-WSVg@mail.gmail.com> <CAP7rwcjUBYcts2si_UTXz7rbtBe%2B5PYUWCe-p67QXmJ558TdHg@mail.gmail.com>
next in thread | previous in thread | raw e-mail | index | archive | help
--Apple-Mail=_EC67AF10-89E7-4AC0-A769-FBBBC38D9276 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=us-ascii > On Aug 14, 2018, at 3:15 PM, Adam Weinberger <adamw@adamw.org> wrote: >=20 > On Tue, Aug 14, 2018 at 1:13 PM Adam Weinberger <adamw@adamw.org> = wrote: >>=20 >> On Tue, Aug 14, 2018 at 11:54 AM Dan Langille <dan@langille.org> = wrote: >>>=20 >>> I am in the process of adding FreshPorts support for CONFLICTS[1]. >>>=20 >>> I reference www/p5-CGI only because it had a recent commit and it = contains a CONFLICTS directive. >>>=20 >>> At https://dev.freshports.org/www/p5-CGI/ you can see: >>>=20 >>> CONFLICTS: p5-CGI.pm-[1-3]* >>>=20 >>> My goal is to allow a link to the search page or to the page for = that port. >>>=20 >>> The CONFLICTS field is a 'A list of package name patterns'[2] >>>=20 >>> I interpret this to mean the values returned by make -V PKGNAME and = the documentation[3] indicates this is correct. >>>=20 >>> Thus, the CONFLICTS matches https://dev.freshports.org/www/p5-CGI.pm = [4] >>>=20 >>> To extract the PKGNAME values from the CONFLICTS I will need to = remove everything after the trailing dash. >>>=20 >>> Can someone do me up a regex for that please? regex is a weak point = for me. Or point me into the Mk infrastructure to locate an existing = solution. >>=20 >> Hi Dan, >>=20 >> I suspect that the best you can get is to make some assumptions about >> what versions look like. This will catch most, but not all: >>=20 >> /^(.*?)-[-_\.,0-9ab]+$/ >=20 > On second thought, 'p' should be in there too. [-_\.,0-9abp]. I think we are trying to match the regex instead of noticing a regex and = removing it. Am I doing it wrong? $ cat ~/tmp/pkg-name.php <?php $CONFLICTS =3D "p5-CGI.pm-[1-3]*"; #$pkgname =3D preg_match("/(.*)[-_\.,0-9,abp]*/", $CONFLICTS, $matches); $pkgname =3D preg_match("/(.*)-[\[.*\]+]/", $CONFLICTS, $matches); print_r($matches); $ php ~/tmp/pkg-name.php Array ( [0] =3D> p5-CGI.pm-[ [1] =3D> p5-CGI.pm ) It's close, but not quite. Thank you. -- Dan Langille - BSDCan / PGCon dan@langille.org --Apple-Mail=_EC67AF10-89E7-4AC0-A769-FBBBC38D9276 Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename=signature.asc Content-Type: application/pgp-signature; name=signature.asc Content-Description: Message signed with OpenPGP -----BEGIN PGP SIGNATURE----- Comment: GPGTools - http://gpgtools.org iQGTBAEBCgB9FiEEzqcJ4oeyf8sgTIEBIU09XU2nXtMFAltzQ4RfFIAAAAAALgAo aXNzdWVyLWZwckBub3RhdGlvbnMub3BlbnBncC5maWZ0aGhvcnNlbWFuLm5ldENF QTcwOUUyODdCMjdGQ0IyMDRDODEwMTIxNEQzRDVENERBNzVFRDMACgkQIU09XU2n XtObQQf+LEekpEOa7aXX2WedGz+GGvA17kBDHSkpNMiJmZldNPcDTnkV64CtUfIW 5QUcivCp754APrbnNcpAX7Ua6EpqUgu7IdNYmDiTxKujonJ/3dW+fCWsO+xWQez1 lR83AxzygkeqHnQGpjR35YDrIdMqqlPgAQZ7skyK+U1z8HnRlI1dSeFyrzUS74Hp u0K1/fZ4C481dbLdYuzH1wpbrJEwA+jXOcFcqEFG6ZPlmfQRdYLK9ZsejiaAP0FJ 8zyI1jo+3l9F5pTTJ31cHTJYpac7cPI50M3H/BjOJPlhS3wv5oXIDbLtwqZq/rYL vyXXC0j42f8YoYwPgSv873YCDxg+pg== =rtfK -----END PGP SIGNATURE----- --Apple-Mail=_EC67AF10-89E7-4AC0-A769-FBBBC38D9276--
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?29956974-76C3-4345-973D-18003128BEA1>