Merge lp:~sergiusens/goget-ubuntu-touch/installYaml into lp:goget-ubuntu-touch

Proposed by Sergio Schvezov
Status: Merged
Approved by: Sergio Schvezov
Approved revision: 191
Merged at revision: 184
Proposed branch: lp:~sergiusens/goget-ubuntu-touch/installYaml
Merge into: lp:goget-ubuntu-touch
Prerequisite: lp:~sergiusens/goget-ubuntu-touch/beBetter
Diff against target: 111 lines (+59/-2)
3 files modified
dependencies.tsv (+1/-1)
diskimage/common.go (+1/-0)
ubuntu-device-flash/core.go (+57/-1)
To merge this branch: bzr merge lp:~sergiusens/goget-ubuntu-touch/installYaml
Reviewer Review Type Date Requested Status
Sergio Schvezov Approve
John Lenton (community) Approve
Michael Vogt (community) Approve
Snappy Developers continuous-integration Pending
Review via email: mp+261865@code.launchpad.net

This proposal supersedes a proposal from 2015-04-14.

Commit message

Stamp a yaml with install/setup information

Description of the change

* Record sideloads to ensure "snappy update" doesn't try to upgrade a system that uses custom
  assets.

Creates a stamp file on the writable partition when --device-part= is specified. This is clearly trivial to defeat, but will allow snappy to refuse to update a system with such a stamp file.

There is a potential gotcha with this approach (albeit unlikely for anyone to hit it): if u-d-f is used to first download the set of s-i tar files and then u-d-f is called again with --device-part= pointing to the valid, official device part just downloaded, the stamp will still be created.

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote : Posted in a previous version of this proposal

FAILED: Continuous integration, rev:160
No commit message was specified in the merge proposal. Click on the following link and set the commit message (if you want a jenkins rebuild you need to trigger it yourself):
https://code.launchpad.net/~jamesodhunt/goget-ubuntu-touch/record-sideload/+merge/256190/+edit-commit-message

http://jenkins.qa.ubuntu.com/job/goget-ubuntu-touch-ci/171/
Executed test runs:
    FAILURE: http://jenkins.qa.ubuntu.com/job/goget-ubuntu-touch-vivid-amd64-ci/84/console
    FAILURE: http://jenkins.qa.ubuntu.com/job/goget-ubuntu-touch-vivid-armhf-ci/84/console
    FAILURE: http://jenkins.qa.ubuntu.com/job/goget-ubuntu-touch-vivid-i386-ci/84/console

Click here to trigger a rebuild:
http://s-jenkins.ubuntu-ci:8080/job/goget-ubuntu-touch-ci/171/rebuild

review: Needs Fixing (continuous-integration)
Revision history for this message
James Hunt (jamesodhunt) wrote : Posted in a previous version of this proposal
Revision history for this message
Sergio Schvezov (sergiusens) wrote : Posted in a previous version of this proposal

As I said on irc, this looks great; I would change:
- writeLocation to a factory reset safe location
- maybe instead of storing sideLoaded and do if sideLoaded you can just if coreCmd.DeviceTarball != "" (which is essentially the same).
- remove the changelog change, I will draft a proper one when this is released into the archive.

Revision history for this message
James Hunt (jamesodhunt) wrote : Posted in a previous version of this proposal

Thanks for the comments. Branch updated.

Revision history for this message
Sergio Schvezov (sergiusens) wrote : Posted in a previous version of this proposal

This looks really good, I liked the yaml idea you proposed on irc; and discussed it a bit with mvo and he was in favor of it too.

Just make it /boot/provisioning.yaml or /boot/setup.yaml or /boot/install.yaml (no need to hide it).

Regarding the layout, I'd just keep these:
meta:
    timestamp: 1429185020
    initial-revision: r345
    system-image-server: http://system-image.ubuntu.com

provisioning-tool:
    name: ubuntu-device-flash
    path: /usr/bin/ubuntu-device-flash
    version: 0.20snappy3-0ubuntu1

