Skip to content

Commit ae50191

Browse files
committed
New upstream version 0.1.1
2 parents 204293a + 8c30050 commit ae50191

File tree

3 files changed

+69
-54
lines changed

3 files changed

+69
-54
lines changed

make.go

Lines changed: 54 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -77,11 +77,12 @@ func findVendorDirs(dir string) ([]string, error) {
7777

7878
// upstream describes the upstream repo we are about to package.
7979
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
8282
firstMain string // import path of the first main package within repo, if any
8383
vendorDirs []string // all vendor sub directories, relative to the repo directory
8484
repoDeps []string // the repository paths of all dependencies (e.g. github.com/zyedidia/glob)
85+
hasGodeps bool // whether the Godeps/_workspace directory exists
8586
}
8687

8788
func (u *upstream) get(gopath, repo, rev string) error {
@@ -114,8 +115,8 @@ func (u *upstream) tar(gopath, repo string) error {
114115
"cJf",
115116
u.tarPath,
116117
"--exclude=.git",
117-
"--exclude=Godeps",
118-
fmt.Sprintf("--exclude=%s/debian", base),
118+
"--exclude=Godeps/_workspace",
119+
"--exclude="+base+"/debian",
119120
base)
120121
cmd.Dir = filepath.Join(gopath, "src", dir)
121122
cmd.Stderr = os.Stderr
@@ -258,6 +259,11 @@ func makeUpstreamSourceTarball(repo, revision string) (*upstream, error) {
258259
}
259260
}
260261

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+
261267
log.Printf("Determining upstream version number\n")
262268

263269
u.version, err = pkgVersionFromGit(repoDir)
@@ -289,7 +295,7 @@ func runGitCommandIn(dir string, arg ...string) error {
289295
return cmd.Run()
290296
}
291297

292-
func createGitRepository(debsrc, gopkg, orig string, dep14 bool) (string, error) {
298+
func createGitRepository(debsrc, gopkg, orig string, dep14, pristineTar bool) (string, error) {
293299
wd, err := os.Getwd()
294300
if err != nil {
295301
return "", err
@@ -304,41 +310,44 @@ func createGitRepository(debsrc, gopkg, orig string, dep14 bool) (string, error)
304310
}
305311

306312
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 {
308314
return dir, err
309315
}
310316
}
311317

318+
// Set repository options
319+
312320
if debianName := getDebianName(); debianName != "TODO" {
313321
if err := runGitCommandIn(dir, "config", "user.name", debianName); err != nil {
314322
return dir, err
315323
}
316324
}
317-
318325
if debianEmail := getDebianEmail(); debianEmail != "TODO" {
319326
if err := runGitCommandIn(dir, "config", "user.email", debianEmail); err != nil {
320327
return dir, err
321328
}
322329
}
323-
324330
if err := runGitCommandIn(dir, "config", "push.default", "matching"); err != nil {
325331
return dir, err
326332
}
327-
328333
if err := runGitCommandIn(dir, "config", "--add", "remote.origin.push", "+refs/heads/*:refs/heads/*"); err != nil {
329334
return dir, err
330335
}
331-
332336
if err := runGitCommandIn(dir, "config", "--add", "remote.origin.push", "+refs/tags/*:refs/tags/*"); err != nil {
333337
return dir, err
334338
}
335339

336-
var cmd *exec.Cmd
340+
// Import upstream orig tarball
341+
342+
arg := []string{"import-orig", "--no-interactive"}
337343
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")
341345
}
346+
if pristineTar {
347+
arg = append(arg, "--pristine-tar")
348+
}
349+
arg = append(arg, filepath.Join(wd, orig))
350+
cmd := exec.Command("gbp", arg...)
342351
cmd.Dir = dir
343352
cmd.Stderr = os.Stderr
344353
if err := cmd.Run(); err != nil {
@@ -752,7 +761,7 @@ func execMake(args []string, usage func()) {
752761

753762
debversion := u.version + "-1"
754763

755-
dir, err := createGitRepository(debsrc, gopkg, orig, dep14)
764+
dir, err := createGitRepository(debsrc, gopkg, orig, dep14, pristineTar)
756765
if err != nil {
757766
log.Fatalf("Could not create git repository: %v\n", err)
758767
}
@@ -773,7 +782,7 @@ func execMake(args []string, usage func()) {
773782
}
774783

775784
if err := writeTemplates(dir, gopkg, debsrc, debLib, debProg, debversion,
776-
pkgType, debdependencies, u.vendorDirs,
785+
pkgType, debdependencies, u.vendorDirs, u.hasGodeps,
777786
dep14, pristineTar); err != nil {
778787
log.Fatalf("Could not create debian/ from templates: %v\n", err)
779788
}
@@ -783,37 +792,38 @@ func execMake(args []string, usage func()) {
783792
log.Fatalf("Could not write ITP email: %v\n", err)
784793
}
785794

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)
790800
switch pkgType {
791801
case typeLibrary:
792-
log.Printf(" Package: %s\n", debLib)
802+
fmt.Printf(" Binary: %s\n", debLib)
793803
case typeProgram:
794-
log.Printf(" Package: %s\n", debProg)
804+
fmt.Printf(" Binary: %s\n", debProg)
795805
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)
798808
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")
819829
}

