def generate_pkgbuild(distro, package, directory, force=False, no_overwrite=False, recursive=False, update=False, exclude_dependencies=[], rosdep_urls=[], generated=None): """ Generate a PKGBUILD file for the given package and the given ROS distribution. """ if generated is None: generated = set() elif package.name in generated: return generated.add(package.name) if package.packages: for child_package in package.packages: generate_pkgbuild(distro, child_package, directory, force=force, exclude_dependencies=exclude_dependencies, no_overwrite=no_overwrite, recursive=recursive, update=update, rosdep_urls=rosdep_urls, generated=generated) # If this is a virtual package (i.e. not an actual package) if package.is_virtual: return if recursive: for dependency in package.run_dependencies + package.build_dependencies: if distro.is_package(dependency): generate_pkgbuild(distro, distro.package(dependency), directory, force=force, no_overwrite=no_overwrite, recursive=recursive, exclude_dependencies=exclude_dependencies, update=update, rosdep_urls=rosdep_urls, generated=generated) output_directory = os.path.join(directory, package.name) if not os.path.exists(output_directory): os.mkdir(output_directory) if os.path.exists(os.path.join(output_directory, 'PKGBUILD')): if no_overwrite: return if not force and query_yes_no( "Directory '%s' already contains a PKGBUILD file. Overwrite?" % ( output_directory)) == "no": return pkgbuild_file = os.path.join(output_directory, 'PKGBUILD') if update: if package.is_same_version(pkgbuild_file): print('PKGBUILD for package %s already up-to-date (%s)' % (colored(package.name, 'yellow', attrs=['bold']), colored(package.version + '-' + package.version_patch, 'white', attrs=['bold']))) return print('Generating PKGBUILD for package %s (%s)' % (colored(package.name, 'green', attrs=['bold']), colored(package.version + '-' + package.version_patch, 'white', attrs=['bold']))) with open(pkgbuild_file, 'w') as pkgbuild: pkgbuild.write(package.generate(distro.python_version, exclude_dependencies, rosdep_urls))
def generate_pkgbuild(distro, package, directory, force=False, no_overwrite=False, recursive=False, update=False, exclude_dependencies=[], rosdep_urls=[], generated=None, written=None): """ Generate a PKGBUILD file for the given package and the given ROS distribution. """ if generated is None: generated = set() elif package.name in generated: return generated.add(package.name) if distro._is_meta_package(package.name): for child_name in distro.meta_package_package_names(package.name): generate_pkgbuild(distro, distro.package(child_name), directory, force=force, exclude_dependencies=exclude_dependencies, no_overwrite=no_overwrite, recursive=recursive, update=update, rosdep_urls=rosdep_urls, generated=generated, written=written) # If this is a virtual package (i.e. not an actual package) if package.is_virtual: return if recursive: for dependency in package.run_dependencies + package.build_dependencies: if distro.is_package(dependency): generate_pkgbuild(distro, distro.package(dependency), directory, force=force, no_overwrite=no_overwrite, recursive=recursive, exclude_dependencies=exclude_dependencies, update=update, rosdep_urls=rosdep_urls, generated=generated, written=written) # If the directory/submodule does not exist, create it output_directory = create_package_directory(directory, package) # If PKGBUILD already exists if os.path.exists(os.path.join(output_directory, 'PKGBUILD')): if no_overwrite: return if not force and query_yes_no( "Directory '%s' already contains a PKGBUILD file. Overwrite?" % ( output_directory)) == "no": return pkgbuild_file = os.path.join(output_directory, 'PKGBUILD') # If we are merely updating packages if update: if package.is_same_version(pkgbuild_file): print('PKGBUILD for package %s already up-to-date (%s)' % (colored(package.name, 'yellow', attrs=['bold']), colored(package.version + '-' + package.version_patch, 'white', attrs=['bold']))) return print('Generating PKGBUILD for package %s (%s)' % (colored(package.name, 'green', attrs=['bold']), colored(package.version + '-' + package.version_patch, 'white', attrs=['bold']))) # Write PKGBUILD file with open(pkgbuild_file, 'w') as pkgbuild: pkgbuild.write(package.generate(distro.python_version, exclude_dependencies, rosdep_urls, output_directory)) if needs_finalize(output_directory): finalize_submodule(output_directory) # Add the package to the txt file containing packages to install if written: written["packages"].append(package.name)
def generate_pkgbuild(distro, package, directory, force=False, no_overwrite=False, recursive=False, update=False, exclude_dependencies=[], rosdep_urls=[], generated=None, written=None): """ Generate a PKGBUILD file for the given package and the given ROS distribution. """ if generated is None: generated = set() elif package.name in generated: return generated.add(package.name) if distro._is_meta_package(package.name): for child_name in distro.meta_package_package_names(package.name): generate_pkgbuild(distro, distro.package(child_name), directory, force=force, exclude_dependencies=exclude_dependencies, no_overwrite=no_overwrite, recursive=recursive, update=update, rosdep_urls=rosdep_urls, generated=generated, written=written) # If this is a virtual package (i.e. not an actual package) if package.is_virtual: return if recursive: for dependency in package.run_dependencies + package.build_dependencies: if distro.is_package(dependency): generate_pkgbuild(distro, distro.package(dependency), directory, force=force, no_overwrite=no_overwrite, recursive=recursive, exclude_dependencies=exclude_dependencies, update=update, rosdep_urls=rosdep_urls, generated=generated, written=written) # If the directory/repo/package does not exist, create it output_directory = create_package_directory(directory, package) pkgbuild_file = os.path.join(output_directory, 'PKGBUILD') # If we are merely updating packages if update: if package.is_same_version(pkgbuild_file): print('PKGBUILD for package %s already up-to-date (%s)' % (colored(package.name, 'yellow', attrs=['bold']), colored(package.version, 'white', attrs=['bold']))) return # If PKGBUILD already exists if os.path.exists(os.path.join(output_directory, 'PKGBUILD')): if no_overwrite: return elif not force and query_yes_no( "Directory '%s' already contains a PKGBUILD file. Overwrite?" % (output_directory)) == "no": return print('Generating PKGBUILD for package %s (%s)' % (colored(package.name, 'green', attrs=['bold']), colored(package.version, 'white', attrs=['bold']))) # Write PKGBUILD file with open(pkgbuild_file, 'w') as pkgbuild: pkgbuild.write( package.generate(distro.python_version, exclude_dependencies, rosdep_urls, output_directory)) # Add the package to the txt file containing packages to install if written: written["packages"].append(package.name)
def generate_pkgbuild(distro, package, directory, force=False, no_overwrite=False, recursive=False, update=False, exclude_dependencies=[], rosdep_urls=[], generated=None): if generated is None: generated = [] elif package.name in generated: return generated.append(package.name) if package.packages: for child_package in package.packages: generate_pkgbuild(distro, child_package, directory, force=force, exclude_dependencies=exclude_dependencies, no_overwrite=no_overwrite, recursive=recursive, update=update, rosdep_urls=rosdep_urls, generated=generated) if recursive: for dependency in package.run_dependencies + package.build_dependencies: if distro.is_package(dependency): generate_pkgbuild(distro, distro.package(dependency), directory, force=force, no_overwrite=no_overwrite, recursive=recursive, exclude_dependencies=exclude_dependencies, update=update, rosdep_urls=rosdep_urls, generated=generated) output_directory = os.path.join(directory, package.name) if not os.path.exists(output_directory): os.mkdir(output_directory) if os.path.exists(os.path.join(output_directory, 'PKGBUILD')): if no_overwrite: return if not force and query_yes_no( "Directory '%s' already contains a PKGBUILD file. Overwrite?" % (output_directory)) == "no": return pkgbuild_file = os.path.join(output_directory, 'PKGBUILD') if update: if package.is_same_version(pkgbuild_file): print('PKGBUILD for package %s already up-to-date (%s)' % (colored(package.name, 'yellow', attrs=['bold']), colored(package.version + '-' + package.version_patch, 'white', attrs=['bold']))) return print('Generating PKGBUILD for package %s (%s)' % (colored(package.name, 'green', attrs=['bold']), colored(package.version + '-' + package.version_patch, 'white', attrs=['bold']))) with open(pkgbuild_file, 'w') as pkgbuild: pkgbuild.write(package.generate(exclude_dependencies, rosdep_urls))