Skip to content

Commit

Permalink
template: Generate debian/upstream/metadata too
Browse files Browse the repository at this point in the history
Fixes #144
  • Loading branch information
anthonyfok committed Nov 13, 2020
1 parent 3bdaee6 commit 2412963
Showing 1 changed file with 34 additions and 0 deletions.
34 changes: 34 additions & 0 deletions template.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@ func writeTemplates(dir, gopkg, debsrc, debLib, debProg, debversion string,
if err := writeDebianPackageInstall(dir, debLib, debProg, pkgType); err != nil {
return err
}
if err := writeDebianUpstreamMetadata(dir, gopkg); err != nil {
return err
}

if err := writeDebianGbpConf(dir, dep14, pristineTar); err != nil {
return err
Expand Down Expand Up @@ -377,6 +380,37 @@ func writeDebianPackageInstall(dir, debLib, debProg string, pkgType packageType)
return nil
}

func writeDebianUpstreamMetadata(dir, gopkg string) error {
// TODO: Support other hosters too
host := "github.com"

owner, repo, err := findGitHubRepo(gopkg)
if err != nil {
log.Printf("debian/upstream/metadata: Unable to resolve %s to github.com, skipping\n", gopkg)
return nil
}
if !strings.HasPrefix(gopkg, "github.com/") {
log.Printf("debian/upstream/metadata: %s resolves to %s/%s/%s\n", gopkg, host, owner, repo)
}

if err := os.Mkdir(filepath.Join(dir, "debian", "upstream"), 0755); err != nil {
return err
}
f, err := os.Create(filepath.Join(dir, "debian", "upstream", "metadata"))
if err != nil {
return err
}
defer f.Close()

fmt.Fprintf(f, "---\n")
fmt.Fprintf(f, "Bug-Database: https://%s/%s/%s/issues\n", host, owner, repo)
fmt.Fprintf(f, "Bug-Submit: https://%s/%s/%s/issues/new\n", host, owner, repo)
fmt.Fprintf(f, "Repository: https://%s/%s/%s.git\n", host, owner, repo)
fmt.Fprintf(f, "Repository-Browse: https://%s/%s/%s\n", host, owner, repo)

return nil
}

func writeDebianGitLabCI(dir string) error {
const gitlabciymlTmpl = `# auto-generated, DO NOT MODIFY.
# The authoritative copy of this file lives at:
Expand Down

0 comments on commit 2412963

Please sign in to comment.