Makefile.PL: avoid in-place editing with sed
authorPhilipp A. Hartmann <philipp.hartmann@offis.de>
Mon, 27 Aug 2012 13:15:34 +0000 (15:15 +0200)
committerPhilipp A. Hartmann <philipp.hartmann@offis.de>
Mon, 27 Aug 2012 13:22:51 +0000 (15:22 +0200)
This patch avoids the usage of the in-place editing option '-i' of sed for
version number extraction from debian/changelog to update pristine-tar.spec.

The -i option is not supported by all versions of sed (e.g. not by SunOS 5.9
nor by NetBSD 6.0).  Additionally, the exact syntax may vary.  E.g., the sed
of Mac OS X requires -i to be followed by a suffix, which is added to the
original filename to create a backup file.  The portable solution is to avoid
the in-place editing altogether and to instead write first to a temporary
file, which is then moved back to the original filename.

In addition to the use of a temporary file, the rule has been changed to
use the PERLRUN variable to invoke the correct perl interpreter and a
dependency on debian/changelog (the phonyness of the rule could be
dropped as well).

Signed-off-by: Philipp A. Hartmann <philipp.hartmann@offis.de>
Makefile.PL

index cd4f31b679021eb55a7a9c4220fe2f30a6fa9985..e28b6368686b53b4d99946a1791a96de975c06c3 100755 (executable)
@@ -38,8 +38,9 @@ extra_clean:
        rm -f *.1 zgz/zgz
        $(MAKE) clean -C pit/suse-bzip2 PREFIX=$(PREFIX)
 
-pristine-tar.spec:
-       sed -i "s/Version:.*/Version: $$(perl -e '$$_=<>;print m/\((.*?)\)/'<debian/changelog)/" pristine-tar.spec
+pristine-tar.spec: debian/changelog
+       sed "s/Version:.*/Version: $$($(PERLRUN) -e '$$_=<>;print m/\((.*?)\)/'<$<)/" \
+               $@ > $@.new && $(MV) $@.new $@
 
 .PHONY: pristine-tar.spec
 }