* New: "extrapatches" bbclass.
@ 2019-03-08 3:26 Kaz Kylheku (poky)
2019-03-09 10:01 ` Richard Purdie
0 siblings, 1 reply; 3+ messages in thread
From: Kaz Kylheku (poky) @ 2019-03-08 3:26 UTC (permalink / raw)
To: yocto
#
# extrapatches bbclass
#
# This bbclass allows for a recipe to apply additional patches.
#
# "Additional patches" refers to patches that are not individually
# fetched by the SRC_URI mechanism, but are already present
# inside the source trees that are fetched and unpacked.
# Referring directly to recipe-side patches
# without fetching them via SRC_URI is also possible.
#
# How to use this class:
#
# 1. Add inherit extrapatches to your recipe.
# 2. Optionally set the EXTRAPATCHES_WORKDIR,
# 3. List the patches in EXTRAPATCHES in order of application.
# - Relative paths are interpreted relative to
EXTRAPATCHES_WORKDIR.
# - Absolute paths are allowed
#
# Influential variables:
#
# Name Default Desc
#
--------------------------------------------------------------------------
# EXTRAPATCHES_WORKDIR ${S} extrapatches changes to this
directory.
#
# EXTRAPATCHES "" list of path names of patch files
# relative paths are resolved from
# the EXTRAPATCHES_WORKDIR directory.
# EXTRAPATCHES entries must not
contain
# spaces or shell meta-characters.
#
# The following SRC_URI style options supported in EXTRAPATCHES
variable:
#
# Name Default Desc
#
--------------------------------------------------------------------------
# apply 1 Boolean, apply the patch or not.
#
# striplevel 1 How many leading directory
components
# to remove, passed as the -p option
# of patch.
#
# For Boolean options: yes, y, true, t, and 1 all specify "true";
# no, n, false, f and 0 specify "false".
#
# Additional usage notes:
#
# The patches you list in EXTRAPATCHES will be applied *AFTER* any
# patches that Yocto applies that are specified on the SRC_URI.
#
# If this is a problem, you can follow this method, or the alternative:
#
# 1. Add do_patch[noexec] = "1" to your recipe.
# 2. List your SRC_URI patches again in the EXTRAPATCHES variable,
# keeping in mind they are fetched into ${WORKDIR}.
# Absolute paths may be used like ${WORKDIR}/001-foo.patch
#
# Alternative:
#
# 1. Add do_patch[noexec] = "1" to suppress Yocto's do_patch.
# 2. Do *NOT* list any patches in SRC_URI.
# 3. Refer directly to your recipe-side patches in EXTRAPATCHES,
# for instance EXTRAPATCHES = "${THISDIR}/files/my-patch.patch ..."
#
EXTRAPATCHES_WORKDIR = "${S}"
do_patch_extra() {
cd ${EXTRAPATCHES_WORKDIR}
mkdir -p patches
if [ "$(quilt top)" = patches/empty-last.patch ] ; then
# extra patches already applied: delete them, but
# keep the empty-first.patch
while [ "$(quilt top)" != patches/empty-first.patch ] ; do
quilt delete
done
elif quilt series | grep -q '^patches/empty-first[.]patch$' ; then
# our patches are half-applied; the markers exist, but
# the patches/empty-last.patch is not on top.
# Let's try to recover.
# blow off all unapplied patches
for patch in $(quilt unapplied) ; do
quilt delete $patch
done
if quilt applied empty-first.patch > /dev/null ; then
# if the empty-first.patch marker is applied, then
# delete everything above it
while [ "$(quilt top)" != patches/empty-first.patch ] ; do
quilt delete
done
else
# the empty-first.patch is not applied, and no
# unapplied patches exist. Let's assume that we
# have a clean slate with the only patches that exist
# being the ones from Yocto's do_patch. We begin our marker.
# quilt ref ensures that the empty patch file is actually
created
quilt new empty-first.patch ; quilt ref
fi
else
# dummy marker patch indicating start of extra patches
quilt new empty-first.patch ; quilt ref
fi
for patch in ${EXTRAPATCHES} ; do
import_patch_with_options "$patch"
quilt push
done
# dummy marker patch indicating that all patches are applied
quilt new empty-last.patch ; quilt ref
}
addtask patch_extra after do_patch before do_configure
import_patch_with_options()
{
local patch=$1
local striplevel=1
local apply=1
local opt
local arg
while true ; do
case $patch in
*' '* )
printf "patch name %s contains spaces\n" "$patch"
exit 1
;;
*\;* )
opt=${patch##*;}
patch=${patch%;*}
case $opt in
*=* )
arg=${opt##*=}
opt=${opt%=*}
case $opt in
striplevel )
striplevel=$arg
;;
apply )
apply=$arg
;;
* )
printf "patch %s specifies unrecognized option:
%s\n" \
$patch $opt
exit 1
esac
;;
* )
printf "patch %s specifies option with no argument:
%s\n" \
$patch $opt
exit 1
;;
esac
;;
* )
break
;;
esac
done
case $apply in
yes | y | true | t | 1 )
quilt import -p $striplevel $patch
;;
no | n | false | f | 0 )
printf "patch %s disabled by apply option\n" $patch
;;
* )
printf "patch %s specifies invalid boolean value for apply:
%s\n" \
$patch $apply
;;
esac
}
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: New: "extrapatches" bbclass.
2019-03-08 3:26 New: "extrapatches" bbclass Kaz Kylheku (poky)
@ 2019-03-09 10:01 ` Richard Purdie
2019-03-09 16:20 ` Kaz Kylheku (poky)
0 siblings, 1 reply; 3+ messages in thread
From: Richard Purdie @ 2019-03-09 10:01 UTC (permalink / raw)
To: Kaz Kylheku (poky), yocto
On Thu, 2019-03-07 at 19:26 -0800, Kaz Kylheku (poky) wrote:
> #
> # extrapatches bbclass
> #
> # This bbclass allows for a recipe to apply additional patches.
> #
> # "Additional patches" refers to patches that are not individually
> # fetched by the SRC_URI mechanism, but are already present
> # inside the source trees that are fetched and unpacked.
> # Referring directly to recipe-side patches
> # without fetching them via SRC_URI is also possible.
> #
> # How to use this class:
> #
> # 1. Add inherit extrapatches to your recipe.
> # 2. Optionally set the EXTRAPATCHES_WORKDIR,
> # 3. List the patches in EXTRAPATCHES in order of application.
> # - Relative paths are interpreted relative to
> EXTRAPATCHES_WORKDIR.
> # - Absolute paths are allowed
Can't you already do this if you put a file:// url in SRC_URI for the
patch as its unpacked in the workdir?
Cheers,
Richard
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: New: "extrapatches" bbclass.
2019-03-09 10:01 ` Richard Purdie
@ 2019-03-09 16:20 ` Kaz Kylheku (poky)
0 siblings, 0 replies; 3+ messages in thread
From: Kaz Kylheku (poky) @ 2019-03-09 16:20 UTC (permalink / raw)
To: Richard Purdie; +Cc: yocto
On 2019-03-09 02:01, Richard Purdie wrote:
> On Thu, 2019-03-07 at 19:26 -0800, Kaz Kylheku (poky) wrote:
>> #
>> # extrapatches bbclass
>> #
>> # This bbclass allows for a recipe to apply additional patches.
>> #
>> # "Additional patches" refers to patches that are not individually
>> # fetched by the SRC_URI mechanism, but are already present
>> # inside the source trees that are fetched and unpacked.
>> # Referring directly to recipe-side patches
>> # without fetching them via SRC_URI is also possible.
>> #
>> # How to use this class:
>> #
>> # 1. Add inherit extrapatches to your recipe.
>> # 2. Optionally set the EXTRAPATCHES_WORKDIR,
>> # 3. List the patches in EXTRAPATCHES in order of application.
>> # - Relative paths are interpreted relative to
>> EXTRAPATCHES_WORKDIR.
>> # - Absolute paths are allowed
>
> Can't you already do this if you put a file:// url in SRC_URI for the
> patch as its unpacked in the workdir?
That doesn't work due SRC_URI materials not being fetched and unpacked
in left-to-right order, but in separate do_fetch and do_unpack phases.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2019-03-09 16:20 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-03-08 3:26 New: "extrapatches" bbclass Kaz Kylheku (poky)
2019-03-09 10:01 ` Richard Purdie
2019-03-09 16:20 ` Kaz Kylheku (poky)
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.