progress.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,12 @@ func humanizeBytes(b int64) string {
3232
}
3333

3434
func progressSize(prefix, path string, done chan struct{}) {
35-
// previous holds how many bytes the previous line contained, so that we
36-
// can clear it in its entirety.
35+
// previous holds how many bytes the previous line contained
36+
// so that we can clear it in its entirety.
3737
var previous int
38+
tty := isatty.IsTerminal(os.Stdout.Fd())
3839
for {
39-
if isatty.IsTerminal(os.Stdout.Fd()) {
40+
if tty {
4041
var usage int64
4142
filepath.Walk(path, func(path string, info os.FileInfo, err error) error {
4243
if err == nil && info.Mode().IsRegular() {

template.go

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import (
1212

1313
func writeTemplates(dir, gopkg, debsrc, debLib, debProg, debversion string,
1414
pkgType packageType, dependencies []string, vendorDirs []string,
15-
dep14, pristineTar bool) error {
15+
hasGodeps bool, dep14, pristineTar bool) error {
1616
if err := os.Mkdir(filepath.Join(dir, "debian"), 0755); err != nil {
1717
return err
1818
}
@@ -26,7 +26,7 @@ func writeTemplates(dir, gopkg, debsrc, debLib, debProg, debversion string,
2626
if err := writeDebianControl(dir, gopkg, debsrc, debLib, debProg, pkgType, dependencies); err != nil {
2727
return err
2828
}
29-
if err := writeDebianCopyright(dir, gopkg, vendorDirs); err != nil {
29+
if err := writeDebianCopyright(dir, gopkg, vendorDirs, hasGodeps); err != nil {
3030
return err
3131
}
3232
if err := writeDebianRules(dir, pkgType); err != nil {
@@ -183,7 +183,7 @@ func writeDebianControl(dir, gopkg, debsrc, debLib, debProg string, pkgType pack
183183
return nil
184184
}
185185

186-
func writeDebianCopyright(dir, gopkg string, vendorDirs []string) error {
186+
func writeDebianCopyright(dir, gopkg string, vendorDirs []string, hasGodeps bool) error {
187187
license, fulltext, err := getLicenseForGopkg(gopkg)
188188
if err != nil {
189189
log.Printf("Could not determine license for %q: %v\n", gopkg, err)
@@ -213,11 +213,15 @@ func writeDebianCopyright(dir, gopkg string, vendorDirs []string) error {
213213
fmt.Fprintf(f, "Format: https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/\n")
214214
fmt.Fprintf(f, "Source: %s\n", getHomepageForGopkg(gopkg))
215215
fmt.Fprintf(f, "Upstream-Name: %s\n", filepath.Base(gopkg))
216-
fmt.Fprintf(f, "Files-Excluded:\n")
217-
for _, dir := range vendorDirs {
218-
fmt.Fprintf(f, indent+"%s\n", dir)
216+
if len(vendorDirs) > 0 || hasGodeps {
217+
fmt.Fprintf(f, "Files-Excluded:\n")
218+
for _, dir := range vendorDirs {
219+
fmt.Fprintf(f, indent+"%s\n", dir)
220+
}
221+
if hasGodeps {
222+
fmt.Fprintf(f, indent+"Godeps/_workspace\n")
223+
}
219224
}
220-
fmt.Fprintf(f, indent+"Godeps/_workspace\n")
221225
fmt.Fprintf(f, "\n")
222226
fmt.Fprintf(f, "Files:"+linebreak+" *\n")
223227
fmt.Fprintf(f, "Copyright:"+linebreak+" %s\n", copyright)

0 commit comments

Comments
 (0)