Skip to content

Commit cc5ad87

Browse files
committed
1 parent 8928059 commit cc5ad87

File tree

3 files changed

+169
-0
lines changed

3 files changed

+169
-0
lines changed
Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
From: =?utf-8?b?T3R0byBLZWvDpGzDpGluZW4=?= <[email protected]>
2+
Date: Tue, 19 Nov 2024 22:21:58 -0800
3+
Subject: Use DEP-14 branch names `debian/latest` and `upstream/latest`
4+
5+
In DEP-14, the preferred branch name for the Debian packaging target
6+
branch is `debian/latest` and the preferred name for the upstream import
7+
target branch is `upstream/latest`.
8+
9+
Note that the upstream development branch name can be whatever and
10+
should stay as it is upstream, typically `main` or `master`. The branch
11+
`upstream/latest` should not point to the latest upstream development
12+
commit, but to the latest commit that was used as the upstream release
13+
that the Debian revision was derived from.
14+
---
15+
make.go | 14 +++++++++-----
16+
template.go | 3 ++-
17+
2 files changed, 11 insertions(+), 6 deletions(-)
18+
19+
diff --git a/make.go b/make.go
20+
index 14f267f..74e45e3 100644
21+
--- a/make.go
22+
+++ b/make.go
23+
@@ -416,7 +416,8 @@ func runGitCommandIn(dir string, arg ...string) error {
24+
}
25+
26+
func createGitRepository(debsrc, gopkg, orig string, u *upstream,
27+
- includeUpstreamHistory bool, allowUnknownHoster bool, debianBranch string, pristineTar bool) (string, error) {
28+
+ includeUpstreamHistory bool, allowUnknownHoster bool, debianBranch string,
29+
+ dep14 bool, pristineTar bool) (string, error) {
30+
wd, err := os.Getwd()
31+
if err != nil {
32+
return "", fmt.Errorf("get cwd: %w", err)
33+
@@ -462,7 +463,7 @@ func createGitRepository(debsrc, gopkg, orig string, u *upstream,
34+
35+
// Preconfigure branches
36+
37+
- branches := []string{debianBranch, "upstream"}
38+
+ branches := []string{debianBranch, "upstream/latest"}
39+
if pristineTar {
40+
branches = append(branches, "pristine-tar")
41+
}
42+
@@ -496,6 +497,9 @@ func createGitRepository(debsrc, gopkg, orig string, u *upstream,
43+
// Import upstream orig tarball
44+
45+
arg := []string{"import-orig", "--no-interactive", "--debian-branch=" + debianBranch}
46+
+ if dep14 {
47+
+ arg = append(arg, "--upstream-branch=upstream/latest")
48+
+ }
49+
if pristineTar {
50+
arg = append(arg, "--pristine-tar")
51+
}
52+
@@ -754,7 +758,7 @@ func execMake(args []string, usage func()) {
53+
fs.BoolVar(&dep14,
54+
"dep14",
55+
true,
56+
- "Follow DEP-14 branch naming and use debian/sid (instead of master)\n"+
57+
+ "Follow DEP-14 branch naming and use debian/latest (instead of master)\n"+
58+
"as the default debian-branch.")
59+
60+
var pristineTar bool
61+
@@ -864,7 +868,7 @@ func execMake(args []string, usage func()) {
62+
// Set the debian branch.
63+
debBranch := "master"
64+
if dep14 {
65+
- debBranch = "debian/sid"
66+
+ debBranch = "debian/latest"
67+
}
68+
69+
switch strings.TrimSpace(wrapAndSort) {
70+
@@ -955,7 +959,7 @@ func execMake(args []string, usage func()) {
71+
72+
debversion := u.version + "-1"
73+
74+
- dir, err := createGitRepository(debsrc, gopkg, orig, u, includeUpstreamHistory, allowUnknownHoster, debBranch, pristineTar)
75+
+ dir, err := createGitRepository(debsrc, gopkg, orig, u, includeUpstreamHistory, allowUnknownHoster, debBranch, dep14, pristineTar)
76+
if err != nil {
77+
log.Fatalf("Could not create git repository: %v\n", err)
78+
}
79+
diff --git a/template.go b/template.go
80+
index 78c2ba9..0e356c5 100644
81+
--- a/template.go
82+
+++ b/template.go
83+
@@ -342,7 +342,8 @@ func writeDebianGbpConf(dir string, dep14, pristineTar bool) error {
84+
85+
fmt.Fprintf(f, "[DEFAULT]\n")
86+
if dep14 {
87+
- fmt.Fprintf(f, "debian-branch = debian/sid\n")
88+
+ fmt.Fprintf(f, "debian-branch = debian/latest\n")
89+
+ fmt.Fprintf(f, "upstream-branch = upstream/latest\n")
90+
fmt.Fprintf(f, "dist = DEP14\n")
91+
}
92+
if pristineTar {
Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
From: =?utf-8?b?T3R0byBLZWvDpGzDpGluZW4=?= <[email protected]>
2+
Date: Thu, 21 Nov 2024 00:18:30 -0800
3+
Subject: Always call upstream git remote `upstreamvcs`
4+
5+
Instead of using various different upstream remote names, use the one
6+
and same upstream git remote name consistently. As the name pick
7+
`upstreamvcs` just as git-buildpackage does, so that if anybody runs
8+
`gbp clone` they will automatically end up with the same git remotes and
9+
branches as anyone in to go-team.
10+
---
11+
make.go | 29 ++++++++++++++++++-----------
12+
1 file changed, 18 insertions(+), 11 deletions(-)
13+
14+
diff --git a/make.go b/make.go
15+
index 74e45e3..5fbe5c4 100644
16+
--- a/make.go
17+
+++ b/make.go
18+
@@ -418,6 +418,14 @@ func runGitCommandIn(dir string, arg ...string) error {
19+
func createGitRepository(debsrc, gopkg, orig string, u *upstream,
20+
includeUpstreamHistory bool, allowUnknownHoster bool, debianBranch string,
21+
dep14 bool, pristineTar bool) (string, error) {
22+
+
23+
+ // debianBranch is passed in function call, but upstream import branch needs
24+
+ // also to be defined
25+
+ upstreamImportBranch := "upstream"
26+
+ if dep14 {
27+
+ upstreamImportBranch = "upstream/latest"
28+
+ }
29+
+
30+
wd, err := os.Getwd()
31+
if err != nil {
32+
return "", fmt.Errorf("get cwd: %w", err)
33+
@@ -463,7 +471,8 @@ func createGitRepository(debsrc, gopkg, orig string, u *upstream,
34+
35+
// Preconfigure branches
36+
37+
- branches := []string{debianBranch, "upstream/latest"}
38+
+ branches := []string{debianBranch, upstreamImportBranch}
39+
+
40+
if pristineTar {
41+
branches = append(branches, "pristine-tar")
42+
}
43+
@@ -477,13 +486,8 @@ func createGitRepository(debsrc, gopkg, orig string, u *upstream,
44+
}
45+
46+
if includeUpstreamHistory {
47+
- u.remote, err = shortHostName(gopkg, allowUnknownHoster)
48+
- if err != nil {
49+
- return dir, fmt.Errorf("unable to fetch upstream history: %q", err)
50+
- }
51+
- if u.remote == "debian" {
52+
- u.remote = "salsa"
53+
- }
54+
+ // Always call the upstream git remote 'upstreamvcs' just like git-buildpackage does
55+
+ u.remote = "upstreamvcs"
56+
log.Printf("Adding remote %q with URL %q\n", u.remote, u.rr.Repo)
57+
if err := runGitCommandIn(dir, "remote", "add", u.remote, u.rr.Repo); err != nil {
58+
return dir, fmt.Errorf("git remote add %s %s: %w", u.remote, u.rr.Repo, err)
59+
@@ -495,10 +499,13 @@ func createGitRepository(debsrc, gopkg, orig string, u *upstream,
60+
}
61+
62+
// Import upstream orig tarball
63+
+ // (and release git tag if includeUpstreamHistory)
64+
65+
- arg := []string{"import-orig", "--no-interactive", "--debian-branch=" + debianBranch}
66+
- if dep14 {
67+
- arg = append(arg, "--upstream-branch=upstream/latest")
68+
+ arg := []string{
69+
+ "import-orig",
70+
+ "--no-interactive",
71+
+ "--debian-branch=" + debianBranch,
72+
+ "--upstream-branch=" + upstreamImportBranch,
73+
}
74+
if pristineTar {
75+
arg = append(arg, "--pristine-tar")

debian/patches/series

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,4 @@
11
0001-Put-build-artifacts-in-debian-.build-upstream-to-avo.patch
22
0002-Stop-modifying-upstream-.gitignore-file.patch
3+
0003-Use-DEP-14-branch-names-debian-latest-and-upstream-l.patch
4+
0004-Always-call-upstream-git-remote-upstreamvcs.patch

0 commit comments

Comments
 (0)