Commit 742aaffc authored by Simon McVittie's avatar Simon McVittie

Do not modify GamePackage.component in-place

parent 1bbbb2a8
...@@ -231,6 +231,11 @@ class PackagingTask(object): ...@@ -231,6 +231,11 @@ class PackagingTask(object):
# 'usr/share/games/quake3-data/baseq3/pak0.pk3': '1197ca...' } # 'usr/share/games/quake3-data/baseq3/pak0.pk3': '1197ca...' }
self.package_md5sums = {} self.package_md5sums = {}
# Components for packages, possibly modified: if the license
# for a freely redistributable game is missing, we demote it from
# main or non-free to local (i.e. non-distributable).
self.package_components = {}
# Found CD tracks # Found CD tracks
# e.g. { 'quake-music': { 2: '/usr/.../id1/music/track02.ogg' } } # e.g. { 'quake-music': { 2: '/usr/.../id1/music/track02.ogg' } }
self.cd_tracks = {} self.cd_tracks = {}
...@@ -1189,10 +1194,10 @@ class PackagingTask(object): ...@@ -1189,10 +1194,10 @@ class PackagingTask(object):
'usr/share/doc/%s/%s' % (package.name, 'usr/share/doc/%s/%s' % (package.name,
license_file)) license_file))
if package.component == 'local': if self.package_components[package.name] == 'local':
o.write('It contains proprietary game data ' o.write('It contains proprietary game data '
'and must not be redistributed.\n\n') 'and must not be redistributed.\n\n')
elif package.component == 'non-free': elif self.package_components[package.name] == 'non-free':
o.write('It contains proprietary game data ' o.write('It contains proprietary game data '
'that may be redistributed\n' 'that may be redistributed\n'
'only under conditions specified in\n') 'only under conditions specified in\n')
...@@ -1260,7 +1265,7 @@ class PackagingTask(object): ...@@ -1260,7 +1265,7 @@ class PackagingTask(object):
o.write(package.copyright or self.game.copyright) o.write(package.copyright or self.game.copyright)
o.write(', with all rights reserved.\n') o.write(', with all rights reserved.\n')
if licenses and package.component == 'local': if licenses and self.package_components[package.name] == 'local':
o.write('\nThe full license appears in ') o.write('\nThe full license appears in ')
o.write(',\n'.join(licenses)) o.write(',\n'.join(licenses))
o.write('\n') o.write('\n')
...@@ -1281,6 +1286,7 @@ class PackagingTask(object): ...@@ -1281,6 +1286,7 @@ class PackagingTask(object):
shutil.copyfile(os.path.join(DATADIR, 'changelog.gz'), shutil.copyfile(os.path.join(DATADIR, 'changelog.gz'),
os.path.join(dest_pkgdocdir, 'changelog.gz')) os.path.join(dest_pkgdocdir, 'changelog.gz'))
self.__check_component(package)
self.fill_docs(package, destdir, pkgdocdir) self.fill_docs(package, destdir, pkgdocdir)
for wanted in (package.install_files | package.optional_files): for wanted in (package.install_files | package.optional_files):
...@@ -2013,10 +2019,10 @@ class PackagingTask(object): ...@@ -2013,10 +2019,10 @@ class PackagingTask(object):
destdir = os.path.join(per_package_dir, 'DESTDIR') destdir = os.path.join(per_package_dir, 'DESTDIR')
self.fill_dest_dir(package, destdir) self.fill_dest_dir(package, destdir)
self.__check_component(package)
pkg = self.packaging.build_package(per_package_dir, self.game, pkg = self.packaging.build_package(per_package_dir, self.game,
package, destination, compress=compress, package, destination, compress=compress,
md5sums=self.package_md5sums.get(package.name)) md5sums=self.package_md5sums.get(package.name),
component=self.package_components[package.name])
assert pkg is not None assert pkg is not None
packages.add(pkg) packages.add(pkg)
...@@ -2133,8 +2139,7 @@ class PackagingTask(object): ...@@ -2133,8 +2139,7 @@ class PackagingTask(object):
def __check_component(self, package): def __check_component(self, package):
# redistributable packages are redistributable as long as their # redistributable packages are redistributable as long as their
# optional license file is present # optional license file is present
# FIXME: only do this for .deb? self.package_components[package.name] = package.component
# FIXME: shouldn't modify package.component in-place
if package.component == 'local': if package.component == 'local':
return return
for f in package.optional_files: for f in package.optional_files:
...@@ -2142,7 +2147,7 @@ class PackagingTask(object): ...@@ -2142,7 +2147,7 @@ class PackagingTask(object):
continue continue
if self.file_status[f.name] is not FillResult.COMPLETE: if self.file_status[f.name] is not FillResult.COMPLETE:
package.component = 'local' self.package_components[package.name] = 'local'
return return
return return
......
...@@ -218,8 +218,10 @@ class PackagingSystem(metaclass=ABCMeta): ...@@ -218,8 +218,10 @@ class PackagingSystem(metaclass=ABCMeta):
def merge_relations(self, package, rel): def merge_relations(self, package, rel):
return set(self.format_relations(package.relations[rel])) return set(self.format_relations(package.relations[rel]))
def generate_description(self, game, package): def generate_description(self, game, package, component=None):
longname = package.longname or game.longname longname = package.longname or game.longname
if component is None:
component = package.component
if package.short_description is not None: if package.short_description is not None:
short_desc = package.short_description short_desc = package.short_description
...@@ -234,10 +236,10 @@ class PackagingSystem(metaclass=ABCMeta): ...@@ -234,10 +236,10 @@ class PackagingSystem(metaclass=ABCMeta):
return (short_desc, long_desc) return (short_desc, long_desc)
long_desc = 'This package was built using game-data-packager.\n' long_desc = 'This package was built using game-data-packager.\n'
if package.component == 'local': if component == 'local':
long_desc += 'It contains proprietary game data and must not be redistributed.\n' long_desc += 'It contains proprietary game data and must not be redistributed.\n'
long_desc += '.\n' long_desc += '.\n'
elif package.component == 'non-free': elif component == 'non-free':
long_desc += 'It contains proprietary game data that may be redistributed\n' long_desc += 'It contains proprietary game data that may be redistributed\n'
long_desc += 'only under some conditions.\n' long_desc += 'only under some conditions.\n'
long_desc += '.\n' long_desc += '.\n'
...@@ -304,7 +306,7 @@ class PackagingSystem(metaclass=ABCMeta): ...@@ -304,7 +306,7 @@ class PackagingSystem(metaclass=ABCMeta):
@abstractmethod @abstractmethod
def build_package(self, per_package_dir, game, package, def build_package(self, per_package_dir, game, package,
destination, compress=True, md5sums=None): destination, compress=True, md5sums=None, component=None):
"""Build the .deb or equivalent in destination, and return its """Build the .deb or equivalent in destination, and return its
filename. filename.
......
...@@ -155,7 +155,7 @@ class ArchPackaging(PackagingSystem): ...@@ -155,7 +155,7 @@ class ArchPackaging(PackagingSystem):
+ sorted(files), env={'LANG':'C'}, cwd=destdir) + sorted(files), env={'LANG':'C'}, cwd=destdir)
def build_package(self, per_package_dir, game, package, destination, def build_package(self, per_package_dir, game, package, destination,
compress=True, md5sums=None): compress=True, md5sums=None, component=None):
destdir = os.path.join(per_package_dir, 'DESTDIR') destdir = os.path.join(per_package_dir, 'DESTDIR')
arch = self.get_effective_architecture(package) arch = self.get_effective_architecture(package)
......
...@@ -217,7 +217,7 @@ class DebPackaging(PackagingSystem): ...@@ -217,7 +217,7 @@ class DebPackaging(PackagingSystem):
return self.rename_package(pr.package) return self.rename_package(pr.package)
def __generate_control(self, game, package, destdir): def __generate_control(self, game, package, destdir, component):
if Deb822 is None: if Deb822 is None:
raise FileNotFoundError('Cannot generate .deb packages without ' raise FileNotFoundError('Cannot generate .deb packages without '
'python3-debian') 'python3-debian')
...@@ -256,10 +256,10 @@ class DebPackaging(PackagingSystem): ...@@ -256,10 +256,10 @@ class DebPackaging(PackagingSystem):
installed_size += 1 installed_size += 1
control['Installed-Size'] = str(installed_size) control['Installed-Size'] = str(installed_size)
if package.component == 'main': if component == 'main':
control['Section'] = package.section control['Section'] = package.section
else: else:
control['Section'] = package.component + '/' + package.section control['Section'] = component + '/' + package.section
if package.architecture == 'all': if package.architecture == 'all':
control['Architecture'] = 'all' control['Architecture'] = 'all'
...@@ -347,8 +347,12 @@ class DebPackaging(PackagingSystem): ...@@ -347,8 +347,12 @@ class DebPackaging(PackagingSystem):
return control return control
def __fill_dest_dir_deb(self, game, package, destdir, md5sums=None): def __fill_dest_dir_deb(self, game, package, destdir, md5sums=None,
if package.component == 'local': component=None):
if component is None:
component = package.component
if component == 'local':
self.override_lintian(destdir, package.name, self.override_lintian(destdir, package.name,
'unknown-section', 'local/%s' % package.section) 'unknown-section', 'local/%s' % package.section)
...@@ -380,15 +384,16 @@ class DebPackaging(PackagingSystem): ...@@ -380,15 +384,16 @@ class DebPackaging(PackagingSystem):
os.chmod(md5sums_path, 0o644) os.chmod(md5sums_path, 0o644)
control = os.path.join(destdir, 'DEBIAN/control') control = os.path.join(destdir, 'DEBIAN/control')
self.__generate_control(game, package, destdir).dump( self.__generate_control(game, package, destdir, component).dump(
fd=open(control, 'wb'), encoding='utf-8') fd=open(control, 'wb'), encoding='utf-8')
os.chmod(control, 0o644) os.chmod(control, 0o644)
def build_package(self, per_package_dir, game, package, destination, def build_package(self, per_package_dir, game, package, destination,
compress=True, md5sums=None): compress=True, md5sums=None, component=None):
destdir = os.path.join(per_package_dir, 'DESTDIR') destdir = os.path.join(per_package_dir, 'DESTDIR')
arch = self.get_effective_architecture(package) arch = self.get_effective_architecture(package)
self.__fill_dest_dir_deb(game, package, destdir, md5sums) self.__fill_dest_dir_deb(game, package, destdir, md5sums,
component)
normalize_permissions(destdir) normalize_permissions(destdir)
# it had better have a /usr and a DEBIAN directory or # it had better have a /usr and a DEBIAN directory or
......
...@@ -231,7 +231,7 @@ class RpmPackaging(PackagingSystem): ...@@ -231,7 +231,7 @@ class RpmPackaging(PackagingSystem):
return specfile return specfile
def build_package(self, per_package_dir, game, package, destination, def build_package(self, per_package_dir, game, package, destination,
compress=True, md5sums=None): compress=True, md5sums=None, component=None):
destdir = os.path.join(per_package_dir, 'DESTDIR') destdir = os.path.join(per_package_dir, 'DESTDIR')
arch = self.get_effective_architecture(package) arch = self.get_effective_architecture(package)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment