Merge lp:~townsend/libertine/update-package-cache into lp:libertine

Proposed by Christopher Townsend
Status: Merged
Approved by: Larry Price
Approved revision: 305
Merged at revision: 303
Proposed branch: lp:~townsend/libertine/update-package-cache
Merge into: lp:libertine
Diff against target: 122 lines (+21/-12)
3 files modified
python/libertine/ChrootContainer.py (+4/-4)
python/libertine/Libertine.py (+16/-7)
python/libertine/LxcContainer.py (+1/-1)
To merge this branch: bzr merge lp:~townsend/libertine/update-package-cache
Reviewer Review Type Date Requested Status
Libertine CI Bot continuous-integration Approve
Larry Price Approve
Review via email: mp+306220@code.launchpad.net

Commit message

Add a new update_apt_cache method and call that when needed, especially when installing new packages.

To post a comment you must log in.
Revision history for this message
Libertine CI Bot (libertine-ci-bot) wrote :

PASSED: Continuous integration, rev:303
https://jenkins.canonical.com/libertine/job/lp-libertine-ci/128/
Executed test runs:
    SUCCESS: https://jenkins.canonical.com/libertine/job/build/348
    SUCCESS: https://jenkins.canonical.com/libertine/job/test-0-autopkgtest/label=amd64,release=vivid+overlay,testname=default/281
    SUCCESS: https://jenkins.canonical.com/libertine/job/test-0-autopkgtest/label=amd64,release=xenial+overlay,testname=default/281
    SUCCESS: https://jenkins.canonical.com/libertine/job/test-0-autopkgtest/label=amd64,release=yakkety,testname=default/281
    SUCCESS: https://jenkins.canonical.com/libertine/job/test-0-autopkgtest/label=i386,release=vivid+overlay,testname=default/281
    SUCCESS: https://jenkins.canonical.com/libertine/job/test-0-autopkgtest/label=i386,release=xenial+overlay,testname=default/281
    SUCCESS: https://jenkins.canonical.com/libertine/job/test-0-autopkgtest/label=i386,release=yakkety,testname=default/281
    None: https://jenkins.canonical.com/libertine/job/lp-generic-update-mp/263/console
    SUCCESS: https://jenkins.canonical.com/libertine/job/build-0-fetch/350
    SUCCESS: https://jenkins.canonical.com/libertine/job/build-1-sourcepkg/release=vivid+overlay/333
    SUCCESS: https://jenkins.canonical.com/libertine/job/build-1-sourcepkg/release=xenial+overlay/333
    SUCCESS: https://jenkins.canonical.com/libertine/job/build-1-sourcepkg/release=yakkety/333
    SUCCESS: https://jenkins.canonical.com/libertine/job/build-2-binpkg/arch=amd64,release=vivid+overlay/332
        deb: https://jenkins.canonical.com/libertine/job/build-2-binpkg/arch=amd64,release=vivid+overlay/332/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/libertine/job/build-2-binpkg/arch=amd64,release=xenial+overlay/332
        deb: https://jenkins.canonical.com/libertine/job/build-2-binpkg/arch=amd64,release=xenial+overlay/332/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/libertine/job/build-2-binpkg/arch=amd64,release=yakkety/332
        deb: https://jenkins.canonical.com/libertine/job/build-2-binpkg/arch=amd64,release=yakkety/332/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/libertine/job/build-2-binpkg/arch=i386,release=vivid+overlay/332
        deb: https://jenkins.canonical.com/libertine/job/build-2-binpkg/arch=i386,release=vivid+overlay/332/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/libertine/job/build-2-binpkg/arch=i386,release=xenial+overlay/332
        deb: https://jenkins.canonical.com/libertine/job/build-2-binpkg/arch=i386,release=xenial+overlay/332/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/libertine/job/build-2-binpkg/arch=i386,release=yakkety/332
        deb: https://jenkins.canonical.com/libertine/job/build-2-binpkg/arch=i386,release=yakkety/332/artifact/output/*zip*/output.zip

Click here to trigger a rebuild:
https://jenkins.canonical.com/libertine/job/lp-libertine-ci/128/rebuild

review: Approve (continuous-integration)
Revision history for this message
Libertine CI Bot (libertine-ci-bot) wrote :

PASSED: Continuous integration, rev:304
https://jenkins.canonical.com/libertine/job/lp-libertine-ci/129/
Executed test runs:
    SUCCESS: https://jenkins.canonical.com/libertine/job/build/349
    SUCCESS: https://jenkins.canonical.com/libertine/job/test-0-autopkgtest/label=amd64,release=vivid+overlay,testname=default/282
    SUCCESS: https://jenkins.canonical.com/libertine/job/test-0-autopkgtest/label=amd64,release=xenial+overlay,testname=default/282
    SUCCESS: https://jenkins.canonical.com/libertine/job/test-0-autopkgtest/label=amd64,release=yakkety,testname=default/282
    SUCCESS: https://jenkins.canonical.com/libertine/job/test-0-autopkgtest/label=i386,release=vivid+overlay,testname=default/282
    SUCCESS: https://jenkins.canonical.com/libertine/job/test-0-autopkgtest/label=i386,release=xenial+overlay,testname=default/282
    SUCCESS: https://jenkins.canonical.com/libertine/job/test-0-autopkgtest/label=i386,release=yakkety,testname=default/282
    None: https://jenkins.canonical.com/libertine/job/lp-generic-update-mp/264/console
    SUCCESS: https://jenkins.canonical.com/libertine/job/build-0-fetch/351
    SUCCESS: https://jenkins.canonical.com/libertine/job/build-1-sourcepkg/release=vivid+overlay/334
    SUCCESS: https://jenkins.canonical.com/libertine/job/build-1-sourcepkg/release=xenial+overlay/334
    SUCCESS: https://jenkins.canonical.com/libertine/job/build-1-sourcepkg/release=yakkety/334
    SUCCESS: https://jenkins.canonical.com/libertine/job/build-2-binpkg/arch=amd64,release=vivid+overlay/333
        deb: https://jenkins.canonical.com/libertine/job/build-2-binpkg/arch=amd64,release=vivid+overlay/333/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/libertine/job/build-2-binpkg/arch=amd64,release=xenial+overlay/333
        deb: https://jenkins.canonical.com/libertine/job/build-2-binpkg/arch=amd64,release=xenial+overlay/333/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/libertine/job/build-2-binpkg/arch=amd64,release=yakkety/333
        deb: https://jenkins.canonical.com/libertine/job/build-2-binpkg/arch=amd64,release=yakkety/333/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/libertine/job/build-2-binpkg/arch=i386,release=vivid+overlay/333
        deb: https://jenkins.canonical.com/libertine/job/build-2-binpkg/arch=i386,release=vivid+overlay/333/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/libertine/job/build-2-binpkg/arch=i386,release=xenial+overlay/333
        deb: https://jenkins.canonical.com/libertine/job/build-2-binpkg/arch=i386,release=xenial+overlay/333/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/libertine/job/build-2-binpkg/arch=i386,release=yakkety/333
        deb: https://jenkins.canonical.com/libertine/job/build-2-binpkg/arch=i386,release=yakkety/333/artifact/output/*zip*/output.zip

Click here to trigger a rebuild:
https://jenkins.canonical.com/libertine/job/lp-libertine-ci/129/rebuild

review: Approve (continuous-integration)
305. By Christopher Townsend

Remove --force-yes for the update operation as it's not needed.

Revision history for this message
Larry Price (larryprice) wrote :

lgtm

review: Approve
Revision history for this message
Libertine CI Bot (libertine-ci-bot) wrote :

PASSED: Continuous integration, rev:305
https://jenkins.canonical.com/libertine/job/lp-libertine-ci/130/
Executed test runs:
    SUCCESS: https://jenkins.canonical.com/libertine/job/build/350
    SUCCESS: https://jenkins.canonical.com/libertine/job/test-0-autopkgtest/label=amd64,release=vivid+overlay,testname=default/283
    SUCCESS: https://jenkins.canonical.com/libertine/job/test-0-autopkgtest/label=amd64,release=xenial+overlay,testname=default/283
    SUCCESS: https://jenkins.canonical.com/libertine/job/test-0-autopkgtest/label=amd64,release=yakkety,testname=default/283
    SUCCESS: https://jenkins.canonical.com/libertine/job/test-0-autopkgtest/label=i386,release=vivid+overlay,testname=default/283
    SUCCESS: https://jenkins.canonical.com/libertine/job/test-0-autopkgtest/label=i386,release=xenial+overlay,testname=default/283
    SUCCESS: https://jenkins.canonical.com/libertine/job/test-0-autopkgtest/label=i386,release=yakkety,testname=default/283
    None: https://jenkins.canonical.com/libertine/job/lp-generic-update-mp/265/console
    SUCCESS: https://jenkins.canonical.com/libertine/job/build-0-fetch/352
    SUCCESS: https://jenkins.canonical.com/libertine/job/build-1-sourcepkg/release=vivid+overlay/335
    SUCCESS: https://jenkins.canonical.com/libertine/job/build-1-sourcepkg/release=xenial+overlay/335
    SUCCESS: https://jenkins.canonical.com/libertine/job/build-1-sourcepkg/release=yakkety/335
    SUCCESS: https://jenkins.canonical.com/libertine/job/build-2-binpkg/arch=amd64,release=vivid+overlay/334
        deb: https://jenkins.canonical.com/libertine/job/build-2-binpkg/arch=amd64,release=vivid+overlay/334/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/libertine/job/build-2-binpkg/arch=amd64,release=xenial+overlay/334
        deb: https://jenkins.canonical.com/libertine/job/build-2-binpkg/arch=amd64,release=xenial+overlay/334/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/libertine/job/build-2-binpkg/arch=amd64,release=yakkety/334
        deb: https://jenkins.canonical.com/libertine/job/build-2-binpkg/arch=amd64,release=yakkety/334/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/libertine/job/build-2-binpkg/arch=i386,release=vivid+overlay/334
        deb: https://jenkins.canonical.com/libertine/job/build-2-binpkg/arch=i386,release=vivid+overlay/334/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/libertine/job/build-2-binpkg/arch=i386,release=xenial+overlay/334
        deb: https://jenkins.canonical.com/libertine/job/build-2-binpkg/arch=i386,release=xenial+overlay/334/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/libertine/job/build-2-binpkg/arch=i386,release=yakkety/334
        deb: https://jenkins.canonical.com/libertine/job/build-2-binpkg/arch=i386,release=yakkety/334/artifact/output/*zip*/output.zip

Click here to trigger a rebuild:
https://jenkins.canonical.com/libertine/job/lp-libertine-ci/130/rebuild

review: Approve (continuous-integration)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'python/libertine/ChrootContainer.py'
--- python/libertine/ChrootContainer.py 2016-09-06 12:36:47 +0000
+++ python/libertine/ChrootContainer.py 2016-09-20 14:35:18 +0000
@@ -122,7 +122,7 @@
122 self.update_packages(verbosity)122 self.update_packages(verbosity)
123123
124 for package in self.default_packages:124 for package in self.default_packages:
125 if not self.install_package(package, verbosity):125 if not self.install_package(package, verbosity, update_cache=False):
126 print("Failure installing %s during container creation" % package)126 print("Failure installing %s during container creation" % package)
127 self.destroy_libertine_container()127 self.destroy_libertine_container()
128 return False128 return False
@@ -130,7 +130,7 @@
130 if self.installed_release == "vivid":130 if self.installed_release == "vivid":
131 if verbosity == 1:131 if verbosity == 1:
132 print("Installing the Vivid Stable Overlay PPA...")132 print("Installing the Vivid Stable Overlay PPA...")
133 if not self.install_package("software-properties-common", verbosity):133 if not self.install_package("software-properties-common", verbosity, update_cache=False):
134 print("Failure installing software-properties-common during container creation")134 print("Failure installing software-properties-common during container creation")
135 self.destroy_libertine_container()135 self.destroy_libertine_container()
136 return False136 return False
@@ -148,8 +148,8 @@
148 self._run_ldconfig(verbosity)148 self._run_ldconfig(verbosity)
149 return retcode149 return retcode
150150
151 def install_package(self, package_name, verbosity=1, readline=False):151 def install_package(self, package_name, verbosity=1, readline=False, update_cache=True):
152 returncode = super().install_package(package_name, verbosity, readline)152 returncode = super().install_package(package_name, verbosity, readline, update_cache)
153153
154 if returncode:154 if returncode:
155 self._run_ldconfig(verbosity)155 self._run_ldconfig(verbosity)
156156
=== modified file 'python/libertine/Libertine.py'
--- python/libertine/Libertine.py 2016-09-06 12:36:47 +0000
+++ python/libertine/Libertine.py 2016-09-20 14:35:18 +0000
@@ -133,16 +133,24 @@
133 """133 """
134 pass134 pass
135135
136 def update_apt_cache(self, verbosity=1):
137 """
138 Updates the apt cache in the container.
139
140 :param verbosity: the chattiness of the output on a range from 0 to 2
141 """
142 return self.run_in_container(apt_command_prefix(verbosity) + 'update')
143
136 def update_packages(self, verbosity=1):144 def update_packages(self, verbosity=1):
137 """145 """
138 Updates all packages installed in the container.146 Updates all packages installed in the container.
139147
140 :param verbosity: the chattiness of the output on a range from 0 to 2148 :param verbosity: the chattiness of the output on a range from 0 to 2
141 """149 """
142 self.run_in_container(apt_command_prefix(verbosity) + '--force-yes update')150 self.update_apt_cache(verbosity)
143 return self.run_in_container(apt_command_prefix(verbosity) + '--force-yes dist-upgrade')151 return self.run_in_container(apt_command_prefix(verbosity) + '--force-yes dist-upgrade')
144152
145 def install_package(self, package_name, verbosity=1, readline=False):153 def install_package(self, package_name, verbosity=1, readline=False, update_cache=True):
146 """154 """
147 Installs a named package in the container.155 Installs a named package in the container.
148156
@@ -150,6 +158,9 @@
150 a full path to a Debian package on the host.158 a full path to a Debian package on the host.
151 :param verbosity: the chattiness of the output on a range from 0 to 2159 :param verbosity: the chattiness of the output on a range from 0 to 2
152 """160 """
161 if update_cache:
162 self.update_apt_cache(verbosity)
163
153 if package_name.endswith('.deb'):164 if package_name.endswith('.deb'):
154 delete_package = self.copy_package_to_container(package_name)165 delete_package = self.copy_package_to_container(package_name)
155166
@@ -178,7 +189,7 @@
178 if should_enable:189 if should_enable:
179 ret = self.run_in_container("dpkg --add-architecture i386")190 ret = self.run_in_container("dpkg --add-architecture i386")
180 if ret or ret == 0:191 if ret or ret == 0:
181 self.run_in_container(apt_command_prefix(verbosity) + '--force-yes update')192 self.update_apt_cache(verbosity)
182 return ret193 return ret
183 else:194 else:
184 self.run_in_container(apt_command_prefix(verbosity) + "purge \".*:i386\"")195 self.run_in_container(apt_command_prefix(verbosity) + "purge \".*:i386\"")
@@ -193,10 +204,8 @@
193 :param verbosity: the chattiness of the output on a range from 0 to 2204 :param verbosity: the chattiness of the output on a range from 0 to 2
194 """205 """
195 if not os.path.exists(os.path.join(self.root_path, 'usr', 'bin', 'add-apt-repository')):206 if not os.path.exists(os.path.join(self.root_path, 'usr', 'bin', 'add-apt-repository')):
196 self.update_packages(verbosity)
197 self.install_package("software-properties-common", verbosity)207 self.install_package("software-properties-common", verbosity)
198 if 'https://' in archive and not os.path.exists(os.path.join(self.root_path, 'usr', 'lib', 'apt', 'methods', 'https')):208 if 'https://' in archive and not os.path.exists(os.path.join(self.root_path, 'usr', 'lib', 'apt', 'methods', 'https')):
199 self.update_packages(verbosity)
200 self.install_package("apt-transport-https", verbosity)209 self.install_package("apt-transport-https", verbosity)
201210
202 retcode = self.run_in_container("add-apt-repository -y " + archive)211 retcode = self.run_in_container("add-apt-repository -y " + archive)
@@ -332,13 +341,13 @@
332 except RuntimeError as e:341 except RuntimeError as e:
333 return handle_runtime_error(e)342 return handle_runtime_error(e)
334343
335 def install_package(self, package_name, verbosity=1, readline=False):344 def install_package(self, package_name, verbosity=1, readline=False, update_cache=True):
336 """345 """
337 Installs a package in the container.346 Installs a package in the container.
338 """347 """
339 try:348 try:
340 with ContainerRunning(self.container):349 with ContainerRunning(self.container):
341 return self.container.install_package(package_name, verbosity, readline)350 return self.container.install_package(package_name, verbosity, readline, update_cache)
342 except RuntimeError as e:351 except RuntimeError as e:
343 return handle_runtime_error(e)352 return handle_runtime_error(e)
344353
345354
=== modified file 'python/libertine/LxcContainer.py'
--- python/libertine/LxcContainer.py 2016-09-07 19:08:12 +0000
+++ python/libertine/LxcContainer.py 2016-09-20 14:35:18 +0000
@@ -240,7 +240,7 @@
240 self.update_packages(verbosity)240 self.update_packages(verbosity)
241241
242 for package in self.default_packages:242 for package in self.default_packages:
243 if not self.install_package(package, verbosity):243 if not self.install_package(package, verbosity, update_cache=False):
244 print("Failure installing %s during container creation" % package)244 print("Failure installing %s during container creation" % package)
245 self.destroy_libertine_container()245 self.destroy_libertine_container()
246 return False246 return False

Subscribers

People subscribed via source and target branches