diff -Nru dh-exec-0.12/debian/changelog dh-exec-0.13~ubuntu14.04.1~ppa1/debian/changelog --- dh-exec-0.12/debian/changelog 2013-11-05 09:04:13.000000000 +0000 +++ dh-exec-0.13~ubuntu14.04.1~ppa1/debian/changelog 2019-03-14 14:17:35.000000000 +0000 @@ -1,3 +1,25 @@ +dh-exec (0.13~ubuntu14.04.1~ppa1) trusty; urgency=medium + + * No-change backport to trusty + + -- Colin Watson Thu, 14 Mar 2019 14:17:35 +0000 + +dh-exec (0.13) unstable; urgency=medium + + * Fix a typo in the package description. Thanks James Cowgill! + (Closes: #731078) + * Add support for filtering based on architecture. Thanks Andreas + Henriksson for the suggestion and testing! (Closes: #757233) + * Remove empty and commented lines before processing too, allowing one + to disable certain lines that would normally get translated. Thanks + Andreas Henriksson for spotting the issue. (Closes: #757273) + * Add support for renaming files in debian/$package.manpages too. + Requested by Andreas Henriksson. (Closes: #757270) + * Updated the package description, mentioning the new features. + * Updated the copyright years in debian/copyright. + + -- Gergely Nagy Thu, 07 Aug 2014 13:43:51 +0200 + dh-exec (0.12) unstable; urgency=low * The test suite was cleaned up and migrated from a custom solution to BATS. diff -Nru dh-exec-0.12/debian/control dh-exec-0.13~ubuntu14.04.1~ppa1/debian/control --- dh-exec-0.12/debian/control 2013-11-05 09:01:28.000000000 +0000 +++ dh-exec-0.13~ubuntu14.04.1~ppa1/debian/control 2014-08-07 10:43:38.000000000 +0000 @@ -19,7 +19,7 @@ ${perl:Depends}, perl (>= 5.14.2~), debhelper (>= 8.9.13~) Description: Scripts to help with executable debhelper files Debhelper (in compat level 9 and above) allows its config files to be - executable, and uses the output of suchs scripts as if it was the + executable, and uses the output of such scripts as if it was the content of the config file. . To ease and standardize the most common tasks, this package provides @@ -27,4 +27,7 @@ . * A way to ease variable substitution, from environment variables or dpkg-architecture. - * An extension to dh_install, with the ability to rename files. + * Ability to filter files by architecture, within a single debhelper + control file. + * An extension to dh_install and dh_installman, with the ability to + rename files. diff -Nru dh-exec-0.12/debian/copyright dh-exec-0.13~ubuntu14.04.1~ppa1/debian/copyright --- dh-exec-0.12/debian/copyright 2013-11-02 10:17:43.000000000 +0000 +++ dh-exec-0.13~ubuntu14.04.1~ppa1/debian/copyright 2014-08-07 10:45:01.000000000 +0000 @@ -2,11 +2,11 @@ Upstream-Name: dh-exec Upstream-Contact: Gergely Nagy Source: git://github.com/algernon/dh-exec.git -Copyright: Copyright (C) 2011-2013 Gergely Nagy +Copyright: Copyright (C) 2011-2014 Gergely Nagy License: GPL-3+ Files: * -Copyright: Copyright (C) 2011-2013 Gergely Nagy +Copyright: Copyright (C) 2011-2014 Gergely Nagy License: GPL-3+ Files: t/bats/* diff -Nru dh-exec-0.12/lib/dh-exec-filter-arch dh-exec-0.13~ubuntu14.04.1~ppa1/lib/dh-exec-filter-arch --- dh-exec-0.12/lib/dh-exec-filter-arch 1970-01-01 00:00:00.000000000 +0000 +++ dh-exec-0.13~ubuntu14.04.1~ppa1/lib/dh-exec-filter-arch 2014-08-07 07:50:21.000000000 +0000 @@ -0,0 +1,61 @@ +#! /usr/bin/perl -wnp +## +## This script removes lines that are for foreign architectures. If it +## finds a line prefixed with [arch1 arch2 ...], it will check - +## with dpkg-architecture - if we match any of the wildcards. If we +## match any of it, the line will be kept, otherwise eliminated. + +BEGIN { + sub arch_filter { + my $arch = $_[0]; + my $check_arch = $arch; + + if ($arch =~ /^!/) { + $check_arch =~ s/^!//; + } + `dpkg-architecture -i${check_arch} 2>/dev/null`; + + if ($arch =~ /^!/) { + return FALSE if $? == 0; + return TRUE; + } else { + return TRUE if $? == 0; + return FALSE; + } + } + + sub validate_arches { + my $p = 0; + my $n = 0; + + foreach my $arch (@_) { + if ($arch =~ /^!/) { + $p++; + } else { + $n++; + } + } + if ($n > 0 && $p > 0) { + print STDERR "ERROR: Positive and negative arch ". + "filters cannot be mixed!\n"; + exit (1); + } + } +} + +if (/\[([^\]]*)\]/) { + my @archlist = split (/\s+/, $1); + my $valid = FALSE; + + validate_arches(@archlist); + + for my $arch (@archlist) { + $valid = TRUE if (arch_filter($arch) eq TRUE); + } + + if ($valid eq TRUE) { + s/[ \t]*\[([^\]]*)\][ \t]*//; + } else { + $_ = ""; + } +} diff -Nru dh-exec-0.12/lib/dh-exec-filter-comments dh-exec-0.13~ubuntu14.04.1~ppa1/lib/dh-exec-filter-comments --- dh-exec-0.12/lib/dh-exec-filter-comments 1970-01-01 00:00:00.000000000 +0000 +++ dh-exec-0.13~ubuntu14.04.1~ppa1/lib/dh-exec-filter-comments 2014-02-27 14:23:28.000000000 +0000 @@ -0,0 +1,5 @@ +#! /usr/bin/perl -wnp +## +## This script removes commented and empty (or whitespace-only) lines +## from its input. +$_ = "" if /^\#|^\s*$/; diff -Nru dh-exec-0.12/lib/dh-exec-install-rename dh-exec-0.13~ubuntu14.04.1~ppa1/lib/dh-exec-install-rename --- dh-exec-0.12/lib/dh-exec-install-rename 2013-07-27 12:44:20.000000000 +0000 +++ dh-exec-0.13~ubuntu14.04.1~ppa1/lib/dh-exec-install-rename 2014-08-07 10:56:14.000000000 +0000 @@ -15,6 +15,10 @@ make_path("debian/tmp"); our $tempdir = tempdir ("debian/tmp/dh-exec.XXXXXXXX"); + our $append_destpath = TRUE; + if ($ENV{DH_EXEC_SOURCE} =~ /manpages$/) { + $append_destpath = FALSE; + } } if (/([^\s]*)\s+=>\s+([^\s]*)/) { @@ -29,5 +33,7 @@ move (File::Spec->catfile ("debian/tmp", $src), File::Spec->catfile ($debpath, $dstfile)) or die "Copy failed: $!"; - $_ = File::Spec->catfile ($debpath, $dstfile) . " " . $dstpath . "\n"; + $_ = File::Spec->catfile ($debpath, $dstfile); + $_ .= " " . $dstpath if ($append_destpath eq TRUE); + $_ .= "\n"; } diff -Nru dh-exec-0.12/Makefile.am dh-exec-0.13~ubuntu14.04.1~ppa1/Makefile.am --- dh-exec-0.12/Makefile.am 2013-11-02 15:11:07.000000000 +0000 +++ dh-exec-0.13~ubuntu14.04.1~ppa1/Makefile.am 2014-08-06 21:17:42.000000000 +0000 @@ -3,7 +3,8 @@ pkglibexec_PROGRAMS = src/dh-exec-subst \ src/dh-exec-install \ src/dh-exec-illiterate \ - src/dh-exec-strip + src/dh-exec-strip \ + src/dh-exec-filter man1_MANS = src/dh-exec-subst.1 \ src/dh-exec-install.1 \ src/dh-exec-illiterate.1 \ @@ -13,7 +14,9 @@ lib/dh-exec-subst-multiarch \ lib/dh-exec-install-rename \ lib/dh-exec-illiterate-tangle \ - lib/dh-exec-strip-output + lib/dh-exec-strip-output \ + lib/dh-exec-filter-arch \ + lib/dh-exec-filter-comments # --- Sources & flags --- AM_CFLAGS = ${LIBPIPELINE_CFLAGS} @@ -52,6 +55,13 @@ src_dh_exec_strip_CFLAGS = -DDH_EXEC_CMD=\"strip\" \ -DDH_EXEC_CMD_ALWAYS=1 +src_dh_exec_filter_SOURCES = \ + src/dh-exec.simple.c \ + src/dh-exec.lib.c \ + src/dh-exec.lib.h +src_dh_exec_filter_CFLAGS = -DDH_EXEC_CMD=\"filter\" \ + -DDH_EXEC_CMD_ALWAYS=1 + # --- Test suite --- TESTCASES_SUBST = test_subst_syntax.bats \ @@ -63,7 +73,8 @@ TESTCASES_DH = test_dh.bats TESTCASES_MISC = test_combined.bats \ test_dh_exec.bats \ - test_strip.bats + test_strip.bats \ + test_filter.bats TESTCASES = ${TESTCASES_SUBST} ${TESTCASES_INSTALL} \ ${TESTCASES_MISC} ${TESTCASES_DH} \ diff -Nru dh-exec-0.12/README.md dh-exec-0.13~ubuntu14.04.1~ppa1/README.md --- dh-exec-0.12/README.md 2013-06-10 09:38:46.000000000 +0000 +++ dh-exec-0.13~ubuntu14.04.1~ppa1/README.md 2014-02-27 14:23:28.000000000 +0000 @@ -4,7 +4,7 @@ [![Build Status](https://secure.travis-ci.org/algernon/dh-exec.png?branch=master)](http://travis-ci.org/algernon/dh-exec) [Debhelper][1] (in compat level 9 and above) allows its config files -to be executable, and uses the output of suchs scripts as if it was +to be executable, and uses the output of such scripts as if it was the content of the config file. This is a collection of scripts and programs to help creating diff -Nru dh-exec-0.12/src/dh-exec.1 dh-exec-0.13~ubuntu14.04.1~ppa1/src/dh-exec.1 --- dh-exec-0.12/src/dh-exec.1 2012-09-20 16:19:22.000000000 +0000 +++ dh-exec-0.13~ubuntu14.04.1~ppa1/src/dh-exec.1 2014-08-06 13:34:30.000000000 +0000 @@ -1,4 +1,4 @@ -.TH "DH\-EXEC" "1" "2012-05-03" "" "dh-exec" +.TH "DH\-EXEC" "1" "2014-08-06" "" "dh-exec" .ad l .nh .SH "NAME" @@ -9,6 +9,8 @@ src/libfoo-*.so.* debian/foo-plugins/usr/lib/foo/${DEB_HOST_MULTIARCH}/ .br etc/example.conf => debian/foo/etc/foo/foo.conf +.br +[linux-any kfreebsd-any] some-arch-specific-file /usr/lib/foo/ .SH "DESCRIPTION" dh\-exec is a simple program, meant to be used as the interpreter for @@ -22,6 +24,13 @@ by \fIdh\-exec\-install\fR, so that variable expansion happens before files need to be copied. +.SH "FILTERING" + +In all dh\-exec handled files, lines can be pre\- or post\-fixed with +a list of architectures for which the rest of the line should apply +to. All architectures and wildcards known by +\fIdpkg\-architecture\fR(1) are recognised, even negated ones. + .SH "ARCHITECTURE" dh\-exec is built up from three layers: there is the \fBdh-exec\fR @@ -131,4 +140,4 @@ \fIdh\-exec\-install\fR(1) .SH "AUTHOR" -dh\-exec is copyright \(co 2011-2012 by Gergely Nagy . +dh\-exec is copyright \(co 2011-2014 by Gergely Nagy . diff -Nru dh-exec-0.12/src/dh-exec.c dh-exec-0.13~ubuntu14.04.1~ppa1/src/dh-exec.c --- dh-exec-0.12/src/dh-exec.c 2013-11-02 20:25:09.000000000 +0000 +++ dh-exec-0.13~ubuntu14.04.1~ppa1/src/dh-exec.c 2014-08-06 21:36:56.000000000 +0000 @@ -1,5 +1,5 @@ /* dh-exec.c -- Wrapper around dh-exec-* commands. - * Copyright (C) 2011-2013 Gergely Nagy + * Copyright (C) 2011-2014 Gergely Nagy * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -292,6 +292,8 @@ setenv ("DH_EXEC_SOURCE", src, 1); } + dh_exec_pipeline_add (p, "dh-exec-filter"); + if (dhe_scripts) { int i = 0; diff -Nru dh-exec-0.12/src/dh-exec-install.1 dh-exec-0.13~ubuntu14.04.1~ppa1/src/dh-exec-install.1 --- dh-exec-0.12/src/dh-exec-install.1 2012-09-20 16:19:22.000000000 +0000 +++ dh-exec-0.13~ubuntu14.04.1~ppa1/src/dh-exec-install.1 2014-08-07 10:08:14.000000000 +0000 @@ -1,4 +1,4 @@ -.TH "DH\-EXEC\-INSTALL" "1" "2012-05-03" "" "dh-exec" +.TH "DH\-EXEC\-INSTALL" "1" "2014-08-07" "" "dh-exec" .ad l .nh .SH "NAME" @@ -9,6 +9,8 @@ debian/default.conf => /etc/my\-package/start.conf .br usr/bin/* +.br +[linux-any kfreebsd-any] some-arch-specific-file /usr/lib/foo/ .SH "DESCRIPTION" Being a sub\-command of \fIdh\-exec\fR(1), this program must not be @@ -16,9 +18,10 @@ available sub\-commands if run bare; or explicitly with \fBdh\-exec \-\-with=install\fR. -It is meant to be used for \fIdh_install\fR(1) files, and those -alone. If it finds that its input is not such a file, it will do -nothing, but echo back the contents. +It is meant to be used for the \fIdh_install\fR(1) family of files, +and those alone. If it finds that its input is not such a file, it +will do nothing, but echo back the contents. For a ful list of +recognised files, see the \fBFILE TYPES\fR section of this manual. The purpose of the program is to extend \fIdh_install\fR(1)'s functionality, by allowing to specify a destination filename. @@ -30,7 +33,9 @@ For obvious reasons, the source \fBmust not\fR be a wildcard, and the destination in this case \fBmust\fR be a file, and not a directory. -All other non\-comment lines are left alone. +See the \fBFILTERING\fR section of \fIdh\-exec\fR(1) for more +information about how lines are filtered. Any non\-comment lines +without a filter will be left alone. .SH "RESTRICTIONS" Due to the way executable scripts are called from \fIdebhelper\fR(1), @@ -39,6 +44,11 @@ of \fIdh_install\fR(1) will not work correctly when \fIdh\-exec\-install\fR is in use. +.SH "FILE TYPES" + +The program supports \fIdh_install\fR(1) and +\fIdh_installmanpages\fR(1) files only. + .SH "IMPLEMENTATION" Internally, the renaming happens by creating a temporary directory under \fIdebian/tmp/\fR, and copying (or moving, if the source was diff -Nru dh-exec-0.12/src/dh-exec-install.c dh-exec-0.13~ubuntu14.04.1~ppa1/src/dh-exec-install.c --- dh-exec-0.12/src/dh-exec-install.c 2013-11-03 11:38:39.000000000 +0000 +++ dh-exec-0.13~ubuntu14.04.1~ppa1/src/dh-exec-install.c 2014-08-07 10:11:47.000000000 +0000 @@ -1,5 +1,5 @@ /* dh-exec-install.c -- Wrapper around dh-exec-install-magic. - * Copyright (C) 2011, 2013 Gergely Nagy + * Copyright (C) 2011, 2013, 2014 Gergely Nagy * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -26,6 +26,22 @@ #include "dh-exec.lib.h" static int +_match_extension (const char *src, const char *ext) +{ + char *glob; + + glob = malloc (strlen (ext) + 6); + memcpy (glob, "*[./]", 5); + memcpy (glob + 5, ext, strlen (ext) + 1); + + if (strcmp (src, ext) != 0 && + fnmatch (glob, src, 0) != 0) + return 0; + + return 1; +} + +static int preamble(int argc, char *argv[]) { const char *src = dh_exec_source (argc, 1, argv); @@ -39,8 +55,8 @@ } /* Handle cases where the source is not an .install file */ - if (strcmp (src, "install") != 0 && - fnmatch ("*[./]install", src, 0) != 0) + if (!_match_extension (src, "install") && + !_match_extension (src, "manpages")) { /* Source is stdin, we're piped, ignore it. */ if (argc < 2) @@ -50,7 +66,7 @@ /* Source is from the command-line directly, raise an error. */ fprintf (stderr, - "%s: Only .install filename extensions are allowed: %s\n", + "%s: Unsupported filename extension: %s\n", argv[0], src); return EXIT_FAILURE; } diff -Nru dh-exec-0.12/t/test_combined.bats dh-exec-0.13~ubuntu14.04.1~ppa1/t/test_combined.bats --- dh-exec-0.12/t/test_combined.bats 2013-11-02 10:17:43.000000000 +0000 +++ dh-exec-0.13~ubuntu14.04.1~ppa1/t/test_combined.bats 2014-08-06 20:56:38.000000000 +0000 @@ -19,6 +19,7 @@ ${pkgfile} => /var/lib/dh-exec/new-file ${pkgfile} /usr/lib/dh-exec/\${DEB_HOST_MULTIARCH}/ ${pkgfile} => /usr/lib/dh-exec/\${DEB_HOST_MULTIARCH}/new-file +[!hurd-i386] ${pkgfile} => /var/lib/dh-exec/not-hurd EOF chmod +x ${pkgfile} @@ -89,3 +90,8 @@ EOF expect_output "$(dpkg-architecture -qDEB_HOST_MULTIARCH)/\${dh_subst_test_var}" } + +@test "combined: dh-exec arch filters with install work" { + DEB_HOST_ARCH=hurd-i386 run_dh_exec ${td}/${pkgfile} + ! expect_file "/var/lib/dh-exec/not-hurd" +} diff -Nru dh-exec-0.12/t/test_dh_exec.bats dh-exec-0.13~ubuntu14.04.1~ppa1/t/test_dh_exec.bats --- dh-exec-0.12/t/test_dh_exec.bats 2013-11-02 12:15:38.000000000 +0000 +++ dh-exec-0.13~ubuntu14.04.1~ppa1/t/test_dh_exec.bats 2014-08-06 21:07:00.000000000 +0000 @@ -23,7 +23,8 @@ @test "dh-exec --no-act works" { run_dh_exec src/dh-exec --no-act random.install expect_output \ - "^[^\|]*/dh-exec-subst | [^\|]*/dh-exec-install |" \ + "^[^\|]*/dh-exec-filter | [^\|]*/dh-exec-subst |" \ + "[^\|]*/dh-exec-install |" \ "[^\|]*/dh-exec-strip \[input: {0, random.install}," \ "output: {0, NULL}\]\$" } @@ -73,7 +74,7 @@ } @test "dh-exec: non-existing helper produces an error" { - run_dh_exec src/dh-exec --with=something + run_dh_exec src/dh-exec --with=something /var/lib/dh-exec/foo.8 +EOF + + expect_file "/var/lib/dh-exec/foo.8" + ! expect_output " /var/lib/" +} diff -Nru dh-exec-0.12/t/test_install_syntax.bats dh-exec-0.13~ubuntu14.04.1~ppa1/t/test_install_syntax.bats --- dh-exec-0.12/t/test_install_syntax.bats 2013-11-02 11:21:13.000000000 +0000 +++ dh-exec-0.13~ubuntu14.04.1~ppa1/t/test_install_syntax.bats 2014-08-07 10:11:59.000000000 +0000 @@ -45,6 +45,12 @@ expect_error "No such file or directory" } +@test "install: calling with a manpages file works" { + run_dh_exec src/dh-exec-install debian/manpages + + expect_error "No such file or directory" +} + @test "install: calling with an unqualified install works" { run_dh_exec src/dh-exec-install install @@ -56,7 +62,7 @@ #! ${top_builddir}/src/dh-exec-install EOF - expect_error "Only \.install filename extensions are allowed" + expect_error "Unsupported filename extension" } @test "install: calling with too many arguments fails" { diff -Nru dh-exec-0.12/t/test_strip.bats dh-exec-0.13~ubuntu14.04.1~ppa1/t/test_strip.bats --- dh-exec-0.12/t/test_strip.bats 2013-11-02 10:17:43.000000000 +0000 +++ dh-exec-0.13~ubuntu14.04.1~ppa1/t/test_strip.bats 2014-08-06 21:17:20.000000000 +0000 @@ -47,7 +47,8 @@ . EOF - expect_output "^[^\|]*/dh-exec-strip \[input: {0, NULL}," \ + expect_output "^[^\|]*/dh-exec-filter |" \ + "[^\|]*/dh-exec-strip \[input: {0, NULL}," \ "output: {0, NULL}\]\$" }