@@ -11,8 +11,7 @@ import (
11
11
)
12
12
13
13
func writeTemplates (dir , gopkg , debsrc , debLib , debProg , debversion string ,
14
- pkgType packageType , dependencies []string , vendorDirs []string ,
15
- hasGodeps bool , dep14 , pristineTar bool ) error {
14
+ pkgType packageType , dependencies []string , u * upstream , dep14 , pristineTar bool ) error {
16
15
if err := os .Mkdir (filepath .Join (dir , "debian" ), 0755 ); err != nil {
17
16
return err
18
17
}
@@ -26,7 +25,7 @@ func writeTemplates(dir, gopkg, debsrc, debLib, debProg, debversion string,
26
25
if err := writeDebianControl (dir , gopkg , debsrc , debLib , debProg , pkgType , dependencies ); err != nil {
27
26
return err
28
27
}
29
- if err := writeDebianCopyright (dir , gopkg , vendorDirs , hasGodeps ); err != nil {
28
+ if err := writeDebianCopyright (dir , gopkg , u . vendorDirs , u . hasGodeps ); err != nil {
30
29
return err
31
30
}
32
31
if err := writeDebianRules (dir , pkgType ); err != nil {
@@ -38,7 +37,7 @@ func writeTemplates(dir, gopkg, debsrc, debLib, debProg, debversion string,
38
37
if err := writeDebianGbpConf (dir , dep14 , pristineTar ); err != nil {
39
38
return err
40
39
}
41
- if err := writeDebianWatch (dir , gopkg , debsrc ); err != nil {
40
+ if err := writeDebianWatch (dir , gopkg , debsrc , u . hasRelease ); err != nil {
42
41
return err
43
42
}
44
43
if err := writeDebianPackageInstall (dir , debLib , debProg , pkgType ); err != nil {
@@ -296,19 +295,48 @@ func writeDebianGbpConf(dir string, dep14, pristineTar bool) error {
296
295
return nil
297
296
}
298
297
299
- func writeDebianWatch (dir , gopkg , debsrc string ) error {
300
- if strings .HasPrefix (gopkg , "github.com/" ) {
301
- f , err := os .Create (filepath .Join (dir , "debian" , "watch" ))
302
- if err != nil {
303
- return err
304
- }
305
- defer f .Close ()
298
+ func writeDebianWatch (dir , gopkg , debsrc string , hasRelease bool ) error {
299
+ // TODO: Support other hosters too
300
+ host := "github.com"
301
+
302
+ owner , repo , err := findGitHubRepo (gopkg )
303
+ if err != nil {
304
+ log .Printf ("debian/watch: Unable to resolve %s to github.com, skipping\n " , gopkg )
305
+ return nil
306
+ }
307
+ if ! strings .HasPrefix (gopkg , "github.com/" ) {
308
+ log .Printf ("debian/watch: %s resolves to %s/%s/%s\n " , gopkg , host , owner , repo )
309
+ }
306
310
311
+ f , err := os .Create (filepath .Join (dir , "debian" , "watch" ))
312
+ if err != nil {
313
+ return err
314
+ }
315
+ defer f .Close ()
316
+
317
+ if hasRelease {
318
+ log .Printf ("Setting debian/watch to track release tarball" )
307
319
fmt .Fprintf (f , "version=4\n " )
308
- fmt .Fprintf (f , `opts=filenamemangle=s/.+\/v?(\d\S*)\.tar\.gz/%s-\$1\.tar\.gz/,\` + "\n " , debsrc )
309
- fmt .Fprintf (f , `uversionmangle=s/(\d)[_\.\-\+]?(RC|rc|pre|dev|beta|alpha)[.]?(\d*)$/\$1~\$2\$3/ \` + "\n " )
310
- fmt .Fprintf (f , ` https://%s/tags .*/v?(\d\S*)\.tar\.gz` + "\n " , gopkg )
320
+ fmt .Fprintf (f , `opts="filenamemangle=s/.+\/v?(\d\S*)\.tar\.gz/%s-\$1\.tar\.gz/, \` + "\n " , debsrc )
321
+ fmt .Fprintf (f , ` uversionmangle=s/(\d)[_\.\-\+]?(RC|rc|pre|dev|beta|alpha)[.]?(\d*)$/\$1~\$2\$3/" \` + "\n " )
322
+ fmt .Fprintf (f , ` https://%s/%s/%s/tags .*/v?(\d\S*)\.tar\.gz debian` + "\n " , host , owner , repo )
323
+ } else {
324
+ log .Printf ("Setting debian/watch to track git HEAD" )
325
+ fmt .Fprintf (f , "version=4\n " )
326
+ fmt .Fprintf (f , `opts="mode=git, pgpmode=none" \` + "\n " )
327
+ fmt .Fprintf (f , ` https://%s/%s/%s.git \` + "\n " , host , owner , repo )
328
+ fmt .Fprintf (f , " HEAD debian\n " )
329
+
330
+ // Anticipate that upstream would eventually switch to tagged releases
331
+ fmt .Fprintf (f , "\n " )
332
+ fmt .Fprintf (f , "# Use the following when upstream starts to tag releases:\n " )
333
+ fmt .Fprintf (f , "#\n " )
334
+ fmt .Fprintf (f , "#version=4\n " )
335
+ fmt .Fprintf (f , `#opts="filenamemangle=s/.+\/v?(\d\S*)\.tar\.gz/%s-\$1\.tar\.gz/, \` + "\n " , debsrc )
336
+ fmt .Fprintf (f , `# uversionmangle=s/(\d)[_\.\-\+]?(RC|rc|pre|dev|beta|alpha)[.]?(\d*)$/\$1~\$2\$3/" \` + "\n " )
337
+ fmt .Fprintf (f , `# https://%s/%s/%s/tags .*/v?(\d\S*)\.tar\.gz debian` + "\n " , host , owner , repo )
311
338
}
339
+
312
340
return nil
313
341
}
314
342
0 commit comments