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

Add "license-org" and "license-text" parameters #298

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
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
4 changes: 1 addition & 3 deletions superflore/generators/bitbake/gen_packages.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,6 @@
from superflore.utils import retry_on_exception
from superflore.utils import warn

org = "Open Source Robotics Foundation"


def regenerate_pkg(
overlay, pkg, rosdistro, preserve_existing, srcrev_cache,
Expand Down Expand Up @@ -238,4 +236,4 @@ def __init__(
)

def recipe_text(self):
return self.recipe.get_recipe_text(org)
return self.recipe.get_recipe_text()
5 changes: 5 additions & 0 deletions superflore/generators/bitbake/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,11 @@ def main():
args = parser.parse_args(sys.argv[1:])
pr_comment = args.pr_comment
skip_keys = set(args.skip_keys) if args.skip_keys else set()

if args.license_org:
yoctoRecipe.org = args.license_org
if args.license_text:
yoctoRecipe.org_license = args.license_text
if args.pr_only:
if args.dry_run:
parser.error('Invalid args! cannot dry-run and file PR')
Expand Down
22 changes: 17 additions & 5 deletions superflore/generators/bitbake/yocto_recipe.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,9 @@ class yoctoRecipe(object):
platform_deps = set()
max_component_name = 0

org = "Open Source Robotics Foundation"
org_license = ''

def __init__(
self, component_name, num_pkgs, pkg_name, pkg_xml, rosdistro, src_uri,
srcrev_cache, skip_keys
Expand Down Expand Up @@ -377,13 +380,23 @@ def get_dependencies(

return dependencies, system_dependencies

def get_recipe_text(self, distributor):
def get_recipe_license_line(self):
ret = "# Copyright " + yoctoRecipe.org + "\n"
if yoctoRecipe.org_license:
ret += "# Distributed under the terms of the "
ret += yoctoRecipe.org_license
ret += " license\n\n"
else:
ret += "\n"
return ret

def get_recipe_text(self):
"""
Generate the Yocto Recipe, given the distributor line
and the license text.
"""
ret = "# Generated by superflore -- DO NOT EDIT\n#\n"
ret += "# Copyright " + distributor + "\n\n"
ret += self.get_recipe_license_line()
ret += self.get_top_inherit_line()
# description
if self.description:
Expand Down Expand Up @@ -535,7 +548,7 @@ def generate_superflore_datetime_inc(basepath, dist, now):
dist, datetime_file_name))
datetime_file.write('# Generated by superflore -- DO NOT EDIT')
datetime_file.write(
'\n#\n# Copyright Open Source Robotics Foundation\n\n')
'\n#' + yoctoRecipe.get_recipe_license_line())
datetime_file.write(
'\n# The time, in UTC, associated with the last superflore'
+ ' run that resulted in a change to the generated files.'
Expand Down Expand Up @@ -566,8 +579,7 @@ def generate_ros_distro_inc(
conf_file.write('# Generated by superflore -- DO NOT EDIT')
conf_file.write(
' (except ROS_DISTRO_METADATA_VERSION_REVISION)\n#\n')
conf_file.write(
'# Copyright Open Source Robotics Foundation\n\n')
conf_file.write(yoctoRecipe.get_recipe_license_line())
conf_file.write(
'# Increment every time meta-ros is released because of '
+ 'a manually created change, ie, NOT as a result of a '
Expand Down
13 changes: 8 additions & 5 deletions superflore/generators/ebuild/ebuild.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,9 @@ class Ebuild(object):
Basic definition of an ebuild.
This is where any necessary variables will be filled.
"""
org = "Open Source Robotics Foundation"
org_license = "BSD"

def __init__(self):
self.eapi = str(6)
self.description = ""
Expand Down Expand Up @@ -101,10 +104,10 @@ def add_test_depend(self, tdepend, internal=True):
def add_keyword(self, keyword, stable=False):
self.keys.append(ebuild_keyword(keyword, stable))

def get_license_line(self, distributor, license_text):
def get_license_line(self):
ret = "# Copyright " + strftime("%Y", gmtime()) + " "
ret += distributor + "\n"
ret += "# Distributed under the terms of the " + license_text
ret += self.org + "\n"
ret += "# Distributed under the terms of the " + self.org_license
ret += " license\n\n"
return ret

Expand All @@ -130,13 +133,13 @@ def get_inherit_line(self):
else:
raise UnknownBuildType(self.build_type)

def get_ebuild_text(self, distributor, license_text):
def get_ebuild_text(self):
"""
Generate the ebuild in text, given the distributor line
and the license text.
"""
# EAPI=<eapi>
ret = self.get_license_line(distributor, license_text)
ret = self.get_license_line()
ret += self.get_eapi_line()
if self.python_3 and not self.is_ros2:
# enable python 2.7 and python 3.5
Expand Down
6 changes: 1 addition & 5 deletions superflore/generators/ebuild/gen_packages.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,6 @@

no_python3 = ['tf']

org = "Open Source Robotics Foundation"
org_license = "BSD"


def regenerate_pkg(overlay, pkg, distro, preserve_existing=False):
version = get_pkg_version(distro, pkg)
ebuild_name =\
Expand Down Expand Up @@ -214,4 +210,4 @@ def metadata_text(self):
return self.metadata_xml.get_metadata_text()

def ebuild_text(self):
return self.ebuild.get_ebuild_text(org, org_license)
return self.ebuild.get_ebuild_text()
6 changes: 6 additions & 0 deletions superflore/generators/ebuild/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
from superflore.generate_installers import generate_installers
from superflore.generators.ebuild.gen_packages import regenerate_pkg
from superflore.generators.ebuild.overlay_instance import RosOverlay
from superflore.generators.ebuild.ebuild import Ebuild
from superflore.parser import get_parser
from superflore.repo_instance import RepoInstance
from superflore.TempfileManager import TempfileManager
Expand All @@ -45,6 +46,11 @@ def main():
pr_comment = args.pr_comment
skip_keys = args.skip_keys or []
selected_targets = None

if args.license_org:
Ebuild.org = args.license_org
if args.license_text:
Ebuild.org_license = args.license_text
if not args.dry_run:
if 'SUPERFLORE_GITHUB_TOKEN' not in os.environ:
raise NoGitHubAuthToken()
Expand Down
10 changes: 10 additions & 0 deletions superflore/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,4 +82,14 @@ def get_parser(
nargs='+',
help='packages to skip during regeneration'
)
parser.add_argument(
'--license-org',
help='the distributor in copyright line of generated files',
type=str,
)
parser.add_argument(
'--license-text',
help='the license text in copyright line of generated files',
type=str,
)
return parser