Rework the install to use git files
Instead of installing everything except a few ignored files. This is consistent with the other packagers.
This commit is contained in:
parent
9db81af598
commit
07d593fe52
@ -97,6 +97,7 @@ class Builder(object):
|
|||||||
|
|
||||||
def __init__(self, config):
|
def __init__(self, config):
|
||||||
self.config = config
|
self.config = config
|
||||||
|
self.locale_dir = os.path.join(self.config.source_dir, 'locale')
|
||||||
|
|
||||||
def build(self):
|
def build(self):
|
||||||
self.build_locale()
|
self.build_locale()
|
||||||
@ -108,10 +109,8 @@ class Builder(object):
|
|||||||
logging.warn('Missing po/ dir, cannot build_locale')
|
logging.warn('Missing po/ dir, cannot build_locale')
|
||||||
return
|
return
|
||||||
|
|
||||||
locale_dir = os.path.join(self.config.source_dir, 'locale')
|
if os.path.exists(self.locale_dir):
|
||||||
|
shutil.rmtree(self.locale_dir)
|
||||||
if os.path.exists(locale_dir):
|
|
||||||
shutil.rmtree(locale_dir)
|
|
||||||
|
|
||||||
for f in os.listdir(po_dir):
|
for f in os.listdir(po_dir):
|
||||||
if not f.endswith('.po') or f == 'pseudo.po':
|
if not f.endswith('.po') or f == 'pseudo.po':
|
||||||
@ -140,10 +139,8 @@ class Builder(object):
|
|||||||
f.write('summary = %s\n' % translated_summary)
|
f.write('summary = %s\n' % translated_summary)
|
||||||
f.close()
|
f.close()
|
||||||
|
|
||||||
def get_files(self):
|
def get_locale_files(self):
|
||||||
allfiles = list_files(self.config.source_dir,
|
return list_files(self.locale_dir, IGNORE_DIRS, IGNORE_FILES)
|
||||||
IGNORE_DIRS, IGNORE_FILES)
|
|
||||||
return allfiles
|
|
||||||
|
|
||||||
|
|
||||||
class Packager(object):
|
class Packager(object):
|
||||||
@ -195,10 +192,9 @@ class XOPackager(Packager):
|
|||||||
for f in self.get_files_in_git():
|
for f in self.get_files_in_git():
|
||||||
bundle_zip.write(os.path.join(self.config.source_dir, f),
|
bundle_zip.write(os.path.join(self.config.source_dir, f),
|
||||||
os.path.join(self.config.bundle_root_dir, f))
|
os.path.join(self.config.bundle_root_dir, f))
|
||||||
locale_dir = os.path.join(self.config.source_dir, 'locale')
|
|
||||||
locale_files = list_files(locale_dir, IGNORE_DIRS, IGNORE_FILES)
|
for f in self.builder.get_locale_files():
|
||||||
for f in locale_files:
|
bundle_zip.write(os.path.join(self.builder.locale_dir, f),
|
||||||
bundle_zip.write(os.path.join(locale_dir, f),
|
|
||||||
os.path.join(self.config.bundle_root_dir,
|
os.path.join(self.config.bundle_root_dir,
|
||||||
'locale', f))
|
'locale', f))
|
||||||
|
|
||||||
@ -220,19 +216,11 @@ class SourcePackager(Packager):
|
|||||||
tar.close()
|
tar.close()
|
||||||
|
|
||||||
|
|
||||||
class Installer(object):
|
class Installer(Packager):
|
||||||
IGNORES = ['po/*', 'MANIFEST', 'AUTHORS']
|
|
||||||
|
|
||||||
def __init__(self, builder):
|
def __init__(self, builder):
|
||||||
self.config = builder.config
|
self.config = builder.config
|
||||||
self.builder = builder
|
self.builder = builder
|
||||||
|
|
||||||
def should_ignore(self, f):
|
|
||||||
for pattern in self.IGNORES:
|
|
||||||
if fnmatch(f, pattern):
|
|
||||||
return True
|
|
||||||
return False
|
|
||||||
|
|
||||||
def install(self, prefix):
|
def install(self, prefix):
|
||||||
self.builder.build()
|
self.builder.build()
|
||||||
|
|
||||||
@ -240,13 +228,21 @@ class Installer(object):
|
|||||||
self.config.bundle_root_dir)
|
self.config.bundle_root_dir)
|
||||||
|
|
||||||
source_to_dest = {}
|
source_to_dest = {}
|
||||||
for f in self.builder.get_files():
|
|
||||||
if self.should_ignore(f):
|
for f in self.get_files_in_git():
|
||||||
pass
|
source_path = os.path.join(self.config.source_dir, f)
|
||||||
elif f.startswith('locale/') and f.endswith('.mo'):
|
dest_path = os.path.join(activity_path, f)
|
||||||
source_to_dest[f] = os.path.join(prefix, 'share', f)
|
source_to_dest[source_path] = dest_path
|
||||||
|
|
||||||
|
for f in self.builder.get_locale_files():
|
||||||
|
source_path = os.path.join(self.builder.locale_dir, f)
|
||||||
|
|
||||||
|
if source_path.endswith(".mo"):
|
||||||
|
dest_path = os.path.join(prefix, 'share', 'locale', f)
|
||||||
else:
|
else:
|
||||||
source_to_dest[f] = os.path.join(activity_path, f)
|
dest_path = os.path.join(activity_path, 'locale', f)
|
||||||
|
|
||||||
|
source_to_dest[source_path] = dest_path
|
||||||
|
|
||||||
for source, dest in source_to_dest.items():
|
for source, dest in source_to_dest.items():
|
||||||
print 'Install %s to %s.' % (source, dest)
|
print 'Install %s to %s.' % (source, dest)
|
||||||
|
Loading…
Reference in New Issue
Block a user