[Build-common-hackers] Bug#219132: cdbs: misc improvements to simple-patchsys.mk
Robert Millan
Robert Millan <rmh@debian.org>, 219132@bugs.debian.org
Tue, 04 Nov 2003 15:46:30 +0100
This is a multi-part MIME message sent by reportbug.
--===============0298518970==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline
Package: cdbs
Version: 0.4.13
Severity: wishlist
Tags: patch
This patch does the following improvements to simple-patchsys.mk:
- add DEB_PATCH_SUFFIX variable, to override patch suffix (.patch, .gz, etc)
- permit overriding DEB_PATCHDIRS variable
- support for compressed patches (detects .gz|.bz2 and issues proper command)
- add DEB_PATCHDIRS_READONLY variable. when set to "yes", it will avoid
writing log files in the patch directory.
-- System Information:
Debian Release: testing/unstable
Architecture: i386
Kernel: Linux aragorn 2.4.22-1-k7 #5 Sat Oct 4 14:11:12 EST 2003 i686
Locale: LANG=ca_ES@euro, LC_CTYPE=ca_ES@euro
-- no debconf information
--===============0298518970==
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
Content-Type: text/plain; charset="utf-8"
Content-Disposition: attachment; filename="cdbs.diff"
--- /usr/share/cdbs/1/rules/simple-patchsys.mk 2003-10-16 05:24:56.000000000 +0200
+++ debian/simple-patchsys.mk 2003-11-04 13:38:13.000000000 +0100
@@ -1,7 +1,7 @@
# -*- mode: makefile; coding: utf-8 -*-
# Copyright © 2002,2003 Colin Walters <walters@debian.org>
# Description: A sample patch system which uses separate files in debian/patches
-# Patch names must end in .patch, currently.
+# Patch suffix is specified by DEB_PATCH_SUFFIX. Defaults to .patch.
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License as
@@ -35,8 +35,13 @@
_cdbs_patch_system_apply_rule := apply-patches
_cdbs_patch_system_unapply_rule := reverse-patches
+ifeq ($(DEB_PATCH_SUFFIX),)
+DEB_PATCH_SUFFIX = .patch
+endif
+ifeq ($(DEB_PATCHDIRS),)
DEB_PATCHDIRS = debian/patches
-DEB_PATCHES = $(foreach dir,$(DEB_PATCHDIRS),$(shell echo $(wildcard $(dir)/*.patch) $(wildcard $(dir)/*.diff)))
+endif
+DEB_PATCHES = $(foreach dir,$(DEB_PATCHDIRS),$(shell echo $(wildcard $(dir)/*$(DEB_PATCH_SUFFIX)) $(wildcard $(dir)/*.diff)))
post-patches:: apply-patches
@@ -56,6 +61,11 @@
patches="$$reversepatches"; \
fi; \
for patch in $$patches; do \
+ case $$patch in \
+ *.gz) cat=zcat ;; \
+ *.bz2) cat=bzcat ;; \
+ *) cat=cat ;; \
+ esac; \
level=$(head $$patch | egrep '^#DPATCHLEVEL=' | cut -f 2 -d '='); \
reverse=""; \
if [ "$@" = "reverse-patches" ]; then reverse="-R"; fi; \
@@ -65,8 +75,13 @@
for level in 0 1 2; do \
if test -z "$$success"; then \
echo -n "$$level..."; \
- if cat $$patch | patch -d $(DEB_SRCDIR) $$reverse -E --dry-run -p$$level 1>$$patch.level-$$level.log 2>&1; then \
- if cat $$patch | patch -d $(DEB_SRCDIR) $$reverse -E --no-backup-if-mismatch -V never -p$$level 1>$$patch.level-$$level.log 2>&1; then \
+ if [ $(DEB_PATCHDIRS_READONLY) = "yes" ] ; then \
+ logfile="/dev/null" ; \
+ else \
+ logfile="$$patch.level-$$level.log" ; \
+ fi ; \
+ if $$cat $$patch | patch -d $(DEB_SRCDIR) $$reverse -E --dry-run -p$$level 1>$$logfile 2>&1; then \
+ if $$cat $$patch | patch -d $(DEB_SRCDIR) $$reverse -E --no-backup-if-mismatch -V never -p$$level 1>$$logfile 2>&1; then \
success=yes; \
touch debian/stamp-patch-$$(basename $$patch); \
echo "success."; \
@@ -84,12 +99,18 @@
fi; \
else \
echo -n "Trying patch $$patch at level $$level..."; \
- if cat $$patch | patch -d $(DEB_SRCDIR) $$reverse -E --no-backup-if-mismatch -V never -p$$level 1>$$patch.log 2>&1; then \
+ echo -n "$$level..."; \
+ if [ $(DEB_PATCHDIRS_READONLY) = "yes" ] ; then \
+ logfile="/dev/null" ; \
+ else \
+ logfile="$$patch.log" ; \
+ fi ; \
+ if $$cat $$patch | patch -d $(DEB_SRCDIR) $$reverse -E --no-backup-if-mismatch -V never -p$$level 1>$$logfile 2>&1; then \
touch debian/stamp-patch-$$(basename $$patch); \
echo "success."; \
else \
echo "failure:"; \
- cat $$patch.log; \
+ cat $$logfile; \
if test -z "$$reverse"; then exit 1; fi; \
fi; \
fi; \
--===============0298518970==--