Merge lp:~florian-will/touch-preview-images/phablet-build-scripts-extract-from-sdcard into lp:touch-preview-images/phablet-build-scripts

Proposed by Florian W.
Status: Work in progress
Proposed branch: lp:~florian-will/touch-preview-images/phablet-build-scripts-extract-from-sdcard
Merge into: lp:touch-preview-images/phablet-build-scripts
Diff against target: 152 lines (+95/-19)
2 files modified
META-INF/com/google/android/updater-script (+28/-16)
ubuntu_data (+67/-3)
To merge this branch: bzr merge lp:~florian-will/touch-preview-images/phablet-build-scripts-extract-from-sdcard
Reviewer Review Type Date Requested Status
Florian W. (community) Needs Fixing
Ubuntu Phablet Team Pending
Review via email: mp+172300@code.launchpad.net

Description of the change

See the commit message for what this merge request does.

NB: I've used that modification for my Desire Z and it seems to work fine. However, I've only modified an existing (from cdimages.ubuntu.com) saucy armhf zip file to include the changes. I haven't actually tested if the build scripts as modified with this merge request yield a useable zip file because I don't use those scripts. So make sure the changes are sane before merging. After all, they might even contain syntax errors.. :-)

I also don't know if there are unwanted side-effects (like worse performance) for devices where the /data partition is big enough.

To post a comment you must log in.
Revision history for this message
Florian W. (florian-will) wrote :

See https://lists.launchpad.net/ubuntu-phone/msg02699.html

This won't work on some (most?) devices, so is not a good solution for the problem. I've replied to that mailing list post, but somehow my mails appear to get lost.

review: Needs Fixing
24. By Florian W.

Use /ext/sdcard or /sdcard only if /data is too small.

Unmerged revisions

24. By Florian W.

Use /ext/sdcard or /sdcard only if /data is too small.

23. By Florian W.

