Hello,

This is new dh-golang feature should allow to include more files to the
install in an easier way. It should be useful, for example, with cgo
projects.

DH_GOLANG_INSTALL_EXTRA_EXTENSIONS := .cgo,.h,.c

Will include all files with .cgo, .h and .c extensions.

I have had this issue (not just with cgo projects) a couple times last
week so I thought this would be useful.

I have never done perl before, feel free to comment on the code.

-- 
Alexandre Viau
alexan...@alexandreviau.net
From 41130c1752ee81a5582d63dd424cbc580c081e80 Mon Sep 17 00:00:00 2001
From: aviau <alexandre.v...@savoirfairelinux.com>
Date: Wed, 29 Jul 2015 14:51:20 -0400
Subject: [PATCH] New DH_GOLANG_INSTALL_EXTRA_EXTENSIONS option

By default, only .go files are installed.
DH_GOLANG_INSTALL_EXTRA_EXTENSIONS allows to specify more file
extensions to install.
---
 lib/Debian/Debhelper/Buildsystem/golang.pm | 22 ++++++++++++++++++++--
 1 file changed, 20 insertions(+), 2 deletions(-)

diff --git a/lib/Debian/Debhelper/Buildsystem/golang.pm b/lib/Debian/Debhelper/Buildsystem/golang.pm
index 6b33f69..96a82d6 100644
--- a/lib/Debian/Debhelper/Buildsystem/golang.pm
+++ b/lib/Debian/Debhelper/Buildsystem/golang.pm
@@ -56,6 +56,14 @@ sub configure {
 
     my $install_all = (exists($ENV{DH_GOLANG_INSTALL_ALL}) &&
                        $ENV{DH_GOLANG_INSTALL_ALL} == 1);
+
+    # By default, only .go files are installed.
+    my @installed_file_extensions = ('.go');
+    if (exists($ENV{DH_GOLANG_INSTALL_EXTRA_EXTENSIONS})) {
+        push(@installed_file_extensions,
+             split(',', $ENV{DH_GOLANG_INSTALL_EXTRA_EXTENSIONS}));
+    }
+
     my @sourcefiles;
     find({
         # Ignores ./debian entirely, but not e.g. foo/debian/debian.go
@@ -69,8 +77,18 @@ sub configure {
             my $name = $File::Find::name;
             if ($install_all) {
                 # All files will be installed
-            } elsif (substr($name, -3) ne '.go') {
-                return;
+            } else {
+                my $matched_extension = 0;
+                foreach (@installed_file_extensions)
+                {
+                      if (substr($name, -length($_)) eq $_){
+                          $matched_extension = 1;
+                          last;
+                      }
+                }
+                if (not $matched_extension) {
+                    return;
+                }
             }
             return unless -f $name;
             # Store regexp/utf.go instead of ./regexp/utf.go
-- 
2.4.6

Attachment: signature.asc
Description: OpenPGP digital signature

_______________________________________________
Pkg-go-maintainers mailing list
Pkg-go-maintainers@lists.alioth.debian.org
http://lists.alioth.debian.org/cgi-bin/mailman/listinfo/pkg-go-maintainers

Reply via email to