dh-golang-1.13~0ubuntu0~14.04.1/0000775000000000000000000000000012732363535012724 5ustar dh-golang-1.13~0ubuntu0~14.04.1/lib/0000775000000000000000000000000012424013665013464 5ustar dh-golang-1.13~0ubuntu0~14.04.1/lib/Debian/0000775000000000000000000000000012424013665014646 5ustar dh-golang-1.13~0ubuntu0~14.04.1/lib/Debian/Debhelper/0000775000000000000000000000000012424013665016540 5ustar dh-golang-1.13~0ubuntu0~14.04.1/lib/Debian/Debhelper/Buildsystem/0000775000000000000000000000000012732363144021046 5ustar dh-golang-1.13~0ubuntu0~14.04.1/lib/Debian/Debhelper/Buildsystem/golang.pm0000664000000000000000000001437112732363144022661 0ustar package Debian::Debhelper::Buildsystem::golang; use strict; use base 'Debian::Debhelper::Buildsystem'; use Debian::Debhelper::Dh_Lib; use Dpkg::Control::Info; use File::Copy; # in core since 5.002 use File::Path qw(make_path); # in core since 5.001 use File::Find; # in core since 5 sub DESCRIPTION { "Go" } sub check_auto_buildable { return 0 } sub new { my $class = shift; my $this = $class->SUPER::new(@_); $this->prefer_out_of_source_building(); _set_dh_gopkg(); return $this; } sub _set_dh_gopkg { # If DH_GOPKG is missing, try to set it from the XS-Go-Import-Path field # from debian/control. If this approach works well, we will only use this # method in the future. return if defined($ENV{DH_GOPKG}) && $ENV{DH_GOPKG} ne ''; my $control = Dpkg::Control::Info->new(); my $source = $control->get_source(); $ENV{DH_GOPKG} = $source->{"XS-Go-Import-Path"}; } sub _link_contents { my ($src, $dst) = @_; my @contents = <$src/*>; # Safety-Check: We are already _in_ a Go library. Don’t copy its # subfolders, this has no use and potentially only screws things up. # This situation should never happen, unless some package ships files that # are already shipped in another package. my @gosrc = grep { /\.go$/ } @contents; return if @gosrc > 0; my @dirs = grep { -d } @contents; for my $dir (@dirs) { my $base = basename($dir); if (-d "$dst/$base") { _link_contents("$src/$base", "$dst/$base"); } else { symlink("$src/$base", "$dst/$base"); } } } sub configure { my $this = shift; $this->mkdir_builddir(); my $builddir = $this->get_builddir(); ############################################################################ # Copy all source files into the build directory $builddir/src/$go_package ############################################################################ my $install_all = (exists($ENV{DH_GOLANG_INSTALL_ALL}) && $ENV{DH_GOLANG_INSTALL_ALL} == 1); # By default, only files with the following extensions are installed: my %whitelisted_exts = ( '.go' => 1, '.c' => 1, '.h' => 1, '.proto' => 1, '.s' => 1, ); my @sourcefiles; find({ # Ignores ./debian entirely, but not e.g. foo/debian/debian.go # Ignores ./.pc (quilt) entirely. # Also ignores the build directory to avoid recursive copies. preprocess => sub { return @_ if $File::Find::dir ne '.'; return grep { $_ ne 'debian' && $_ ne '.pc' && $_ ne '.git' && $_ ne $builddir } @_; }, wanted => sub { # Strip “./” in the beginning of the path. my $name = substr($File::Find::name, 2); if ($install_all) { # All files will be installed } else { my $dot = rindex($name, "."); return if $dot == -1; return unless $whitelisted_exts{substr($name, $dot)}; } return unless -f $name; push @sourcefiles, $name; }, no_chdir => 1, }, '.'); for my $source (@sourcefiles) { my $dest = "$builddir/src/$ENV{DH_GOPKG}/$source"; make_path(dirname($dest)); # Avoid re-copying the files, this would update their timestamp and # make go(1) recompile them. next if -f $dest; copy($source, $dest) or error("Could not copy $source to $dest: $!"); } ############################################################################ # Symlink all available libraries from /usr/share/gocode/src into our # buildroot. ############################################################################ # NB: The naïve idea of just setting GOPATH=$builddir:/usr/share/godoc does # not work. Let’s call the two paths in $GOPATH components. go(1), when # installing a package, such as github.com/Debian/dcs/cmd/..., will also # install the compiled dependencies, e.g. github.com/mstap/godebiancontrol. # When such a dependency is found in a component’s src/ directory, the # resulting files will be stored in the same component’s pkg/ directory. # That is, in this example, go(1) wants to modify # /usr/share/gocode/pkg/linux_amd64/github.com/mstap/godebiancontrol, which # will obviously not succeed due to permission errors. # # Therefore, we just work with a single component that is under our control # and symlink all the sources into that component ($builddir). _link_contents('/usr/share/gocode/src', "$builddir/src"); } sub get_targets { my $buildpkg = $ENV{DH_GOLANG_BUILDPKG} || "$ENV{DH_GOPKG}/..."; my $output = qx(go list $buildpkg); my @excludes = split(/ /, $ENV{DH_GOLANG_EXCLUDES}); my @targets = split(/\n/, $output); # Remove all targets that are matched by one of the regular expressions in DH_GOLANG_EXCLUDES. for my $pattern (@excludes) { @targets = grep { !/$pattern/ } @targets; } return @targets; } sub build { my $this = shift; $ENV{GOPATH} = $this->{cwd} . '/' . $this->get_builddir(); if (exists($ENV{DH_GOLANG_GO_GENERATE}) && $ENV{DH_GOLANG_GO_GENERATE} == 1) { $this->doit_in_builddir("go", "generate", "-v", @_, get_targets()); } $this->doit_in_builddir("go", "install", "-v", @_, get_targets()); } sub test { my $this = shift; $ENV{GOPATH} = $this->{cwd} . '/' . $this->get_builddir(); $this->doit_in_builddir("go", "test", "-v", @_, get_targets()); } sub install { my $this = shift; my $destdir = shift; my $builddir = $this->get_builddir(); my @binaries = <$builddir/bin/*>; if (@binaries > 0) { $this->doit_in_builddir('mkdir', '-p', "$destdir/usr"); $this->doit_in_builddir('cp', '-r', 'bin', "$destdir/usr"); } # Path to the src/ directory within $destdir my $dest_src = "$destdir/usr/share/gocode/src/$ENV{DH_GOPKG}"; $this->doit_in_builddir('mkdir', '-p', $dest_src); $this->doit_in_builddir('cp', '-r', '-T', "src/$ENV{DH_GOPKG}", $dest_src); } sub clean { my $this = shift; $this->rmdir_builddir(); } 1 # vim:ts=4:sw=4:expandtab dh-golang-1.13~0ubuntu0~14.04.1/lib/Debian/Debhelper/Sequence/0000775000000000000000000000000012732360632020311 5ustar dh-golang-1.13~0ubuntu0~14.04.1/lib/Debian/Debhelper/Sequence/golang.pm0000664000000000000000000000060612732360632022120 0ustar #!/usr/bin/perl use warnings; use strict; use Debian::Debhelper::Dh_Lib; insert_before('dh_gencontrol', 'dh_golang'); # XXX: -u is deprecated, but we cannot use “-- -Zxz” because additional command # options will be appended (“-O--buildsystem=golang”), resulting in # “dh_builddeb -- -Zxz -O--buildsystem=golang”, which fails. add_command_options('dh_builddeb', '-u-Zxz'); 1 dh-golang-1.13~0ubuntu0~14.04.1/script/0000775000000000000000000000000012732363144014224 5ustar dh-golang-1.13~0ubuntu0~14.04.1/script/dh_golang0000775000000000000000000000776312732363144016111 0ustar #!/usr/bin/perl -w =head1 NAME dh_golang - Generates Built-Using substvar =cut use strict; use Debian::Debhelper::Dh_Lib; # not in core use Dpkg; # not in core use Dpkg::Control; # not in core use Dpkg::Control::Info; # not in core use Dpkg::Deps; # not in core use Dpkg::Gettext; # not in core use Scalar::Util qw(blessed); # in core since v5.7.3 use List::Util qw(first); # in core since v5.7.3 =head1 SYNOPSIS B [S>] =head1 DESCRIPTION B is a debhelper program which adds the misc:Built-Using substvar based on the Build-Dependencies of your packages. Every package starting with golang is queried for the precise version number. As an example, if you Build-Depend on golang-pq-dev, the resulting misc:Built-Using value (aside from the precise version number) will look like this: golang (= 2:1.1.1-1), golang-pq-dev (= 0.0~git20130606-1), =head1 NOTES The best way to invoke B is by using B. =cut init(); # This code was copied from dpkg-checkbuilddeps, see # http://sources.debian.net/src/dpkg/1.18.1/scripts/dpkg-checkbuilddeps.pl/?hl=140#L140 sub parse_status { my $status = shift; my $facts = Dpkg::Deps::KnownFacts->new(); local $/ = ''; open(my $status_fh, '<', $status) or syserr(g_('cannot open %s'), $status); while (<$status_fh>) { next unless /^Status: .*ok installed$/m; my ($package) = /^Package: (.*)$/m; my ($version) = /^Version: (.*)$/m; my ($arch) = /^Architecture: (.*)$/m; my ($multiarch) = /^Multi-Arch: (.*)$/m; $facts->add_installed_package($package, $version, $arch, $multiarch); if (/^Provides: (.*)$/m) { my $provides = deps_parse($1, reduce_arch => 1, union => 1); next if not defined $provides; foreach (grep { $_->isa('Dpkg::Deps::Simple') } $provides->get_deps()) { $facts->add_provided_package($_->{package}, $_->{relation}, $_->{version}, $package); } } } close $status_fh; return $facts; } ############################################################################ # Generate misc:Built-Using substvar with the versions of all golang-* # build-dependency packages. ############################################################################ my $built_using; my $control = Dpkg::Control::Info->new(); my $source = $control->get_source(); my $build_depends = $source->{"Build-Depends"}; if (defined($build_depends) && $build_depends ne '') { my $facts; if ($Dpkg::VERSION >= 1.01) { $facts = parse_status($Dpkg::ADMINDIR . "/status"); } else { $facts = parse_status($Dpkg::admindir . "/status"); } sub flatten { my ($dep) = @_; if (blessed($dep) eq 'Dpkg::Deps::Simple') { return $dep->get_evaluation($facts) ? $dep->{package} : undef; } if (blessed($dep) eq 'Dpkg::Deps::OR') { # Return the first installed package. return first { defined($_) } map { flatten($_) } $dep->get_deps(); } die 'Unexpected object (of type ' . blessed($dep) . '), has the Dpkg::Deps API changed?'; } my $deps = deps_parse($build_depends, reduce_restrictions => 1, build_dep => 1); my $golang_deps = join(' ', grep { /^golang-/ } map { flatten($_) } $deps->get_deps()); if ($golang_deps ne '') { $built_using = `dpkg-query -f='\${source:Package} (= \${source:Version}), ' -W $golang_deps`; } } # If there is an easier way to have a universal misc:Built-Using on all binary # packages, I am happy to merge your patch :). foreach my $package (@{$dh{DOPACKAGES}}) { addsubstvar($package, "misc:Built-Using", $built_using); } =head1 SEE ALSO dh(1) =head1 AUTHORS Michael Stapelberg =cut # vim:ts=4:sw=4:et dh-golang-1.13~0ubuntu0~14.04.1/debian/0000775000000000000000000000000013424157231014137 5ustar dh-golang-1.13~0ubuntu0~14.04.1/debian/changelog0000664000000000000000000001026313424157231016013 0ustar dh-golang (1.13~0ubuntu0~14.04.1) trusty-security; urgency=medium * No change rebuild for trusty-security -- Jamie Strandboge Tue, 29 Jan 2019 23:15:05 +0000 dh-golang (1.13~0ubuntu0~14.04) trusty; urgency=medium * Build for trusty. (LP: #1595021) -- Michael Hudson-Doyle Thu, 16 Jun 2016 10:46:14 +1200 dh-golang (1.13) unstable; urgency=medium [ Stephen Gelman ] * Set build_dep to 1 to support the “native” architecture (Closes: #819596) -- Michael Stapelberg Thu, 14 Apr 2016 08:51:20 +0200 dh-golang (1.12) unstable; urgency=medium [ Hilko Bengen ] * Make dh-golang work with older dpkg versions (Closes: #794956) -- Michael Stapelberg Mon, 10 Aug 2015 19:46:17 +0200 dh-golang (1.11) unstable; urgency=medium * Only call go generate if DH_GOLANG_GO_GENERATE == 1 (Closes: #794815) -- Michael Stapelberg Fri, 07 Aug 2015 09:47:50 +0200 dh-golang (1.10) unstable; urgency=medium * If DH_GOPKG is not set in debian/rules, use XS-Go-Import-Path from debian/control. If this works out well, this will become the encouraged mechanism. The advantage is that it is easier to parse this field for other automation that deals with Go packaging. -- Michael Stapelberg Thu, 06 Aug 2015 22:26:55 +0200 dh-golang (1.9) unstable; urgency=medium * Also install .{c,h,proto,s} files by default. -- Michael Stapelberg Mon, 03 Aug 2015 21:44:51 +0200 dh-golang (1.8) unstable; urgency=medium * Correctly parse Build-Depends when they contain an OR. * Relicense under GPL-2+ due to having copied a large chunk of GPL-2+ code into dh_golang(1). -- Michael Stapelberg Sun, 26 Jul 2015 19:25:48 +0200 dh-golang (1.7) unstable; urgency=medium * Call go generate (introduced with Go 1.4) when building packages. * Bump Standards-Version to 3.9.6 (no changes necessary) -- Michael Stapelberg Sat, 25 Jul 2015 12:41:44 +0200 dh-golang (1.6) unstable; urgency=low [ Michael Stapelberg ] * In debian/rules, export DH_GOLANG_BUILDPKG to overwrite "${DH_GOPKG}/..." in the go install and go test commands. This can be used to avoid recursing into subpackages or to specify just one specific part of the package that should be built and installed. * In debian/rules, export DH_GOLANG_EXCLUDES (containing a space-separated list of perl regular expressions) to filter targets, e.g.: export DH_GOLANG_EXCLUDES := github.com/coreos/etcd/third_party (Closes: #721496) [ Alessandro Ghedini ] * Enable debian/control comment stripping (Closes: #734785) -- Michael Stapelberg Tue, 29 Jul 2014 09:59:18 +0200 dh-golang (1.5) unstable; urgency=low * Fix a bug introduce in 1.4 which lead to .go files not being installed without DH_GOLANG_INSTALL_ALL=1 (Closes: #731991) -- Michael Stapelberg Thu, 12 Dec 2013 10:46:36 +0100 dh-golang (1.4) unstable; urgency=low * in debian/rules, export DH_GOLANG_INSTALL_ALL=1 to install all files into the builddir, not just .go files. This may be necessary to include golden files for testcases, but then you need to manually delete extra LICENSE files and such. -- Michael Stapelberg Mon, 02 Dec 2013 21:54:11 +0100 dh-golang (1.3) unstable; urgency=low * Skip quilt’s .pc directories when copying the source code into the builddir -- Michael Stapelberg Tue, 24 Sep 2013 22:47:47 +0200 dh-golang (1.2) unstable; urgency=low * Only copy bin/ if there actually are any binaries -- Michael Stapelberg Thu, 05 Sep 2013 09:20:34 +0200 dh-golang (1.1) unstable; urgency=low * Add dependency on dpkg >= 1.16.2 for the source: fields * Install files into /usr/share/gocode/src/${DH_GOPKG} and /usr/bin/ by default -- Michael Stapelberg Tue, 30 Jul 2013 17:41:29 +0200 dh-golang (1.0) unstable; urgency=low * Initial release (Closes: #718183) -- Michael Stapelberg Sun, 28 Jul 2013 16:02:04 +0200 dh-golang-1.13~0ubuntu0~14.04.1/debian/control0000664000000000000000000000156212732363241015547 0ustar Source: dh-golang Section: devel Priority: extra Maintainer: Ubuntu Developers XSBC-Original-Maintainer: Michael Stapelberg Build-Depends: debhelper (>= 8.0.0), libmodule-install-perl Standards-Version: 3.9.6 Vcs-Git: git://anonscm.debian.org/collab-maint/dh-golang.git Vcs-Browser: http://anonscm.debian.org/gitweb/?p=collab-maint/dh-golang.git;a=summary Package: dh-golang Architecture: all Depends: ${perl:Depends}, ${misc:Depends}, debhelper, libdpkg-perl, dpkg (>= 1.16.2) Description: debhelper add-on for packaging software written in Go (golang) dh-golang provides a debhelper sequence addon named 'golang', a buildsystem module named 'golang' and a command called dh_golang. . The golang debhelper buildsystem is designed to make packaging programs written in Go very simple. dh-golang-1.13~0ubuntu0~14.04.1/debian/rules0000775000000000000000000000067212424013665015225 0ustar #!/usr/bin/make -f # -*- makefile -*- # Sample debian/rules that uses debhelper. # This file was originally written by Joey Hess and Craig Small. # As a special exception, when this file is copied by dh-make into a # dh-make output file, you may use that output file without restriction. # This special exception was added by Craig Small in version 0.37 of dh-make. # Uncomment this to turn on verbose mode. #export DH_VERBOSE=1 %: dh $@ dh-golang-1.13~0ubuntu0~14.04.1/debian/compat0000664000000000000000000000000212424013665015336 0ustar 8 dh-golang-1.13~0ubuntu0~14.04.1/debian/source/0000775000000000000000000000000012424013665015440 5ustar dh-golang-1.13~0ubuntu0~14.04.1/debian/source/format0000664000000000000000000000001512424013665016647 0ustar 3.0 (native) dh-golang-1.13~0ubuntu0~14.04.1/debian/copyright0000664000000000000000000000161612704004040016063 0ustar Format: http://www.debian.org/doc/packaging-manuals/copyright-format/1.0/ Files: * Copyright: 2013 Michael Stapelberg License: GPL-2+ Files: debian/* Copyright: 2013 Michael Stapelberg License: GPL-2+ License: GPL-2+ 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 the Free Software Foundation; either version 2 of the License, or (at your option) any later version. . This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. . On Debian systems, the complete text of the GNU General Public License can be found in ‘/usr/share/common-licenses/GPL-2’ or in the dpkg source as the file ‘COPYING’. dh-golang-1.13~0ubuntu0~14.04.1/Makefile.PL0000664000000000000000000000060112732360632014666 0ustar use inc::Module::Install; name 'dh-golang'; version '1.0'; install_script 'dh_golang'; #postamble <<'END_OF_MAKEFILE'; #install:: extra_install #pure_install:: extra_install #install_vendor:: extra_install # #extra_install: # install -d $(DESTDIR)/usr/share/debhelper/autoscripts # install -m 640 autoscripts/* $(DESTDIR)/usr/share/debhelper/autoscripts #END_OF_MAKEFILE WriteAll; dh-golang-1.13~0ubuntu0~14.04.1/example/0000775000000000000000000000000012732360632014352 5ustar dh-golang-1.13~0ubuntu0~14.04.1/example/control0000664000000000000000000000124012424013665015751 0ustar Source: dcs Section: net Priority: extra Maintainer: Michael Stapelberg Build-Depends: debhelper (>= 8.0.0), dh-golang, golang-pq-dev, golang-go, golang-godebiancontrol-dev, golang-codesearch-dev Standards-Version: 3.9.2 #Vcs-Git: git://git.debian.org/collab-maint/dcs.git #Vcs-Browser: http://git.debian.org/?p=collab-maint/dcs.git;a=summary Package: dcs Architecture: any Depends: ${shlibs:Depends}, ${misc:Depends}, dpkg-dev Built-Using: ${misc:Built-Using} Description: Debian Code Search Server binaries, tools and templates/static assets to run Debian Code Search. dh-golang-1.13~0ubuntu0~14.04.1/example/rules0000664000000000000000000000017612424013665015432 0ustar #!/usr/bin/make -f export DH_OPTIONS export DH_GOPKG := github.com/Debian/dcs %: dh $@ --buildsystem=golang --with=golang