Skip to content

Commit 0c423b9

Browse files
authored
Merge pull request #245 from guillemj/pu/workflow
Revert workflow changes from #225 and #230 until there is proper consensus.
2 parents d0b9a43 + f2d4ca9 commit 0c423b9

File tree

2 files changed

+39
-66
lines changed

2 files changed

+39
-66
lines changed

make.go

Lines changed: 36 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -416,16 +416,7 @@ func runGitCommandIn(dir string, arg ...string) error {
416416
}
417417

418418
func createGitRepository(debsrc, gopkg, orig string, u *upstream,
419-
includeUpstreamHistory bool, allowUnknownHoster bool, debianBranch string,
420-
dep14 bool, pristineTar bool) (string, error) {
421-
422-
// debianBranch is passed in function call, but upstream import branch needs
423-
// also to be defined
424-
upstreamImportBranch := "upstream"
425-
if dep14 {
426-
upstreamImportBranch = "upstream/latest"
427-
}
428-
419+
includeUpstreamHistory bool, allowUnknownHoster bool, debianBranch string, pristineTar bool) (string, error) {
429420
wd, err := os.Getwd()
430421
if err != nil {
431422
return "", fmt.Errorf("get cwd: %w", err)
@@ -471,8 +462,7 @@ func createGitRepository(debsrc, gopkg, orig string, u *upstream,
471462

472463
// Preconfigure branches
473464

474-
branches := []string{debianBranch, upstreamImportBranch}
475-
465+
branches := []string{debianBranch, "upstream"}
476466
if pristineTar {
477467
branches = append(branches, "pristine-tar")
478468
}
@@ -486,8 +476,13 @@ func createGitRepository(debsrc, gopkg, orig string, u *upstream,
486476
}
487477

488478
if includeUpstreamHistory {
489-
// Always call the upstream git remote 'upstreamvcs' just like git-buildpackage does
490-
u.remote = "upstreamvcs"
479+
u.remote, err = shortHostName(gopkg, allowUnknownHoster)
480+
if err != nil {
481+
return dir, fmt.Errorf("unable to fetch upstream history: %q", err)
482+
}
483+
if u.remote == "debian" {
484+
u.remote = "salsa"
485+
}
491486
log.Printf("Adding remote %q with URL %q\n", u.remote, u.rr.Repo)
492487
if err := runGitCommandIn(dir, "remote", "add", u.remote, u.rr.Repo); err != nil {
493488
return dir, fmt.Errorf("git remote add %s %s: %w", u.remote, u.rr.Repo, err)
@@ -499,14 +494,8 @@ func createGitRepository(debsrc, gopkg, orig string, u *upstream,
499494
}
500495

501496
// Import upstream orig tarball
502-
// (and release git tag if includeUpstreamHistory)
503497

504-
arg := []string{
505-
"import-orig",
506-
"--no-interactive",
507-
"--debian-branch=" + debianBranch,
508-
"--upstream-branch=" + upstreamImportBranch,
509-
}
498+
arg := []string{"import-orig", "--no-interactive", "--debian-branch=" + debianBranch}
510499
if pristineTar {
511500
arg = append(arg, "--pristine-tar")
512501
}
@@ -521,6 +510,29 @@ func createGitRepository(debsrc, gopkg, orig string, u *upstream,
521510
return dir, fmt.Errorf("import-orig: %w", err)
522511
}
523512

513+
{
514+
f, err := os.OpenFile(filepath.Join(dir, ".gitignore"), os.O_APPEND|os.O_CREATE|os.O_WRONLY, 0644)
515+
if err != nil {
516+
return dir, fmt.Errorf("open .gitignore: %w", err)
517+
}
518+
// Beginning newline in case the file already exists and lacks a newline
519+
// (not all editors enforce a newline at the end of the file):
520+
if _, err := f.Write([]byte("\n/.pc/\n/_build/\n")); err != nil {
521+
return dir, fmt.Errorf("write to .gitignore: %w", err)
522+
}
523+
if err := f.Close(); err != nil {
524+
return dir, fmt.Errorf("close .gitignore: %w", err)
525+
}
526+
}
527+
528+
if err := runGitCommandIn(dir, "add", ".gitignore"); err != nil {
529+
return dir, fmt.Errorf("git add .gitignore: %w", err)
530+
}
531+
532+
if err := runGitCommandIn(dir, "commit", "-m", "Ignore _build and quilt .pc dirs via .gitignore"); err != nil {
533+
return dir, fmt.Errorf("git commit (.gitignore): %w", err)
534+
}
535+
524536
return dir, nil
525537
}
526538

@@ -765,7 +777,7 @@ func execMake(args []string, usage func()) {
765777
fs.BoolVar(&dep14,
766778
"dep14",
767779
true,
768-
"Follow DEP-14 branch naming and use debian/latest (instead of master)\n"+
780+
"Follow DEP-14 branch naming and use debian/sid (instead of master)\n"+
769781
"as the default debian-branch.")
770782

771783
var pristineTar bool
@@ -875,7 +887,7 @@ func execMake(args []string, usage func()) {
875887
// Set the debian branch.
876888
debBranch := "master"
877889
if dep14 {
878-
debBranch = "debian/latest"
890+
debBranch = "debian/sid"
879891
}
880892

881893
switch strings.TrimSpace(wrapAndSort) {
@@ -966,7 +978,7 @@ func execMake(args []string, usage func()) {
966978

967979
debversion := u.version + "-1"
968980

969-
dir, err := createGitRepository(debsrc, gopkg, orig, u, includeUpstreamHistory, allowUnknownHoster, debBranch, dep14, pristineTar)
981+
dir, err := createGitRepository(debsrc, gopkg, orig, u, includeUpstreamHistory, allowUnknownHoster, debBranch, pristineTar)
970982
if err != nil {
971983
log.Fatalf("Could not create git repository: %v\n", err)
972984
}

template.go

Lines changed: 3 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,6 @@ func writeDebianGitIgnore(dir, debLib, debProg string, pkgType packageType) erro
8686
fmt.Fprintf(f, "*.log\n")
8787
fmt.Fprintf(f, "*.substvars\n")
8888
fmt.Fprintf(f, "/.debhelper/\n")
89-
fmt.Fprintf(f, "/build/\n")
9089
fmt.Fprintf(f, "/debhelper-build-stamp\n")
9190
fmt.Fprintf(f, "/files\n")
9291

@@ -300,12 +299,7 @@ func writeDebianRules(dir string, pkgType packageType) error {
300299
fmt.Fprintf(f, "#!/usr/bin/make -f\n")
301300
fmt.Fprintf(f, "\n")
302301
fmt.Fprintf(f, "%%:\n")
303-
fmt.Fprintf(f, "\tdh $@ --builddirectory=debian/build --buildsystem=golang\n")
304-
// Note: The above `--builddirectory=debian/build` will eventually be obsolete
305-
// in 2028+ then the dh-golang version 1.63+ that has
306-
// https://salsa.debian.org/go-team/packages/dh-golang/-/commit/bc16dff5381b668a71fa99c381baba202c34c789
307-
// is in use everywhere
308-
302+
fmt.Fprintf(f, "\tdh $@ --builddirectory=_build --buildsystem=golang\n")
309303
if pkgType == typeProgram {
310304
fmt.Fprintf(f, "\n")
311305
fmt.Fprintf(f, "override_dh_auto_install:\n")
@@ -343,45 +337,12 @@ func writeDebianGbpConf(dir string, dep14, pristineTar bool) error {
343337

344338
fmt.Fprintf(f, "[DEFAULT]\n")
345339
if dep14 {
346-
fmt.Fprintf(f, "debian-branch = debian/latest\n")
347-
fmt.Fprintf(f, "upstream-branch = upstream/latest\n")
340+
fmt.Fprintf(f, "debian-branch = debian/sid\n")
348341
fmt.Fprintf(f, "dist = DEP14\n")
349342
}
350343
if pristineTar {
351-
fmt.Fprintf(f, `
352-
# Always use pristine tar to improve supply chain security and auditability
353-
pristine-tar = True
354-
355-
`)
344+
fmt.Fprintf(f, "pristine-tar = True\n")
356345
}
357-
358-
// Additional text to the template which is useful for 99% of the go packages
359-
fmt.Fprint(f, `
360-
# Lax requirement to use branch name 'debian/latest' so that git-buildpackage
361-
# will always build using the currently checked out branch as the Debian branch.
362-
# This makes it easier for contributors to work with feature and bugfix
363-
# branches.
364-
ignore-branch = True
365-
366-
# Configure the upstream tag format below, so that 'gbp import-orig' will run
367-
# correctly, and link tarball import branch ('upstream/latest') with the
368-
# equivalent upstream release tag, showing a complete audit trail of what
369-
# upstream released and what was imported into Debian.
370-
#
371-
# Most Go packages have tags of form 'v1.0.0'
372-
upstream-vcs-tag = v%(version%~%-)s
373-
374-
# If upstream publishes tarball signatures, git-buildpackage will by default
375-
# import and use the them. Change this to 'on' to make 'gbp import-orig' abort
376-
# if the signature is not found or is not valid.
377-
#
378-
# Most Go packages don't publish signatures for the tarball releases, so this is
379-
# not enabled by default.
380-
#upstream-signatures = on
381-
382-
# Ensure the Debian maintainer signs git tags automatically
383-
sign-tags = True
384-
`)
385346
return nil
386347
}
387348

0 commit comments

Comments
 (0)