sources: support symlinks in deb sources #941

Merged
merged 4 commits into from Jan 3, 2017
View
@@ -58,7 +58,7 @@ If you don't have python3 installed, you can use the one from the archives:
Install the needed dependencies.
- sudo apt install build-essential python3-dev libapt-pkg-dev libsodium-dev gcc libffi-dev libarchive13 squashfs-tools xdelta3
+ sudo apt install build-essential python3-dev python3-debian libapt-pkg-dev libsodium-dev gcc libffi-dev libarchive13 squashfs-tools xdelta3
If installing to `PYTHONHOME` run:
View
@@ -8,6 +8,7 @@ Build-Depends: bash-completion,
pkg-config,
python3 (>= 3.4),
python3-apt,
+ python3-debian,
python3-docopt,
python3-fixtures,
python3-jsonschema,
@@ -38,6 +39,7 @@ Standards-Version: 3.9.8
Package: snapcraft
Architecture: all
Depends: python3-apt,
+ python3-debian,
python3-docopt,
python3-jsonschema,
python3-libarchive-c,
@@ -13,3 +13,6 @@ parts:
plugin: dump
source: small_0.1-1.deb
+ deb-with-symlink:
+ plugin: dump
+ source: symlink_1.0.deb
Binary file not shown.
@@ -16,7 +16,10 @@
import os
-from testtools.matchers import FileExists
+from testtools.matchers import (
+ Equals,
+ FileExists
+)
import integration_tests
@@ -25,11 +28,23 @@ class DebSourceTestCase(integration_tests.TestCase):
def test_stage_deb(self):
project_dir = self.copy_project_to_tmp('simple-deb')
- self.run_snapcraft('stage', project_dir)
+ self.run_snapcraft(['stage', 'deb'], project_dir)
self.assertThat(
os.path.join(project_dir, 'stage', 'bin', 'hello'),
FileExists())
self.assertThat(
os.path.join(project_dir, 'stage', 'usr', 'bin', 'world'),
FileExists())
+
+ # Regression test for LP: #1634813
+ def test_stage_deb_with_symlink(self):
+ project_dir = self.copy_project_to_tmp('simple-deb')
+ self.run_snapcraft(['stage', 'deb-with-symlink'], project_dir)
+
+ target = os.path.join(project_dir, 'stage', 'target')
+ symlink = os.path.join(project_dir, 'stage', 'symlink')
+ self.assertThat(target, FileExists())
+ self.assertThat(symlink, FileExists())
+ self.assertTrue(os.path.islink(symlink))
+ self.assertThat(os.readlink(symlink), Equals('target'))
View
@@ -16,3 +16,5 @@ pymacaroons==0.9.2
pymacaroons-pynacl==0.9.3
simplejson==3.8.2
tabulate==0.7.5
+python-debian==0.1.28
+chardet==2.3.0
@@ -14,7 +14,7 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
-import apt_inst
+import debian.debfile
import os
import shutil
import tempfile
@@ -49,8 +49,8 @@ def provision(self, dst, clean_target=True, keep_deb=False):
os.makedirs(dst)
shutil.move(tmp_deb, deb_file)
- deb = apt_inst.DebFile(deb_file)
- deb.data.extractall(dst)
+ deb = debian.debfile.DebFile(deb_file)
+ deb.data.tgz().extractall(dst)
if not keep_deb:
os.remove(deb_file)
@@ -27,7 +27,7 @@ class TestDeb(tests.FakeFileHTTPServerBasedTestCase):
def setUp(self):
super().setUp()
- patcher = mock.patch('apt_inst.DebFile')
+ patcher = mock.patch('debian.debfile.DebFile')
self.mock_deb = patcher.start()
self.addCleanup(patcher.stop)