Merge lp:~sergiusens/snappy/noUselessUpdate into lp:~snappy-dev/snappy/15.04-deprecated

Proposed by Sergio Schvezov on 2015-07-14
Status: Merged
Approved by: Sergio Schvezov on 2015-07-14
Approved revision: 461
Merged at revision: 460
Proposed branch: lp:~sergiusens/snappy/noUselessUpdate
Merge into: lp:~snappy-dev/snappy/15.04-deprecated
Diff against target: 50 lines (+30/-6)
1 file modified
snappy/systemimage.go (+30/-6)
To merge this branch: bzr merge lp:~sergiusens/snappy/noUselessUpdate
Reviewer Review Type Date Requested Status
Michael Vogt 2015-07-14 Approve on 2015-07-14
Review via email: mp+264665@code.launchpad.net

Commit Message

Only update bootloader files on newer versions or channel changes.

Description of the Change

Sorry, no tests, I started to look but it felt like too much. This will not fix versions in the past btw, hence the ./snappy from version 3 that follows ;-)

(BeagleBoneBlack)ubuntu@localhost:~$ snappy list --verbose
Name Date Version Developer
ubuntu-core 2015-06-10 3 ubuntu*
ubuntu-core 2015-07-13 4 ubuntu
beagleblack 2015-07-14 1.8 *
(BeagleBoneBlack)ubuntu@localhost:~$ md5sum /boot/uboot/a/VMLINUZ
baae473daca1d9fa2c2e998aab1c0bcc /boot/uboot/a/VMLINUZ
(BeagleBoneBlack)ubuntu@localhost:~$ md5sum /boot/uboot/a/INITRD.IMG
c42761096016a6a8813a3f718b24f777 /boot/uboot/a/INITRD.IMG
(BeagleBoneBlack)ubuntu@localhost:~$ md5sum /boot/uboot/b/VMLINUZ
462b31071b9f41c50ef05670ca764780 /boot/uboot/b/VMLINUZ
(BeagleBoneBlack)ubuntu@localhost:~$ md5sum /boot/uboot/b/INITRD.IMG
b4423a1dc0411a356b94ca487f118f61 /boot/uboot/b/INITRD.IMG
(BeagleBoneBlack)ubuntu@localhost:~$ sudo ./snappy update
Installing ubuntu-core (4)
Starting download of ubuntu-core
6.96 KB / 6.96 KB [=========================================] 100.00 % 423 B/s 0
Apply done
Updating boot files
6.96 KB / 6.96 KB [=======================================] 100.00 % 384 B/s 18s
Done
Name Date Version Developer
ubuntu-core 2015-07-13 4 ubuntu!
Reboot to use the new ubuntu-core.
(BeagleBoneBlack)ubuntu@localhost:~$ md5sum /boot/uboot/a/VMLINUZ
baae473daca1d9fa2c2e998aab1c0bcc /boot/uboot/a/VMLINUZ
(BeagleBoneBlack)ubuntu@localhost:~$ md5sum /boot/uboot/a/INITRD.IMG
c42761096016a6a8813a3f718b24f777 /boot/uboot/a/INITRD.IMG
(BeagleBoneBlack)ubuntu@localhost:~$ md5sum /boot/uboot/b/VMLINUZ
462b31071b9f41c50ef05670ca764780 /boot/uboot/b/VMLINUZ
(BeagleBoneBlack)ubuntu@localhost:~$ md5sum /boot/uboot/b/INITRD.IMG
b4423a1dc0411a356b94ca487f118f61 /boot/uboot/b/INITRD.IMG

To post a comment you must log in.
Michael Vogt (mvo) wrote :

Thanks for working on this, this is great! I will look into adding tests soon. One inline thing that I can probably answer once I added tests.

461. By Sergio Schvezov on 2015-07-14

Use VersionCompare for proper version comparisons

Michael Vogt (mvo) wrote :

Thanks a bunch! Nice work and nice finding! I guess I mentioned that I dislike the SyncbootloaderFiles and here is another reason why :) Fortunately we will get rid of it with the OS/kernel snaps (AFAICT at least).

Sergio Schvezov (sergiusens) wrote :

> Thanks a bunch! Nice work and nice finding! I guess I mentioned that I dislike
> the SyncbootloaderFiles and here is another reason why :) Fortunately we will
> get rid of it with the OS/kernel snaps (AFAICT at least).

Thanks, it is indeed an issue, also related to the fact that we are using system image here for something it wasn't designed for (going backwards and forwards again).

Michael Vogt (mvo) wrote :

I did not manage to add tests for this today, but feel free to land it, the code looks fine and its a improvement over what we have.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'snappy/systemimage.go'
2--- snappy/systemimage.go 2015-05-29 11:52:39 +0000
3+++ snappy/systemimage.go 2015-07-14 14:42:38 +0000
4@@ -189,12 +189,14 @@
5
6 // Ensure there is always a kernel + initrd to boot with, even
7 // if the update does not provide new versions.
8- if pb != nil {
9- pb.Notify("Syncing boot files")
10- }
11- err = s.partition.SyncBootloaderFiles()
12- if err != nil {
13- return "", err
14+ if s.needsBootAssetSync() {
15+ if pb != nil {
16+ pb.Notify("Syncing boot files")
17+ }
18+ err = s.partition.SyncBootloaderFiles()
19+ if err != nil {
20+ return "", err
21+ }
22 }
23
24 // find out what config file to use, the other partition may be
25@@ -475,3 +477,25 @@
26
27 return parts, err
28 }
29+
30+// needsSync determines if syncing boot assets is required
31+func (s *SystemImagePart) needsBootAssetSync() bool {
32+ // current partition
33+ curr := makeCurrentPart(s.partition)
34+ if curr == nil {
35+ // this should never ever happen
36+ panic("current part does not exist")
37+ }
38+
39+ // other partition
40+ other := makeOtherPart(s.partition)
41+ if other == nil {
42+ return true
43+ }
44+
45+ if curr.Channel() != other.Channel() {
46+ return false
47+ }
48+
49+ return VersionCompare(curr.Version(), other.Version()) > 0
50+}

Subscribers

People subscribed via source and target branches