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

Proposed by Dimitri John Ledkov
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 Approve
Brian Murray Approve
PS Jenkins bot continuous-integration Approve
Benjamin Zeller 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.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
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.

Revision history for this message
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.

Revision history for this message
Dimitri John Ledkov (xnox) wrote :

ping, why was this still not merged?

Revision history for this message
Brian Murray (brian-murray) :
review: Approve
Revision history for this message
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?

Revision history for this message
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.

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

Can you merge trunk?

Revision history for this message
Brian Murray (brian-murray) wrote :

Is this useful anymore?

Unmerged revisions

62. By Dimitri John Ledkov

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

61. By Dimitri John Ledkov

Enable product_uuid on ubuntu-emulator.

Preview Diff

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

Subscribers

People subscribed via source and target branches