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:
Juan RP 2010-11-03 15:56:37 +01:00
parent 304ece8e60
commit 722db61ea2
2 changed files with 57 additions and 46 deletions

View file

@ -27,56 +27,67 @@
# Applies to the build directory all patches found in PATCHESDIR
# (templates/$pkgname/patches).
#
_process_patch()
{
local args _patch i=$1
args="-Np0"
_patch=$(basename $i)
if [ -f $PATCHESDIR/${_patch}.args ]; then
args=$(cat $PATCHESDIR/${_patch}.args)
elif [ -n "$patch_args" ]; then
args=$patch_args
fi
cp -f $i $wrksrc
# Try to guess if its a compressed patch.
if $(echo $i|grep -q '.diff.gz'); then
gunzip $wrksrc/${_patch}
_patch=${_patch%%.gz}
elif $(echo $i|grep -q '.patch.gz'); then
gunzip $wrksrc/${_patch}
_patch=${_patch%%.gz}
elif $(echo $i|grep -q '.diff.bz2'); then
bunzip2 $wrksrc/${_patch}
_patch=${_patch%%.bz2}
elif $(echo $i|grep -q '.patch.bz2'); then
bunzip2 $wrksrc/${_patch}
_patch=${_patch%%.bz2}
elif $(echo $i|grep -q '.diff'); then
:
elif $(echo $i|grep -q '.patch'); then
:
else
msg_warn "unknown patch type: $i."
continue
fi
cd $wrksrc && patch -s ${args} < ${_patch} 2>/dev/null
if [ $? -eq 0 ]; then
msg_normal "Patch applied: ${_patch}."
else
msg_error "couldn't apply patch: ${_patch}."
fi
}
apply_tmpl_patches()
{
local patch_files args patch i
local f
[ ! -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"
patch=$(basename $i)
if [ -f $PATCHESDIR/$patch.args ]; then
args=$(cat $PATCHESDIR/$patch.args)
fi
cp -f $i $wrksrc
# Try to guess if its a compressed patch.
if $(echo $i|grep -q '.diff.gz'); then
gunzip $wrksrc/$patch
patch=${patch%%.gz}
elif $(echo $i|grep -q '.patch.gz'); then
gunzip $wrksrc/$patch
patch=${patch%%.gz}
elif $(echo $i|grep -q '.diff.bz2'); then
bunzip2 $wrksrc/$patch
patch=${patch%%.bz2}
elif $(echo $i|grep -q '.patch.bz2'); then
bunzip2 $wrksrc/$patch
patch=${patch%%.bz2}
elif $(echo $i|grep -q '.diff'); then
:
elif $(echo $i|grep -q '.patch'); then
:
else
msg_warn "unknown patch type: $i."
continue
fi
cd $wrksrc && patch -s ${args} < $patch 2>/dev/null
if [ $? -eq 0 ]; then
msg_normal "Patch applied: $patch."
else
msg_error "couldn't apply patch: $patch."
fi
done
if [ -r $PATCHESDIR/series ]; then
cat $PATCHESDIR/series | while read f; do
_process_patch "$PATCHESDIR/$f"
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
}

View file

@ -68,7 +68,7 @@ reset_tmpl_vars()
make_build_target configure_script noextract nofetch \
pre_configure pre_build pre_install build_depends \
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 \
disable_parallel_build run_depends font_dirs preserve \
only_for_archs conf_files keep_libtool_archives \