Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master' into icon-theme-support
Browse files Browse the repository at this point in the history
  • Loading branch information
jhenstridge committed Sep 12, 2019
2 parents a001514 + f45128b commit 6918530
Show file tree
Hide file tree
Showing 650 changed files with 25,657 additions and 6,512 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ cmd/snap-confine/unit-tests
cmd/snap-discard-ns/snap-discard-ns
cmd/snap-gdb-shim/snap-gdb-shim
cmd/snap-mgmt/snap-mgmt
cmd/snap-seccomp/snap-seccomp
cmd/snap-update-ns/snap-update-ns
cmd/snap-update-ns/unit-tests
cmd/snapd-env-generator/snapd-env-generator
Expand Down
17 changes: 15 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
language: go
git:
quiet: true
jobs:
matrix:
include:
- stage: quick
name: go 1.9/xenial static and unit test suites
Expand Down Expand Up @@ -71,7 +71,20 @@ jobs:
- true
script:
- ./run-checks --spread-no-ubuntu
env:
- stage: integration
name: Unstable systems
dist: xenial
addons:
apt:
packages:
- xdelta3
install:
# override the default install for language:go
- true
script:
- ./run-checks --spread-unstable
allow_failures:
- name: Unstable systems
global:
# SPREAD_LINODE_KEY
- secure: "bzALrfNSLwM0bjceal1PU5rFErvqVhi00Sygx8jruo6htpZay3hrC2sHCKCQKPn1kvCfHidrHX1vnomg5N+B9o25GZEYSjKSGxuvdNDfCZYqPNjMbz5y7xXYfKWgyo+xtrKRM85Nqy121SfRz3KLDvrOLwwreb+pZv8DG1WraFTd7D6rK7nLnnYNUyw665XBMFVnM8ue3Zu9496Ih/TfQXhnNpsZY8xFWte4+cH7JvVCVTs8snjoGVZi3972PzinNkfBgJa24cUzxFMfiN/AwSBXJQKdVv+FsbB4uRgXAqTNwuus7PptiPNxpWWojuhm1Qgbk0XhGIdJxyUYkmNA4UrZ3C29nIRWbuAiHJ6ZWd1ur3dqphqOcgFInltSHkpfEdlL3YK4dCa2SmJESzotUGnyowCUUCXkWdDaZmFTwyK0Y6He9oyXDK5f+/U7SFlPvok0caJCvB9HbTQR1kYdh048I/R+Ht5QrFOZPk21DYWDOYhn7SzthBDZLsaL6n5gX7Y547SsL4B35YVbpaeHzccG6Mox8rI4bqlGFvP1U5i8uXD4uQjJChlVxpmozUEMok9T5RVediJs540p5uc8DQl48Nke02tXzC/XpGAvpnXT7eiiRNW67zOj2QcIV+ni3lBj3HvZeB9cgjzLNrZSl/t9vseqnNwQWpl3V6nd/bU="
Expand Down
81 changes: 58 additions & 23 deletions HACKING.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ integration test framework for the integration/system level tests.

### Supported Go versions

snapd is supported on Go 1.6 onwards.
From snapd 2.38, snapd supports Go 1.9 and onwards. For earlier snapd
releases, snapd supports Go 1.6.

### Setting up a GOPATH

Expand Down Expand Up @@ -108,8 +109,8 @@ Contributions are always welcome! Please make sure that you sign the
Canonical contributor license agreement at
http://www.ubuntu.com/legal/contributors

Snapd can be found on Github, so in order to fork the source and contribute,
go to https://github.com/snapcore/snapd. Check out [Github's help
Snapd can be found on GitHub, so in order to fork the source and contribute,
go to https://github.com/snapcore/snapd. Check out [GitHub's help
pages](https://help.github.com/) to find out how to set up your local branch,
commit changes and create pull requests.

Expand All @@ -126,9 +127,11 @@ To run the various tests that we have to ensure a high quality source just run:
This will check if the source format is consistent, that it builds, all tests
work as expected and that "go vet" has nothing to complain.

The source format follows the `gofmt -s` formating. Please run this on your sources files if `run-checks` complains about the format.
The source format follows the `gofmt -s` formating. Please run this on your
source files if `run-checks` complains about the format.

You can run individual test for a sub-package by changing into that directory and:
You can run an individual test for a sub-package by changing into that
directory and:

go test -check.f $testname

Expand All @@ -140,33 +143,64 @@ If a test hangs, you can enable verbose mode:

There is more to read about the testing framework on the [website](https://labix.org/gocheck)

### Running the spread tests
### Running spread tests

To run the spread tests locally you need the latest version of spread
from https://github.com/snapcore/spread. It can be installed via:
To run the spread tests locally via QEMU, you need the latest version of
[spread](https://github.com/snapcore/spread). You can get spread, QEMU, and the
build tools to build QEMU images with:

$ sudo apt install qemu-kvm autopkgtest
$ sudo snap install --devmode spread
$ sudo apt update && sudo apt install -y qemu-kvm autopkgtest
$ curl https://niemeyer.s3.amazonaws.com/spread-amd64.tar.gz | tar -xz -C $GOPATH/bin

Then setup the environment via:
#### Building spread VM images

$ mkdir -p .spread/qemu
$ cd .spread/qemu
# For xenial (same works for yakkety/zesty)
$ adt-buildvm-ubuntu-cloud -r xenial
$ mv adt-xenial-amd64-cloud.img ubuntu-16.04.img
# For trusty
$ adt-buildvm-ubuntu-cloud -r trusty --post-command='sudo apt-get install -y --install-recommends linux-generic-lts-xenial && update-grub'
To run the spread tests via QEMU you need to create VM images in the
`~/.spread/qemu` directory:

$ mkdir -p ~/.spread/qemu
$ cd ~/.spread/qemu

Assuming you are building on Ubuntu 18.04 LTS (Bionic Beaver) (or a later
development release like Ubuntu 19.04 (Disco Dingo)), run the following to
build a 64-bit Ubuntu 16.04 LTS (Xenial Xerus) VM to run the spread tests on:

$ autopkgtest-buildvm-ubuntu-cloud -r xenial
$ mv autopkgtest-xenial-amd64.img ubuntu-16.04-64.img

To build an Ubuntu 14.04 (Trusty Tahr) based VM, use:

$ autopkgtest-buildvm-ubuntu-cloud -r trusty --post-command='sudo apt-get install -y --install-recommends linux-generic-lts-xenial && update-grub'
$ mv adt-trusty-amd64-cloud.img ubuntu-14.04-64.img

This is because we need at least 4.4+ kernel for snapd to run on Ubuntu 14.04
LTS, which is available through the `linux-generic-lts-xenial` package.

If you are running Ubuntu 16.04 LTS, use
`adt-buildvm-ubuntu-cloud` instead of `autopkgtest-buildvm-ubuntu-cloud` (the
latter replaced the former in 18.04):

$ adt-buildvm-ubuntu-cloud -r xenial
$ mv adt-xenial-amd64-cloud.img ubuntu-16.04-64.img

#### Downloading spread VM images

Alternatively, instead of building the QEMU images manually, you can download
pre-built and somewhat maintained images from
[spread.zygoon.pl](spread.zygoon.pl). The images will need to be extracted
with `gunzip` and placed into `~/.spread/qemu` as above.

#### Running spread with QEMU

Finally, you can run the spread tests for Ubuntu 16.04 LTS 64-bit with:

And you can run the tests via:
$ spread -v qemu:ubuntu-16.04-64

$ spread -v qemu:
To run for a different system, replace `ubuntu-16.04-64` with a different system
name.

For quick reuse you can use:

$ spread -reuse qemu:
$ spread -reuse qemu:ubuntu-16.04-64

It will print how to reuse the systems. Make sure to use
`export REUSE_PROJECT=1` in your environment too.
Expand Down Expand Up @@ -200,7 +234,7 @@ To get started from a pristine tree you want to do this:
./mkversion.sh
cd cmd/
autoreconf -i -f
./configure --prefix=/usr --libexecdir=/usr/lib/snapd --enable-nvidia-ubuntu
./configure --prefix=/usr --libexecdir=/usr/lib/snapd
```

This will drop makefiles and let you build stuff. You may find the `make hack`
Expand All @@ -209,4 +243,5 @@ version on your system and reloads the apparmor profile.

## Submitting patches

Please run `make fmt` before sending your patches.
Please run `(cd cmd; make fmt)` before sending your patches for the "C" part of
the source code.
43 changes: 20 additions & 23 deletions arch/arch.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,33 +33,30 @@ type ArchitectureType string
// change the architecture. This is important to e.g. install
// armhf snaps onto a armhf image that is generated on an amd64
// machine
var arch = ArchitectureType(ubuntuArchFromGoArch(runtime.GOARCH))
var arch = ArchitectureType(dpkgArchFromGoArch(runtime.GOARCH))

// SetArchitecture allows overriding the auto detected Architecture
func SetArchitecture(newArch ArchitectureType) {
arch = newArch
}

// FIXME: rename all Ubuntu*Architecture() to SnapdArchitecture()
// (or DpkgArchitecture)

// UbuntuArchitecture returns the debian equivalent architecture for the
// DpkgArchitecture returns the debian equivalent architecture for the
// currently running architecture.
//
// If the architecture does not map any debian architecture, the
// GOARCH is returned.
func UbuntuArchitecture() string {
func DpkgArchitecture() string {
return string(arch)
}

// ubuntuArchFromGoArch maps a go architecture string to the coresponding
// Ubuntu architecture string.
// dpkgArchFromGoArch maps a go architecture string to the coresponding
// Debian equivalent architecture string.
//
// E.g. the go "386" architecture string maps to the ubuntu "i386"
// architecture.
func ubuntuArchFromGoArch(goarch string) string {
func dpkgArchFromGoArch(goarch string) string {
goArchMapping := map[string]string{
// go ubuntu
// go dpkg
"386": "i386",
"amd64": "amd64",
"arm": "armhf",
Expand All @@ -82,27 +79,27 @@ func ubuntuArchFromGoArch(goarch string) string {
}
}

ubuntuArch := goArchMapping[goarch]
if ubuntuArch == "" {
dpkgArch := goArchMapping[goarch]
if dpkgArch == "" {
log.Panicf("unknown goarch %q", goarch)
}

return ubuntuArch
return dpkgArch
}

// UbuntuKernelArchitecture return the debian equivalent architecture
// DpkgKernelArchitecture returns the debian equivalent architecture
// for the current running kernel. This is usually the same as the
// UbuntuArchitecture - however there maybe cases that you run e.g.
// DpkgArchitecture - however there maybe cases that you run e.g.
// a snapd:i386 on an amd64 kernel.
func UbuntuKernelArchitecture() string {
return ubuntuArchFromKernelArch(osutil.MachineName())
func DpkgKernelArchitecture() string {
return dpkgArchFromKernelArch(osutil.MachineName())
}

// ubuntuArchFromkernelArch maps the kernel architecture as reported
// dpkgArchFromkernelArch maps the kernel architecture as reported
// via uname() to the dpkg architecture
func ubuntuArchFromKernelArch(utsMachine string) string {
func dpkgArchFromKernelArch(utsMachine string) string {
kernelArchMapping := map[string]string{
// kernel ubuntu
// kernel dpkg
"i686": "i386",
"x86_64": "amd64",
"armv7l": "armhf",
Expand All @@ -115,12 +112,12 @@ func ubuntuArchFromKernelArch(utsMachine string) string {
"ppc64": "ppc64",
}

ubuntuArch := kernelArchMapping[utsMachine]
if ubuntuArch == "" {
dpkgArch := kernelArchMapping[utsMachine]
if dpkgArch == "" {
log.Panicf("unknown kernel arch %q", utsMachine)
}

return ubuntuArch
return dpkgArch
}

// IsSupportedArchitecture returns true if the system architecture is in the
Expand Down
25 changes: 14 additions & 11 deletions arch/arch_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,29 +33,32 @@ var _ = Suite(&ArchTestSuite{})
type ArchTestSuite struct {
}

func (ts *ArchTestSuite) TestUbuntuArchitecture(c *C) {
c.Check(ubuntuArchFromGoArch("386"), Equals, "i386")
c.Check(ubuntuArchFromGoArch("amd64"), Equals, "amd64")
c.Check(ubuntuArchFromGoArch("arm"), Equals, "armhf")
c.Check(ubuntuArchFromGoArch("arm64"), Equals, "arm64")
c.Check(ubuntuArchFromGoArch("ppc64le"), Equals, "ppc64el")
c.Check(ubuntuArchFromGoArch("ppc64"), Equals, "ppc64")
c.Check(ubuntuArchFromGoArch("s390x"), Equals, "s390x")
func (ts *ArchTestSuite) TestArchDpkgArchitecture(c *C) {
c.Check(dpkgArchFromGoArch("386"), Equals, "i386")
c.Check(dpkgArchFromGoArch("amd64"), Equals, "amd64")
c.Check(dpkgArchFromGoArch("arm"), Equals, "armhf")
c.Check(dpkgArchFromGoArch("arm64"), Equals, "arm64")
c.Check(dpkgArchFromGoArch("ppc64le"), Equals, "ppc64el")
c.Check(dpkgArchFromGoArch("ppc64"), Equals, "ppc64")
c.Check(dpkgArchFromGoArch("s390x"), Equals, "s390x")
c.Check(dpkgArchFromGoArch("ppc"), Equals, "powerpc")
c.Check(dpkgArchFromGoArch("ppc64"), Equals, "ppc64")
}

func (ts *ArchTestSuite) TestSetArchitecture(c *C) {
func (ts *ArchTestSuite) TestArchSetArchitecture(c *C) {
SetArchitecture("armhf")
c.Assert(UbuntuArchitecture(), Equals, "armhf")
c.Assert(DpkgArchitecture(), Equals, "armhf")
}

func (ts *ArchTestSuite) TestSupportedArchitectures(c *C) {
func (ts *ArchTestSuite) TestArchSupportedArchitectures(c *C) {
arch = "armhf"
c.Check(IsSupportedArchitecture([]string{"all"}), Equals, true)
c.Check(IsSupportedArchitecture([]string{"amd64", "armhf", "powerpc"}), Equals, true)
c.Check(IsSupportedArchitecture([]string{"armhf"}), Equals, true)
c.Check(IsSupportedArchitecture([]string{"amd64", "powerpc"}), Equals, false)

arch = "amd64"
c.Check(IsSupportedArchitecture([]string{"all"}), Equals, true)
c.Check(IsSupportedArchitecture([]string{"amd64", "armhf", "powerpc"}), Equals, true)
c.Check(IsSupportedArchitecture([]string{"powerpc"}), Equals, false)
}
11 changes: 11 additions & 0 deletions asserts/asserts.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,17 @@ const (
noAuthority typeFlags = iota + 1
)

// MetaHeaders is a list of headers in assertions which are about the assertion
// itself.
var MetaHeaders = [...]string{
"type",
"format",
"authority-id",
"revision",
"body-length",
"sign-key-sha3-384",
}

// AssertionType describes a known assertion type with its name and metadata.
type AssertionType struct {
// Name of the type.
Expand Down
Loading

0 comments on commit 6918530

Please sign in to comment.