Skip to content

Commit 3d58077

Browse files
committed
1 parent 1009f63 commit 3d58077

File tree

2 files changed

+89
-0
lines changed

2 files changed

+89
-0
lines changed
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
From: =?utf-8?b?T3R0byBLZWvDpGzDpGluZW4=?= <[email protected]>
2+
Date: Thu, 28 Nov 2024 21:29:03 -0800
3+
Subject: Put build artifacts in `debian/build/` to avoid polluting upstream
4+
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 `debian/build/` along
9+
with all other build artifacts that get generated in `debian/`.
10+
---
11+
template.go | 8 +++++++-
12+
1 file changed, 7 insertions(+), 1 deletion(-)
13+
14+
diff --git a/template.go b/template.go
15+
index 4c87c7d..1240ab1 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,12 @@ 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 --buildsystem=golang\n")
32+
+ // Note: The above `--builddirectory=debian/build` will eventually be obsolete
33+
+ // in 2028+ then the dh-golang version 1.63+ that has
34+
+ // https://salsa.debian.org/go-team/packages/dh-golang/-/commit/bc16dff5381b668a71fa99c381baba202c34c789
35+
+ // is in use everywhere
36+
+
37+
if pkgType == typeProgram {
38+
fmt.Fprintf(f, "\n")
39+
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=?= <[email protected]>
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 9f48c07..0286bdb 100644
19+
--- a/make.go
20+
+++ b/make.go
21+
@@ -516,29 +516,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+

0 commit comments

Comments
 (0)