Extract ubuntu rootfs tarball from /sdcard instead of /data.
This works better for devices with small /data partitions.

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-28 06:52:42 +0000
3+++ META-INF/com/google/android/updater-script 2013-07-04 15:00:37 +0000
4@@ -5,21 +5,33 @@
5 show_progress(1.000000, 60);
6
7 ui_print("Mounting system and userdata partitions...");
8-run_program("/sbin/mount","/system");
9-run_program("/sbin/mount","/data");
10+if !is_mounted("/system") then run_program("/sbin/mount","/system"); endif;
11+if !is_mounted("/data") then run_program("/sbin/mount","/data"); endif;
12 set_progress(0.100000);
13
14-ui_print("Copying the ubuntu rootfs tarball...");
15-package_extract_file("#UBUNTUROOTFS#", "/data/ubuntu-rootfs.tar.gz");
16-package_extract_file("ubuntu_deploy.sh", "/tmp/ubuntu_deploy.sh");
17-set_perm(0, 0, 0777, "/tmp/ubuntu_deploy.sh");
18-set_progress(0.300000);
19-
20-ui_print("Deploying Ubuntu Touch...");
21-run_program("/tmp/ubuntu_deploy.sh");
22-set_progress(0.800000);
23-
24-unmount("/data");
25-unmount("/system");
26-run_program("/sbin/sync");
27-set_progress(1.000000);
28+package_extract_file("find_extract_location.sh", "/tmp/find_extract_location.sh");
29+set_perm(0, 0, 0777, "/tmp/find_extract_location.sh");
30+run_program("/tmp/find_extract_location.sh");
31+
32+ifelse(getprop("ubuntu.rootfs.extract.location") != "failed",
33+(
34+ ui_print("Copying the ubuntu rootfs tarball to");
35+ ui_print(getprop("ubuntu.rootfs.extract.location"));
36+ package_extract_file("#UBUNTUROOTFS#", getprop("ubuntu.rootfs.extract.location"));
37+ package_extract_file("ubuntu_deploy.sh", "/tmp/ubuntu_deploy.sh");
38+ set_perm(0, 0, 0777, "/tmp/ubuntu_deploy.sh");
39+ set_progress(0.300000);
40+
41+ ui_print("Deploying Ubuntu Touch...");
42+ run_program("/tmp/ubuntu_deploy.sh");
43+ set_progress(0.800000);
44+
45+ unmount("/data");
46+ unmount("/system");
47+ run_program("/sbin/sync");
48+ set_progress(1.000000);
49+),
50+(
51+ abort("No suitable temporary partition for file extraction found! Try wiping /data or make sure there's enough free space on your SD card.");
52+));
53+
54
55=== modified file 'ubuntu_data'
56--- ubuntu_data 2013-05-31 04:15:02 +0000
57+++ ubuntu_data 2013-07-04 15:00:37 +0000
58@@ -83,6 +83,7 @@
59 network_settings_bak=$ubuntu_bak/nm_connections
60
61 tmp_extract=/data/ubuntu_tmp_extract
62+tarball_location=$(/system/bin/getprop ubuntu.rootfs.extract.location)
63
64 backup() {
65 mkdir -p $ubuntu_bak
66@@ -111,13 +112,13 @@
67 }
68
69 deploy_ubuntu() {
70- echo "Deploying Ubuntu"
71+ echo "Deploying Ubuntu from tarball $tarball_location"
72 if [ -d $tmp_extract ]; then
73 rm -rf $tmp_extract
74 fi
75 mkdir $tmp_extract
76- tar --numeric-owner -xzf /data/ubuntu-rootfs.tar.gz -C $tmp_extract
77- rm /data/ubuntu-rootfs.tar.gz
78+ tar --numeric-owner -xzf $tarball_location -C $tmp_extract
79+ rm $tarball_location
80 if [ -d $ubuntu ]; then
81 rm -rf $ubuntu
82 fi
83@@ -137,6 +138,69 @@
84 restore $timezone $timezone_bak
85 EOF
86
87+cat > ${WORKDIR}/find_extract_location.sh << 'EOF'
88+#!/sbin/sh
89+
90+# threshold for free space on /data in kib
91+datafree_threshold=2097152
92+
93+# threshold for free space on sdcard in kib
94+sdfree_threshold=512000
95+
96+
97+# check if the given parameter $1 is
98+# * a mount point
99+# * has enough free space ($2 kib)
100+# if so, mount the partition, set the "ubuntu.rootfs.extract.location" property
101+# based on the partition path and return 0, otherwise do nothing and return 1.
102+check_mount() {
103+ echo "Checking $1.."
104+ is_valid_storage=1 # assume this is not a valid storage
105+
106+ mountpoint -q $1
107+ retcode=$?
108+ if [ $retcode -eq 0 ]; then # we have found a valid mount point..
109+
110+ # see if this needs to be mounted first
111+ if mount | grep "on $1 "; then
112+ is_mounted=0 # is already mounted!
113+ else
114+ echo "Mounting $1.."
115+ is_mounted=1 # not mounted yet!
116+ mount $1
117+ fi
118+
119+ # check free space on this partition
120+ freesize=$(df -P | grep $1 | awk '{ print $4 }')
121+ if [ -z $freesize ]; then freesize=0; fi
122+
123+ if [ $freesize -ge $2 ]; then
124+ /system/bin/setprop ubuntu.rootfs.extract.location "$1/tmp-ubuntu-rootfs.tar.gz"
125+ is_valid_storage=0 # success
126+ echo "Using $1!"
127+ else
128+ echo "$1: Not enough free space, only $freesize / $2 KiB"
129+ fi
130+
131+ # unmount if this was previously not mounted and is not valid storage
132+ if [ $is_mounted -eq 1 ] && [ $is_valid_storage -eq 1 ]; then
133+ echo "Unmounting $1.."
134+ umount $1
135+ fi
136+ fi
137+
138+ return $is_valid_storage
139+}
140+
141+# check possible locations (NB: mind the || at the end of each line)
142+check_mount "/data" $datafree_threshold ||
143+check_mount "/ext/sdcard" $sdfree_threshold ||
144+check_mount "/sdcard" $sdfree_threshold ||
145+/system/bin/setprop ubuntu.rootfs.extract.location "failed"
146+
147+sync
148+EOF
149+
150
151 # Create and publish the update zip file
152 cd ${WORKDIR}

Subscribers

People subscribed via source and target branches