xbps-src: improve how patches can be applied.
1) $patch_args can be used if all patches need special args other than "-Np0" (set by default). 2) If the $PATCHESDIR/series file exist, it will specify how the patches will be applied, in that order.
This commit is contained in:
parent
304ece8e60
commit
722db61ea2
2 changed files with 57 additions and 46 deletions
|
@ -27,40 +27,32 @@
|
||||||
# Applies to the build directory all patches found in PATCHESDIR
|
# Applies to the build directory all patches found in PATCHESDIR
|
||||||
# (templates/$pkgname/patches).
|
# (templates/$pkgname/patches).
|
||||||
#
|
#
|
||||||
apply_tmpl_patches()
|
_process_patch()
|
||||||
{
|
{
|
||||||
local patch_files args patch i
|
local args _patch i=$1
|
||||||
|
|
||||||
[ ! -d $PATCHESDIR ] && return 0
|
|
||||||
|
|
||||||
for f in $(echo $PATCHESDIR/*); do
|
|
||||||
if $(echo $f|grep -q '.args'); then
|
|
||||||
continue
|
|
||||||
fi
|
|
||||||
patch_files="$patch_files $f"
|
|
||||||
done
|
|
||||||
|
|
||||||
for i in ${patch_files}; do
|
|
||||||
args="-Np0"
|
args="-Np0"
|
||||||
patch=$(basename $i)
|
_patch=$(basename $i)
|
||||||
if [ -f $PATCHESDIR/$patch.args ]; then
|
if [ -f $PATCHESDIR/${_patch}.args ]; then
|
||||||
args=$(cat $PATCHESDIR/$patch.args)
|
args=$(cat $PATCHESDIR/${_patch}.args)
|
||||||
|
elif [ -n "$patch_args" ]; then
|
||||||
|
args=$patch_args
|
||||||
fi
|
fi
|
||||||
cp -f $i $wrksrc
|
cp -f $i $wrksrc
|
||||||
|
|
||||||
# Try to guess if its a compressed patch.
|
# Try to guess if its a compressed patch.
|
||||||
if $(echo $i|grep -q '.diff.gz'); then
|
if $(echo $i|grep -q '.diff.gz'); then
|
||||||
gunzip $wrksrc/$patch
|
gunzip $wrksrc/${_patch}
|
||||||
patch=${patch%%.gz}
|
_patch=${_patch%%.gz}
|
||||||
elif $(echo $i|grep -q '.patch.gz'); then
|
elif $(echo $i|grep -q '.patch.gz'); then
|
||||||
gunzip $wrksrc/$patch
|
gunzip $wrksrc/${_patch}
|
||||||
patch=${patch%%.gz}
|
_patch=${_patch%%.gz}
|
||||||
elif $(echo $i|grep -q '.diff.bz2'); then
|
elif $(echo $i|grep -q '.diff.bz2'); then
|
||||||
bunzip2 $wrksrc/$patch
|
bunzip2 $wrksrc/${_patch}
|
||||||
patch=${patch%%.bz2}
|
_patch=${_patch%%.bz2}
|
||||||
elif $(echo $i|grep -q '.patch.bz2'); then
|
elif $(echo $i|grep -q '.patch.bz2'); then
|
||||||
bunzip2 $wrksrc/$patch
|
bunzip2 $wrksrc/${_patch}
|
||||||
patch=${patch%%.bz2}
|
_patch=${_patch%%.bz2}
|
||||||
elif $(echo $i|grep -q '.diff'); then
|
elif $(echo $i|grep -q '.diff'); then
|
||||||
:
|
:
|
||||||
elif $(echo $i|grep -q '.patch'); then
|
elif $(echo $i|grep -q '.patch'); then
|
||||||
|
@ -70,13 +62,32 @@ apply_tmpl_patches()
|
||||||
continue
|
continue
|
||||||
fi
|
fi
|
||||||
|
|
||||||
cd $wrksrc && patch -s ${args} < $patch 2>/dev/null
|
cd $wrksrc && patch -s ${args} < ${_patch} 2>/dev/null
|
||||||
if [ $? -eq 0 ]; then
|
if [ $? -eq 0 ]; then
|
||||||
msg_normal "Patch applied: $patch."
|
msg_normal "Patch applied: ${_patch}."
|
||||||
else
|
else
|
||||||
msg_error "couldn't apply patch: $patch."
|
msg_error "couldn't apply patch: ${_patch}."
|
||||||
fi
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
apply_tmpl_patches()
|
||||||
|
{
|
||||||
|
local f
|
||||||
|
|
||||||
|
[ ! -d $PATCHESDIR ] && return 0
|
||||||
|
|
||||||
|
if [ -r $PATCHESDIR/series ]; then
|
||||||
|
cat $PATCHESDIR/series | while read f; do
|
||||||
|
_process_patch "$PATCHESDIR/$f"
|
||||||
done
|
done
|
||||||
|
else
|
||||||
|
for f in $(echo $PATCHESDIR/*); do
|
||||||
|
if $(echo $f|grep -q '.args'); then
|
||||||
|
continue
|
||||||
|
fi
|
||||||
|
_process_patch $f
|
||||||
|
done
|
||||||
|
fi
|
||||||
|
|
||||||
touch -f $XBPS_APPLYPATCHES_DONE
|
touch -f $XBPS_APPLYPATCHES_DONE
|
||||||
}
|
}
|
||||||
|
|
|
@ -68,7 +68,7 @@ reset_tmpl_vars()
|
||||||
make_build_target configure_script noextract nofetch \
|
make_build_target configure_script noextract nofetch \
|
||||||
pre_configure pre_build pre_install build_depends \
|
pre_configure pre_build pre_install build_depends \
|
||||||
post_configure post_build post_install nostrip \
|
post_configure post_build post_install nostrip \
|
||||||
make_install_target version revision \
|
make_install_target version revision patch_args \
|
||||||
sgml_catalogs xml_catalogs xml_entries sgml_entries \
|
sgml_catalogs xml_catalogs xml_entries sgml_entries \
|
||||||
disable_parallel_build run_depends font_dirs preserve \
|
disable_parallel_build run_depends font_dirs preserve \
|
||||||
only_for_archs conf_files keep_libtool_archives \
|
only_for_archs conf_files keep_libtool_archives \
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue