Merge lp:~lutostag/charms/trusty/logstash/trunk+local-download-fix into lp:~lazypower/charms/trusty/logstash/trunk

Proposed by Greg Lutostanski on 2014-08-07
Status: Rejected
Rejected by: Charles Butler on 2014-10-27
Proposed branch: lp:~lutostag/charms/trusty/logstash/trunk+local-download-fix
Merge into: lp:~lazypower/charms/trusty/logstash/trunk
Diff against target: 45 lines (+11/-6)
1 file modified
hooks/install (+11/-6)
To merge this branch: bzr merge lp:~lutostag/charms/trusty/logstash/trunk+local-download-fix
Reviewer Review Type Date Requested Status
Charles Butler 2014-08-07 Pending
Review via email: mp+229997@code.launchpad.net

Description of the change

Just two minor fixes:
One to get downloaded files to work appropriately.
And do not try to install '' extra packages.

To post a comment you must log in.
Charles Butler (lazypower) wrote :

Greg, apologies on missing this merge - I've refactored the charm quite a bit and this no longer cleanly applies. I'll dig into this later and get it merged in.

Thanks for the fix!

Charles Butler (lazypower) wrote :

This was fixed in my latest upstream copy. Thanks for the contribution - i used it as a reference.

Unmerged revisions

19. By Greg Lutostanski on 2014-08-07

fix using downloaded logstash.tar.gz in charm/files and install of no extra packages by default

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'hooks/install'
2--- hooks/install 2014-07-24 13:26:45 +0000
3+++ hooks/install 2014-08-07 19:33:20 +0000
4@@ -8,6 +8,7 @@
5 import subprocess
6 import sys
7 import tarfile
8+import tempfile
9
10 sys.path.insert(0, os.path.join(os.environ['CHARM_DIR'], 'lib'))
11
12@@ -36,7 +37,7 @@
13 extra_packages = config('extra-packages')
14 apt_update(fatal=True)
15 apt_install(packages, fatal=True)
16- if extra_packages is not None:
17+ if extra_packages:
18 apt_install(extra_packages, fatal=True)
19
20 # Place default redis template
21@@ -82,15 +83,19 @@
22 sha.hexdigest()))
23
24 # Extract and move into place
25- extract_package(filename)
26+ extract_package(fpath)
27
28
29 def extract_package(filename):
30- t = tarfile.open(os.path.join(os.path.sep, 'tmp', filename))
31- t.extractall(path='.')
32+ tempdir = tempfile.mkdtemp()
33+ t = tarfile.open(filename)
34+ t.extractall(path=tempdir)
35 t.close()
36- basename = filename.rsplit('.', 2)[0]
37- shutil.move(basename, BASEPATH)
38+ dirnames = os.listdir(tempdir)
39+ if not len(dirnames) == 1:
40+ raise ValueError('Did not extract archive correctly to %s' % tempdir)
41+ shutil.move(os.path.join(tempdir, dirnames[0]), BASEPATH)
42+ shutil.rmtree(tempdir)
43
44
45 def create_skeleton():

Subscribers

People subscribed via source and target branches