Skip to content

Commit 2412963

Browse files
committed
template: Generate debian/upstream/metadata too
Fixes Debian#144
1 parent 3bdaee6 commit 2412963

File tree

1 file changed

+34
-0
lines changed

1 file changed

+34
-0
lines changed

template.go

Lines changed: 34 additions & 0 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
@@ -377,6 +380,37 @@ func writeDebianPackageInstall(dir, debLib, debProg string, pkgType packageType)
377380
return nil
378381
}
379382

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+
380414
func writeDebianGitLabCI(dir string) error {
381415
const gitlabciymlTmpl = `# auto-generated, DO NOT MODIFY.
382416
# The authoritative copy of this file lives at:

0 commit comments

Comments
 (0)