installation-options:
    size: 3
    size-unit: GB
    output: /tmp/bbb.img
    channel: ubuntu-core/devel-proposed
    device-part: /some/path/file.tgz
    developer-mode: true

Since platform and architecture are already in the oem snap, so it would be duplicate information (oem snaps will become mandatory).

Can't wait to see this make it in!

Oh, there's one minor inline comment.

Revision history for this message
James Hunt (jamesodhunt) wrote : Posted in a previous version of this proposal

This branch + lp:~jamesodhunt/snappy/install.yaml are what I have so far.

Any thoughts on how we set Version sensibly in writeInstallYaml()? We have the same problem in snappy.

Revision history for this message
James Hunt (jamesodhunt) wrote : Posted in a previous version of this proposal

The other slight wart is the "GB" in writeInstallYaml().

Revision history for this message
James Hunt (jamesodhunt) wrote : Posted in a previous version of this proposal

lp:~jamesodhunt/snappy/install.yaml is now essentially complete.

Revision history for this message
Sergio Schvezov (sergiusens) wrote : Posted in a previous version of this proposal

looks good, we just need to adjust some knobs here and there.

review: Needs Fixing
Revision history for this message
James Hunt (jamesodhunt) wrote : Posted in a previous version of this proposal

Thanks for reviewing. Branch updated.

Revision history for this message
Sergio Schvezov (sergiusens) : Posted in a previous version of this proposal
Revision history for this message
James Hunt (jamesodhunt) wrote : Posted in a previous version of this proposal

It tested fine, but it looks like a snappy change earlier today has broken 'udf ... --oem file.snap':
________________________________________
$ sudo ubuntu-device-flash --verbose core --size 3 --channel devel-proposed --developer-mode --output=amd64.img --device-part device-e4e9d6632c5266aac95bde68729bcce796509f6abeac8c7ebca25be34aa0c431.tar.xz --oem ./generic-amd64.canonical_1.0_all.snap
Determining oem configuration
2015-04-21 16:46:57 ERROR snappy logger.go:199 ./generic-amd64.canonical_1.0_all.snap failed to install: oem package installation not allowed
./generic-amd64.canonical_1.0_all.snap failed to install: oem package installation not allowed

________________________________________

Revision history for this message
James Hunt (jamesodhunt) wrote : Posted in a previous version of this proposal
Revision history for this message
James Hunt (jamesodhunt) wrote : Posted in a previous version of this proposal
Revision history for this message
Sergio Schvezov (sergiusens) wrote : Posted in a previous version of this proposal

> Or is it that udf just needs this branch merging?
>
> https://code.launchpad.net/~sergiusens/goget-ubuntu-
> touch/oemFlag/+merge/256922

yes, that is blocked in the pipeline from an MP by steve

Revision history for this message
Sergio Schvezov (sergiusens) wrote : Posted in a previous version of this proposal

> > Or is it that udf just needs this branch merging?
> >
> > https://code.launchpad.net/~sergiusens/goget-ubuntu-
> > touch/oemFlag/+merge/256922
>
> yes, that is blocked in the pipeline from an MP by steve

Rebased and landed

Revision history for this message
James Hunt (jamesodhunt) wrote : Posted in a previous version of this proposal
Download full text (3.2 KiB)

Re-tested:

= amd64 =

$ sudo ubuntu-device-flash --verbose core --size 3 --channel edge --output=amd64.img --device-part device-e4e9d6632c5266aac95bde68729bcce796509f6abeac8c7ebca25be34aa0c431.tar.xz --oem ./generic-amd64.canonical_1.
0_all.snap 15.04
Determining oem configuration
Fetching information from server...
Downloading and setting up...
Using a custom device tarball
Searching for hardware.yaml in device part
Download finished for /home/james/device-e4e9d6632c5266aac95bde68729bcce796509f6abeac8c7ebca25be34aa0c431.tar.xz
Partitioning...
Download finished for /home/james/.cache/ubuntuimages/ubuntu-core/15.04/edge/generic_amd64/version-26.tar.xz
Download finished for /home/james/.cache/ubuntuimages/pool/ubuntu-4fbe24300a5d5e443a0a455fc3428f780d273bd03673896cfcf51ba0eba4000d.tar.xz
Mapping...
Formatting...
Mapping...
Mounting...
Provisioning...
Installing ./generic-amd64.canonical_1.0_all.snap
Unmounting...
Unmapping...
New image complete
Summary:
 Output: amd64.img
 Architecture: amd64
 Channel: edge
 Version: 26
Launch by running: kvm -m 768 amd64.img
$ sudo kpartx -avs amd64.img
$ sudo mount /dev/mapper/loop0p2 /mnt
$ cat /mnt/install.yaml
meta:
  timestamp: 2015-04-22T09:08:41.393114048+01:00
  initial-version: "26"
  system-image-server: https://system-image.ubuntu.com
tool:
  name: ubuntu-device-flash
  path: /usr/bin/ubuntu-device-flash
  version: ""
options:
  size: 3
  size-unit: GB
  output: amd64.img
  channel: edge
  device-part: device-e4e9d6632c5266aac95bde68729bcce796509f6abeac8c7ebca25be34aa0c431.tar.xz
  oem: ./generic-amd64.canonical_1.0_all.snap

= armhf =

$ sudo ubuntu-device-flash --verbose core --size 3 --channel edge --output=armhf.img --device-part device-e4e9d6632c5266aac95bde68729bcce796509f6abeac8c7ebca25be34aa0c431.tar.xz --device generic_armhf 15.04 --oem ./beagleblack.canonical_1.7_all.snap
Determining oem configuration
Fetching information from server...
WARNING: this option should only be used to build azure images
Downloading and setting up...
Using a custom device tarball
Searching for hardware.yaml in device part
Download finished for /home/james/device-e4e9d6632c5266aac95bde68729bcce796509f6abeac8c7ebca25be34aa0c431.tar.xz
Download finished for /home/james/.cache/ubuntuimages/ubuntu-core/15.04/edge/generic_armhf/version-22.tar.xz
Download finished for /home/james/.cache/ubuntuimages/pool/ubuntu-3599d2c285a4bd0f54d0b13a290c4f9c8b10ae10354afee55237994af7a28f1c.tar.xz
Partitioning...
Mapping...
Formatting...
Mapping...
Mounting...
Provisioning...
Installing ./beagleblack.canonical_1.7_all.snap
Replicating system-a into system-b
Unmounting...
Unmapping...
New image complete
Summary:
 Output: armhf.img
 Architecture: armhf
 Channel: edge
 Version: 22
$ sudo kpartx -avs armhf.img
$ sudo mount /dev/mapper/loop0p2 /mnt
$ cat /mnt/install.yaml
meta:
  timestamp: 2015-04-22T09:22:29.418832806+01:00
  initial-version: "22"
  system-image-server: https://system-image.ubuntu.com
tool:
  name: ubuntu-device-flash
  path: /usr/bin/ubuntu-device-flash
  version: ""
options:
  size: 3
  size-unit: GB
  output: armhf.img
  channel: edge
  device-part: device-e4e9d6632c5266aac95bde68729bcce796509f6abeac8c7ebca25be34aa...

Read more...

Revision history for this message
James Hunt (jamesodhunt) wrote : Posted in a previous version of this proposal

Grr, of course although this "works" for grub, it won't work on a running system where it will have to live in /boot/grub/.

Revision history for this message
Sergio Schvezov (sergiusens) wrote : Posted in a previous version of this proposal

> Grr, of course although this "works" for grub, it won't work on a running
> system where it will have to live in /boot/grub/.

Right, but actually wrong, this is what I mentioned wrt can't find it on a running system, it's actually under /boot/efi/

Revision history for this message
James Hunt (jamesodhunt) wrote : Posted in a previous version of this proposal

Branch updated.

Revision history for this message
Sergio Schvezov (sergiusens) wrote : Posted in a previous version of this proposal

For this to land an updated lp:snappy needs to make it to wily

Revision history for this message
Sergio Schvezov (sergiusens) :
review: Abstain
Revision history for this message
Michael Vogt (mvo) wrote :

Looks good.

review: Approve
Revision history for this message
John Lenton (chipaca) wrote :

go go go

review: Approve
Revision history for this message
Snappy Tarmac (snappydevtarmac) wrote :

The attempt to merge lp:~sergiusens/goget-ubuntu-touch/installYaml into lp:goget-ubuntu-touch failed. Below is the output from the failed tests.

Checking formatting
Formatting wrong in following files
ubuntu-device-flash/core.go

# we always run in a fresh dir in tarmac
export GOPATH=$(mktemp -d)
trap 'rm -rf "$GOPATH"' EXIT

# this is a hack, but not sure tarmac is golang friendly
mkdir -p $GOPATH/src/launchpad.net/goget-ubuntu-touch
cp -a . $GOPATH/src/launchpad.net/goget-ubuntu-touch
cd $GOPATH/src/launchpad.net/goget-ubuntu-touch

./run-checks

Revision history for this message
Sergio Schvezov (sergiusens) :
review: Approve
Revision history for this message
Snappy Tarmac (snappydevtarmac) wrote :

The attempt to merge lp:~sergiusens/goget-ubuntu-touch/installYaml into lp:goget-ubuntu-touch failed. Below is the output from the failed tests.

Checking formatting
Installing godeps
Install golint
Obtaining dependencies
update github.com/blakesmith/ar failed; trying to fetch newer version
update github.com/cheggaaa/pb failed; trying to fetch newer version
github.com/blakesmith/ar now at c9a977dd0cc1392b023382c7bfa5a22af8d3b730
update github.com/jessevdk/go-flags failed; trying to fetch newer version
github.com/cheggaaa/pb now at e8c7cc515bfde3e267957a3b110080ceed51354e
update github.com/mvo5/goconfigparser failed; trying to fetch newer version
github.com/jessevdk/go-flags now at 15347ef417a300349807983f15af9e65cd2e1b3a
update gopkg.in/yaml.v2 failed; trying to fetch newer version
github.com/mvo5/goconfigparser now at 26426272dda20cc76aa1fa44286dc743d2972fe8
update launchpad.net/gocheck failed; trying to fetch newer version
gopkg.in/yaml.v2 now at 49c95bdc21843256fb6c4e0d370a05f24a0bf213
update launchpad.net/snappy failed; trying to fetch newer version
launchpad.net/gocheck now at <email address hidden>
launchpad.net/snappy now at snappy_tarmac-20150609131158-tl9ndj3aor8m3kna
Building

# we always run in a fresh dir in tarmac
export GOPATH=$(mktemp -d)
trap 'rm -rf "$GOPATH"' EXIT

# this is a hack, but not sure tarmac is golang friendly
mkdir -p $GOPATH/src/launchpad.net/goget-ubuntu-touch
cp -a . $GOPATH/src/launchpad.net/goget-ubuntu-touch
cd $GOPATH/src/launchpad.net/goget-ubuntu-touch

./run-checks
ubuntu-device-flash/core.go:28:2: cannot find package "launchpad.net/snappy/provisioning" in any of:
 /usr/lib/go/src/pkg/launchpad.net/snappy/provisioning (from $GOROOT)
 /home/tarmac/tmp/tmp.9mZ8cTA8TJ/src/launchpad.net/snappy/provisioning (from $GOPATH)

191. By Sergio Schvezov

godeps godeps godeps...

