Separate patches in ocaml-source "binary" package
authorStephane Glondu <steph@glondu.net>
Fri, 18 Mar 2011 15:12:10 +0000 (16:12 +0100)
committerStephane Glondu <steph@glondu.net>
Fri, 18 Mar 2011 15:40:03 +0000 (16:40 +0100)
debian/ocaml-source.exclude
debian/rules

index 5e41a02b4c5b67d60653e7d2c07e918bcf0bf0be..a1a443470aa6a4fd8e70eccfceff7a4a7456be17 100644 (file)
@@ -1,3 +1,4 @@
 */debian
 */*-stamp
 */.git
+*/.pc
index fcbc561258215c558c6158fdb7ec19bb29df15fb..936b99255e015cd741e05ce621c058737906190b 100755 (executable)
@@ -32,6 +32,12 @@ INSTDIR = $(CURDIR)/debian/tmp/usr
 DISTDIR = $(PACKAGE)-$(OCAML_ABI)
 SRCTARBALL = $(PACKAGE)-source-$(OCAML_ABI).tar.bz2
 
+ifneq (,$(findstring ocaml-source,$(ALL_PACKAGES)))
+  TARBALL_TARGET = debian/$(SRCTARBALL)
+else
+  TARBALL_TARGET =
+endif
+
 # Environment variable for dh_ocaml
 export OCAMLOBJINFO = OCAMLLIB=tools boot/ocamlrun tools/objinfo
 
@@ -62,7 +68,7 @@ CONFIGURE_SED := \
 %:
        dh $@
 
-ocamlinit-stamp: debian/$(SRCTARBALL)
+ocamlinit-stamp: $(TARBALL_TARGET)
 
 # Generate ocaml-native-compilers' Architecture field.
 # Should never be called automatically.
@@ -70,7 +76,7 @@ ocamlinit-stamp: debian/$(SRCTARBALL)
 debian/control:
        sed -e 's/@OCamlNativeArchs@/$(OCAML_NATIVE_ARCHS)/g' debian/control.in > $@
 
-pre-config-stamp: debian/$(SRCTARBALL)
+pre-config-stamp: $(TARBALL_TARGET)
        chmod +x debian/gen_modules.pl
 # Backup upstream config.{sub,guess}, and use most up-to-date ones
        for ext in sub guess; do \
@@ -82,13 +88,26 @@ pre-config-stamp: debian/$(SRCTARBALL)
        done
        touch $@
 
-debian/$(SRCTARBALL):
+ifneq (,$(TARBALL_TARGET))
+$(TARBALL_TARGET):
+# Make a copy of the current (patched) sources in debian/$(DISTDIR)
        ln -fs . $(DISTDIR)     # beware of the symlink recursion!
-       tar --anchored -chjf $@ \
+       mkdir debian/$(DISTDIR)
+       tar --anchored -ch \
          --exclude=$(DISTDIR)/$(DISTDIR)       \
          --exclude-from=debian/ocaml-source.exclude \
-         $(DISTDIR)/
+         $(DISTDIR)/ | tar -C debian -x
        rm -f $(DISTDIR)
+# Copy patches and unapply them
+       cp -a debian/patches debian/$(DISTDIR)/debian-patches
+       cd debian/$(DISTDIR) && sort -r debian-patches/series | \
+       while read u; do \
+         patch -R -V never -p1 < debian-patches/$$u; \
+       done
+# Create the tarball and cleanup
+       tar -C debian -cjf $@ $(DISTDIR)
+       rm -Rf debian/$(DISTDIR)
+endif
 
 .PHONY: override_dh_auto_configure
 override_dh_auto_configure: config-stamp