Merge lp:~ogra/phablet-tools/phablet-tools-phablet-config-changes into lp:phablet-tools

Proposed by Oliver Grawert
Status: Merged
Approved by: Manuel de la Peña
Approved revision: 304
Merged at revision: 297
Proposed branch: lp:~ogra/phablet-tools/phablet-tools-phablet-config-changes
Merge into: lp:phablet-tools
Diff against target: 131 lines (+67/-23)
1 file modified
phablet-config (+67/-23)
To merge this branch: bzr merge lp:~ogra/phablet-tools/phablet-tools-phablet-config-changes
Reviewer Review Type Date Requested Status
Manuel de la Peña (community) Approve
PS Jenkins bot continuous-integration Approve
Martin Pitt Approve
Review via email: mp+231711@code.launchpad.net

Commit message

add changes to phablet-config autopilot and writable-image functions to work with the new adbd running as phablet (needs latest dbus-property-service on the device)

Description of the change

add changes to phablet-config autopilot and writable-image functions to work with the new adbd running as phablet (needs latest dbus-property-service on the device)

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
296. By Oliver Grawert

fix pep8 issues

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Martin Pitt (pitti) wrote :

I have some inline code comments which need to be addressed.

However, even with a fixed is_remote_root() this doesn't seem to work with the non-root adb, I still get AppArmor "DENIED" errors.

Revision history for this message
Martin Pitt (pitti) :
review: Needs Fixing
Revision history for this message
Martin Pitt (pitti) wrote :

Ah, that's because the previous code was synchronous, but the D-BUS call is asynchronous: When the gdbus returns apparmor_parser is still running in the background (for about one minute). So after that there should be a loop that waits for "pidof apparmor_parser" to be empty, perhaps with a timeout of 5 minutes?

297. By Oliver Grawert

fix the check for remote root in phablet-config

Revision history for this message
Martin Pitt (pitti) wrote :

Ugly as hell, but I confirmed this to work:

--- phablet-config 2014-08-25 10:47:35 +0000
+++ phablet-config 2014-08-25 11:04:29 +0000
@@ -116,6 +116,10 @@
                     '/com/canonical/PropertyService com.canonical.PropertyService.SetProperty ' \
                     'string:autopilot boolean:%s' % dbusarg
         adb.shell(dbus_call, False)
+ # wait until it is done; it takes a while to start apparmor_parser, so
+ # we need to wait a bit in advance
+ adb.shell('sleep 5; while pidof apparmor_parser; do sleep 5; done',
+ False)
     else:
         if args.dbus_probe == 'enable':
             rfile = '/usr/share/autopilot-touch/apparmor/click.rules'

Revision history for this message
Martin Pitt (pitti) wrote :

Meh, LP mistreating spaces. http://paste.ubuntu.com/8139757/ is the patch

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
298. By Oliver Grawert

add check if aa-clickhook has finished (thanks pitti)

299. By Oliver Grawert

make adb wait for teh device to come back after "writable reboot" when using the dbus call as well, also wait for teh network to be back

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
300. By Oliver Grawert

fix indendation in phablet-config

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
301. By Oliver Grawert

fix indendation even harder, add some spacing too

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Martin Pitt (pitti) wrote :

LGTM now, thanks!

review: Approve
302. By Oliver Grawert

add support for package installation when sudo passowrd is supplied on cmdline with phablet-config writable-image

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
303. By Oliver Grawert

fix pep8

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
304. By Oliver Grawert

