[modified] Added an attribute for defining a destination directory. #210

Merged
merged 1 commit into from Jan 26, 2016

Conversation

Projects
None yet
4 participants
Contributor

rbreitenmoser commented Jan 8, 2016

The tar will be untared to the defined directory in the ../build and
../install directory from the snap. The new attribute "destination" is optional.

Extract from the spancraft.yaml
destination-dir:
plugin: tar-content
source: simple.tar.bz2
destination: destdir1/destdir2

Member

kyrofa commented Jan 8, 2016

I'm having trouble understanding why this change is necessary given we have all the organization keywords. Can you please explain?

Contributor

rbreitenmoser commented Jan 8, 2016

What do you mean with "organization keywords"? It has to do with this
https://bugs.launchpad.net/snapcraft/+bug/1478055.

On 8 January 2016 at 14:38, Kyle Fazzari notifications@github.com wrote:

I'm having trouble understanding why this change is necessary given we
have all the organization keywords. Can you please explain?


Reply to this email directly or view it on GitHub
ubuntu-core#210 (comment)
.

Member

kyrofa commented Jan 8, 2016

@rbreitenmoser please read our contributing guidelines. You're missing a few steps here.

Contributor

rbreitenmoser commented Jan 9, 2016

@kyrofa I saw, that I didn't made a feature branche on my fork. Should I make a new pull request and then you can delete this one? The Canonical Contributor Agreement should now be ok. Some tests are missing (coverage decreased)

@rbreitenmoser rbreitenmoser reopened this Jan 9, 2016

Member

kyrofa commented Jan 11, 2016

@rbreitenmoser you need to make sure your launchpad account is associated with the email address you used to commit, or we can't verify that you signed the CLA. Regarding the feature branch, no big deal. Just keep it in mind for the future.

Contributor

rbreitenmoser commented Jan 11, 2016

@kyrofa I added the email address, which I used to commit, also to my launchpad account. I hope it works now.

@@ -0,0 +1,84 @@
+# -*- Mode:Python; indent-tabs-mode:nil; tab-width:4 -*-
+#
+# Copyright (C) 2015 Canonical Ltd
@sergiusens

sergiusens Jan 12, 2016

Collaborator

2016

Member

kyrofa commented Jan 20, 2016

Verified CLA.

Member

kyrofa commented Jan 20, 2016

@rbreitenmoser please update the date as @sergiusens mentioned, and squash. Make sure the LP bug reference is on a line by itself in the commit message, after the title.

Contributor

rbreitenmoser commented Jan 24, 2016

Something went wrong with the squash. I will try to fix it tomorrow

Contributor

rbreitenmoser commented Jan 25, 2016

@kyrofa finally I got it :-) Everything squashed to one commit

Member

kyrofa commented Jan 25, 2016

@rbreitenmoser heh, you're so close! Your commit actually needs a meaningful title though-- swap the two lines, putting the LP bug reference on the second line. Instead of saying what needs to happen, say what the commit does, e.g. "tar-content plugin: Add ability to unpack into a specific destination directory" or something.

snapcraft/plugins/tar_content.py
+ raise ValueError('path "{}" must be relative'
+ .format(self.options.destination))
+
+ builddir = self.builddir + '/' + self.options.destination
@kyrofa

kyrofa Jan 25, 2016

Member

You probably want to use os.path.join() here, no?

snapcraft/plugins/tar_content.py
+ if not self.options.destination:
+ installdir = self.installdir
+ else:
+ installdir = self.installdir + '/' + self.options.destination
@kyrofa

kyrofa Jan 25, 2016

Member

os.path.join() here as well.

snapcraft/tests/test_plugin_copy.py
@@ -1,6 +1,6 @@
# -*- Mode:Python; indent-tabs-mode:nil; tab-width:4 -*-
#
-# Copyright (C) 2015 Canonical Ltd
+# Copyright (C) 2016 Canonical Ltd
@kyrofa

kyrofa Jan 25, 2016

Member

You didn't update this file-- why update its copyright?

Contributor

rbreitenmoser commented Jan 25, 2016

@kyrofa I updated everything based on your feedback. The travis build failed now, but I think id's not because of me.

travis --> W: Failed to fetch https://apt.dockerproject.org/repo/dists/ubuntu-trusty/main/binary-amd64/Packages gnutls_handshake() failed: Handshake failed

