Merge lp:~sergiusens/snapcraft/1500505 into lp:~snappy-dev/snapcraft/core

Proposed by Sergio Schvezov
Status: Merged
Approved by: Sergio Schvezov
Approved revision: 235
Merged at revision: 234
Proposed branch: lp:~sergiusens/snapcraft/1500505
Merge into: lp:~snappy-dev/snapcraft/core
Diff against target: 106 lines (+44/-4)
4 files modified
plugins/jdk.yaml (+2/-0)
snapcraft/repo.py (+37/-3)
snapcraft/sources.py (+1/-1)
snapcraft/tests/test_repo.py (+4/-0)
To merge this branch: bzr merge lp:~sergiusens/snapcraft/1500505
Reviewer Review Type Date Requested Status
John Lenton (community) Approve
Review via email: mp+273826@code.launchpad.net

Commit message

Copy links to packages we did not download and also untarring not world writable.

Description of the change

I'm not sure I like this, if you look at the bug, most of the dangling symlinks are from libraries provided by libc6.

The one I haven't figured out how it go onto my system is the target for /usr/lib/jvm/java-7-openjdk-amd64/jre/lib/security/cacerts as no package owns it.

To post a comment you must log in.
Revision history for this message
John Lenton (chipaca) :
review: Approve
Revision history for this message
Snappy Tarmac (snappydevtarmac) wrote :

The attempt to merge lp:~sergiusens/snapcraft/1500505 into lp:snapcraft failed. Below is the output from the failed tests.

name: # the name of the snap
version: # the version of the snap
# The vendor for the snap (replace 'Vendor <email address hidden>')
vendor: Vendor <email address hidden>
summary: # 79 char long summary
description: # A longer description for the snap
icon: # A path to an icon for the package
cp --preserve=all -R zzz /tmp/tmpfqjb5zom/parts/copy/install/zzz
cp --preserve=all -R src /tmp/tmp4yykp3c4/parts/copy/install/dst
cp --preserve=all -R src /tmp/tmpo047wt4b/parts/copy/install/dir/dst

...................................Warning: unable to find "test_relexepath" in the path
............../tmp/tmp71nc0tyw/abs-to-b will be a dangling symlink
F.....................................................
======================================================================
FAIL: test_fix_symlinks (snapcraft.tests.test_repo.UbuntuTestCase)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/tmp/tarmac/branch.lg1XOE/snapcraft/tests/test_repo.py", line 84, in test_fix_symlinks
    self.assertEqual(os.readlink(tempdir + '/abs-to-b'), '/b')
AssertionError: 'b' != '/b'
- b
+ /b
? +

----------------------------------------------------------------------
Ran 103 tests in 2.933s

FAILED (failures=1)

lp:~sergiusens/snapcraft/1500505 updated
235. By Sergio Schvezov

