diff --git a/superflore/generators/bitbake/gen_packages.py b/superflore/generators/bitbake/gen_packages.py index 7c9cd8fb..08cdfea5 100644 --- a/superflore/generators/bitbake/gen_packages.py +++ b/superflore/generators/bitbake/gen_packages.py @@ -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, @@ -238,4 +236,4 @@ def __init__( ) def recipe_text(self): - return self.recipe.get_recipe_text(org) + return self.recipe.get_recipe_text() diff --git a/superflore/generators/bitbake/run.py b/superflore/generators/bitbake/run.py index 88c9c4cd..39fc3f8f 100644 --- a/superflore/generators/bitbake/run.py +++ b/superflore/generators/bitbake/run.py @@ -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') diff --git a/superflore/generators/bitbake/yocto_recipe.py b/superflore/generators/bitbake/yocto_recipe.py index 9e413f6a..2fe00e81 100644 --- a/superflore/generators/bitbake/yocto_recipe.py +++ b/superflore/generators/bitbake/yocto_recipe.py @@ -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 @@ -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: @@ -534,8 +547,7 @@ def generate_superflore_datetime_inc(basepath, dist, now): datetime_file.write('# {}/generated/{}\n'.format( 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') + datetime_file.write('\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.' @@ -566,8 +578,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 ' diff --git a/superflore/generators/ebuild/ebuild.py b/superflore/generators/ebuild/ebuild.py index e4034572..33865231 100644 --- a/superflore/generators/ebuild/ebuild.py +++ b/superflore/generators/ebuild/ebuild.py @@ -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 = "" @@ -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 @@ -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= - 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 diff --git a/superflore/generators/ebuild/gen_packages.py b/superflore/generators/ebuild/gen_packages.py index 915ec519..393cf16f 100644 --- a/superflore/generators/ebuild/gen_packages.py +++ b/superflore/generators/ebuild/gen_packages.py @@ -39,8 +39,6 @@ no_python3 = ['tf'] -org = "Open Source Robotics Foundation" -org_license = "BSD" def regenerate_pkg(overlay, pkg, distro, preserve_existing=False): @@ -214,4 +212,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() diff --git a/superflore/generators/ebuild/run.py b/superflore/generators/ebuild/run.py index 866d4c52..fc876e89 100644 --- a/superflore/generators/ebuild/run.py +++ b/superflore/generators/ebuild/run.py @@ -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 @@ -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() diff --git a/superflore/parser.py b/superflore/parser.py index 184c984f..d3085b39 100644 --- a/superflore/parser.py +++ b/superflore/parser.py @@ -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