Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Generation of copyright files #709

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion bloom/generators/debian/generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,12 @@
debug(traceback.format_exc())
error("empy was not detected, please install it.", exit=True)

try:
from ros_license_toolkit.package import get_packages_in_path
except ImportError:
debug(traceback.format_exc())
error("ros_license_toolkit was not detected, please install it.", exit=True)

# Fix unicode bug in empy
# This should be removed once upstream empy is fixed
# See: https://github.com/ros-infrastructure/bloom/issues/196
Expand All @@ -118,7 +124,6 @@
except NameError:
pass
# End fix

# Drop the first log prefix for this command
enable_drop_first_log_prefix(True)

Expand Down Expand Up @@ -467,6 +472,10 @@ def generate_substitutions_from_package(
# Summarize dependencies
summarize_dependency_mapping(data, depends, build_depends, resolved_deps)
# Copyright
package_path = os.path.abspath(os.path.dirname(package.filename))
pkg = get_packages_in_path(package_path)[0]
data['Copyright_file_content'] = pkg.get_copyright_file_contents()

licenses = []
for l in package.licenses:
if hasattr(l, 'file') and l.file is not None:
Expand Down
12 changes: 1 addition & 11 deletions bloom/generators/debian/templates/ament_cmake/copyright.em
Original file line number Diff line number Diff line change
@@ -1,11 +1 @@
Format: Bloom subset of https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/
Upstream-Name: @(Name)
@[if BugTracker]Upstream-Contact: @(BugTracker)@\n@[end if]@
@[if Source]Source: @(Source)@\n@[end if]@
@[for License, Text in Licenses]@

Files: See file headers in repository for details
Copyright: See package copyright in source code for details
License: @(License)
@(Text)
@[end for]@
@(Copyright_file_content)
12 changes: 1 addition & 11 deletions bloom/generators/debian/templates/ament_python/copyright.em
Original file line number Diff line number Diff line change
@@ -1,11 +1 @@
Format: Bloom subset of https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/
Upstream-Name: @(Name)
@[if BugTracker]Upstream-Contact: @(BugTracker)@\n@[end if]@
@[if Source]Source: @(Source)@\n@[end if]@
@[for License, Text in Licenses]@

Files: See file headers in repository for details
Copyright: See package copyright in source code for details
License: @(License)
@(Text)
@[end for]@
@(Copyright_file_content)
12 changes: 1 addition & 11 deletions bloom/generators/debian/templates/catkin/copyright.em
Original file line number Diff line number Diff line change
@@ -1,11 +1 @@
Format: Bloom subset of https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/
Upstream-Name: @(Name)
@[if BugTracker]Upstream-Contact: @(BugTracker)@\n@[end if]@
@[if Source]Source: @(Source)@\n@[end if]@
@[for License, Text in Licenses]@

Files: See file headers in repository for details
Copyright: See package copyright in source code for details
License: @(License)
@(Text)
@[end for]@
@(Copyright_file_content)
12 changes: 1 addition & 11 deletions bloom/generators/debian/templates/cmake/copyright.em
Original file line number Diff line number Diff line change
@@ -1,11 +1 @@
Format: Bloom subset of https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/
Upstream-Name: @(Name)
@[if BugTracker]Upstream-Contact: @(BugTracker)@\n@[end if]@
@[if Source]Source: @(Source)@\n@[end if]@
@[for License, Text in Licenses]@

Files: See file headers in repository for details
Copyright: See package copyright in source code for details
License: @(License)
@(Text)
@[end for]@
@(Copyright_file_content)
1 change: 1 addition & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
'PyYAML',
'rosdep >= 0.15.0',
'rosdistro >= 0.8.0',
'ros_license_toolkit >= 1.2.2',
'vcstools >= 0.1.22',
]

Expand Down
22 changes: 18 additions & 4 deletions test/system_tests/test_catkin_release.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,13 +82,19 @@ def create_upstream_repository(packages, directory=None, format_versions=None):
os.symlink('../{0}.h'.format(package), 'include/sym/{0}.h'.format(package))
user('mkdir debian')
user('touch debian/something.udev')
user('echo "{0} license" > LICENSE'.format(package))
user('echo "{0} license text" > LICENSE'.format(package))
user('echo "(c) 2010 {0} Inc.\n//comment\nsome sourcecode" > include/file.h'.format(package))
user('git add package.xml .cproject .project include debian "white space.txt~" LICENSE')
user('git commit -m "Releasing version 0.1.0" --allow-empty')
user('git tag 0.1.0 -m "Releasing version 0.1.0"')
return os.getcwd()


def _check_string_for_content(string, to_check):
assert string.count(to_check) == 1, \
">" + to_check + "< not found in:\n---\n" + string + "\n---"


def _test_unary_package_repository(release_dir, version, directory=None, env=None):
print("Testing in {0} at version {1}".format(release_dir, version))
with change_directory(release_dir):
Expand Down Expand Up @@ -236,7 +242,8 @@ def test_multi_package_repository(directory=None):
env.update(set_up_fake_rosdep(rosdep_dir, fake_distros, fake_rosdeps))
# Setup
pkgs = ['foo', 'bar_ros', 'baz']
upstream_dir = create_upstream_repository(pkgs, directory, format_versions=[1, 2, 3])
upstream_dir = create_upstream_repository(
pkgs, directory, format_versions=[1, 2, 3])
upstream_url = 'file://' + upstream_dir
release_url = create_release_repo(
upstream_url,
Expand Down Expand Up @@ -379,8 +386,15 @@ def test_multi_package_repository(directory=None):
package_xml).group(1))
# Is there a copyright file for this pkg?
with open('debian/copyright', 'r') as f:
assert (format_version <= 2) ^ (pkg + ' license' in f.read()), \
"debian/copyright does not include right license text"
copyright_file = f.read()
_check_string_for_content(copyright_file,
"Format: https://www.debian.org/doc/")
_check_string_for_content(copyright_file,
"License: BSD")
_check_string_for_content(copyright_file,
'Copyright: (c) 2010 ' + pkg + ' Inc.')
_check_string_for_content(copyright_file,
pkg + ' license text')

@in_temporary_directory
def test_upstream_tag_special_tag(directory=None):
Expand Down
Loading