more pep8 fixes

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Manuel de la Peña (mandel) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'phablet-config'
2--- phablet-config 2014-06-19 15:10:15 +0000
3+++ phablet-config 2014-08-29 08:52:17 +0000
4@@ -100,25 +100,63 @@
5 sys.exit(1)
6
7
8+def is_remote_root(adb):
9+ return adb.shell("id -ru").strip() == "0"
10+
11+
12 def _handle_autopilot(adb, args):
13- if args.dbus_probe == 'enable':
14- rfile = '/usr/share/autopilot-touch/apparmor/click.rules'
15- adb.shell('aa-clickhook -f --include=%s' % rfile)
16+ if not is_remote_root(adb):
17+ dbusarg = 'false'
18+ if args.dbus_probe == 'enable':
19+ dbusarg = 'true'
20+ dbus_call = 'dbus-send --system --print-reply --dest=com.canonical.PropertyService ' \
21+ '/com/canonical/PropertyService com.canonical.PropertyService.SetProperty ' \
22+ 'string:autopilot boolean:%s' % dbusarg
23+ adb.shell(dbus_call, False)
24+ # wait until it is done; it takes a while to start apparmor_parser, so
25+ # we need to wait a bit in advance
26+ adb.shell('sleep 5; while pidof apparmor_parser; do sleep 5; done',
27+ False)
28 else:
29- adb.shell('aa-clickhook -f')
30+ if args.dbus_probe == 'enable':
31+ rfile = '/usr/share/autopilot-touch/apparmor/click.rules'
32+ adb.shell('aa-clickhook -f --include=%s' % rfile)
33+ else:
34+ adb.shell('aa-clickhook -f')
35+
36+
37+def sudo_shell(adb, sudocmd, cmd):
38+ adb.shell('%s %s' % (sudocmd, cmd))
39
40
41 def _handle_writable_image(adb, args):
42- fname = '/userdata/.writable_image'
43- try:
44- adb.shell('test -e %s' % fname, False)
45- except CalledProcessError as e:
46- adb.shell('touch %s' % fname, False)
47- adb.reboot()
48- adb.wait_for_device()
49- adb.wait_for_network()
50-
51- try:
52+ if not is_remote_root(adb):
53+ dbus_call = 'dbus-send --system --print-reply --dest=com.canonical.PropertyService ' \
54+ '/com/canonical/PropertyService com.canonical.PropertyService.SetProperty ' \
55+ 'string:writable boolean:true'
56+ adb.shell(dbus_call, False)
57+ else:
58+ fname = '/userdata/.writable_image'
59+ try:
60+ adb.shell('test -e %s' % fname, False)
61+ except CalledProcessError as e:
62+ adb.shell('touch %s' % fname, False)
63+ adb.reboot()
64+
65+ adb.wait_for_device()
66+ adb.wait_for_network()
67+
68+ try:
69+ sudocmd = ''
70+ tempfile = ''
71+ if not is_remote_root(adb):
72+ tempfile = adb.shell('mktemp -t sudo_askpass.XXXX').rstrip()
73+
74+ adb.shell('/bin/echo -e \\"#!/bin/sh\necho %s \\" > %s ' %
75+ (args.sudopassword[0], tempfile), ignore_errors=False)
76+ adb.shell("chmod u+x %s" % tempfile)
77+ sudocmd = 'SUDO_ASKPASS=%s sudo -A' % tempfile
78+
79 if args.package_dir:
80 tmp_archive = create_temp_dir()
81 for package_dir in args.package_dir:
82@@ -145,27 +183,31 @@
83 pin_file.write(LOCAL_PIN_FILE)
84
85 adb.push(tmp_archive, '/tmp/archive')
86- adb.shell('mv /tmp/archive/00localrepo.list '
87- '/etc/apt/sources.list.d')
88- adb.shell('mv /tmp/archive/local-pin-1100 '
89- '/etc/apt/preferences.d')
90+ sudo_shell(adb, sudocmd, 'mv /tmp/archive/00localrepo.list '
91+ '/etc/apt/sources.list.d')
92+ sudo_shell(adb. sudocmd, 'mv /tmp/archive/local-pin-1100 '
93+ '/etc/apt/preferences.d')
94
95 if args.ppa:
96 for ppa in args.ppa:
97- adb.shell('add-apt-repository -y %s' % ppa, False)
98+ sudo_shell(adb, sudocmd, 'add-apt-repository -y %s' % ppa)
99
100 if args.package_dir or args.ppa:
101- adb.shell('apt-get update -qq')
102+ sudo_shell(adb, sudocmd, 'apt-get update -qq')
103
104 if args.package:
105 package = ' '.join(args.package)
106- adb.shell('apt-get install -yq --force-yes %s' % package, False)
107+ sudo_shell(adb, sudocmd,
108+ 'apt-get install -yq --force-yes %s' % package)
109
110 if args.package_dir:
111 # Remove the local archive
112- adb.shell('rm /etc/apt/sources.list.d/00localrepo.list')
113- adb.shell('rm /etc/apt/preferences.d/local-pin-1100')
114+ sudo_shell(adb, sudocmd,
115+ 'rm /etc/apt/sources.list.d/00localrepo.list')
116+ sudo_shell(adb, sudocmd,
117+ 'rm /etc/apt/preferences.d/local-pin-1100')
118 adb.shell('rm -rf /tmp/archive')
119+ adb.shell('rm -rf %s' % tempfile)
120
121 except CalledProcessError as e:
122 print(e)
123@@ -243,6 +285,8 @@
124 repository. Can be repeated.''')
125 dm.add_argument('-p', '--package', action='append',
126 help='Package to install. Can be repeated.')
127+ dm.add_argument('-s', '--sudopassword', action='append',
128+ help='Password to use for sudo on the device.')
129 dm.set_defaults(func=_handle_writable_image)
130
131 ei = sub.add_parser('edges-intro', help='Enable/disable the edges intro.')

Subscribers

People subscribed via source and target branches