2009-10-18 09:17:26 +00:00
|
|
|
#-
|
2010-12-19 23:22:12 +00:00
|
|
|
# Copyright (c) 2008-2010 Juan Romero Pardines.
|
2009-10-18 09:17:26 +00:00
|
|
|
# All rights reserved.
|
|
|
|
#
|
|
|
|
# Redistribution and use in source and binary forms, with or without
|
|
|
|
# modification, are permitted provided that the following conditions
|
|
|
|
# are met:
|
|
|
|
# 1. Redistributions of source code must retain the above copyright
|
|
|
|
# notice, this list of conditions and the following disclaimer.
|
|
|
|
# 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
# notice, this list of conditions and the following disclaimer in the
|
|
|
|
# documentation and/or other materials provided with the distribution.
|
|
|
|
#
|
|
|
|
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
|
|
|
# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
|
|
|
# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
|
|
|
# IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
|
|
|
# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
|
|
|
# NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
|
|
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
|
|
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
|
|
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
|
|
|
# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
#-
|
|
|
|
|
|
|
|
#
|
|
|
|
# Applies to the build directory all patches found in PATCHESDIR
|
|
|
|
# (templates/$pkgname/patches).
|
|
|
|
#
|
2010-11-03 14:56:37 +00:00
|
|
|
_process_patch()
|
2009-10-18 09:17:26 +00:00
|
|
|
{
|
2010-12-19 23:22:12 +00:00
|
|
|
local lver args _patch i=$1
|
2009-10-18 09:17:26 +00:00
|
|
|
|
2010-11-03 14:56:37 +00:00
|
|
|
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
|
2009-10-18 09:17:26 +00:00
|
|
|
|
2010-12-19 23:22:12 +00:00
|
|
|
if [ -n "$revision" ]; then
|
|
|
|
lver="${version}_${revision}"
|
|
|
|
else
|
|
|
|
lver="${version}"
|
|
|
|
fi
|
|
|
|
|
2010-11-03 14:56:37 +00:00
|
|
|
# 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
|
2010-12-19 23:22:12 +00:00
|
|
|
msg_warn "'$pkgname-$lver': unknown patch type: $i.\n"
|
2010-11-03 14:56:37 +00:00
|
|
|
continue
|
|
|
|
fi
|
2009-10-18 09:17:26 +00:00
|
|
|
|
2010-11-03 14:56:37 +00:00
|
|
|
cd $wrksrc && patch -s ${args} < ${_patch} 2>/dev/null
|
|
|
|
if [ $? -eq 0 ]; then
|
2010-12-19 23:22:12 +00:00
|
|
|
msg_normal "'$pkgname-$lver': Patch applied: ${_patch}.\n"
|
2010-11-03 14:56:37 +00:00
|
|
|
else
|
2010-12-19 23:22:12 +00:00
|
|
|
msg_error "'$pkgname-$lver': couldn't apply patch: ${_patch}.\n"
|
2010-11-03 14:56:37 +00:00
|
|
|
fi
|
|
|
|
}
|
2009-10-18 09:17:26 +00:00
|
|
|
|
2010-11-03 14:56:37 +00:00
|
|
|
apply_tmpl_patches()
|
|
|
|
{
|
|
|
|
local f
|
|
|
|
|
|
|
|
[ ! -d $PATCHESDIR ] && return 0
|
2009-10-18 09:17:26 +00:00
|
|
|
|
2010-11-03 14:56:37 +00:00
|
|
|
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
|
2009-10-18 09:17:26 +00:00
|
|
|
|
|
|
|
touch -f $XBPS_APPLYPATCHES_DONE
|
|
|
|
}
|