@@ -77,11 +77,12 @@ func findVendorDirs(dir string) ([]string, error) {
77
77
78
78
// upstream describes the upstream repo we are about to package.
79
79
type upstream struct {
80
- tarPath string // path to the generated orig tarball
81
- version string // Debian package version number, e.g. 0.0~git20180204.1d24609-1
80
+ tarPath string // path to the generated orig tarball tempfile
81
+ version string // Debian package upstream version number, e.g. 0.0~git20180204.1d24609
82
82
firstMain string // import path of the first main package within repo, if any
83
83
vendorDirs []string // all vendor sub directories, relative to the repo directory
84
84
repoDeps []string // the repository paths of all dependencies (e.g. github.com/zyedidia/glob)
85
+ hasGodeps bool // whether the Godeps/_workspace directory exists
85
86
}
86
87
87
88
func (u * upstream ) get (gopath , repo , rev string ) error {
@@ -114,8 +115,8 @@ func (u *upstream) tar(gopath, repo string) error {
114
115
"cJf" ,
115
116
u .tarPath ,
116
117
"--exclude=.git" ,
117
- "--exclude=Godeps" ,
118
- fmt . Sprintf ( "--exclude=%s /debian" , base ) ,
118
+ "--exclude=Godeps/_workspace " ,
119
+ "--exclude=" + base + " /debian" ,
119
120
base )
120
121
cmd .Dir = filepath .Join (gopath , "src" , dir )
121
122
cmd .Stderr = os .Stderr
@@ -258,6 +259,11 @@ func makeUpstreamSourceTarball(repo, revision string) (*upstream, error) {
258
259
}
259
260
}
260
261
262
+ if _ , err := os .Stat (filepath .Join (repoDir , "Godeps" , "_workspace" )); ! os .IsNotExist (err ) {
263
+ log .Println ("Godeps/_workspace detected" )
264
+ u .hasGodeps = true
265
+ }
266
+
261
267
log .Printf ("Determining upstream version number\n " )
262
268
263
269
u .version , err = pkgVersionFromGit (repoDir )
@@ -289,7 +295,7 @@ func runGitCommandIn(dir string, arg ...string) error {
289
295
return cmd .Run ()
290
296
}
291
297
292
- func createGitRepository (debsrc , gopkg , orig string , dep14 bool ) (string , error ) {
298
+ func createGitRepository (debsrc , gopkg , orig string , dep14 , pristineTar bool ) (string , error ) {
293
299
wd , err := os .Getwd ()
294
300
if err != nil {
295
301
return "" , err
@@ -304,41 +310,44 @@ func createGitRepository(debsrc, gopkg, orig string, dep14 bool) (string, error)
304
310
}
305
311
306
312
if dep14 {
307
- if err := runGitCommandIn (dir , "checkout" , "-b" , "debian/sid" ); err != nil {
313
+ if err := runGitCommandIn (dir , "checkout" , "-q" , "- b" , "debian/sid" ); err != nil {
308
314
return dir , err
309
315
}
310
316
}
311
317
318
+ // Set repository options
319
+
312
320
if debianName := getDebianName (); debianName != "TODO" {
313
321
if err := runGitCommandIn (dir , "config" , "user.name" , debianName ); err != nil {
314
322
return dir , err
315
323
}
316
324
}
317
-
318
325
if debianEmail := getDebianEmail (); debianEmail != "TODO" {
319
326
if err := runGitCommandIn (dir , "config" , "user.email" , debianEmail ); err != nil {
320
327
return dir , err
321
328
}
322
329
}
323
-
324
330
if err := runGitCommandIn (dir , "config" , "push.default" , "matching" ); err != nil {
325
331
return dir , err
326
332
}
327
-
328
333
if err := runGitCommandIn (dir , "config" , "--add" , "remote.origin.push" , "+refs/heads/*:refs/heads/*" ); err != nil {
329
334
return dir , err
330
335
}
331
-
332
336
if err := runGitCommandIn (dir , "config" , "--add" , "remote.origin.push" , "+refs/tags/*:refs/tags/*" ); err != nil {
333
337
return dir , err
334
338
}
335
339
336
- var cmd * exec.Cmd
340
+ // Import upstream orig tarball
341
+
342
+ arg := []string {"import-orig" , "--no-interactive" }
337
343
if dep14 {
338
- cmd = exec .Command ("gbp" , "import-orig" , "--debian-branch=debian/sid" , "--no-interactive" , filepath .Join (wd , orig ))
339
- } else {
340
- cmd = exec .Command ("gbp" , "import-orig" , "--no-interactive" , filepath .Join (wd , orig ))
344
+ arg = append (arg , "--debian-branch=debian/sid" )
341
345
}
346
+ if pristineTar {
347
+ arg = append (arg , "--pristine-tar" )
348
+ }
349
+ arg = append (arg , filepath .Join (wd , orig ))
350
+ cmd := exec .Command ("gbp" , arg ... )
342
351
cmd .Dir = dir
343
352
cmd .Stderr = os .Stderr
344
353
if err := cmd .Run (); err != nil {
@@ -752,7 +761,7 @@ func execMake(args []string, usage func()) {
752
761
753
762
debversion := u .version + "-1"
754
763
755
- dir , err := createGitRepository (debsrc , gopkg , orig , dep14 )
764
+ dir , err := createGitRepository (debsrc , gopkg , orig , dep14 , pristineTar )
756
765
if err != nil {
757
766
log .Fatalf ("Could not create git repository: %v\n " , err )
758
767
}
@@ -773,7 +782,7 @@ func execMake(args []string, usage func()) {
773
782
}
774
783
775
784
if err := writeTemplates (dir , gopkg , debsrc , debLib , debProg , debversion ,
776
- pkgType , debdependencies , u .vendorDirs ,
785
+ pkgType , debdependencies , u .vendorDirs , u . hasGodeps ,
777
786
dep14 , pristineTar ); err != nil {
778
787
log .Fatalf ("Could not create debian/ from templates: %v\n " , err )
779
788
}
@@ -783,37 +792,38 @@ func execMake(args []string, usage func()) {
783
792
log .Fatalf ("Could not write ITP email: %v\n " , err )
784
793
}
785
794
786
- log .Printf ("\n " )
787
- log .Printf ("Packaging successfully created in %s\n " , dir )
788
- log .Printf ("\n " )
789
- log .Printf (" Source: %s\n " , debsrc )
795
+ log .Println ("Done!" )
796
+
797
+ fmt .Printf ("\n " )
798
+ fmt .Printf ("Packaging successfully created in %s\n " , dir )
799
+ fmt .Printf (" Source: %s\n " , debsrc )
790
800
switch pkgType {
791
801
case typeLibrary :
792
- log .Printf (" Package : %s\n " , debLib )
802
+ fmt .Printf (" Binary : %s\n " , debLib )
793
803
case typeProgram :
794
- log .Printf (" Package : %s\n " , debProg )
804
+ fmt .Printf (" Binary : %s\n " , debProg )
795
805
case typeLibraryProgram :
796
- log .Printf (" Package : %s\n " , debLib )
797
- log .Printf (" Package : %s\n " , debProg )
806
+ fmt .Printf (" Binary : %s\n " , debLib )
807
+ fmt .Printf (" Binary : %s\n " , debProg )
798
808
case typeProgramLibrary :
799
- log .Printf (" Package : %s\n " , debProg )
800
- log .Printf (" Package : %s\n " , debLib )
801
- }
802
- log .Printf ("\n " )
803
- log .Printf ("Resolve all TODOs in %s, then email it out:\n " , itpname )
804
- log .Printf (" sendmail -t < %s\n " , itpname )
805
- log .Printf ("\n " )
806
- log .Printf ("Resolve all the TODOs in debian/, find them using:\n " )
807
- log .Printf (" grep -r TODO debian\n " )
808
- log .Printf ("\n " )
809
- log .Printf ("To build the package, commit the packaging and use gbp buildpackage:\n " )
810
- log .Printf (" git add debian && git commit -a -m 'Initial packaging'\n " )
811
- log .Printf (" gbp buildpackage --git-pbuilder\n " )
812
- log .Printf ("\n " )
813
- log .Printf ("To create the packaging git repository on salsa, use:\n " )
814
- log .Printf (" dh-make-golang create-salsa-project %s" , debsrc )
815
- log .Printf ("\n " )
816
- log .Printf ("Once you are happy with your packaging, push it to salsa using:\n " )
817
- log .
Printf (
" git remote set-url origin [email protected] :go-team/packages/%s.git\n " ,
debsrc )
818
- log .Printf (" gbp push\n " )
809
+ fmt .Printf (" Binary : %s\n " , debProg )
810
+ fmt .Printf (" Binary : %s\n " , debLib )
811
+ }
812
+ fmt .Printf ("\n " )
813
+ fmt .Printf ("Resolve all TODOs in %s, then email it out:\n " , itpname )
814
+ fmt .Printf (" sendmail -t < %s\n " , itpname )
815
+ fmt .Printf ("\n " )
816
+ fmt .Printf ("Resolve all the TODOs in debian/, find them using:\n " )
817
+ fmt .Printf (" grep -r TODO debian\n " )
818
+ fmt .Printf ("\n " )
819
+ fmt .Printf ("To build the package, commit the packaging and use gbp buildpackage:\n " )
820
+ fmt .Printf (" git add debian && git commit -a -m 'Initial packaging'\n " )
821
+ fmt .Printf (" gbp buildpackage --git-pbuilder\n " )
822
+ fmt .Printf ("\n " )
823
+ fmt .Printf ("To create the packaging git repository on salsa, use:\n " )
824
+ fmt .Printf (" dh-make-golang create-salsa-project %s\n " , debsrc )
825
+ fmt .Printf ("\n " )
826
+ fmt .Printf ("Once you are happy with your packaging, push it to salsa using:\n " )
827
+ fmt .
Printf (
" git remote set-url origin [email protected] :go-team/packages/%s.git\n " ,
debsrc )
828
+ fmt .Printf (" gbp push\n " )
819
829
}
0 commit comments