Revision history for this message
Sergio Schvezov (sergiusens) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'dependencies.tsv'
2--- dependencies.tsv 2015-06-09 13:57:34 +0000
3+++ dependencies.tsv 2015-06-17 12:21:42 +0000
4@@ -4,4 +4,4 @@
5 github.com/mvo5/goconfigparser git 26426272dda20cc76aa1fa44286dc743d2972fe8 2015-02-12T09:37:50Z
6 gopkg.in/yaml.v2 git 49c95bdc21843256fb6c4e0d370a05f24a0bf213 2015-02-24T22:57:58Z
7 launchpad.net/gocheck bzr gustavo@niemeyer.net-20140225173054-xu9zlkf9kxhvow02 87
8-launchpad.net/snappy bzr snappy_tarmac-20150609131158-tl9ndj3aor8m3kna 493
9+launchpad.net/snappy bzr snappy_tarmac-20150617101203-6hsfxqrckt6koobw 512
10
11=== modified file 'diskimage/common.go'
12--- diskimage/common.go 2015-06-15 15:32:25 +0000
13+++ diskimage/common.go 2015-06-17 12:21:42 +0000
14@@ -54,6 +54,7 @@
15 }
16
17 type SystemImage interface {
18+ Boot() string
19 System() string
20 Writable() string
21 }
22
23=== modified file 'ubuntu-device-flash/core.go'
24--- ubuntu-device-flash/core.go 2015-06-12 04:39:13 +0000
25+++ ubuntu-device-flash/core.go 2015-06-17 12:21:42 +0000
26@@ -25,6 +25,7 @@
27 "gopkg.in/yaml.v2"
28 "launchpad.net/snappy/helpers"
29 "launchpad.net/snappy/progress"
30+ "launchpad.net/snappy/provisioning"
31 "launchpad.net/snappy/release"
32 "launchpad.net/snappy/snappy"
33
34@@ -277,6 +278,9 @@
35 return err
36 }
37
38+ // avoid passing more args to setup()
39+ globalArgs.Revision = image.Version
40+
41 if err := coreCmd.setup(img, filePathChan, len(image.Files)); err != nil {
42 return err
43 }
44@@ -392,7 +396,7 @@
45 }
46 }
47
48- return nil
49+ return coreCmd.writeInstallYaml(img.Boot())
50 }
51
52 func (coreCmd *CoreCmd) install(systemPath string) error {
53@@ -586,6 +590,58 @@
54 return oem, nil
55 }
56
57+// Creates a YAML file inside the image that contains metadata relating
58+// to the installation.
59+func (coreCmd CoreCmd) writeInstallYaml(bootMountpoint string) error {
60+ selfPath, err := exec.LookPath(os.Args[0])
61+ if err != nil {
62+ return err
63+ }
64+
65+ bootDir := ""
66+
67+ switch coreCmd.oem.OEM.Hardware.Bootloader {
68+ // Running systems use a bindmount for /boot/grub, but
69+ // since the system isn't booted, create the file in the
70+ // real location.
71+ case "grub":
72+ bootDir = "/EFI/ubuntu/grub"
73+ }
74+
75+ installYamlFilePath := filepath.Join(bootMountpoint, bootDir, provisioning.InstallYamlFile)
76+
77+ i := provisioning.InstallYaml{
78+ InstallMeta: provisioning.InstallMeta{
79+ Timestamp: time.Now(),
80+ InitialVersion: fmt.Sprintf("%d", globalArgs.Revision),
81+ SystemImageServer: globalArgs.Server,
82+ },
83+ InstallTool: provisioning.InstallTool{
84+ Name: filepath.Base(selfPath),
85+ Path: selfPath,
86+ // FIXME: we don't know our own version yet :)
87+ // Version: "???",
88+ },
89+ InstallOptions: provisioning.InstallOptions{
90+ Size: coreCmd.Size,
91+ SizeUnit: "GB",
92+ Output: coreCmd.Output,
93+ Channel: coreCmd.Channel,
94+ DevicePart: coreCmd.Development.DevicePart,
95+ Oem: coreCmd.Oem,
96+ DeveloperMode: coreCmd.Development.DeveloperMode,
97+ },
98+ }
99+
100+ data, err := yaml.Marshal(&i)
101+ if err != nil {
102+ return err
103+ }
104+
105+ // the file isn't supposed to be modified, hence r/o.
106+ return ioutil.WriteFile(installYamlFilePath, data, 0444)
107+}
108+
109 func extractHWDescription(path string) (hw diskimage.HardwareDescription, err error) {
110 // hack to circumvent https://code.google.com/p/go/issues/detail?id=1435
111 if syscall.Getuid() == 0 {

Subscribers

People subscribed via source and target branches