Skip to content

Commit

Permalink
Try Travis on xenial workers
Browse files Browse the repository at this point in the history
  • Loading branch information
smira committed Jul 10, 2019
1 parent 673abae commit bb1def2
Show file tree
Hide file tree
Showing 5 changed files with 167 additions and 86 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
dist: trusty
dist: xenial
sudo: required

language: go
Expand Down
2 changes: 1 addition & 1 deletion pgp/gnupg.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ func (g *GpgSigner) gpgArgs() []string {

if g.batch {
args = append(args, "--no-tty", "--batch")
if g.version == GPG21xPlus {
if g.version >= GPG21x {
args = append(args, "--pinentry-mode", "loopback")
}
}
Expand Down
7 changes: 5 additions & 2 deletions pgp/gnupg_finder.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ type GPGVersion int
const (
GPG1x GPGVersion = 1
GPG20x GPGVersion = 2
GPG21xPlus GPGVersion = 3
GPG21x GPGVersion = 3
GPG22xPlus GPGVersion = 4
)

var gpgVersionRegex = regexp.MustCompile(`\(GnuPG\) (\d)\.(\d)`)
Expand Down Expand Up @@ -135,13 +136,15 @@ func cliVersionCheck(cmd string, marker string) (result bool, version GPGVersion
strOutput := string(output)
result = strings.Contains(strOutput, marker)

version = GPG21xPlus
version = GPG22xPlus
matches := gpgVersionRegex.FindStringSubmatch(strOutput)
if matches != nil {
if matches[1] == "1" {
version = GPG1x
} else if matches[1] == "2" && matches[2] == "0" {
version = GPG20x
} else if matches[1] == "2" && matches[2] == "1" {
version = GPG21x
}
}

Expand Down
11 changes: 7 additions & 4 deletions pgp/gnupg_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,9 @@ func (s *Gnupg2SignerSuite) SetUpTest(c *C) {
if err != nil {
c.Skip(err.Error())
}
if ver == GPG21x {
c.Skip("skipping sign test on GnuPG 2.1.x, due to loopback pinentry mode troubles")
}

// import private keys into gpg2, they're stored outside of keyring files
for _, item := range []struct {
Expand All @@ -172,11 +175,11 @@ func (s *Gnupg2SignerSuite) SetUpTest(c *C) {
continue
}

args := []string{"--import", "--no-default-keyring"}
args := []string{"--import", "--no-default-keyring", "--batch"}

if item.suffix == "_passprhase" {
args = append(args, "--passphrase", "verysecret", "--no-tty", "--batch")
if ver == GPG21xPlus {
args = append(args, "--passphrase", "verysecret", "--no-tty")
if ver >= GPG21x {
args = append(args, "--pinentry-mode", "loopback")
}
}
Expand All @@ -190,7 +193,7 @@ func (s *Gnupg2SignerSuite) SetUpTest(c *C) {
// import public keys into gpg2
// we can't use pre-built keyrings as gpg 2.0.x and 2.1+ have different keyring formats
for _, suffix := range []string{"", "_passphrase"} {
output, err := exec.Command(gpg, "--no-default-keyring", "--keyring", "./keyrings/aptly2"+suffix+".gpg",
output, err := exec.Command(gpg, "--no-default-keyring", "--batch", "--keyring", "./keyrings/aptly2"+suffix+".gpg",
"--import", "keyrings/aptly2"+suffix+".pub.armor").CombinedOutput()
c.Log(string(output))
c.Check(err, IsNil)
Expand Down
Loading

0 comments on commit bb1def2

Please sign in to comment.