Skip to content

Commit a8dc1f2

Browse files
committed
New upstream version 0.4.0
2 parents 98c5946 + 3671570 commit a8dc1f2

File tree

10 files changed

+114
-17
lines changed

10 files changed

+114
-17
lines changed

.travis.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ go:
1010
arch:
1111
- amd64
1212
- arm64
13+
- ppc64le
1314

1415
jobs:
1516
allow_failures:

dh-make-golang.md

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
% DH-MAKE-GOLANG(1) 2018-09-15
2+
3+
# NAME
4+
5+
dh-make-golang - automatically creates Debian packaging for Go packages
6+
7+
# SYNOPSIS
8+
9+
**dh-make-golang** [*globalflags*] <*command*> [*flags*] <*args*>
10+
11+
# DESCRIPTION
12+
13+
**dh-make-golang** is a tool to automatically create Debian packaging for Go
14+
packages. Its goal is to automate away as much of the work as possible when
15+
creating a Debian package for a Go library package.
16+
17+
For backwards compatibility, when no command is specified, the **make**
18+
command is executed. To learn more about a command, run
19+
"dh-make-golang <*command*> -help", for example "dh-make-golang make -help".
20+
21+
# COMMANDS
22+
23+
**make** *go-package-importpath*
24+
: Create a Debian package. **dh-make-golang** will create new files and
25+
directories in the current working directory. It will connect to
26+
the internet to download the specified Go package.
27+
28+
**search** *pattern*
29+
: Search Debian for already-existing packages. Uses Go's default
30+
regexp syntax (https://golang.org/pkg/regexp/syntax/).
31+
32+
**estimate** *go-package-importpath*
33+
: Estimates the work necessary to bring *go-package-importpath*
34+
into Debian by printing all currently unpacked repositories.
35+
36+
**create-salsa-project** *project-name*
37+
: Create a project for hosting Debian packaging.
38+
39+
# OPTIONS
40+
41+
Run **dh-make-golang** -help for more details.
42+
43+
# AUTHOR
44+
45+
This manual page was written by Michael Stapelberg <[email protected]>
46+
and Dr.\ Tobias Quathamer <[email protected]>,
47+
for the Debian project (and may be used by others).

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ module github.com/Debian/dh-make-golang
33
go 1.12
44

55
require (
6-
github.com/google/go-github/v28 v28.1.1
6+
github.com/google/go-github/v32 v32.1.0
77
github.com/gregjones/httpcache v0.0.0-20190611155906-901d90724c79
88
github.com/mattn/go-isatty v0.0.10
99
github.com/russross/blackfriday v1.5.2

go.sum

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
2-
github.com/google/go-github/v28 v28.1.1 h1:kORf5ekX5qwXO2mGzXXOjMe/g6ap8ahVe0sBEulhSxo=
3-
github.com/google/go-github/v28 v28.1.1/go.mod h1:bsqJWQX05omyWVmc00nEUql9mhQyv38lDZ8kPZcQVoM=
1+
github.com/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
2+
github.com/google/go-github/v32 v32.1.0 h1:GWkQOdXqviCPx7Q7Fj+KyPoGm4SwHRh8rheoPhd27II=
3+
github.com/google/go-github/v32 v32.1.0/go.mod h1:rIEpZD9CTDQwDK9GDrtMTycQNA4JU3qBsCizh3q2WCI=
44
github.com/google/go-querystring v1.0.0 h1:Xkwi/a1rcvNg1PPYe5vI8GbeBY/jrVuDX5ASuANWTrk=
55
github.com/google/go-querystring v1.0.0/go.mod h1:odCYkC5MyYFN7vkCjXpyrEuKhc/BUO6wN/zVPAxq5ck=
66
github.com/gregjones/httpcache v0.0.0-20190611155906-901d90724c79 h1:+ngKgrYPPJrOjhax5N+uePQ0Fh1Z7PheYoUI/0nzkPA=
@@ -16,7 +16,6 @@ golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLL
1616
golang.org/x/net v0.0.0-20190724013045-ca1201d0de80 h1:Ao/3l156eZf2AW5wK8a7/smtodRU+gha3+BeqJ69lRk=
1717
golang.org/x/net v0.0.0-20190724013045-ca1201d0de80/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
1818
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
19-
golang.org/x/sync v0.0.0-20190227155943-e225da77a7e6/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
2019
golang.org/x/sync v0.0.0-20190423024810-112230192c58 h1:8gQV6CLnAEikrhgkHFbMAEhagSSnXWGV915qUMm9mrU=
2120
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
2221
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=

main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import (
44
"fmt"
55
"os"
66

7-
"github.com/google/go-github/v28/github"
7+
"github.com/google/go-github/v32/github"
88
"github.com/gregjones/httpcache"
99
)
1010

make.go

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,7 @@ type upstream struct {
107107
tarPath string // path to the downloaded or generated orig tarball tempfile
108108
compression string // compression method, either "gz" or "xz"
109109
version string // Debian package upstream version number, e.g. 0.0~git20180204.1d24609
110+
tag string // Latest upstream tag, if any
110111
commitIsh string // commit-ish corresponding to upstream version to be packaged
111112
remote string // git remote, set to short hostname if upstream git history is included
112113
firstMain string // import path of the first main package within repo, if any
@@ -144,16 +145,16 @@ func (u *upstream) tarballFromHoster() error {
144145

145146
switch repoU.Host {
146147
case "github.com":
147-
tarURL = fmt.Sprintf("%s/archive/v%s.tar.%s",
148-
repo, u.version, u.compression)
148+
tarURL = fmt.Sprintf("%s/archive/%s.tar.%s",
149+
repo, u.tag, u.compression)
149150
case "gitlab.com":
150151
parts := strings.Split(repoU.Path, "/")
151152
if len(parts) < 3 {
152153
return fmt.Errorf("Incomplete repo URL: %s", u.rr.Repo)
153154
}
154155
project := parts[2]
155-
tarURL = fmt.Sprintf("%s/-/archive/v%[3]s/%[2]s-%s.tar.%s",
156-
repo, project, u.version, u.compression)
156+
tarURL = fmt.Sprintf("%s/-/archive/%s/%s-%s.tar.%s",
157+
repo, u.tag, project, u.tag, u.compression)
157158
default:
158159
return fmt.Errorf("Unsupported hoster")
159160
}
@@ -563,6 +564,7 @@ func shortHostName(gopkg string, allowUnknownHoster bool) (host string, err erro
563564
"howett.net": "howett",
564565
"k8s.io": "k8s",
565566
"pault.ag": "pault",
567+
"rsc.io": "rsc",
566568
"salsa.debian.org": "debian",
567569
"sigs.k8s.io": "k8s-sigs",
568570
}
@@ -596,7 +598,15 @@ func debianNameFromGopkg(gopkg string, t packageType, allowUnknownHoster bool) s
596598
}
597599
parts[0] = host
598600

599-
return strings.Trim("golang-"+strings.ToLower(strings.Replace(strings.Join(parts, "-"), "_", "-", -1)), "-")
601+
for i := range parts {
602+
if i == 0 {
603+
continue
604+
}
605+
606+
parts[i] = normalizeDebianProgramName(parts[i])
607+
}
608+
609+
return strings.Trim("golang-"+strings.Join(parts, "-"), "-")
600610
}
601611

602612
func getDebianName() string {

template.go

Lines changed: 36 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,9 @@ func writeTemplates(dir, gopkg, debsrc, debLib, debProg, debversion string,
4646
if err := writeDebianPackageInstall(dir, debLib, debProg, pkgType); err != nil {
4747
return err
4848
}
49+
if err := writeDebianUpstreamMetadata(dir, gopkg); err != nil {
50+
return err
51+
}
4952

5053
if err := writeDebianGbpConf(dir, dep14, pristineTar); err != nil {
5154
return err
@@ -143,13 +146,12 @@ func writeDebianControl(dir, gopkg, debsrc, debLib, debProg string, pkgType pack
143146
fmt.Fprintf(f, "Source: %s\n", debsrc)
144147
fmt.Fprintf(f, "Maintainer: Debian Go Packaging Team <[email protected]>\n")
145148
fprintfControlField(f, "Uploaders", []string{getDebianName() + " <" + getDebianEmail() + ">"})
146-
// TODO: change this once we have a “golang” section.
147-
fmt.Fprintf(f, "Section: devel\n")
149+
fmt.Fprintf(f, "Section: golang\n")
148150
fmt.Fprintf(f, "Testsuite: autopkgtest-pkg-go\n")
149151
fmt.Fprintf(f, "Priority: optional\n")
150152

151153
builddeps := append([]string{
152-
"debhelper-compat (= 12)",
154+
"debhelper-compat (= 13)",
153155
"dh-golang",
154156
"golang-any"},
155157
dependencies...)
@@ -378,6 +380,37 @@ func writeDebianPackageInstall(dir, debLib, debProg string, pkgType packageType)
378380
return nil
379381
}
380382

383+
func writeDebianUpstreamMetadata(dir, gopkg string) error {
384+
// TODO: Support other hosters too
385+
host := "github.com"
386+
387+
owner, repo, err := findGitHubRepo(gopkg)
388+
if err != nil {
389+
log.Printf("debian/upstream/metadata: Unable to resolve %s to github.com, skipping\n", gopkg)
390+
return nil
391+
}
392+
if !strings.HasPrefix(gopkg, "github.com/") {
393+
log.Printf("debian/upstream/metadata: %s resolves to %s/%s/%s\n", gopkg, host, owner, repo)
394+
}
395+
396+
if err := os.Mkdir(filepath.Join(dir, "debian", "upstream"), 0755); err != nil {
397+
return err
398+
}
399+
f, err := os.Create(filepath.Join(dir, "debian", "upstream", "metadata"))
400+
if err != nil {
401+
return err
402+
}
403+
defer f.Close()
404+
405+
fmt.Fprintf(f, "---\n")
406+
fmt.Fprintf(f, "Bug-Database: https://%s/%s/%s/issues\n", host, owner, repo)
407+
fmt.Fprintf(f, "Bug-Submit: https://%s/%s/%s/issues/new\n", host, owner, repo)
408+
fmt.Fprintf(f, "Repository: https://%s/%s/%s.git\n", host, owner, repo)
409+
fmt.Fprintf(f, "Repository-Browse: https://%s/%s/%s\n", host, owner, repo)
410+
411+
return nil
412+
}
413+
381414
func writeDebianGitLabCI(dir string) error {
382415
const gitlabciymlTmpl = `# auto-generated, DO NOT MODIFY.
383416
# The authoritative copy of this file lives at:

version.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import (
99
"strconv"
1010
"strings"
1111
"time"
12+
"unicode"
1213
)
1314

1415
var (
@@ -37,6 +38,7 @@ func pkgVersionFromGit(gitdir string, u *upstream, forcePrerelease bool) (string
3738
if out, err := cmd.Output(); err == nil {
3839
latestTag = strings.TrimSpace(string(out))
3940
u.hasRelease = true
41+
u.tag = latestTag
4042
log.Printf("Found latest tag %q", latestTag)
4143

4244
if !semverRegexp.MatchString(latestTag) {
@@ -64,7 +66,9 @@ func pkgVersionFromGit(gitdir string, u *upstream, forcePrerelease bool) (string
6466
}
6567

6668
u.commitIsh = latestTag
67-
u.version = strings.TrimPrefix(latestTag, "v")
69+
u.version = strings.TrimLeftFunc(latestTag, func(r rune) bool {
70+
return !unicode.IsNumber(r)
71+
})
6872

6973
if forcePrerelease {
7074
log.Printf("INFO: Force packaging master (prerelease) as requested by user")

version_current.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ type Version struct {
1515

1616
var currentVersion = Version{
1717
major: 0,
18-
minor: 3,
19-
patch: 3,
18+
minor: 4,
19+
patch: 0,
2020
preRelease: "",
2121
}
2222

version_test.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@ func gitCmdOrFatal(t *testing.T, tempdir string, arg ...string) {
1919
}
2020

2121
func TestSnapshotVersion(t *testing.T) {
22+
os.Setenv("TZ", "UTC")
23+
defer os.Unsetenv("TZ")
24+
2225
tempdir, err := ioutil.TempDir("", "dh-make-golang")
2326
if err != nil {
2427
t.Fatalf("Could not create temp dir: %v", err)

0 commit comments

Comments
 (0)