dh-golang-1.5/0000755000000000000000000000000012247152156010112 5ustar dh-golang-1.5/debian/0000755000000000000000000000000012252302777011336 5ustar dh-golang-1.5/debian/changelog0000644000000000000000000000262612252302776013215 0ustar 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.5/debian/source/0000755000000000000000000000000012247152156012634 5ustar dh-golang-1.5/debian/source/format0000644000000000000000000000001512247152156014043 0ustar 3.0 (native) dh-golang-1.5/debian/control0000644000000000000000000000145212247152156012741 0ustar Source: dh-golang Section: devel Priority: extra Maintainer: Michael Stapelberg Build-Depends: debhelper (>= 8.0.0), libmodule-install-perl Standards-Version: 3.9.4 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, libparse-debcontrol-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.5/debian/rules0000755000000000000000000000067212247152156012421 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.5/debian/compat0000644000000000000000000000000212247152156012532 0ustar 8 dh-golang-1.5/debian/copyright0000644000000000000000000000336212247152156013273 0ustar Format: http://www.debian.org/doc/packaging-manuals/copyright-format/1.0/ Files: * Copyright: 2013 Michael Stapelberg License: BSD-3-clause Files: debian/* Copyright: 2013 Michael Stapelberg License: BSD-3-clause License: BSD-3-clause Copyright © 2013 Michael Stapelberg All rights reserved. . Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: . * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. . * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. . * Neither the name of Michael Stapelberg nor the names of contributors may be used to endorse or promote products derived from this software without specific prior written permission. . THIS SOFTWARE IS PROVIDED BY Michael Stapelberg ''AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL Michael Stapelberg BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. dh-golang-1.5/lib/0000755000000000000000000000000012247152156010660 5ustar dh-golang-1.5/lib/Debian/0000755000000000000000000000000012247152156012042 5ustar dh-golang-1.5/lib/Debian/Debhelper/0000755000000000000000000000000012247152156013734 5ustar dh-golang-1.5/lib/Debian/Debhelper/Sequence/0000755000000000000000000000000012247152156015504 5ustar dh-golang-1.5/lib/Debian/Debhelper/Sequence/golang.pm0000644000000000000000000000060612247152156017313 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.5/lib/Debian/Debhelper/Buildsystem/0000755000000000000000000000000012252302563016233 5ustar dh-golang-1.5/lib/Debian/Debhelper/Buildsystem/golang.pm0000644000000000000000000001151612252302563020044 0ustar package Debian::Debhelper::Buildsystem::golang; use strict; use base 'Debian::Debhelper::Buildsystem'; use Debian::Debhelper::Dh_Lib; 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(); return $this; } 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 .go files into the build directory $builddir/src/$go_package ############################################################################ my $install_all = (exists($ENV{DH_GOLANG_INSTALL_ALL}) && $ENV{DH_GOLANG_INSTALL_ALL} == 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 $builddir } @_; }, wanted => sub { my $name = $File::Find::name; if ($install_all) { # All files will be installed } elsif (substr($name, -3) ne '.go') { return; } return unless -f $name; # Store regexp/utf.go instead of ./regexp/utf.go push @sourcefiles, substr($name, 2); }, 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 build { my $this = shift; $ENV{GOPATH} = $this->{cwd} . '/' . $this->get_builddir(); $this->doit_in_builddir("go", "install", "-v", @_, "$ENV{DH_GOPKG}/..."); } sub test { my $this = shift; $ENV{GOPATH} = $this->{cwd} . '/' . $this->get_builddir(); $this->doit_in_builddir("go", "test", "-v", @_, "$ENV{DH_GOPKG}/..."); } 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.5/example/0000755000000000000000000000000012247152156011545 5ustar dh-golang-1.5/example/control0000644000000000000000000000124012247152156013145 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.5/example/rules0000644000000000000000000000017612247152156012626 0ustar #!/usr/bin/make -f export DH_OPTIONS export DH_GOPKG := github.com/Debian/dcs %: dh $@ --buildsystem=golang --with=golang dh-golang-1.5/script/0000755000000000000000000000000012247152156011416 5ustar dh-golang-1.5/script/dh_golang0000755000000000000000000000376212247152156013276 0ustar #!/usr/bin/perl -w =head1 NAME dh_golang - Generates Built-Using substvar =cut use strict; use Debian::Debhelper::Dh_Lib; use Parse::DebControl; # not in core =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(); ############################################################################ # Generate misc:Built-Using substvar with the versions of all golang-* # build-dependency packages. ############################################################################ my $built_using; # TODO: switch to Dpkg::Control::Info, maybe? my $control_parser = Parse::DebControl->new(); my $control_data = $control_parser->parse_file('./debian/control'); my $source_data = $control_data->[0]; if (!defined($source_data)) { error('Could not parse ./debian/control'); } if (defined($source_data->{'Build-Depends'})) { my $golang_deps = join(' ', grep { defined } map { /^\s*(golang-[^\s]+)/; $1 } split(',', $source_data->{'Build-Depends'})); 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.5/Makefile.PL0000644000000000000000000000060112247152156012061 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;