Merge lp:~barry/ubuntu-system-image/citrain232 into lp:~ubuntu-managed-branches/ubuntu-system-image/system-image

Proposed by Barry Warsaw
Status: Merged
Approved by: Barry Warsaw
Approved revision: 237
Merged at revision: 235
Proposed branch: lp:~barry/ubuntu-system-image/citrain232
Merge into: lp:~ubuntu-managed-branches/ubuntu-system-image/system-image
Diff against target: 260 lines (+100/-22)
10 files modified
NEWS.rst (+6/-0)
PKG-INFO (+1/-1)
debian/changelog (+14/-0)
debian/control (+11/-10)
setup.cfg (+1/-1)
system_image.egg-info/PKG-INFO (+1/-1)
systemimage/settings.py (+28/-5)
systemimage/tests/test_config.py (+5/-2)
systemimage/tests/test_settings.py (+32/-1)
systemimage/version.txt (+1/-1)
To merge this branch: bzr merge lp:~barry/ubuntu-system-image/citrain232
Reviewer Review Type Date Requested Status
Ubuntu CI managed package branches Pending
Review via email: mp+229149@code.launchpad.net

Commit message

Description of the change

2.3.2 (2014-07-31)
==================
 * When system-image-{cli,dbus} is run as non-root, use a fallback location
   for the settings.db file, if the parent directory isn't writable.
   (LP: #1349478)

To post a comment you must log in.
236. By Barry Warsaw

* d/control:
  - Bump X-Python3-Version to (Python) 3.4.
  - Update run-time dependencies so that system-image-common now depends
    on python3-dbus and python3-xdg, while -dbus and -cli only need to
    depend on system-image-common.

237. By Barry Warsaw

bump version number for ppa happiness

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'NEWS.rst'
--- NEWS.rst 2014-07-23 22:51:19 +0000
+++ NEWS.rst 2014-08-01 18:33:04 +0000
@@ -2,6 +2,12 @@
2NEWS for system-image updater2NEWS for system-image updater
3=============================3=============================
44
52.3.2 (2014-07-31)
6==================
7 * When system-image-{cli,dbus} is run as non-root, use a fallback location
8 for the settings.db file, if the parent directory isn't writable.
9 (LP: #1349478)
10
52.3.1 (2014-07-23)112.3.1 (2014-07-23)
6==================12==================
7 * Fix a traceback that occurs when the `systemimage.testing` subpackage isn't13 * Fix a traceback that occurs when the `systemimage.testing` subpackage isn't
814
=== modified file 'PKG-INFO'
--- PKG-INFO 2014-07-23 17:56:24 +0000
+++ PKG-INFO 2014-08-01 18:33:04 +0000
@@ -1,6 +1,6 @@
1Metadata-Version: 1.01Metadata-Version: 1.0
2Name: system-image2Name: system-image
3Version: 2.3.13Version: 2.3.2
4Summary: Ubuntu System Image Based Upgrades4Summary: Ubuntu System Image Based Upgrades
5Home-page: UNKNOWN5Home-page: UNKNOWN
6Author: Barry Warsaw6Author: Barry Warsaw
77
=== modified file 'debian/changelog'
--- debian/changelog 2014-07-23 23:07:39 +0000
+++ debian/changelog 2014-08-01 18:33:04 +0000
@@ -1,3 +1,17 @@
1system-image (2.3.2-0ubuntu2) UNRELEASED; urgency=medium
2
3 * New upstream release.
4 - LP: #1349478 - When system-image-{cli,dbus} is run as non-root, use
5 a fallback location for the settings.db file, if the parent
6 directory isn't writable.
7 * d/control:
8 - Bump X-Python3-Version to (Python) 3.4.
9 - Update run-time dependencies so that system-image-common now depends
10 on python3-dbus and python3-xdg, while -dbus and -cli only need to
11 depend on system-image-common.
12
13 -- Barry Warsaw <barry@ubuntu.com> Fri, 01 Aug 2014 14:32:02 -0400
14
1system-image (2.3.1-0ubuntu1) utopic; urgency=medium15system-image (2.3.1-0ubuntu1) utopic; urgency=medium
216
3 [ Barry Warsaw ]17 [ Barry Warsaw ]
418
=== modified file 'debian/control'
--- debian/control 2014-07-17 18:11:57 +0000
+++ debian/control 2014-08-01 18:33:04 +0000
@@ -2,7 +2,7 @@
2Maintainer: Barry Warsaw <barry@ubuntu.com>2Maintainer: Barry Warsaw <barry@ubuntu.com>
3Homepage: https://wiki.ubuntu.com/ImageBasedUpgrades3Homepage: https://wiki.ubuntu.com/ImageBasedUpgrades
4Section: python4Section: python
5X-Python3-Version: >= 3.35X-Python3-Version: >= 3.4
6Priority: optional6Priority: optional
7Build-Depends: dbus,7Build-Depends: dbus,
8 dbus-x11,8 dbus-x11,
@@ -36,18 +36,19 @@
3636
37Package: system-image-dbus37Package: system-image-dbus
38Architecture: all38Architecture: all
39Depends: system-image-common (= ${binary:Version}),
40 ${misc:Depends},
41 ${python3:Depends}
42Description: Ubuntu system image updater command line client
43 This is the command line client for the Ubuntu system image updater.
44
45Package: system-image-common
46Architecture: all
39Depends: python3-dbus,47Depends: python3-dbus,
40 python3-gi,48 python3-gi,
41 system-image-common (= ${binary:Version}),49 python3-gnupg,
42 ${misc:Depends},
43 ${python3:Depends}
44Description: Ubuntu system image updater command line client
45 This is the command line client for the Ubuntu system image updater.
46
47Package: system-image-common
48Architecture: all
49Depends: python3-gnupg,
50 python3-pkg-resources,50 python3-pkg-resources,
51 python3-xdg,
51 ubuntu-download-manager,52 ubuntu-download-manager,
52 ${misc:Depends},53 ${misc:Depends},
53 ${python3:Depends}54 ${python3:Depends}
5455
=== modified file 'setup.cfg'
--- setup.cfg 2014-07-23 22:51:19 +0000
+++ setup.cfg 2014-08-01 18:33:04 +0000
@@ -4,7 +4,7 @@
4logging-filter = systemimage4logging-filter = systemimage
55
6[egg_info]6[egg_info]
7tag_svn_revision = 0
7tag_date = 08tag_date = 0
8tag_build = 9tag_build =
9tag_svn_revision = 0
1010
1111
=== modified file 'system_image.egg-info/PKG-INFO'
--- system_image.egg-info/PKG-INFO 2014-07-23 17:56:24 +0000
+++ system_image.egg-info/PKG-INFO 2014-08-01 18:33:04 +0000
@@ -1,6 +1,6 @@
1Metadata-Version: 1.01Metadata-Version: 1.0
2Name: system-image2Name: system-image
3Version: 2.3.13Version: 2.3.2
4Summary: Ubuntu System Image Based Upgrades4Summary: Ubuntu System Image Based Upgrades
5Home-page: UNKNOWN5Home-page: UNKNOWN
6Author: Barry Warsaw6Author: Barry Warsaw
77
=== modified file 'systemimage/settings.py'
--- systemimage/settings.py 2014-07-23 22:51:19 +0000
+++ systemimage/settings.py 2014-08-01 18:33:04 +0000
@@ -23,7 +23,9 @@
23import sqlite323import sqlite3
2424
25from contextlib import contextmanager25from contextlib import contextmanager
26from pathlib import Path
26from systemimage.config import config27from systemimage.config import config
28from xdg.BaseDirectory import xdg_cache_home
2729
28SCHEMA_VERSION = '1'30SCHEMA_VERSION = '1'
29AUTO_DOWNLOAD_DEFAULT = '1'31AUTO_DOWNLOAD_DEFAULT = '1'
@@ -32,7 +34,16 @@
32class Settings:34class Settings:
33 def __init__(self, use_config=None):35 def __init__(self, use_config=None):
34 self._use_config = use_config36 self._use_config = use_config
35 # If the database file does not yet exist, create it.37 # If the database file does not yet exist, create it. This could fail,
38 # as LP: #1349478 describes, if the parent directory containing
39 # settings.db is not writable by the process. In that case, fall back
40 # to a user path.
41 self._dbpath = None
42 try:
43 with self._cursor():
44 pass
45 except sqlite3.OperationalError:
46 self._check_fallback()
36 with self._cursor() as c:47 with self._cursor() as c:
37 c.execute('select tbl_name from sqlite_master')48 c.execute('select tbl_name from sqlite_master')
38 if len(c.fetchall()) == 0:49 if len(c.fetchall()) == 0:
@@ -43,12 +54,24 @@
43 c.execute('insert into settings values ("__version__", ?)',54 c.execute('insert into settings values ("__version__", ?)',
44 (SCHEMA_VERSION,))55 (SCHEMA_VERSION,))
4556
57 def _check_fallback(self):
58 # This is refactored into a separate method for testing purposes.
59 self._dbpath = Path(xdg_cache_home) / 'lib' / 'settings.db'
60 try:
61 self._dbpath.parent.mkdir(parents=True)
62 except FileExistsError:
63 # http://bugs.python.org/issue21539
64 pass
65 with self._cursor():
66 pass
67
46 @contextmanager68 @contextmanager
47 def _cursor(self):69 def _cursor(self):
48 dbpath = (config.system.settings_db70 if self._dbpath is None:
49 if self._use_config is None71 self._dbpath = (config.system.settings_db
50 else self._use_config.system.settings_db)72 if self._use_config is None
51 with sqlite3.connect(dbpath) as conn:73 else self._use_config.system.settings_db)
74 with sqlite3.connect(str(self._dbpath)) as conn:
52 yield conn.cursor()75 yield conn.cursor()
5376
54 def set(self, key, value):77 def set(self, key, value):
5578
=== modified file 'systemimage/tests/test_config.py'
--- systemimage/tests/test_config.py 2014-07-23 22:51:19 +0000
+++ systemimage/tests/test_config.py 2014-08-01 18:33:04 +0000
@@ -28,7 +28,7 @@
2828
29from datetime import timedelta29from datetime import timedelta
30from pkg_resources import resource_filename30from pkg_resources import resource_filename
31from subprocess import check_output31from subprocess import CalledProcessError, check_output
32from systemimage.config import Configuration32from systemimage.config import Configuration
33from systemimage.device import SystemProperty33from systemimage.device import SystemProperty
34from systemimage.reboot import Reboot34from systemimage.reboot import Reboot
@@ -198,7 +198,10 @@
198 config = Configuration()198 config = Configuration()
199 # Silence the log exceptions this will provoke.199 # Silence the log exceptions this will provoke.
200 with patch('systemimage.device.logging.getLogger'):200 with patch('systemimage.device.logging.getLogger'):
201 self.assertEqual(config.device, '?')201 # It's possible getprop actually does exist on the system.
202 with patch('systemimage.device.check_output',
203 side_effect=CalledProcessError(1, 'ignore')):
204 self.assertEqual(config.device, '?')
202205
203 @configuration206 @configuration
204 def test_get_channel(self, ini_file):207 def test_get_channel(self, ini_file):
205208
=== modified file 'systemimage/tests/test_settings.py'
--- systemimage/tests/test_settings.py 2014-07-23 22:51:19 +0000
+++ systemimage/tests/test_settings.py 2014-08-01 18:33:04 +0000
@@ -23,9 +23,13 @@
23import os23import os
24import unittest24import unittest
2525
26from contextlib import ExitStack
27from pathlib import Path
26from systemimage.config import Configuration28from systemimage.config import Configuration
29from systemimage.helpers import temporary_directory
27from systemimage.settings import Settings30from systemimage.settings import Settings
28from systemimage.testing.helpers import configuration31from systemimage.testing.helpers import chmod, configuration
32from unittest.mock import patch
2933
3034
31class TestSettings(unittest.TestCase):35class TestSettings(unittest.TestCase):
@@ -99,3 +103,30 @@
99 keyval = list(settings)103 keyval = list(settings)
100 keyval.sort()104 keyval.sort()
101 self.assertEqual(keyval, [('a', 'ant'), ('b', 'bee'), ('c', 'cat')])105 self.assertEqual(keyval, [('a', 'ant'), ('b', 'bee'), ('c', 'cat')])
106
107 @configuration
108 def test_settings_db_permission_denied(self, ini_file):
109 # LP: #1349478 - some tests are run as non-root, meaning they don't
110 # have write permission to /var/lib/system-image. This is where
111 # settings.db gets created, but if the process can't create files
112 # there, we get a sqlite3 exception.
113 config = Configuration(ini_file)
114 db_file = Path(config.system.settings_db)
115 self.assertFalse(db_file.exists())
116 with ExitStack() as resources:
117 resources.enter_context(chmod(str(db_file.parent), 0o555))
118 # With no fallback, this will fail.
119 with patch('systemimage.settings.Settings._check_fallback',
120 side_effect=RuntimeError):
121 self.assertRaises(RuntimeError, Settings)
122 # Now, set the XDG cache directory to a temporary directory, allow
123 # the fallback to work and try again.
124 tmpdir = resources.enter_context(temporary_directory())
125 resources.enter_context(
126 patch('systemimage.settings.xdg_cache_home', tmpdir))
127 settings = Settings()
128 settings.set('bar', 'baz')
129 self.assertEqual(Settings().get('bar'), 'baz')
130 # The settings.db file still doesn't exist because it got
131 # created in a different place.
132 self.assertFalse(db_file.exists())
102133
=== modified file 'systemimage/version.txt'
--- systemimage/version.txt 2014-07-23 22:51:19 +0000
+++ systemimage/version.txt 2014-08-01 18:33:04 +0000
@@ -1,1 +1,1 @@
12.3.112.3.2

Subscribers

People subscribed via source and target branches