From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from pigeon.gentoo.org ([208.92.234.80] helo=lists.gentoo.org) by finch.gentoo.org with esmtp (Exim 4.60) (envelope-from ) id 1SL4SO-0003y5-H9 for garchives@archives.gentoo.org; Fri, 20 Apr 2012 03:24:24 +0000 Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 8C812E07AB; Fri, 20 Apr 2012 03:24:09 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) by pigeon.gentoo.org (Postfix) with ESMTP id 77C84E0772 for ; Fri, 20 Apr 2012 03:23:21 +0000 (UTC) Received: from vapier.localnet (localhost [127.0.0.1]) by smtp.gentoo.org (Postfix) with ESMTP id E55B01B4087 for ; Fri, 20 Apr 2012 03:23:20 +0000 (UTC) From: Mike Frysinger Organization: wh0rd.org To: gentoo-dev@lists.gentoo.org Subject: Re: [gentoo-dev] epatch: splitting out common options from user-specific ones Date: Thu, 19 Apr 2012 23:24:19 -0400 User-Agent: KMail/1.13.7 (Linux/3.4.0-rc1; KDE/4.6.5; x86_64; ; ) References: <201204181403.07937.vapier@gentoo.org> In-Reply-To: <201204181403.07937.vapier@gentoo.org> Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-dev@lists.gentoo.org Reply-to: gentoo-dev@lists.gentoo.org MIME-Version: 1.0 Content-Type: multipart/signed; boundary="nextPart4454792.kzQ01MOgrO"; protocol="application/pgp-signature"; micalg=pgp-sha1 Content-Transfer-Encoding: 7bit Message-Id: <201204192324.20395.vapier@gentoo.org> X-Archives-Salt: 4c9d95c7-bc37-453c-b604-1e2de11db723 X-Archives-Hash: 73766a426989b9c2b534285a21273654 --nextPart4454792.kzQ01MOgrO Content-Type: Text/Plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable no complaints, so here's the patch. precedence order is EPATCH_COMMON_OPTS then EPATCH_OPTS then whatever has been specified on the cmdline. so you can do: EPATCH_OPTS=3D"-F0" epatch epatch -p0 epatch (more for highlighting precedence than a realistic use case) =2Dmike =2D-- eutils.eclass +++ eutils.eclass @@ -230,13 +230,21 @@ EPATCH_SUFFIX=3D"patch.bz2" # @VARIABLE: EPATCH_OPTS # @DESCRIPTION: =2D# Default options for patch: +# Options to pass to patch. Meant for ebuild/package-specific tweaking +# such as forcing the patch level (-p#) or fuzz (-F#) factor. Note that +# for single patch tweaking, you can also pass flags directly to epatch. +EPATCH_OPTS=3D"" +# @VARIABLE: EPATCH_COMMON_OPTS +# @DESCRIPTION: +# Common options to pass to `patch`. You probably should never need to +# change these. If you do, please discuss it with base-system first to +# be sure. # @CODE # -g0 - keep RCS, ClearCase, Perforce and SCCS happy #24571 # --no-backup-if-mismatch - do not leave .orig files behind # -E - automatically remove empty files # @CODE =2DEPATCH_OPTS=3D"-g0 -E --no-backup-if-mismatch" +EPATCH_COMMON_OPTS=3D"-g0 -E --no-backup-if-mismatch" # @VARIABLE: EPATCH_EXCLUDE # @DESCRIPTION: # List of patches not to apply. Note this is only file names, @@ -257,7 +265,7 @@ EPATCH_MULTI_MSG=3D"Applying various patch EPATCH_FORCE=3D"no" =20 # @FUNCTION: epatch =2D# @USAGE: [patches] [dirs of patches] +# @USAGE: [options] [patches] [dirs of patches] # @DESCRIPTION: # epatch is designed to greatly simplify the application of patches. It c= an # process patch files directly, or directories of patches. The patches ma= y be @@ -265,8 +273,12 @@ EPATCH_FORCE=3D"no" # the -p option as epatch will automatically attempt -p0 to -p5 until thin= gs # apply successfully. # =2D# If you do not specify any options, then epatch will default to the dir= ectory =2D# specified by EPATCH_SOURCE. +# If you do not specify any patches/dirs, then epatch will default to the +# directory specified by EPATCH_SOURCE. +# +# Any options specified that start with a dash will be passed down to patch +# for this specific invocation. As soon as an arg w/out a dash is found, = then +# arg processing stops. # # When processing directories, epatch will apply all patches that match: # @CODE @@ -294,6 +306,18 @@ epatch() { =20 unset P4CONFIG P4PORT P4USER # keep perforce at bay #56402 =20 + # First process options. We localize the EPATCH_OPTS setting + # from above so that we can pass it on in the loop below with + # any additional values the user has specified. + local EPATCH_OPTS=3D( ${EPATCH_OPTS[*]} ) + while [[ $# -gt 0 ]] ; do + case $1 in + -*) EPATCH_OPTS+=3D( "$1" ) ;; + *) break ;; + esac + shift + done + # Let the rest of the code process one user arg at a time -- # each arg may expand into multiple patches, and each arg may # need to start off with the default global EPATCH_xxx values @@ -305,6 +329,10 @@ epatch() { return 0 fi =20 + # Now that we know we're actually going to apply something, merge + # all of the patch options back in to a single variable for below. + EPATCH_OPTS=3D"${EPATCH_COMMON_OPTS} ${EPATCH_OPTS[*]}" + local SINGLE_PATCH=3D"no" # no args means process ${EPATCH_SOURCE} [[ $# -eq 0 ]] && set -- "${EPATCH_SOURCE}" @@ -445,6 +473,7 @@ epatch() { local patch_cmd while [[ ${count} -lt 5 ]] ; do patch_cmd=3D"${BASH_ALIASES[patch]:-patch} -p${count} ${EPATCH_OPTS}" +einfo $patch_cmd =20 # Generate some useful debug info ... ( --nextPart4454792.kzQ01MOgrO Content-Type: application/pgp-signature; name=signature.asc Content-Description: This is a digitally signed message part. -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.17 (GNU/Linux) iQIcBAABAgAGBQJPkNbkAAoJEEFjO5/oN/WB1MEP/26ef0NMMgYw1Q7WJGL5RCp0 YV+HfmAs1Dv7FR2EPOQLSD90RDzK9K91E8+JMhbGjWh1WeNnHsD8YZAWh+yPyidQ Nk7IIwb2AZ3lIcFwgDFDaBKR5ZS+a74zfrpFCNd/qi777sVMoWCZTR/YI2AQlxKs fcwZBAanLPrKGsgd1whl6FX3ArYhRVwWIIXpQQYfyG/vsJw/DkFBPqtzXqXkkhvx sWk7ZjcdjRSY3hjpK2aqmMMPay67wx8PxvYu8FJuLQedA6sWLFxjpb4kq3ZMLAl2 smyGf+Eg0ERT3YE2cSqlZll1FQOiv8RW+t580w9JajC0VT/hn5ZEJG6Vz+hJpZfi 0gd18bchg1eFieZ6kIbODcIbLMsO+rwkQudMkq5EIadGe/dID70E8bY/+cKU3nnv E7t1xob2VP0cKNkNfjIKhndCJmKQDUWcW3i0XGGUAZc3wPEU6wGJYjNcLNFJNAWt 4jwxLKMFm6d7jQkBZr3UnvYc0S5ZjOz8nYN33TLwG3MW8ZR/mJiNweCKsTbp1xK+ ANWix4Xe8cHNIxbQp+BrXag3UjWH1wLjdp+EKss7UnO52C7cumxjcI7bUIlB/RCY /Vjfv1ezlngH8IuMH5QYqoUnKfXRCqadzBh9q1hE1jeDSYC8OSJwZUujLoiVqNEu 5PVscVrIcZNPHC8RICV/ =emcH -----END PGP SIGNATURE----- --nextPart4454792.kzQ01MOgrO--