fixing logic

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'plugins/jdk.yaml'
--- plugins/jdk.yaml 2015-07-20 21:11:39 +0000
+++ plugins/jdk.yaml 2015-10-08 19:26:03 +0000
@@ -0,0 +1,2 @@
1build-packages:
2 - ca-certificates-java
03
=== modified file 'snapcraft/repo.py'
--- snapcraft/repo.py 2015-10-05 16:56:10 +0000
+++ snapcraft/repo.py 2015-10-08 19:26:03 +0000
@@ -17,9 +17,11 @@
17import apt17import apt
18import glob18import glob
19import itertools19import itertools
20import logging
20import os21import os
21import platform22import platform
22import string23import string
24import shutil
23import subprocess25import subprocess
24import urllib26import urllib
25import urllib.request27import urllib.request
@@ -28,6 +30,8 @@
2830
29import snapcraft.common31import snapcraft.common
3032
33logger = logging.getLogger(__name__)
34
31_DEFAULT_SOURCES = \35_DEFAULT_SOURCES = \
32 '''deb http://${prefix}.ubuntu.com/${suffix}/ ${release} main restricted36 '''deb http://${prefix}.ubuntu.com/${suffix}/ ${release} main restricted
33deb http://${prefix}.ubuntu.com/${suffix}/ ${release}-updates main restricted37deb http://${prefix}.ubuntu.com/${suffix}/ ${release}-updates main restricted
@@ -232,6 +236,36 @@
232 path = os.path.join(root, entry)236 path = os.path.join(root, entry)
233 if os.path.islink(path) and os.path.isabs(os.readlink(path)):237 if os.path.islink(path) and os.path.isabs(os.readlink(path)):
234 target = os.path.join(debdir, os.readlink(path)[1:])238 target = os.path.join(debdir, os.readlink(path)[1:])
235 if os.path.exists(target):239 if _skip_link(os.readlink(path)):
236 os.remove(path)240 logger.debug('Skipping {}'.format(target))
237 os.symlink(os.path.relpath(target, root), path)241 continue
242 if not os.path.exists(target):
243 if not _try_copy_local(path, target):
244 continue
245 os.remove(path)
246 os.symlink(os.path.relpath(target, root), path)
247
248
249_skip_list = None
250
251
252def _skip_link(target):
253 global _skip_list
254 if not _skip_list:
255 output = snapcraft.common.run_output(['dpkg', '-L', 'libc6']).split()
256 _skip_list = [i for i in output if 'lib' in i]
257
258 return target in _skip_list
259
260
261def _try_copy_local(path, target):
262 real_path = os.path.realpath(path)
263 if os.path.exists(real_path):
264 logger.warning(
265 'Copying needed target link from the system {}'.format(real_path))
266 shutil.copyfile(os.readlink(path), target)
267 return True
268 else:
269 logger.warning(
270 '{} will be a dangling symlink'.format(path))
271 return False
238272
=== modified file 'snapcraft/sources.py'
--- snapcraft/sources.py 2015-10-05 16:56:10 +0000
+++ snapcraft/sources.py 2015-10-08 19:26:03 +0000
@@ -193,7 +193,7 @@
193 m.name = re.sub(r'^(\.{0,2}/)*', r'', m.name)193 m.name = re.sub(r'^(\.{0,2}/)*', r'', m.name)
194 # We mask all files to be writable to be able to easily194 # We mask all files to be writable to be able to easily
195 # extract on top.195 # extract on top.
196 m.mode = m.mode | 0o222196 m.mode = m.mode | 0o200
197 yield m197 yield m
198198
199 tar.extractall(members=filter_members(tar), path=dst)199 tar.extractall(members=filter_members(tar), path=dst)
200200
=== modified file 'snapcraft/tests/test_repo.py'
--- snapcraft/tests/test_repo.py 2015-10-05 16:56:10 +0000
+++ snapcraft/tests/test_repo.py 2015-10-08 19:26:03 +0000
@@ -14,6 +14,8 @@
14# You should have received a copy of the GNU General Public License14# You should have received a copy of the GNU General Public License
15# along with this program. If not, see <http://www.gnu.org/licenses/>.15# along with this program. If not, see <http://www.gnu.org/licenses/>.
1616
17import fixtures
18import logging
17import os19import os
18import tempfile20import tempfile
19import unittest.mock21import unittest.mock
@@ -64,6 +66,8 @@
64 self.assertFalse(mock_cc.called)66 self.assertFalse(mock_cc.called)
6567
66 def test_fix_symlinks(self):68 def test_fix_symlinks(self):
69 fake_logger = fixtures.FakeLogger(level=logging.ERROR)
70 self.useFixture(fake_logger)
67 tempdirObj = tempfile.TemporaryDirectory()71 tempdirObj = tempfile.TemporaryDirectory()
68 self.addCleanup(tempdirObj.cleanup)72 self.addCleanup(tempdirObj.cleanup)
69 tempdir = tempdirObj.name73 tempdir = tempdirObj.name

Subscribers

People subscribed via source and target branches