shutils: improve how the patches are applied.
Now all patches must be placed in PATCHESDIR (templatesdir/$pkgname/patches) and must be in -p0 format. If other args are required, a same file with .args extension should be created with specific args inside of it. --HG-- extra : convert_revision : xtraeme%40gmail.com-20091015140224-x5n026mdhwb4pvyq
This commit is contained in:
parent
9296d25811
commit
e056e23be1
@ -1,5 +1,5 @@
|
||||
#-
|
||||
# Copyright (c) 2008 Juan Romero Pardines.
|
||||
# Copyright (c) 2008-2009 Juan Romero Pardines.
|
||||
# All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
@ -24,57 +24,57 @@
|
||||
#-
|
||||
|
||||
#
|
||||
# Applies to the build directory the patches specified by a template.
|
||||
# Applies to the build directory all patches found in PATCHESDIR
|
||||
# (templates/$pkgname/patches).
|
||||
#
|
||||
apply_tmpl_patches()
|
||||
{
|
||||
local patch=
|
||||
local i=
|
||||
local patch_files args patch i
|
||||
|
||||
# Apply some build/install patches automatically.
|
||||
if [ -f $XBPS_TEMPLATESDIR/$pkgname/build.diff ]; then
|
||||
patch_files="build.diff $patch_files"
|
||||
fi
|
||||
if [ -f $XBPS_TEMPLATESDIR/$pkgname/install.diff ]; then
|
||||
patch_files="install.diff $patch_files"
|
||||
fi
|
||||
[ ! -d $PATCHESDIR ] && return 0
|
||||
|
||||
[ -z "$patch_args" ] && patch_args="-p0"
|
||||
[ -z "$patch_files" ] && return 0
|
||||
|
||||
#
|
||||
# If package needs some patches applied before building,
|
||||
# apply them now.
|
||||
#
|
||||
for i in ${patch_files}; do
|
||||
patch="$XBPS_TEMPLATESDIR/$pkgname/$i"
|
||||
if [ ! -f "$patch" ]; then
|
||||
msg_warn "unexistent patch: $i."
|
||||
for f in $(echo $PATCHESDIR/*); do
|
||||
if $(echo $f|grep -q '.args'); then
|
||||
continue
|
||||
fi
|
||||
patch_files="$patch_files $f"
|
||||
done
|
||||
|
||||
cp -f $patch $wrksrc
|
||||
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 $patch|grep -q '.diff.gz'); then
|
||||
gunzip $wrksrc/$i
|
||||
patch=${i%%.gz}
|
||||
elif $(echo $patch|grep -q '.diff.bz2'); then
|
||||
bunzip2 $wrksrc/$i
|
||||
patch=${i%%.bz2}
|
||||
elif $(echo $patch|grep -q '.diff'); then
|
||||
patch=$i
|
||||
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 ${patch_args} < \
|
||||
$patch 2>/dev/null
|
||||
if [ "$?" -eq 0 ]; then
|
||||
msg_normal "Patch applied: $i."
|
||||
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: $i."
|
||||
msg_error "couldn't apply patch: $patch."
|
||||
fi
|
||||
done
|
||||
|
||||
|
@ -66,7 +66,7 @@ reset_tmpl_vars()
|
||||
local TMPL_VARS="pkgname distfiles configure_args configure_env \
|
||||
make_build_args make_install_args build_style \
|
||||
short_desc maintainer long_desc checksum wrksrc \
|
||||
patch_files make_cmd base_chroot register_shell \
|
||||
make_cmd base_chroot register_shell \
|
||||
make_build_target configure_script noextract nofetch \
|
||||
pre_configure pre_build pre_install configure_shell \
|
||||
post_configure post_build post_install \
|
||||
@ -74,13 +74,13 @@ reset_tmpl_vars()
|
||||
sgml_catalogs xml_catalogs xml_entries sgml_entries \
|
||||
build_depends libtool_fixup_la_stage no_fixup_libtool \
|
||||
disable_parallel_build run_depends cross_compiler \
|
||||
only_for_archs patch_args conf_files keep_dirs \
|
||||
only_for_archs conf_files keep_dirs \
|
||||
noarch subpackages sourcepkg gtk_iconcache_dirs \
|
||||
abi_depends api_depends triggers openrc_services \
|
||||
libtool_no_delete_archives \
|
||||
XBPS_EXTRACT_DONE XBPS_CONFIGURE_DONE \
|
||||
XBPS_BUILD_DONE XBPS_INSTALL_DONE FILESDIR DESTDIR \
|
||||
SRCPKGDESTDIR"
|
||||
SRCPKGDESTDIR PATCHESDIR"
|
||||
|
||||
for v in ${TMPL_VARS}; do
|
||||
eval unset "$v"
|
||||
@ -212,6 +212,7 @@ set_tmpl_common_vars()
|
||||
[ -z "$pkgname" ] && return 1
|
||||
|
||||
FILESDIR=${XBPS_TEMPLATESDIR}/${pkgname}/files
|
||||
PATCHESDIR=${XBPS_TEMPLATESDIR}/${pkgname}/patches
|
||||
DESTDIR=${XBPS_DESTDIR}/${pkgname}-${version}
|
||||
if [ -z "${sourcepkg}" ]; then
|
||||
sourcepkg=${pkgname}
|
||||
|
Loading…
Reference in New Issue
Block a user