Skip to content

Commit 8928059

Browse files
committed
1 parent f45fff0 commit 8928059

File tree

3 files changed

+90
-0
lines changed

3 files changed

+90
-0
lines changed
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
From: =?utf-8?b?T3R0byBLZWvDpGzDpGluZW4=?= <otto@debian.org>
2+
Date: Thu, 28 Nov 2024 21:29:03 -0800
3+
Subject: Put build artifacts in `debian/.build/upstream` to avoid polluting
4+
upstream sources
5+
6+
Instead of putting build artifacts in `_build/` at the project root,
7+
where they pollute the upstream sources and lure some people to also
8+
modify the upstream `.gitignore` file, put it in the `debian/`
9+
subdirectory along with all other Debian build artifacts.
10+
---
11+
template.go | 7 ++++++-
12+
1 file changed, 6 insertions(+), 1 deletion(-)
13+
14+
diff --git a/template.go b/template.go
15+
index 7520f6f..78c2ba9 100644
16+
--- a/template.go
17+
+++ b/template.go
18+
@@ -86,6 +86,7 @@ func writeDebianGitIgnore(dir, debLib, debProg string, pkgType packageType) erro
19+
fmt.Fprintf(f, "*.log\n")
20+
fmt.Fprintf(f, "*.substvars\n")
21+
fmt.Fprintf(f, "/.debhelper/\n")
22+
+ fmt.Fprintf(f, "/.build/\n")
23+
fmt.Fprintf(f, "/debhelper-build-stamp\n")
24+
fmt.Fprintf(f, "/files\n")
25+
26+
@@ -299,7 +300,11 @@ func writeDebianRules(dir string, pkgType packageType) error {
27+
fmt.Fprintf(f, "#!/usr/bin/make -f\n")
28+
fmt.Fprintf(f, "\n")
29+
fmt.Fprintf(f, "%%:\n")
30+
- fmt.Fprintf(f, "\tdh $@ --builddirectory=_build --buildsystem=golang\n")
31+
+ fmt.Fprintf(f, "\tdh $@ --builddirectory=debian/.build/upstream --buildsystem=golang\n")
32+
+ // Note: The above `--builddirectory=debian/.build/upstream` will eventually be obsolete
33+
+ // in 2028+ then the dh-golang version 1.64+ that has merged
34+
+ // https://salsa.debian.org/go-team/packages/dh-golang/-/merge_requests/26
35+
+
36+
if pkgType == typeProgram {
37+
fmt.Fprintf(f, "\n")
38+
fmt.Fprintf(f, "override_dh_auto_install:\n")
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
From: =?utf-8?b?T3R0byBLZWvDpGzDpGluZW4=?= <otto@debian.org>
2+
Date: Thu, 21 Nov 2024 00:23:12 -0800
3+
Subject: Stop modifying upstream .gitignore file
4+
5+
The fact that Debian builds produce extra files in the build directory
6+
is a separate concern and should not be managed by .gitignores in upstream
7+
directory. Anyways, the list is not going to be complete on most packages,
8+
and instead of extending the list, a better practice is to have proper
9+
`make clean` rules in the `debian/rules`, or to simply run `git clean -fdx`
10+
between builds. Additionally, everyone should be using `gbp pq` to update
11+
patches instead of legacy Quilt, so no more `.pc` directories should be
12+
generated.
13+
---
14+
make.go | 23 -----------------------
15+
1 file changed, 23 deletions(-)
16+
17+
diff --git a/make.go b/make.go
18+
index c7e7505..14f267f 100644
19+
--- a/make.go
20+
+++ b/make.go
21+
@@ -510,29 +510,6 @@ func createGitRepository(debsrc, gopkg, orig string, u *upstream,
22+
return dir, fmt.Errorf("import-orig: %w", err)
23+
}
24+
25+
- {
26+
- f, err := os.OpenFile(filepath.Join(dir, ".gitignore"), os.O_APPEND|os.O_CREATE|os.O_WRONLY, 0644)
27+
- if err != nil {
28+
- return dir, fmt.Errorf("open .gitignore: %w", err)
29+
- }
30+
- // Beginning newline in case the file already exists and lacks a newline
31+
- // (not all editors enforce a newline at the end of the file):
32+
- if _, err := f.Write([]byte("\n/.pc/\n/_build/\n")); err != nil {
33+
- return dir, fmt.Errorf("write to .gitignore: %w", err)
34+
- }
35+
- if err := f.Close(); err != nil {
36+
- return dir, fmt.Errorf("close .gitignore: %w", err)
37+
- }
38+
- }
39+
-
40+
- if err := runGitCommandIn(dir, "add", ".gitignore"); err != nil {
41+
- return dir, fmt.Errorf("git add .gitignore: %w", err)
42+
- }
43+
-
44+
- if err := runGitCommandIn(dir, "commit", "-m", "Ignore _build and quilt .pc dirs via .gitignore"); err != nil {
45+
- return dir, fmt.Errorf("git commit (.gitignore): %w", err)
46+
- }
47+
-
48+
return dir, nil
49+
}
50+

debian/patches/series

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
0001-Put-build-artifacts-in-debian-.build-upstream-to-avo.patch
2+
0002-Stop-modifying-upstream-.gitignore-file.patch

0 commit comments

Comments
 (0)