From: Steve Langasek Date: Tue, 24 Jan 2017 21:26:51 +0000 (+0000) Subject: debian-changes X-Git-Tag: archive/raspbian/2.27.6-1+rpi1~1^2^2 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=1da15133fb72bf1e043120ba6816b16a6267bb37;p=snapd.git debian-changes Gbp-Pq: Name debian-changes --- diff --git a/cmd/snap-confine/snap-confine.apparmor.in b/cmd/snap-confine/snap-confine.apparmor.in index 200d9642..f39e6fdf 100644 --- a/cmd/snap-confine/snap-confine.apparmor.in +++ b/cmd/snap-confine/snap-confine.apparmor.in @@ -355,4 +355,9 @@ # Allow snap-confine to be killed signal (receive) peer=unconfined, + + # Required when using unpatched upstream kernel + capability sys_ptrace, + # Debian compiles snap-confine without AppArmor, so allow running snaps unconfined + /usr/lib/snapd/snap-exec uxr, } diff --git a/cmd/snap/cmd_interfaces_test.go b/cmd/snap/cmd_interfaces_test.go index 91254a52..01944e9b 100644 --- a/cmd/snap/cmd_interfaces_test.go +++ b/cmd/snap/cmd_interfaces_test.go @@ -60,7 +60,8 @@ Help Options: -i= Constrain listing to specific interfaces [interfaces command arguments] - :: Constrain listing to a specific snap or snap:name + :: Constrain listing to a specific snap or + snap:name ` rest, err := Parser().ParseArgs([]string{"interfaces", "--help"}) c.Assert(err.Error(), Equals, msg) diff --git a/i18n/i18n.go b/i18n/i18n.go index f5769871..e4b3f9ad 100644 --- a/i18n/i18n.go +++ b/i18n/i18n.go @@ -21,82 +21,15 @@ package i18n //go:generate update-pot -import ( - "fmt" - "os" - "path/filepath" - "strings" - - /* this is actually "github.com/ojii/gettext.go", however because - https://github.com/ojii/gettext.go/pull/4 - is not merged as of this writtting we want to use this fork - */ - "github.com/mvo5/gettext.go" - - "github.com/snapcore/snapd/osutil" -) - -// TEXTDOMAIN is the message domain used by snappy; see dgettext(3) -// for more information. -var ( - TEXTDOMAIN = "snappy" - locale gettext.Catalog - translations gettext.Translations -) - -func init() { - bindTextDomain(TEXTDOMAIN, "/usr/share/locale") - setLocale("") -} - -func langpackResolver(root string, locale string, domain string) string { - - // first check for the real locale (e.g. de_DE) - // then try to simplify the locale (e.g. de_DE -> de) - locales := []string{locale, strings.SplitN(locale, "_", 2)[0]} - for _, locale := range locales { - r := filepath.Join(locale, "LC_MESSAGES", fmt.Sprintf("%s.mo", domain)) - - // ubuntu uses /usr/lib/locale-langpack and patches the glibc gettext - // implementation - langpack := filepath.Join(root, "..", "locale-langpack", r) - if osutil.FileExists(langpack) { - return langpack - } - - regular := filepath.Join(root, r) - if osutil.FileExists(regular) { - return regular - } - } - - return "" -} +import () func bindTextDomain(domain, dir string) { - translations = gettext.NewTranslations(dir, domain, langpackResolver) } func setLocale(loc string) { - if loc == "" { - loc = os.Getenv("LC_MESSAGES") - if loc == "" { - loc = os.Getenv("LANG") - } - } - // de_DE.UTF-8, de_DE@euro all need to get simplified - loc = strings.Split(loc, "@")[0] - loc = strings.Split(loc, ".")[0] - - locale = translations.Locale(loc) } // G is the shorthand for Gettext func G(msgid string) string { - return locale.Gettext(msgid) -} - -// NG is the shorthand for NGettext -func NG(msgid string, msgidPlural string, n uint32) string { - return locale.NGettext(msgid, msgidPlural, n) + return msgid } diff --git a/i18n/i18n_test.go b/i18n/i18n_test.go deleted file mode 100644 index 0caa2f66..00000000 --- a/i18n/i18n_test.go +++ /dev/null @@ -1,129 +0,0 @@ -// -*- Mode: Go; indent-tabs-mode: t -*- - -/* - * Copyright (C) 2014-2015 Canonical Ltd - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 3 as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - * - */ - -package i18n - -import ( - "io/ioutil" - "os" - "os/exec" - "path/filepath" - "testing" - - . "gopkg.in/check.v1" -) - -// Hook up check.v1 into the "go test" runner -func Test(t *testing.T) { TestingT(t) } - -var mockLocalePo = []byte(` -msgid "" -msgstr "" -"Project-Id-Version: snappy\n" -"Report-Msgid-Bugs-To: snappy-devel@lists.ubuntu.com\n" -"POT-Creation-Date: 2015-06-16 09:08+0200\n" -"Language: en_DK\n" -"MIME-Version: 1.0\n" -"Content-Type: text/plain; charset=UTF-8\n" -"Content-Transfer-Encoding: 8bit\n" -"Plural-Forms: nplurals=2; plural=n != 1;>\n" - -msgid "plural_1" -msgid_plural "plural_2" -msgstr[0] "translated plural_1" -msgstr[1] "translated plural_2" - -msgid "singular" -msgstr "translated singular" -`) - -func makeMockTranslations(c *C, localeDir string) { - fullLocaleDir := filepath.Join(localeDir, "en_DK", "LC_MESSAGES") - err := os.MkdirAll(fullLocaleDir, 0755) - c.Assert(err, IsNil) - - po := filepath.Join(fullLocaleDir, "snappy-test.po") - mo := filepath.Join(fullLocaleDir, "snappy-test.mo") - err = ioutil.WriteFile(po, mockLocalePo, 0644) - c.Assert(err, IsNil) - - cmd := exec.Command("msgfmt", po, "--output-file", mo) - cmd.Stdout = os.Stdout - cmd.Stderr = os.Stderr - err = cmd.Run() - c.Assert(err, IsNil) -} - -type i18nTestSuite struct { - origLang string - origLcMessages string -} - -var _ = Suite(&i18nTestSuite{}) - -func (s *i18nTestSuite) SetUpTest(c *C) { - // this dir contains a special hand-crafted en_DK/snappy-test.mo - // file - localeDir := c.MkDir() - makeMockTranslations(c, localeDir) - - // we use a custom test mo file - TEXTDOMAIN = "snappy-test" - - s.origLang = os.Getenv("LANG") - s.origLcMessages = os.Getenv("LC_MESSAGES") - - bindTextDomain("snappy-test", localeDir) - os.Setenv("LANG", "en_DK.UTF-8") - setLocale("") -} - -func (s *i18nTestSuite) TearDownTest(c *C) { - os.Setenv("LANG", s.origLang) - os.Setenv("LC_MESSAGES", s.origLcMessages) -} - -func (s *i18nTestSuite) TestTranslatedSingular(c *C) { - // no G() to avoid adding the test string to snappy-pot - var Gtest = G - c.Assert(Gtest("singular"), Equals, "translated singular") -} - -func (s *i18nTestSuite) TestTranslatesPlural(c *C) { - // no NG() to avoid adding the test string to snappy-pot - var NGtest = NG - c.Assert(NGtest("plural_1", "plural_2", 1), Equals, "translated plural_1") -} - -func (s *i18nTestSuite) TestTranslatedMissingLangNoCrash(c *C) { - setLocale("invalid") - - // no G() to avoid adding the test string to snappy-pot - var Gtest = G - c.Assert(Gtest("singular"), Equals, "singular") -} - -func (s *i18nTestSuite) TestInvalidTextDomainDir(c *C) { - bindTextDomain("snappy-test", "/random/not/existing/dir") - setLocale("invalid") - - // no G() to avoid adding the test string to snappy-pot - var Gtest = G - c.Assert(Gtest("singular"), Equals, "singular") -} diff --git a/progress/progress.go b/progress/progress.go index 820c6db6..8722632c 100644 --- a/progress/progress.go +++ b/progress/progress.go @@ -25,7 +25,7 @@ import ( "os" "unicode" - "github.com/cheggaaa/pb" + "gopkg.in/cheggaaa/pb.v1" "golang.org/x/crypto/ssh/terminal" ) diff --git a/tests/main/i18n/task.yaml b/tests/main/i18n/task.yaml deleted file mode 100644 index 6f95e8a3..00000000 --- a/tests/main/i18n/task.yaml +++ /dev/null @@ -1,4 +0,0 @@ -summary: Test that i18n works - -execute: | - LANG=de_DE.UTF-8 snap changes everything | MATCH "Ja, ja, allerdings." diff --git a/vendor/vendor.json b/vendor/vendor.json index 076c3d95..b8085646 100644 --- a/vendor/vendor.json +++ b/vendor/vendor.json @@ -42,18 +42,6 @@ "revision": "6b9493b3cb60367edd942144879646604089e3f7", "revisionTime": "2016-02-27T09:34:14Z" }, - { - "checksumSHA1": "MXOfmoFN5PBz/N5pDNrFe9ugYf8=", - "path": "github.com/mvo5/gettext.go", - "revision": "da4fdf605f1b0e2aa523423db5c0a3f727d62019", - "revisionTime": "2016-12-13T07:12:38Z" - }, - { - "checksumSHA1": "wClBtrHsGvzusCkIFdF78Iak6y0=", - "path": "github.com/mvo5/gettext.go/pluralforms", - "revision": "da4fdf605f1b0e2aa523423db5c0a3f727d62019", - "revisionTime": "2016-12-13T07:12:38Z" - }, { "checksumSHA1": "bzUdFxQ29mPK0lwgFVcF0GFN74Q=", "path": "github.com/mvo5/goconfigparser",