def generic_to_specific_recipe(generic_data): """Return a mapping representing the target specific recipe data based on the @generic_data""" # XXX: perhaps the generic and target-specific data # should be made available to the template engine as two # different instances? # YES, or more # recipe.InputAttribute # linux.LinuxSpecificAttribute # archlinux.ArchLinuxSpecificAttribute specific_data = {} specific_data.update(generic_data) buildsystem_type = generic_data['BuildSystemType'] if buildsystem_type == 'autotools': build_commands = ['./configure --prefix=/usr', 'make'] install_commands = ['make DESTDIR="$pkgdir" install'] elif buildsystem_type == 'distutils': build_commands = [''] if generic_data['ProjectType'].startswith('python2'): install_commands = ['python2 setup.py install --root="$pkgdir/"'] elif generic_data['ProjectType'].startswith('python3'): install_commands = ['python setup.py install --root="$pkgdir/"'] if generic_data['ProjectType'].startswith('python2'): if not 'executable:python2' in generic_data['Dependencies']: generic_data['Dependencies'].append('executable:python2') if generic_data['ProjectType'].startswith('python3'): if not 'executable:python' in generic_data['Dependencies']: generic_data['Dependencies'].append('executable:python') specific_data['BuildCommands'] = build_commands specific_data['InstallCommands'] = install_commands # Resolve dependencies to native packages specific_data['Dependencies'] = [] for dep in generic_data['Dependencies']: specific_data['Dependencies'].append(linux.map_dependency(dep, map_installed_file_to_package)) specific_data['BuildDependencies'] = [] for dep in generic_data['BuildDependencies']: specific_data['BuildDependencies'].append(linux.map_dependency(dep, map_installed_file_to_package)) specific_data['SupportedArchitectures'] = archlinux_architectures return specific_data
def generic_to_specific_recipe(generic_data): """Return a mapping representing the target specific recipe data based on the @generic_data""" # XXX: perhaps the generic and target-specific data # should be made available to the template engine as two # different instances? specific_data = {} specific_data.update(generic_data) build_commands = ['%configure --disable-static', 'make %{?jobs:-j%jobs}'] install_commands = ['%makeinstall', 'find %{buildroot} -type f -name "*.la" -delete -print'] specific_data['BuildCommands'] = build_commands specific_data['InstallCommands'] = install_commands file_to_package = pkgkit.package_from_file_packagekit_subprocess # Resolve dependencies to native packages specific_data['Dependencies'] = [] for dep in generic_data['Dependencies']: specific_data['Dependencies'].append(linux.map_dependency(dep, file_to_package)) specific_data['BuildDependencies'] = [] for dep in generic_data['BuildDependencies']: specific_data['BuildDependencies'].append(linux.map_dependency(dep, file_to_package)) specific_data['PrepCommands'] = ['%setup -q'] specific_data['CleanCommands'] = ['rm -rf %{buildroot}'] if generic_data['ProjectType'].endswith('application'): specific_data['Files'] = """%defattr(-,root,root) %{_bindir}/* %{_datadir}/*""" elif generic_data['ProjectType'] == 'c-library': specific_data['Files'] = """%defattr(-,root,root) %{_includedir}/* %{_libdir}/*""" # TODO: only if the package is of type=library or similar update_ldconfig = '-p /sbin/ldconfig' specific_data['PostUninstall'] = update_ldconfig specific_data['PostInstall'] = update_ldconfig return specific_data