From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) by finch.gentoo.org (Postfix) with ESMTP id 9625613888F for ; Wed, 14 Oct 2015 18:24:33 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 0129B21C001; Wed, 14 Oct 2015 18:24:29 +0000 (UTC) Received: from a1www.kph.uni-mainz.de (a1www.kph.uni-mainz.de [134.93.134.1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id 5180D21C001 for ; Wed, 14 Oct 2015 18:24:27 +0000 (UTC) Received: from a1i15.kph.uni-mainz.de (a1i15.kph.uni-mainz.de [134.93.134.92]) by a1www.kph.uni-mainz.de (8.14.9/8.14.7) with ESMTP id t9EIOMtH021810; Wed, 14 Oct 2015 20:24:22 +0200 Received: from a1i15.kph.uni-mainz.de (localhost [127.0.0.1]) by a1i15.kph.uni-mainz.de (8.14.8/8.14.2) with ESMTP id t9EIOMbh016256; Wed, 14 Oct 2015 20:24:22 +0200 Received: (from ulm@localhost) by a1i15.kph.uni-mainz.de (8.14.8/8.14.8/Submit) id t9EIOMvo016252; Wed, 14 Oct 2015 20:24:22 +0200 Message-ID: <22046.40406.63642.760729@a1i15.kph.uni-mainz.de> Date: Wed, 14 Oct 2015 20:24:22 +0200 To: =?iso-8859-2?Q?Micha=B3_G=F3rny?= Cc: gentoo-pms@lists.gentoo.org Subject: [gentoo-pms] Re: [PATCH] Explain eapply behavior for EAPI 6 In-Reply-To: <1444841121-2541-1-git-send-email-mgorny@gentoo.org> References: <1444841121-2541-1-git-send-email-mgorny@gentoo.org> X-Mailer: VM 8.2.0b under 24.3.1 (x86_64-pc-linux-gnu) From: Ulrich Mueller Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Package Manager Specification discussions X-BeenThere: gentoo-pms@gentoo.org X-BeenThere: gentoo-pms@lists.gentoo.org Reply-To: gentoo-pms@lists.gentoo.org MIME-Version: 1.0 Content-Type: multipart/signed; boundary="pgp+signed+2Ptmi4xkMqFdpCT"; micalg=pgp-sha256; protocol="application/pgp-signature" X-Archives-Salt: c0bb4255-42ba-4514-ba79-35328d5ac5b1 X-Archives-Hash: 61e14dfbb96472454c4f60a6b1e90264 This is an OpenPGP/MIME signed message (RFC 2440 and 3156) --pgp+signed+2Ptmi4xkMqFdpCT Content-Type: text/plain; charset=iso-8859-2 Content-Transfer-Encoding: quoted-printable >>>>> On Wed, 14 Oct 2015, Micha=B3 G=F3rny wrote: > --- > pkg-mgr-commands.tex | 32 ++++++++++++++++++++++++++++---- > 1 file changed, 28 insertions(+), 4 deletions(-) > // I'm aware this isn't perfect but I tried to keep the algorithm > // readable and reasonably concise. Hope it's good enough for a start= > // though. Thanks, this will indeed serve well as a start. > diff --git a/pkg-mgr-commands.tex b/pkg-mgr-commands.tex > index dbdbdfd..1d57d63 100644 > --- a/pkg-mgr-commands.tex > +++ b/pkg-mgr-commands.tex > @@ -148,10 +148,12 @@ These commands are used during the \t{src\=5Fpr= epare} phase to apply patches to th > Ebuilds must not run any of these commands once the current phase fu= nction has returned. > =20 > \begin{description} > -\item[eapply] \featurelabel{eapply} > - Only available in EAPIs listed in table~\ref{tab:patch-commands}= as supporting \t{eapply}. > +\item[eapply] \featurelabel{eapply} Takes zero or more patch(1) opti= ons, followed by one or more Should we say "GNU patch" here=3F We require it in ebuild-env-commands.= tex. > +=09file or directory paths. Processes options and applies all patche= s found in specified locations > +=09according to Algorithm~\ref{alg:eapply}. Only available in EAPIs = listed in > +=09table~\ref{tab:patch-commands} as supporting \t{eapply}. > =20 > -\item[eapply\=5Fuser] \featurelabel{eapply-user} Takes no arguments.= Package managers supporting it > +\item[eapply\=5Fuser] \featurelabel{eapply-user} Takes no arguments.= Package managers supporting i Slip of fingers. > apply user-provided patches to the source tree in the current wo= rking directory. Exact behaviour > is implementation defined and beyond the scope of this specifica= tion. Package managers not > supporting it must implement the function as a no-op. Only avail= able in EAPIs listed in > @@ -161,7 +163,29 @@ Ebuilds must not run any of these commands once = the current phase function has r > \begin{algorithm} > \caption{eapply logic} \label{alg:eapply} > \begin{algorithmic}[1] > -\STATE \COMMENT{WORK IN PROGRESS} > +\STATE let options=3D() > +\STATE let infiles=3DFALSE > +\FOR{\$x in parameters} > +=09\IF{infiles is FALSE} > +=09=09\IF{\$x is "\t{-{}-}"} > +=09=09=09\STATE let infiles=3DTRUE > +=09=09\ELSIF{\$x starts with "\t{-}"} > +=09=09=09\STATE options+=3D( "\$x" ) > +=09=09\ELSE > +=09=09=09\STATE let infiles=3DTRUE > +=09=09\ENDIF > +=09\ENDIF > + > +=09\IF{infiles is TRUE} I wonder if it wouldn't be cleaner to do the whole option parsing first. Something along the lines of this: IF first parameter begins with a hyphen AND any parameter is equal = to -- collect all parameters before the first -- in the options array= collect all parameters after the first -- in the files array ELSIF any parameter beginning with a hyphen follows one without a h= yphen return an error ELSE collect all parameters starting with a hyphen in the options ar= ray collect all parameters without a hyphen in the files array ENDIF FOR x in files ... > +=09=09\IF{\$x is a directory} > +=09=09=09\FOR{\$f in all files matching \$x/*.diff and \$x/*.patch} > +=09=09=09=09\STATE call \t{patch -p1 -f -s "\$\{options[@]\}" "\$f"}= Options "-p1 -g0 -E --no-backup-if-mismatch" are field-proven in eutils.eclass. This doesn't mean that we have to adhere to it slavishly, but I would suggest that we keep both the -g0 and the --no-backup-if-mismatch options (but drop -E). Also I would omit the -s; it is up to the PM if it wants to suppress or filter output. So in summary, that is: patch -p1 -f -g0 --no-backup-if-mismatch > +=09=09=09\ENDFOR > +=09=09\ELSE > +=09=09=09\STATE call \t{patch -p1 -f -s "\$\{options[@]\}" "\$x"} > +=09=09\ENDIF > +=09\ENDIF > +\ENDFOR > \end{algorithmic} > \end{algorithm} We should say something about error handling. For example, does the function return when it encounters the first error of a called patch(1)=3F Ulrich --pgp+signed+2Ptmi4xkMqFdpCT Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.22 (GNU/Linux) iQEcBAEBCAAGBQJWHp08AAoJEMMJBoUcYcJzVz4H/0CTR+vVPWVv0lMFNA1sbIcs S/yarvU1uD3GiQBKsIaIISETLkPor6Q3DxQ+qqUHgmGjurPEyBe2JxHlumTcP0dr /KmrMm8alho2lWAulTMb2gsN/D5lV4ffBfStCHbUZDVIX4cDKfvJz7a15WVEsmAr mimvdsQmx5yNWx9Y4PhAXVS7tszydWSTFHxTgTHfQTTVfBCni07JmmO1OzJW1Sxz worNzJwmHWvYq639hTFmgNsLVjfQU+EYI8xCZilwyuFqu27Er799k3Jvl3Wmjj2Y kAWJRH6xulOFNfJrA9g2HOLP9MrgGw51pKBcrpyu8+7p6BusFpghTltPBKWgFN0= =2bTt -----END PGP SIGNATURE----- --pgp+signed+2Ptmi4xkMqFdpCT--