How can I restart the build without committing?

Member

kyrofa commented Jan 25, 2016

I restarted it for you.

Contributor

rbreitenmoser commented Jan 25, 2016

@kyrofa still no luck....

Member

kyrofa commented Jan 26, 2016

👍 from me. I'd like one more before merge.

integration_tests/test_tar_plugin.py
@@ -49,6 +50,8 @@ def test_stage_nil_plugin(self):
expected_dirs = [
'dir-simple',
'notopdir',
+ 'destdir1',
+ os.path.join('destdir1','destdir2')
]
for expected_dir in expected_dirs:
self.assertThat(
@elopio

elopio Jan 26, 2016

Member

Please update the copyright year in this file to be 2015, 2016.

+ if not os.path.exists(installdir):
+ os.makedirs(installdir)
+
+ self.tar.provision(installdir)
@elopio

elopio Jan 26, 2016

Member

Please update the copyright year in this file to be 2015, 2016.

integration_tests/test_tar_plugin.py
@@ -40,7 +40,8 @@ def test_stage_nil_plugin(self):
'notop',
'parent',
'slash',
- 'readonly_file'
+ 'readonly_file',
+ os.path.join('destdir1','destdir2','top-simple')
@elopio

elopio Jan 26, 2016

Member

You are missing spaces between the commas here. I wonder why the static tests are not catching this pep8 error.
os.path.join('destdir1', 'destdir2', 'top-simple')

integration_tests/test_tar_plugin.py
@@ -49,6 +50,8 @@ def test_stage_nil_plugin(self):
expected_dirs = [
'dir-simple',
'notopdir',
+ 'destdir1',
+ os.path.join('destdir1','destdir2')
@elopio

elopio Jan 26, 2016

Member

missing spaces.
os.path.join('destdir1', 'destdir2')

+ def setUp(self):
+ super().setUp()
+ # setup the expected target dir in our tempdir
+ self.build_prefix = 'parts/tarContent/build/'
@elopio

elopio Jan 26, 2016

Member

just a nit, because it's not common to find camel case in python code, I would write this as tar_content.

+ # setup the expected target dir in our tempdir
+ self.build_prefix = 'parts/tarContent/build/'
+ os.makedirs(self.build_prefix)
+ self.install_prefix = 'parts/tarContent/install/'
+ TarContentPlugin('tarContent', Options())
+
+ self.assertEqual(raised.exception.__str__(),
+ "path \"/destdir1\" must be relative")
@elopio

elopio Jan 26, 2016

Member

Using single quotes here is a little more readable.
'path "/destdir1" must be relative'

+
+ # create tar file for testing
+ os.mkdir('src')
+ fileToTar = os.path.join('src', 'test.txt')
@elopio

elopio Jan 26, 2016

Member

file_to_tar

+ tar.close()
+
+ t = TarContentPlugin('tarContent', Options())
+ t.build()
@elopio

elopio Jan 26, 2016

Member

one letter variables are not common in practice. I would call this plugin instead of t, or chain the build call, so you don't have to assign it to anything:
TarContentPlugin('tarContent', Options()).build()

Member

elopio commented Jan 26, 2016

lgtm. I just left some pain-in-the-ass style comments.
Thanks for your contribution @rbreitenmoser.

Contributor

rbreitenmoser commented Jan 26, 2016

@elopio no problem. I updated everything based on your feedback.

Member

kyrofa commented Jan 26, 2016

Excellent, thank you @rbreitenmoser!

kyrofa added a commit that referenced this pull request Jan 26, 2016

Merge pull request #210 from rbreitenmoser/master
tar-content plugin: Add ability to unpack into a specific destination directory.

@kyrofa kyrofa merged commit c10327c into snapcore:master Jan 26, 2016

2 checks passed

continuous-integration/travis-ci/pr The Travis CI build passed
Details
coverage/coveralls Coverage increased (+0.7%) to 91.193%
Details

smoser pushed a commit to smoser/snapcraft that referenced this pull request Sep 14, 2016

Implementation for RDMA driver handler (#210)
  + This functions as a base class. Distributions that support RDMA must
    implement a sub class and at least implement install_driver().

kalikiana pushed a commit to kalikiana/snapcraft that referenced this pull request Apr 6, 2017

Merge pull request #210 from rbreitenmoser/master
tar-content plugin: Add ability to unpack into a specific destination directory.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment