[Sugar-devel] [PATCH sugar-toolkit-gtk3 2/3] Rework the install to use git files

Daniel Narvaez dwnarvaez at gmail.com
Thu Dec 6 16:49:17 EST 2012


I found a bug with thise one after writing unit tests, so I just sent
a fixed patch.

On 6 December 2012 01:32, Daniel Narvaez <dwnarvaez at gmail.com> wrote:
> From: Daniel Narvaez <dwnarvaez at gmail.com>
>
> Instead of installing everything except a few ignored files. This
> is consistent with the other packagers.
> ---
>  src/sugar3/activity/bundlebuilder.py |   45 ++++++++++++++--------------------
>  1 file changed, 19 insertions(+), 26 deletions(-)
>
> diff --git a/src/sugar3/activity/bundlebuilder.py b/src/sugar3/activity/bundlebuilder.py
> index 7e54152..aaa2887 100644
> --- a/src/sugar3/activity/bundlebuilder.py
> +++ b/src/sugar3/activity/bundlebuilder.py
> @@ -97,6 +97,7 @@ class Builder(object):
>
>      def __init__(self, config):
>          self.config = config
> +        self.locale_dir = os.path.join(self.config.source_dir, 'locale')
>
>      def build(self):
>          self.build_locale()
> @@ -110,8 +111,8 @@ class Builder(object):
>
>          locale_dir = os.path.join(self.config.source_dir, 'locale')
>
> -        if os.path.exists(locale_dir):
> -            shutil.rmtree(locale_dir)
> +        if os.path.exists(self.locale_dir):
> +            shutil.rmtree(self.locale_dir)
>
>          for f in os.listdir(po_dir):
>              if not f.endswith('.po') or f == 'pseudo.po':
> @@ -140,10 +141,8 @@ class Builder(object):
>              f.write('summary = %s\n' % translated_summary)
>              f.close()
>
> -    def get_files(self):
> -        allfiles = list_files(self.config.source_dir,
> -                              IGNORE_DIRS, IGNORE_FILES)
> -        return allfiles
> +    def get_locale_files(self):
> +        return list_files(self.locale_dir, IGNORE_DIRS, IGNORE_FILES)
>
>
>  class Packager(object):
> @@ -195,10 +194,9 @@ class XOPackager(Packager):
>          for f in self.get_files_in_git():
>              bundle_zip.write(os.path.join(self.config.source_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 locale_files:
> -            bundle_zip.write(os.path.join(locale_dir, f),
> +
> +        for f in self.builder.get_locale_files():
> +            bundle_zip.write(os.path.join(self.builder.locale_dir, f),
>                               os.path.join(self.config.bundle_root_dir,
>                                            'locale', f))
>
> @@ -220,19 +218,11 @@ class SourcePackager(Packager):
>          tar.close()
>
>
> -class Installer(object):
> -    IGNORES = ['po/*', 'MANIFEST', 'AUTHORS']
> -
> +class Installer(Packager):
>      def __init__(self, builder):
>          self.config = builder.config
>          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):
>          self.builder.build()
>
> @@ -240,13 +230,16 @@ class Installer(object):
>                                       self.config.bundle_root_dir)
>
>          source_to_dest = {}
> -        for f in self.builder.get_files():
> -            if self.should_ignore(f):
> -                pass
> -            elif f.startswith('locale/') and f.endswith('.mo'):
> -                source_to_dest[f] = os.path.join(prefix, 'share', f)
> -            else:
> -                source_to_dest[f] = os.path.join(activity_path, f)
> +
> +        for f in self.get_files_in_git():
> +            source_path = os.path.join(self.config.source_dir, f)
> +            dest_path = os.path.join(activity_path, 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)
> +            dest_path = os.path.join(prefix, 'share', 'locale', f)
> +            source_to_dest[source_path] = dest_path
>
>          for source, dest in source_to_dest.items():
>              print 'Install %s to %s.' % (source, dest)
> --
> 1.7.10.4
>



-- 
Daniel Narvaez


More information about the Sugar-devel mailing list