Skip to content

Commit ca03f07

Browse files
committed
Make debian/copyright follow --wrap-and-sort flag too
1 parent c0d52a4 commit ca03f07

File tree

2 files changed

+30
-8
lines changed

2 files changed

+30
-8
lines changed

make.go

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -661,6 +661,21 @@ func execMake(args []string, usage func()) {
661661
log.Fatalf("-type=%q not recognized, aborting\n", pkgTypeString)
662662
}
663663

664+
switch strings.TrimSpace(wrapAndSort) {
665+
case "a":
666+
// Current default, also what "cme fix dpkg" generates
667+
wrapAndSort = "a"
668+
case "at", "ta":
669+
// -t, --trailing-comma, preferred by Martina Ferrari
670+
// and currently used in quite a few packages
671+
wrapAndSort = "at"
672+
case "ast", "ats", "sat", "sta", "tas", "tsa":
673+
// -s, --short-indent too, proposed by Guillem Jover
674+
wrapAndSort = "ast"
675+
default:
676+
log.Fatalf("%q is not a valid value for -wrap-and-sort, aborting.", wrapAndSort)
677+
}
678+
664679
if pkgType != typeGuess {
665680
debsrc = debianNameFromGopkg(gopkg, pkgType, allowUnknownHoster)
666681
if _, err := os.Stat(debsrc); err == nil {

template.go

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -71,11 +71,11 @@ func fprintfControlField(f *os.File, field string, valueArray []string) {
7171
case "a":
7272
// Current default, also what "cme fix dpkg" generates
7373
fmt.Fprintf(f, "%s: %s\n", field, strings.Join(valueArray, ",\n"+strings.Repeat(" ", len(field)+2)))
74-
case "at", "ta":
74+
case "at":
7575
// -t, --trailing-comma, preferred by Martina Ferrari
7676
// and currently used in quite a few packages
7777
fmt.Fprintf(f, "%s: %s,\n", field, strings.Join(valueArray, ",\n"+strings.Repeat(" ", len(field)+2)))
78-
case "ast", "ats", "sat", "sta", "tas", "tsa":
78+
case "ast":
7979
// -s, --short-indent too, proposed by Guillem Jover
8080
fmt.Fprintf(f, "%s:\n %s,\n", field, strings.Join(valueArray, ",\n "))
8181
default:
@@ -203,21 +203,28 @@ func writeDebianCopyright(dir, gopkg string, vendorDirs []string) error {
203203
copyright = "TODO"
204204
}
205205

206+
var indent = " "
207+
var linebreak = ""
208+
if wrapAndSort == "ast" {
209+
indent = " "
210+
linebreak = "\n"
211+
}
212+
206213
fmt.Fprintf(f, "Format: https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/\n")
207214
fmt.Fprintf(f, "Source: %s\n", getHomepageForGopkg(gopkg))
208215
fmt.Fprintf(f, "Upstream-Name: %s\n", filepath.Base(gopkg))
209216
fmt.Fprintf(f, "Files-Excluded:\n")
210217
for _, dir := range vendorDirs {
211-
fmt.Fprintf(f, " %s\n", dir)
218+
fmt.Fprintf(f, indent+"%s\n", dir)
212219
}
213-
fmt.Fprintf(f, " Godeps/_workspace\n")
220+
fmt.Fprintf(f, indent+"Godeps/_workspace\n")
214221
fmt.Fprintf(f, "\n")
215-
fmt.Fprintf(f, "Files:\n *\n")
216-
fmt.Fprintf(f, "Copyright:\n %s\n", copyright)
222+
fmt.Fprintf(f, "Files:"+linebreak+" *\n")
223+
fmt.Fprintf(f, "Copyright:"+linebreak+" %s\n", copyright)
217224
fmt.Fprintf(f, "License: %s\n", license)
218225
fmt.Fprintf(f, "\n")
219-
fmt.Fprintf(f, "Files:\n debian/*\n")
220-
fmt.Fprintf(f, "Copyright:\n %s %s <%s>\n", time.Now().Format("2006"), getDebianName(), getDebianEmail())
226+
fmt.Fprintf(f, "Files:"+linebreak+" debian/*\n")
227+
fmt.Fprintf(f, "Copyright:"+linebreak+" %s %s <%s>\n", time.Now().Format("2006"), getDebianName(), getDebianEmail())
221228
fmt.Fprintf(f, "License: %s\n", license)
222229
fmt.Fprintf(f, "Comment: Debian packaging is licensed under the same terms as upstream\n")
223230
fmt.Fprintf(f, "\n")

0 commit comments

Comments
 (0)