Merge lp:~xnox/goget-ubuntu-touch/product-uuid into lp:goget-ubuntu-touch

Proposed by Dimitri John Ledkov on 2014-08-02
Status: Needs review
Proposed branch: lp:~xnox/goget-ubuntu-touch/product-uuid
Merge into: lp:goget-ubuntu-touch
Diff against target: 157 lines (+76/-1)
5 files modified
debian/control (+1/-0)
ubuntu-emulator/create.go (+4/-0)
ubuntu-emulator/diskimage/image.go (+10/-0)
ubuntu-emulator/run.go (+5/-1)
ubuntu-emulator/sysutils/stamp.go (+56/-0)
To merge this branch: bzr merge lp:~xnox/goget-ubuntu-touch/product-uuid
Reviewer Review Type Date Requested Status
Sergio Schvezov 2014-08-02 Approve on 2015-05-30
Brian Murray 2014-08-05 Approve on 2015-01-20
PS Jenkins bot continuous-integration Approve on 2014-08-02
Benjamin Zeller 2015-04-20 Pending
Review via email: mp+229315@code.launchpad.net

Commit message

Enable unique & persistent whoopsie ids, per ubuntu-emulator instance

Description of the change

Enable unique & persistent whoopsie ids, per ubuntu-emulator instance

To post a comment you must log in.
Brian Murray (brian-murray) wrote :

Do these changes allow one to manually set the CRASH_DB_IDENTIFIER? I ask as in bug 1324455 we want to be able to setup CRASH_DB_IDENTIFIER to start with deadbeef for systems under automated testing so that they are not counted in crash counters.

Otherwise this looks okay to me.

Dimitri John Ledkov (xnox) wrote :

On 17 September 2014 20:05, Brian Murray <email address hidden> wrote:
> Do these changes allow one to manually set the CRASH_DB_IDENTIFIER? I ask as in bug 1324455 we want to be able to setup CRASH_DB_IDENTIFIER to start with deadbeef for systems under automated testing so that they are not counted in crash counters.
>

yes.

> Otherwise this looks okay to me.
> --
> https://code.launchpad.net/~xnox/goget-ubuntu-touch/product-uuid/+merge/229315
> You are the owner of lp:~xnox/goget-ubuntu-touch/product-uuid.

--
Regards,

Dimitri.

Dimitri John Ledkov (xnox) wrote :

ping, why was this still not merged?

review: Approve
Sergio Schvezov (sergiusens) wrote :

Since we error on not being able to read the uuid, how are we going to communicate in a friendly way that people might need to regen their emulator images?

Dimitri John Ledkov (xnox) wrote :

No, that's not what the logic is.

Check if uuid exist, if not write it out.
Read uuid, return uuid.

Thus if it's non-existant it is created on the fly. Thus there is no regeneration required.

review: Approve
Sergio Schvezov (sergiusens) wrote :

Can you merge trunk?

Brian Murray (brian-murray) wrote :

Is this useful anymore?

Unmerged revisions

62. By Dimitri John Ledkov on 2014-08-02

Customize-in whoopsie-id, since !intel does not support dmi/id/product_uuid

61. By Dimitri John Ledkov on 2014-08-02

Enable product_uuid on ubuntu-emulator.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'debian/control'
--- debian/control 2014-06-18 20:57:12 +0000
+++ debian/control 2014-08-02 05:04:35 +0000
@@ -9,6 +9,7 @@
9 golang-go-flags-dev,9 golang-go-flags-dev,
10 golang-gocheck-dev,10 golang-gocheck-dev,
11 golang-pb-dev,11 golang-pb-dev,
12 golang-uuid-dev,
12Standards-Version: 3.9.513Standards-Version: 3.9.5
13Homepage: https://launchpad.net/goget-ubuntu-touch14Homepage: https://launchpad.net/goget-ubuntu-touch
14Vcs-Browser: http://bazaar.launchpad.net/~phablet-team/goget-ubuntu-touch/trunk/files15Vcs-Browser: http://bazaar.launchpad.net/~phablet-team/goget-ubuntu-touch/trunk/files
1516
=== modified file 'ubuntu-emulator/create.go'
--- ubuntu-emulator/create.go 2014-07-02 18:45:34 +0000
+++ ubuntu-emulator/create.go 2014-08-02 05:04:35 +0000
@@ -109,6 +109,10 @@
109 if os.MkdirAll(dataDir, 0700) != nil {109 if os.MkdirAll(dataDir, 0700) != nil {
110 return err110 return err
111 }111 }
112 //First generate UUID & Whoopsie-id as a regular user
113 if err = sysutils.WriteWhoopsieStamp(dataDir); err != nil {
114 return err
115 }
112116
113 fmt.Println("Setting up...")117 fmt.Println("Setting up...")
114 //This image will later be copied into sdcard.img as system.img and will hold the Ubuntu rootfs118 //This image will later be copied into sdcard.img as system.img and will hold the Ubuntu rootfs
115119
=== modified file 'ubuntu-emulator/diskimage/image.go'
--- ubuntu-emulator/diskimage/image.go 2014-07-02 18:45:34 +0000
+++ ubuntu-emulator/diskimage/image.go 2014-08-02 05:04:35 +0000
@@ -27,6 +27,7 @@
27 "io/ioutil"27 "io/ioutil"
28 "os"28 "os"
29 "os/exec"29 "os/exec"
30 "path"
30 "path/filepath"31 "path/filepath"
3132
32 "launchpad.net/goget-ubuntu-touch/ubuntu-emulator/sysutils"33 "launchpad.net/goget-ubuntu-touch/ubuntu-emulator/sysutils"
@@ -138,6 +139,15 @@
138 if err := img.unpackSystem(); err != nil {139 if err := img.unpackSystem(); err != nil {
139 return err140 return err
140 }141 }
142
143 dataDir := path.Dir(img.path)
144 //Generate unique instance .uuid and .whoopsie-id
145 whoopsieid, err := sysutils.ReadWhoopsieStamp(dataDir)
146 if err != nil {
147 return err
148 }
149 setupFiles = append(setupFiles, []setupFile{{"etc/init/whoopsie.override", "env CRASH_DB_IDENTIFIER=" + whoopsieid}}...)
150
141 for _, file := range setupFiles {151 for _, file := range setupFiles {
142 if err := img.writeFile(file); err != nil {152 if err := img.writeFile(file); err != nil {
143 return err153 return err
144154
=== modified file 'ubuntu-emulator/run.go'
--- ubuntu-emulator/run.go 2014-07-08 19:31:13 +0000
+++ ubuntu-emulator/run.go 2014-08-02 05:04:35 +0000
@@ -89,6 +89,10 @@
89 if err != nil {89 if err != nil {
90 return err90 return err
91 }91 }
92 uuid, err := sysutils.ReadUUIDStamp(dataDir)
93 if err != nil {
94 return err
95 }
92 var deviceInfo map[string]string96 var deviceInfo map[string]string
93 if d, ok := devices[device]; ok {97 if d, ok := devices[device]; ok {
94 deviceInfo = d98 deviceInfo = d
@@ -114,7 +118,7 @@
114 "-gpu", "on",118 "-gpu", "on",
115 "-scale", runCmd.Scale,119 "-scale", runCmd.Scale,
116 "-shell", "-no-jni", "-show-kernel", "-verbose",120 "-shell", "-no-jni", "-show-kernel", "-verbose",
117 "-qemu",121 "-qemu", "-uuid", uuid,
118 }122 }
119123
120 if cpu, ok := deviceInfo["cpu"]; ok {124 if cpu, ok := deviceInfo["cpu"]; ok {
121125
=== modified file 'ubuntu-emulator/sysutils/stamp.go'
--- ubuntu-emulator/sysutils/stamp.go 2014-04-23 18:09:19 +0000
+++ ubuntu-emulator/sysutils/stamp.go 2014-08-02 05:04:35 +0000
@@ -21,11 +21,15 @@
2121
22import (22import (
23 "bufio"23 "bufio"
24 "code.google.com/p/go-uuid/uuid"
25 "crypto/sha512"
26 "encoding/hex"
24 "encoding/json"27 "encoding/json"
25 "io/ioutil"28 "io/ioutil"
26 "launchpad.net/goget-ubuntu-touch/ubuntuimage"29 "launchpad.net/goget-ubuntu-touch/ubuntuimage"
27 "os"30 "os"
28 "path/filepath"31 "path/filepath"
32 "strings"
29)33)
3034
31func WriteDeviceStamp(dataDir, device string) (err error) {35func WriteDeviceStamp(dataDir, device string) (err error) {
@@ -42,6 +46,58 @@
42 return string(device), nil46 return string(device), nil
43}47}
4448
49func WriteUUIDStamp(dataDir string) (err error) {
50 path := filepath.Join(dataDir, ".uuid")
51 return ioutil.WriteFile(path, []byte(strings.ToUpper(uuid.New())), 0600)
52}
53
54func ReadUUIDStamp(dataDir string) (string, error) {
55 path := filepath.Join(dataDir, ".uuid")
56
57 if _, err := os.Stat(path); os.IsNotExist(err) {
58 err = WriteUUIDStamp(dataDir)
59 if err != nil {
60 return "", err
61 }
62 }
63
64 uuid, err := ioutil.ReadFile(path)
65 if err != nil {
66 return "", err
67 }
68 return string(uuid), nil
69}
70
71func WriteWhoopsieStamp(dataDir string) (err error) {
72 uuid, err := ReadUUIDStamp(dataDir)
73 if err != nil {
74 return err
75 }
76
77 path := filepath.Join(dataDir, ".whoopsie-id")
78 hasher := sha512.New()
79 hasher.Write([]byte(uuid))
80 hash := hex.EncodeToString(hasher.Sum(nil))
81 return ioutil.WriteFile(path, []byte(hash), 0600)
82}
83
84func ReadWhoopsieStamp(dataDir string) (string, error) {
85 path := filepath.Join(dataDir, ".whoopsie-id")
86
87 if _, err := os.Stat(path); os.IsNotExist(err) {
88 err = WriteWhoopsieStamp(dataDir)
89 if err != nil {
90 return "", err
91 }
92 }
93
94 whoopsieid, err := ioutil.ReadFile(path)
95 if err != nil {
96 return "", err
97 }
98 return string(whoopsieid), nil
99}
100
45func WriteStamp(dataDir string, image ubuntuimage.Image) (err error) {101func WriteStamp(dataDir string, image ubuntuimage.Image) (err error) {
46 path := filepath.Join(dataDir, ".stamp")102 path := filepath.Join(dataDir, ".stamp")
47 file, err := os.Create(path)103 file, err := os.Create(path)

Subscribers

People subscribed via source and target branches