Skip to content

Commit 2af04a9

Browse files
committed
New upstream version 0.3.2
2 parents 4d14f0a + 82916c0 commit 2af04a9

File tree

5 files changed

+60
-66
lines changed

5 files changed

+60
-66
lines changed

make.go

Lines changed: 51 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import (
77
"io/ioutil"
88
"log"
99
"net/http"
10+
"net/url"
1011
"os"
1112
"os/exec"
1213
"os/user"
@@ -133,30 +134,35 @@ func (u *upstream) get(gopath, repo, rev string) error {
133134
return rr.VCS.Create(dir, rr.Repo)
134135
}
135136

136-
func (u *upstream) tarballFromHoster(repo string) error {
137-
var url string
138-
parts := strings.Split(repo, "/")
139-
if len(parts) < 3 {
140-
return fmt.Errorf("Unsupported hoster")
137+
func (u *upstream) tarballFromHoster() error {
138+
var tarURL string
139+
repo := strings.TrimSuffix(u.rr.Repo, ".git")
140+
repoU, err := url.Parse(repo)
141+
if err != nil {
142+
return err
141143
}
142-
host, owner, project := parts[0], parts[1], parts[2]
143144

144-
switch host {
145+
switch repoU.Host {
145146
case "github.com":
146-
url = fmt.Sprintf("https://%s/%s/%s/archive/v%s.tar.%s",
147-
host, owner, project, u.version, u.compression)
147+
tarURL = fmt.Sprintf("%s/archive/v%s.tar.%s",
148+
repo, u.version, u.compression)
148149
case "gitlab.com":
149-
url = fmt.Sprintf("https://%s/%s/%s/-/archive/v%s/%s-%s.tar.%s",
150-
host, owner, project, u.version, project, u.version, u.compression)
150+
parts := strings.Split(repoU.Path, "/")
151+
if len(parts) < 3 {
152+
return fmt.Errorf("Incomplete repo URL: %s", u.rr.Repo)
153+
}
154+
project := parts[2]
155+
tarURL = fmt.Sprintf("%s/-/archive/v%[3]s/%[2]s-%s.tar.%s",
156+
repo, project, u.version, u.compression)
151157
default:
152158
return fmt.Errorf("Unsupported hoster")
153159
}
154160

155161
done := make(chan struct{})
156162
go progressSize("Download", u.tarPath, done)
157163

158-
log.Printf("Downloading %s", url)
159-
err := downloadFile(u.tarPath, url)
164+
log.Printf("Downloading %s", tarURL)
165+
err = downloadFile(u.tarPath, tarURL)
160166

161167
close(done)
162168

@@ -176,7 +182,7 @@ func (u *upstream) tar(gopath, repo string) error {
176182
log.Printf("Godeps/_workspace exists, not downloading tarball from hoster.")
177183
} else {
178184
u.compression = "gz"
179-
err := u.tarballFromHoster(repo)
185+
err := u.tarballFromHoster()
180186
if err != nil && err.Error() == "Unsupported hoster" {
181187
log.Printf("INFO: Hoster does not provide release tarball\n")
182188
} else {
@@ -537,48 +543,40 @@ func normalizeDebianProgramName(str string) string {
537543
}
538544

539545
func shortHostName(gopkg string, allowUnknownHoster bool) (host string, err error) {
546+
knownHosts := map[string]string{
547+
// keep the list in alphabetical order
548+
"bazil.org": "bazil",
549+
"bitbucket.org": "bitbucket",
550+
"blitiri.com.ar": "blitiri",
551+
"cloud.google.com": "googlecloud",
552+
"code.google.com": "googlecode",
553+
"git.sr.ht": "sourcehut",
554+
"github.com": "github",
555+
"gitlab.com": "gitlab",
556+
"go.uber.org": "uber",
557+
"go4.org": "go4",
558+
"gocloud.dev": "gocloud",
559+
"golang.org": "golang",
560+
"google.golang.org": "google",
561+
"gopkg.in": "gopkg",
562+
"howett.net": "howett",
563+
"k8s.io": "k8s",
564+
"pault.ag": "pault",
565+
"salsa.debian.org": "debian",
566+
"sigs.k8s.io": "k8s-sigs",
567+
}
540568
parts := strings.Split(gopkg, "/")
541569
fqdn := parts[0]
542-
543-
switch fqdn {
544-
case "github.com":
545-
host = "github"
546-
case "code.google.com":
547-
host = "googlecode"
548-
case "cloud.google.com":
549-
host = "googlecloud"
550-
case "gopkg.in":
551-
host = "gopkg"
552-
case "golang.org":
553-
host = "golang"
554-
case "google.golang.org":
555-
host = "google"
556-
case "gitlab.com":
557-
host = "gitlab"
558-
case "bitbucket.org":
559-
host = "bitbucket"
560-
case "bazil.org":
561-
host = "bazil"
562-
case "blitiri.com.ar":
563-
host = "blitiri"
564-
case "pault.ag":
565-
host = "pault"
566-
case "howett.net":
567-
host = "howett"
568-
case "go4.org":
569-
host = "go4"
570-
case "salsa.debian.org":
571-
host = "debian"
572-
default:
573-
if allowUnknownHoster {
574-
suffix, _ := publicsuffix.PublicSuffix(host)
575-
host = fqdn[:len(fqdn)-len(suffix)-len(".")]
576-
log.Printf("WARNING: Using %q as canonical hostname for %q. If that is not okay, please file a bug against %s.\n", host, fqdn, os.Args[0])
577-
} else {
578-
err = fmt.Errorf("unknown hoster %q", fqdn)
579-
}
570+
if host, ok := knownHosts[fqdn]; ok {
571+
return host, nil
572+
}
573+
if !allowUnknownHoster {
574+
return "", fmt.Errorf("unknown hoster %q", fqdn)
580575
}
581-
return host, err
576+
suffix, _ := publicsuffix.PublicSuffix(fqdn)
577+
host = fqdn[:len(fqdn)-len(suffix)-len(".")]
578+
log.Printf("WARNING: Using %q as canonical hostname for %q. If that is not okay, please file a bug against %s.\n", host, fqdn, os.Args[0])
579+
return host, nil
582580
}
583581

584582
// debianNameFromGopkg maps a Go package repo path to a Debian package name,

metadata.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@ var githubLicenseToDebianLicense = map[string]string{
2626
"isc": "ISC",
2727
"lgpl-2.1": "LGPL-2.1",
2828
"lgpl-3.0": "LGPL-3.0",
29-
//"mit" - expat?
30-
"mpl-2.0": "MPL-2.0", // include in base-files >= 9.9
29+
"mit": "Expat",
30+
"mpl-2.0": "MPL-2.0", // include in base-files >= 9.9
3131
//"unlicense" (not in debian)
3232
}
3333

progress.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,6 @@ const (
1515
Mebi
1616
Gibi
1717
Tebi
18-
Pebi
19-
Exbi
2018
)
2119

2220
func humanizeBytes(b int64) string {

template.go

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -112,13 +112,11 @@ func addLibraryPackage(f *os.File, gopkg, debLib string, dependencies []string)
112112
addDescription(f, gopkg, "(library)")
113113
}
114114

115-
func addProgramPackage(f *os.File, gopkg, debProg string, dependencies []string) {
115+
func addProgramPackage(f *os.File, gopkg, debProg string) {
116116
fmt.Fprintf(f, "\n")
117117
fmt.Fprintf(f, "Package: %s\n", debProg)
118118
fmt.Fprintf(f, "Architecture: any\n")
119-
deps := dependencies
120-
sort.Strings(deps)
121-
deps = append(deps, "${misc:Depends}", "${shlibs:Depends}")
119+
deps := []string{"${misc:Depends}", "${shlibs:Depends}"}
122120
fprintfControlField(f, "Depends", deps)
123121
fmt.Fprintf(f, "Built-Using: ${misc:Built-Using}\n")
124122
addDescription(f, gopkg, "(program)")
@@ -159,7 +157,7 @@ func writeDebianControl(dir, gopkg, debsrc, debLib, debProg string, pkgType pack
159157
log.Fatalf("Invalid pkgType %d in writeDebianControl(), aborting", pkgType)
160158
}
161159

162-
fmt.Fprintf(f, "Standards-Version: 4.4.1\n")
160+
fmt.Fprintf(f, "Standards-Version: 4.5.0\n")
163161
fmt.Fprintf(f, "Vcs-Browser: https://salsa.debian.org/go-team/packages/%s\n", debsrc)
164162
fmt.Fprintf(f, "Vcs-Git: https://salsa.debian.org/go-team/packages/%s.git\n", debsrc)
165163
fmt.Fprintf(f, "Homepage: %s\n", getHomepageForGopkg(gopkg))
@@ -172,12 +170,12 @@ func writeDebianControl(dir, gopkg, debsrc, debLib, debProg string, pkgType pack
172170
case typeLibrary:
173171
addLibraryPackage(f, gopkg, debLib, dependencies)
174172
case typeProgram:
175-
addProgramPackage(f, gopkg, debProg, dependencies)
173+
addProgramPackage(f, gopkg, debProg)
176174
case typeLibraryProgram:
177175
addLibraryPackage(f, gopkg, debLib, dependencies)
178-
addProgramPackage(f, gopkg, debProg, dependencies)
176+
addProgramPackage(f, gopkg, debProg)
179177
case typeProgramLibrary:
180-
addProgramPackage(f, gopkg, debProg, dependencies)
178+
addProgramPackage(f, gopkg, debProg)
181179
addLibraryPackage(f, gopkg, debLib, dependencies)
182180
default:
183181
log.Fatalf("Invalid pkgType %d in writeDebianControl(), aborting", pkgType)

version.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ func pkgVersionFromGit(gitdir string, u *upstream, forcePrerelease bool) (string
3232
var commitsAhead int
3333

3434
// Find @latest version tag (whether annotated or not)
35-
cmd := exec.Command("git", "describe", "--abbrev=0", "--tags")
35+
cmd := exec.Command("git", "describe", "--abbrev=0", "--tags", "--exclude", "*/v*")
3636
cmd.Dir = gitdir
3737
if out, err := cmd.Output(); err == nil {
3838
latestTag = strings.TrimSpace(string(out))

0 commit comments

Comments
 (0)