Permalink
Browse files

repo: remove symlinks to libc. (#1100)

libc is never staged, as it's always contained in the core snap.
However, currently snapcraft leaves symlinks to its libraries alone and
intact, which causes issues when it comes to content sharing and
building against tarred staging areas. It also doesn't add any
functionality, as those libraries are in the standard library paths
anyway.

Instead of allowing those symlinks to dangle, remove them.

LP: #1658774

Signed-off-by: Kyle Fazzari <kyle@canonical.com>
  • Loading branch information...
1 parent 14873e9 commit 3052b0f459ded440dad2e2362946ee37e09c8606 @kyrofa kyrofa committed with sergiusens Feb 3, 2017
@@ -0,0 +1,18 @@
+name: staged-libc-links
+version: '0.1'
+summary: Attempt to stage libc6-dev twice
+description: |
+ Once by pulling it in via stage-packages, and the other time via
+ a tarred staging area. They should not conflict.
+
+grade: devel
+confinement: devmode
+
+parts:
+ from-package:
+ plugin: nil
+ stage-packages: [libc6-dev]
+
+ from-tar:
+ plugin: dump
+ source: stage.tar
@@ -45,3 +45,22 @@ def test_conflicts(self):
'`snapcraft help plugins`'
)
self.assertThat(exception.output, Contains(expected_help))
+
+ def test_staging_libc_links(self):
+ project_dir = 'staging_links_to_libc'
+
+ # First, stage libc6-dev via stage-packages
+ self.run_snapcraft(['stage', 'from-package'], project_dir)
+
+ # Now tar up the staging area
+ subprocess.check_call(['tar', 'cf', 'stage.tar', 'stage/'])
+
+ # Now attempt to stage the tarred staging area once again. This should
+ # not conflict.
+ try:
+ self.run_snapcraft(['stage', 'from-tar'], project_dir)
+ except subprocess.CalledProcessError as e:
+ if 'have the following file paths in common' in e.output:
+ self.fail('Parts unexpectedly conflicted')
+ else:
+ raise
View
@@ -479,8 +479,9 @@ def _fix_xml_tools(root):
def _fix_symlink(path, debdir, root):
target = os.path.join(debdir, os.readlink(path)[1:])
- if _skip_link(os.readlink(path)):
- logger.debug('Skipping {}'.format(target))
+ if _link_should_be_removed(os.readlink(path)):
+ logger.debug('Removing {}'.format(target))
+ os.remove(path)
return
if not os.path.exists(target) and not _try_copy_local(path, target):
return
@@ -504,16 +505,16 @@ def _fix_shebangs(path):
r'#!/usr/bin/env python\n')
-_skip_list = None
+_remove_list = None
-def _skip_link(target):
- global _skip_list
- if not _skip_list:
+def _link_should_be_removed(target):
+ global _remove_list
+ if not _remove_list:
output = common.run_output(['dpkg', '-L', 'libc6']).split()
- _skip_list = [i for i in output if 'lib' in i]
+ _remove_list = [i for i in output if 'lib' in i]
- return target in _skip_list
+ return target in _remove_list
def _try_copy_local(path, target):

0 comments on commit 3052b0f

Please sign in to comment.