Merge lp:~sergiusens/touch-preview-images/phablet-build-scripts into lp:touch-preview-images/phablet-build-scripts

Proposed by Sergio Schvezov
Status: Merged
Approved by: Ricardo Salveti
Approved revision: no longer in the source branch.
Merged at revision: 15
Proposed branch: lp:~sergiusens/touch-preview-images/phablet-build-scripts
Merge into: lp:touch-preview-images/phablet-build-scripts
Diff against target: 113 lines (+60/-28)
2 files modified
META-INF/com/google/android/updater-script (+4/-28)
ubuntu_data (+56/-0)
To merge this branch: bzr merge lp:~sergiusens/touch-preview-images/phablet-build-scripts
Reviewer Review Type Date Requested Status
Ricardo Salveti (community) Approve
Review via email: mp+163572@code.launchpad.net

Description of the change

Moved the image installation to a script to be more versatile.
Allow storing home and network settings when flashing a new image.

This initial changeset makes it inline to not affect current build system configurations.

To post a comment you must log in.
Revision history for this message
Ricardo Salveti (rsalveti) wrote :

8 +package_extract_file("ubuntu_deploy.sh", "/tmp/ubuntu_deploy.sh");
9 +set_perm(0, 0, 0777, "/tmp/ubuntu_deploy.sh");

Do we really have /tmp/ access at recovery? Never tested, downloading the tarball to test.

55 +cat > ${WORKDIR}/ubuntu_deploy.sh << 'EOF'
56 +#!/sbin/sh

Any reason for it not to be a separated script? If separated, also make sure to add a header with copyright and such.

61 +phablet_home_bak=/data/phablet_home
+network_settings_bak=/data/nm_connections

I'd prefer to use a common directory for backups, like /data/ubuntu_bak or similar, so we know where to find the files in case of a failure when flashing the image.

Rest looks fine, creating an image to test it.

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

> 8 +package_extract_file("ubuntu_deploy.sh", "/tmp/ubuntu_deploy.sh");
> 9 +set_perm(0, 0, 0777, "/tmp/ubuntu_deploy.sh");

We do have access to this, look at the system zip and the backup tool.

> Do we really have /tmp/ access at recovery? Never tested, downloading the
> tarball to test.
>
> 55 +cat > ${WORKDIR}/ubuntu_deploy.sh << 'EOF'
> 56 +#!/sbin/sh
>
> Any reason for it not to be a separated script? If separated, also make sure
> to add a header with copyright and such.

As per the description, I didn't want to interfere with the build system and add yet another parameter.

> 61 +phablet_home_bak=/data/phablet_home
> +network_settings_bak=/data/nm_connections
>
> I'd prefer to use a common directory for backups, like /data/ubuntu_bak or
> similar, so we know where to find the files in case of a failure when flashing
> the image.

Will do this.

> Rest looks fine, creating an image to test it.

Great, works nice from what I tried :-)

Revision history for this message
Ricardo Salveti (rsalveti) wrote :

Good, thanks!

review: Approve
15. By Sergio Schvezov

Moved the image installation to a script to be more versatile. Allow storing home and network settings when flashing a new image.

This initial changeset makes it inline to not affect current build system configurations.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'META-INF/com/google/android/updater-script'
2--- META-INF/com/google/android/updater-script 2013-05-10 16:37:41 +0000
3+++ META-INF/com/google/android/updater-script 2013-05-13 22:04:23 +0000
4@@ -10,38 +10,14 @@
5
6 ui_print("Copying the ubuntu rootfs tarball...");
7 package_extract_file("#UBUNTUROOTFS#", "/data/ubuntu-rootfs.tar.gz");
8+package_extract_file("ubuntu_deploy.sh", "/tmp/ubuntu_deploy.sh");
9+set_perm(0, 0, 0777, "/tmp/ubuntu_deploy.sh");
10 set_progress(0.300000);
11
12-ui_print("Extracting the ubuntu rootfs tarball...");
13-delete_recursive("/data/ubuntu_tmp_extract");
14-run_program("/sbin/mkdir", "/data/ubuntu_tmp_extract");
15-run_program("/sbin/tar", "--numeric-owner", "-xzf", "/data/ubuntu-rootfs.tar.gz", "-C", "/data/ubuntu_tmp_extract");
16-set_progress(0.600000);
17-
18-ui_print("Saving phablet home...");
19-run_program("/sbin/mv", "/data/ubuntu/home/phablet", "/data/phablet_home");
20-ui_print("Saving network settings...");
21-run_program("/sbin/mv", "/data/ubuntu/etc/NetworkManager/system-connections", "/data/nm_connections");
22-set_progress(0.700000);
23-
24-ui_print("Setting up the new ubuntu rootfs...");
25-delete_recursive("/data/ubuntu");
26-run_program("/sbin/mv", "/data/ubuntu_tmp_extract/binary", "/data/ubuntu");
27+ui_print("Deploying Ubuntu Touch...");
28+run_program("/tmp/ubuntu_deploy.sh");
29 set_progress(0.800000);
30
31-ui_print("Restoring phablet home...");
32-delete_recursive("/data/ubuntu/home/phablet");
33-run_program("/sbin/mv", "/data/phablet_home", "/data/ubuntu/home/phablet");
34-ui_print("Restoring network settings...");
35-delete_recursive("/data/ubuntu/etc/NetworkManager/system-connections");
36-run_program("/sbin/mv", "/data/nm_connections", "/data/ubuntu/etc/NetworkManager/system-connections");
37-set_progress(0.850000);
38-
39-ui_print("Cleaning up");
40-delete("/data/ubuntu-rootfs.tar.gz");
41-delete_recursive("/data/ubuntu_tmp_extract");
42-set_progress(0.900000);
43-
44 unmount("/data");
45 run_program("/sbin/sync");
46 set_progress(1.000000);
47
48=== modified file 'ubuntu_data'
49--- ubuntu_data 2013-05-01 05:48:50 +0000
50+++ ubuntu_data 2013-05-13 22:04:23 +0000
51@@ -61,6 +61,62 @@
52 cp -av ${ROOTFS} ${WORKDIR}
53 IMAGE=$(basename $ROOTFS)
54 sed -i "s/#UBUNTUROOTFS#/$IMAGE/" ${WORKDIR}/META-INF/com/google/android/updater-script
55+cat > ${WORKDIR}/ubuntu_deploy.sh << 'EOF'
56+#!/sbin/sh
57+
58+ubuntu=/data/ubuntu
59+ubuntu_bak=/data/ubuntu_bak
60+
61+phablet_home=$ubuntu/home/phablet
62+phablet_home_bak=$ubuntu_bak/home
63+
64+network_settings=$ubuntu/etc/NetworkManager/system-connections
65+network_settings_bak=$ubuntu_bak/nm_connections
66+
67+tmp_extract=/data/ubuntu_tmp_extract
68+
69+backup() {
70+ mkdir -p $ubuntu_bak
71+ if [ -d $2 ]; then
72+ echo "Removing previous backout of $1"
73+ rm -rf $2
74+ fi
75+ if [ -d $1 ]; then
76+ echo "Backing up $1 to $2"
77+ mv $1 $2
78+ fi
79+}
80+
81+restore() {
82+ if [ -d $2 ]; then
83+ echo "Restoring $1 from $2"
84+ rm -rf $1
85+ mv $2 $1
86+ fi
87+}
88+
89+deploy_ubuntu() {
90+ echo "Deploying Ubuntu"
91+ if [ -d $tmp_extract ]; then
92+ rm -rf $tmp_extract
93+ fi
94+ mkdir $tmp_extract
95+ tar --numeric-owner -xzf /data/ubuntu-rootfs.tar.gz -C $tmp_extract
96+ rm /data/ubuntu-rootfs.tar.gz
97+ if [ -d $ubuntu ]; then
98+ rm -rf $ubuntu
99+ fi
100+ mv $tmp_extract/binary $ubuntu
101+ rm -rf $tmp_extract
102+}
103+
104+backup $phablet_home $phablet_home_bak
105+backup $network_settings $network_settings_bak
106+deploy_ubuntu
107+restore $phablet_home $phablet_home_bak
108+restore $network_settings $network_settings_bak
109+EOF
110+
111
112 # Create and publish the update zip file
113 cd ${WORKDIR}

Subscribers

People subscribed via source and target branches