[Libreoffice-commits] core.git: postprocess/CustomTarget_images.mk solenv/bin
postprocess/CustomTarget_images.mk |1 solenv/bin/image-sort.py | 43 - 2 files changed, 25 insertions(+), 19 deletions(-) New commits: commit 03c65d3ed080661430d4af2424d8f525bef67c62 Author: Jan-Marek Glogowski AuthorDate: Fri Jul 17 23:05:15 2020 +0200 Commit: Jan-Marek Glogowski CommitDate: Fri Sep 11 18:25:21 2020 +0200 image-sort: add --quiet option for build-tools Otherwise you'll get many warnings for missing images, because the cross-toolset target just builds some small part of LO. This also converts the program to use argparse. Change-Id: I22adda23ab3a25bced871a87d38373543cd5ae72 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/102478 Tested-by: Jenkins Reviewed-by: Jan-Marek Glogowski diff --git a/postprocess/CustomTarget_images.mk b/postprocess/CustomTarget_images.mk index 0d2db4f7b2bb..42ddfdadd8c7 100644 --- a/postprocess/CustomTarget_images.mk +++ b/postprocess/CustomTarget_images.mk @@ -115,6 +115,7 @@ $(packimages_DIR)/sorted.lst : \ $(call gb_Helper_abbreviate_dirs, \ $(call gb_ExternalExecutable_get_command,python) \ $(SRCDIR)/solenv/bin/image-sort.py \ + $(if $(filter build,$(gb_Side)),--quiet) \ $< $(INSTROOT)/$(gb_UIConfig_INSTDIR) $@) $(call gb_Trace_EndRange,$(subst $(WORKDIR)/,,$@),PRL) diff --git a/solenv/bin/image-sort.py b/solenv/bin/image-sort.py index ce69db3e64a4..d45037e25c7f 100644 --- a/solenv/bin/image-sort.py +++ b/solenv/bin/image-sort.py @@ -18,17 +18,19 @@ # import sys, os, re +import argparse global_list = [] global_hash = {} -base_path = None +args = None def read_icons(fname): -global base_path +global args images = [] -full_path = os.path.join(base_path, fname) +full_path = os.path.join(args.base_path, fname) if not os.path.exists(full_path): -print("Skipping non-existent {}\n".format(full_path)) +if not args.quiet: +print("Skipping non-existent {}\n".format(full_path), file=sys.stderr) return images with open(full_path) as fp: for line in fp: @@ -116,34 +118,37 @@ def chew_controlfile(ifile): else: filelist.append(line) -if len(sys.argv) == 1: -print("image-sort /path/to/OOOo/source/root\n") -sys.exit(1) - +parser = argparse.ArgumentParser() # where the control file lives -control = sys.argv[1] +parser.add_argument('control_file', metavar='image-sort.lst', type=open, +help='the sort control file') # where the uiconfigs live -base_path = sys.argv[2] -# output -if len(sys.argv) > 3: -output = open(sys.argv[3], 'w') +parser.add_argument('base_path', metavar='directory', +help='path to the UIConfigs directory') +parser.add_argument('output', metavar='output file', type=argparse.FileType('w'), +nargs='?', default=None, help='optionally write to this output file') +parser.add_argument("-q", "--quiet", action="store_true", +help="don't print status messages to stdout") + +args = parser.parse_args() + +if args.output is not None: close_output = True else: -output = sys.stdout +args.output = sys.stdout close_output = False -with open(control) as controlfile: -chew_controlfile(controlfile) +chew_controlfile(args.control_file) for icon in global_list: if not icon.startswith('sc_'): -output.write(icon + "\n") +args.output.write(icon + "\n") for icon in global_list: if icon.startswith('sc_'): -output.write(icon + "\n") +args.output.write(icon + "\n") if close_output: -output.close() +args.output.close() # dnl vim:set shiftwidth=4 softtabstop=4 expandtab: ___ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
[Libreoffice-commits] core.git: postprocess/CustomTarget_images.mk solenv/bin
postprocess/CustomTarget_images.mk |9 + solenv/bin/image-sort.pl | 179 - solenv/bin/image-sort.py | 142 + 3 files changed, 148 insertions(+), 182 deletions(-) New commits: commit b29fb89d0a49fde0f5757774d64a7aba8298ac75 Author: Jussi Pakkanen AuthorDate: Sun Feb 23 00:47:07 2020 +0200 Commit: Mike Kaganski CommitDate: Fri Mar 20 09:52:15 2020 +0100 tdf#130911: convert image-sort from Perl to Python Tested with diff that the sorting output file is identical to the one the Perl script produced. Change-Id: I22eb28e71f51315609957e84c6204f1beb5dccaa Reviewed-on: https://gerrit.libreoffice.org/c/core/+/90348 Tested-by: Jenkins Reviewed-by: Mike Kaganski diff --git a/postprocess/CustomTarget_images.mk b/postprocess/CustomTarget_images.mk index 691db4bd0294..0d2db4f7b2bb 100644 --- a/postprocess/CustomTarget_images.mk +++ b/postprocess/CustomTarget_images.mk @@ -52,7 +52,8 @@ $(packimages_DIR)/images_%.zip : \ $(call gb_Trace_StartRange,$(subst $(WORKDIR)/,,$@),PRL) $(call gb_Helper_abbreviate_dirs, \ ILSTFILE=$(call var2file,$(shell $(gb_MKTEMP)),100,$(filter %.ilst,$^)) && \ - $(call gb_ExternalExecutable_get_command,python) $(SRCDIR)/solenv/bin/pack_images.py \ + $(call gb_ExternalExecutable_get_command,python) \ + $(SRCDIR)/solenv/bin/pack_images.py \ $(if $(DEFAULT_THEME),\ -g $(packimages_DIR) -m $(packimages_DIR) -c $(packimages_DIR),\ -g $(SRCDIR)/icon-themes/$* -m $(SRCDIR)/icon-themes/$* -c $(SRCDIR)/icon-themes/$* \ @@ -107,11 +108,13 @@ $(packimages_DIR)/commandimagelist.ilst : $(packimages_DIR)/sorted.lst : \ $(SRCDIR)/postprocess/packimages/image-sort.lst \ - $(call gb_Postprocess_get_target,AllUIConfigs) + $(call gb_Postprocess_get_target,AllUIConfigs) \ + $(call gb_ExternalExecutable_get_dependencies,python) $(call gb_Output_announce,$(subst $(WORKDIR)/,,$@),$(true),PRL,1) $(call gb_Trace_StartRange,$(subst $(WORKDIR)/,,$@),PRL) $(call gb_Helper_abbreviate_dirs, \ - $(PERL) $(SRCDIR)/solenv/bin/image-sort.pl \ + $(call gb_ExternalExecutable_get_command,python) \ + $(SRCDIR)/solenv/bin/image-sort.py \ $< $(INSTROOT)/$(gb_UIConfig_INSTDIR) $@) $(call gb_Trace_EndRange,$(subst $(WORKDIR)/,,$@),PRL) diff --git a/solenv/bin/image-sort.pl b/solenv/bin/image-sort.pl deleted file mode 100755 index a59c7bc714a5.. --- a/solenv/bin/image-sort.pl +++ /dev/null @@ -1,179 +0,0 @@ -#!/usr/bin/env perl -w -# -*- Mode: Perl; tab-width: 4; indent-tabs-mode: nil -*- -# -# This file is part of the LibreOffice project. -# -# This Source Code Form is subject to the terms of the Mozilla Public -# License, v. 2.0. If a copy of the MPL was not distributed with this -# file, You can obtain one at http://mozilla.org/MPL/2.0/. -# -# This file incorporates work covered by the following license notice: -# -# Licensed to the Apache Software Foundation (ASF) under one or more -# contributor license agreements. See the NOTICE file distributed -# with this work for additional information regarding copyright -# ownership. The ASF licenses this file to you under the Apache -# License, Version 2.0 (the "License"); you may not use this file -# except in compliance with the License. You may obtain a copy of -# the License at http://www.apache.org/licenses/LICENSE-2.0 . -# - -my @global_list = (); -my %global_hash = (); -my $base_path; - -sub read_icons($) -{ -my $fname = shift; -my $fileh; -my @images; -if (! -e "$base_path/$fname") { -print "Skipping non-existent $base_path/$fname\n"; -return @images; -} -open ($fileh, "$base_path/$fname") || die "Can't open $base_path/$fname: $!"; -while (<$fileh>) { -m/xlink:href=\"\.uno:(\S+)\"\s+/ || next; -push @images, lc($1); -} -close ($fileh); - -return @images; -} - -# filter out already seen icons & do prefixing -sub read_new_icons($$) -{ -my $fname = shift; -my $prefix = shift; -my @images = read_icons ($fname); -my @new_icons; -my %new_icons; -for my $icon (@images) { -my $iname = "cmd/" . $prefix . $icon . ".png"; -if (!defined $global_hash{$iname} && -!defined $new_icons{$iname}) { -push @new_icons, $iname; -$new_icons{$iname} = 1; -} -} -return @new_icons; -} - -sub process_group($@) -{ -my $prefix = shift; -my @uiconfigs = @_; -my %group; -my $cur_max = 1.0; - -# a very noddy sorting algorithm -for my $uiconfig (@uiconfigs) { -my @images = read_new_icons ($uiconfig, $prefix); -my
[Libreoffice-commits] core.git: postprocess/CustomTarget_images.mk solenv/bin
postprocess/CustomTarget_images.mk |5 +++-- solenv/bin/pack_images.py |1 - 2 files changed, 3 insertions(+), 3 deletions(-) New commits: commit 906a2e4fa4e9ce231126c608e741c0c0d809157d Author: Stephan BergmannDate: Thu Feb 22 14:37:32 2018 +0100 Always execute pack_images.py with the right Python interpreter With --enable-python=fully-internal, where PYTHON_FOR_BUILD is empty, this executed the "#!/usr/bin/env python" shebang in pack_images.py, using whatever python would be found (or not) on the system. With this fixed, there is no need any more for pack_images.py to be executable. Change-Id: I40ad3769898f3eb711dbe555d4c3faa9e3c1456d Reviewed-on: https://gerrit.libreoffice.org/50180 Tested-by: Jenkins Reviewed-by: Stephan Bergmann diff --git a/postprocess/CustomTarget_images.mk b/postprocess/CustomTarget_images.mk index 871c7bd6470c..77c653abf3fe 100644 --- a/postprocess/CustomTarget_images.mk +++ b/postprocess/CustomTarget_images.mk @@ -29,11 +29,12 @@ $(packimages_DIR)/%.zip : \ $(packimages_DIR)/commandimagelist.ilst \ $(packimages_DIR)/sourceimagelist.ilst \ $(SRCDIR)/wizards/source/imagelists/imagelists.ilst \ - $(call gb_Helper_get_imagelists) + $(call gb_Helper_get_imagelists) \ + | $(call gb_ExternalExecutable_get_dependencies,python) $(call gb_Output_announce,$(subst $(WORKDIR)/,,$@),$(true),PRL,2) $(call gb_Helper_abbreviate_dirs, \ ILSTFILE=$(call var2file,$(shell $(gb_MKTEMP)),100,$(filter %.ilst,$^)) && \ - $(PYTHON_FOR_BUILD) $(SRCDIR)/solenv/bin/pack_images.py \ + $(call gb_ExternalExecutable_get_command,python) $(SRCDIR)/solenv/bin/pack_images.py \ $(if $(DEFAULT_THEME),\ -g $(packimages_DIR) -m $(packimages_DIR) -c $(packimages_DIR),\ -g $(SRCDIR)/icon-themes/$(subst images_,,$*) -m $(SRCDIR)/icon-themes/$(subst images_,,$*) -c $(SRCDIR)/icon-themes/$(subst images_,,$*) \ diff --git a/solenv/bin/pack_images.py b/solenv/bin/pack_images.py old mode 100755 new mode 100644 index 0f493c8f3035..bd75b9044210 --- a/solenv/bin/pack_images.py +++ b/solenv/bin/pack_images.py @@ -1,4 +1,3 @@ -#!/usr/bin/env python # -*- coding: utf-8 -*- # -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*- # ___ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
[Libreoffice-commits] core.git: postprocess/CustomTarget_images.mk solenv/bin
postprocess/CustomTarget_images.mk |2 solenv/bin/pack_images.py | 590 + 2 files changed, 591 insertions(+), 1 deletion(-) New commits: commit 6a313ab973378e82715cfda7431a8abbe474fd06 Author: Jens CarlDate: Tue Aug 29 04:48:13 2017 + tdf#106894: Rewrite packimages.pl in Python (pack_images.py) Change-Id: I2e9054775941b38392ba3ee38575891b5339249e Reviewed-on: https://gerrit.libreoffice.org/42790 Reviewed-by: Samuel Mehrbrodt Tested-by: Samuel Mehrbrodt diff --git a/postprocess/CustomTarget_images.mk b/postprocess/CustomTarget_images.mk index 44899e6105a5..603c73d522d4 100644 --- a/postprocess/CustomTarget_images.mk +++ b/postprocess/CustomTarget_images.mk @@ -33,7 +33,7 @@ $(packimages_DIR)/%.zip : \ $(call gb_Output_announce,$(subst $(WORKDIR)/,,$@),$(true),PRL,2) $(call gb_Helper_abbreviate_dirs, \ ILSTFILE=$(call var2file,$(shell $(gb_MKTEMP)),100,$(filter %.ilst,$^)) && \ - $(PERL) $(SRCDIR)/solenv/bin/packimages.pl \ + $(PYTHON) $(SRCDIR)/solenv/bin/pack_images.py \ $(if $(DEFAULT_THEME),\ -g $(packimages_DIR) -m $(packimages_DIR) -c $(packimages_DIR),\ -g $(SRCDIR)/icon-themes/$(subst images_,,$*) -m $(SRCDIR)/icon-themes/$(subst images_,,$*) -c $(SRCDIR)/icon-themes/$(subst images_,,$*) \ diff --git a/solenv/bin/pack_images.py b/solenv/bin/pack_images.py new file mode 100755 index ..0e1a5fe329f0 --- /dev/null +++ b/solenv/bin/pack_images.py @@ -0,0 +1,590 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- +# -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*- +# +# This file is part of the LibreOffice project. +# +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. +# +""" Pack images into archives. """ + +from __future__ import with_statement + +import argparse +from collections import OrderedDict +import logging +import os +import shutil +import sys +import tempfile +import zipfile + + +logging.basicConfig(format='%(message)s') +LOGGER = logging.getLogger() + + +def main(args): +""" Main function. """ + +tmp_output_file = "%s.%d.tmp" % (args.output_file, os.getpid()) + +# Sanity checks +if not os.path.exists(args.imagelist_file): +LOGGER.error("imagelist_file '%s' doesn't exists", args.imagelist_file) +sys.exit(2) + +out_path = os.path.dirname(args.output_file) +for path in (out_path, args.global_path, args.module_path): +if not os.path.exists(path): +LOGGER.error("Path '%s' doesn't exists", path) +sys.exit(2) +if not os.access(path, os.X_OK): +LOGGER.error("Unable to search path %s", path) +sys.exit(2) + +if not os.access(out_path, os.W_OK): +LOGGER.error("Unable to write into path %s", out_path) + +custom_paths = [] +for path in args.custom_path: +if not os.path.exists(path): +LOGGER.warning("Skipping non-existing path: %s", path) +continue +elif not os.access(path, os.X_OK): +LOGGER.error("Unable to search path %s", path) +sys.exit(2) +continue + +custom_paths.append(path) + +imagelist_filenames = get_imagelist_filenames(args.imagelist_file) +global_image_list, module_image_list = parse_image_list(imagelist_filenames) +custom_image_list = find_custom(custom_paths) + +links = {} +read_links(links, ARGS.global_path) +for path in custom_paths: +read_links(links, path) +check_links(links) + +zip_list = create_zip_list(global_image_list, module_image_list, custom_image_list, + args.global_path, args.module_path) +remove_links_from_zip_list(zip_list, links) + +if check_rebuild(args.output_file, imagelist_filenames, custom_paths, zip_list): +tmp_dir = copy_images(zip_list) +create_zip_archive(zip_list, links, tmp_dir, tmp_output_file, args.sort_file) + +replace_zip_file(tmp_output_file, args.output_file) +try: +LOGGER.info("Remove temporary directory %s", tmp_dir) +shutil.rmtree(tmp_dir) +except Exception as e: +LOGGER.error("Unable to remove temporary directory %s", tmp_dir) +sys.exit(2) +else: +LOGGER.info("No rebuild needed. %s is up to date.", args.output_file) + + +def check_rebuild(zip_file, imagelist_filenames, custom_paths, zip_list): +""" Check if a rebuild is needed. + +:type zip_file: str +:param zip_file: File to check against (use st_mtime). + +:type imagelist_filenames: dict +:param imagelist_filenames: List
[Libreoffice-commits] core.git: postprocess/CustomTarget_images.mk solenv/bin
postprocess/CustomTarget_images.mk |2 solenv/bin/pack_images.py | 590 - solenv/bin/packimages.pl | 550 ++ 3 files changed, 551 insertions(+), 591 deletions(-) New commits: commit 138c1252787256a20807caacc9df2af7b19b245e Author: Samuel MehrbrodtDate: Tue Sep 26 09:10:57 2017 +0200 Revert "tdf#106894 Rewrite packimages.pl in Python (pack_images.py)" This broke the build: https://ci.libreoffice.org/job/lo_tb_master_win/14994/console This reverts commit 423ee1020afe1bca896f2ecfc67ffbd49db5081c. Change-Id: I05e6fd68f2bbec189236cbe265f6510731327997 Reviewed-on: https://gerrit.libreoffice.org/42778 Reviewed-by: Samuel Mehrbrodt Tested-by: Samuel Mehrbrodt diff --git a/postprocess/CustomTarget_images.mk b/postprocess/CustomTarget_images.mk index 603c73d522d4..44899e6105a5 100644 --- a/postprocess/CustomTarget_images.mk +++ b/postprocess/CustomTarget_images.mk @@ -33,7 +33,7 @@ $(packimages_DIR)/%.zip : \ $(call gb_Output_announce,$(subst $(WORKDIR)/,,$@),$(true),PRL,2) $(call gb_Helper_abbreviate_dirs, \ ILSTFILE=$(call var2file,$(shell $(gb_MKTEMP)),100,$(filter %.ilst,$^)) && \ - $(PYTHON) $(SRCDIR)/solenv/bin/pack_images.py \ + $(PERL) $(SRCDIR)/solenv/bin/packimages.pl \ $(if $(DEFAULT_THEME),\ -g $(packimages_DIR) -m $(packimages_DIR) -c $(packimages_DIR),\ -g $(SRCDIR)/icon-themes/$(subst images_,,$*) -m $(SRCDIR)/icon-themes/$(subst images_,,$*) -c $(SRCDIR)/icon-themes/$(subst images_,,$*) \ diff --git a/solenv/bin/pack_images.py b/solenv/bin/pack_images.py deleted file mode 100755 index 2e43c1815de4.. --- a/solenv/bin/pack_images.py +++ /dev/null @@ -1,590 +0,0 @@ -#!/usr/bin/env python2 -# -*- coding: utf-8 -*- -# -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*- -# -# This file is part of the LibreOffice project. -# -# This Source Code Form is subject to the terms of the Mozilla Public -# License, v. 2.0. If a copy of the MPL was not distributed with this -# file, You can obtain one at http://mozilla.org/MPL/2.0/. -# -""" Pack images into archives. """ - -from __future__ import with_statement - -import argparse -from collections import OrderedDict -import logging -import os -import shutil -import sys -import tempfile -import zipfile - - -logging.basicConfig(format='%(message)s') -LOGGER = logging.getLogger() - - -def main(args): -""" Main function. """ - -tmp_output_file = "%s.%d.tmp" % (args.output_file, os.getpid()) - -# Sanity checks -if not os.path.exists(args.imagelist_file): -LOGGER.error("imagelist_file '%s' doesn't exists", args.imagelist_file) -sys.exit(2) - -out_path = os.path.dirname(args.output_file) -for path in (out_path, args.global_path, args.module_path): -if not os.path.exists(path): -LOGGER.error("Path '%s' doesn't exists", path) -sys.exit(2) -if not os.access(path, os.X_OK): -LOGGER.error("Unable to search path %s", path) -sys.exit(2) - -if not os.access(out_path, os.W_OK): -LOGGER.error("Unable to write into path %s", out_path) - -custom_paths = [] -for path in args.custom_path: -if not os.path.exists(path): -LOGGER.warning("Skipping non-existing path: %s", path) -continue -elif not os.access(path, os.X_OK): -LOGGER.error("Unable to search path %s", path) -sys.exit(2) -continue - -custom_paths.append(path) - -imagelist_filenames = get_imagelist_filenames(args.imagelist_file) -global_image_list, module_image_list = parse_image_list(imagelist_filenames) -custom_image_list = find_custom(custom_paths) - -links = {} -read_links(links, ARGS.global_path) -for path in custom_paths: -read_links(links, path) -check_links(links) - -zip_list = create_zip_list(global_image_list, module_image_list, custom_image_list, - args.global_path, args.module_path) -remove_links_from_zip_list(zip_list, links) - -if check_rebuild(args.output_file, imagelist_filenames, custom_paths, zip_list): -tmp_dir = copy_images(zip_list) -create_zip_archive(zip_list, links, tmp_dir, tmp_output_file, args.sort_file) - -replace_zip_file(tmp_output_file, args.output_file) -try: -LOGGER.info("Remove temporary directory %s", tmp_dir) -shutil.rmtree(tmp_dir) -except Exception as e: -LOGGER.error("Unable to remove temporary directory %s", tmp_dir) -sys.exit(2) -else: -LOGGER.info("No rebuild needed. %s is up to date.", args.output_file) - - -def
[Libreoffice-commits] core.git: postprocess/CustomTarget_images.mk solenv/bin
postprocess/CustomTarget_images.mk |2 solenv/bin/pack_images.py | 590 + solenv/bin/packimages.pl | 550 -- 3 files changed, 591 insertions(+), 551 deletions(-) New commits: commit 423ee1020afe1bca896f2ecfc67ffbd49db5081c Author: Jens CarlDate: Tue Aug 29 04:48:13 2017 + tdf#106894 Rewrite packimages.pl in Python (pack_images.py) Change-Id: Id627d9295edc77e561f15e0886fdcf9fb64fe68d Reviewed-on: https://gerrit.libreoffice.org/41667 Tested-by: Jenkins Reviewed-by: Samuel Mehrbrodt diff --git a/postprocess/CustomTarget_images.mk b/postprocess/CustomTarget_images.mk index 44899e6105a5..603c73d522d4 100644 --- a/postprocess/CustomTarget_images.mk +++ b/postprocess/CustomTarget_images.mk @@ -33,7 +33,7 @@ $(packimages_DIR)/%.zip : \ $(call gb_Output_announce,$(subst $(WORKDIR)/,,$@),$(true),PRL,2) $(call gb_Helper_abbreviate_dirs, \ ILSTFILE=$(call var2file,$(shell $(gb_MKTEMP)),100,$(filter %.ilst,$^)) && \ - $(PERL) $(SRCDIR)/solenv/bin/packimages.pl \ + $(PYTHON) $(SRCDIR)/solenv/bin/pack_images.py \ $(if $(DEFAULT_THEME),\ -g $(packimages_DIR) -m $(packimages_DIR) -c $(packimages_DIR),\ -g $(SRCDIR)/icon-themes/$(subst images_,,$*) -m $(SRCDIR)/icon-themes/$(subst images_,,$*) -c $(SRCDIR)/icon-themes/$(subst images_,,$*) \ diff --git a/solenv/bin/pack_images.py b/solenv/bin/pack_images.py new file mode 100755 index ..2e43c1815de4 --- /dev/null +++ b/solenv/bin/pack_images.py @@ -0,0 +1,590 @@ +#!/usr/bin/env python2 +# -*- coding: utf-8 -*- +# -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*- +# +# This file is part of the LibreOffice project. +# +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. +# +""" Pack images into archives. """ + +from __future__ import with_statement + +import argparse +from collections import OrderedDict +import logging +import os +import shutil +import sys +import tempfile +import zipfile + + +logging.basicConfig(format='%(message)s') +LOGGER = logging.getLogger() + + +def main(args): +""" Main function. """ + +tmp_output_file = "%s.%d.tmp" % (args.output_file, os.getpid()) + +# Sanity checks +if not os.path.exists(args.imagelist_file): +LOGGER.error("imagelist_file '%s' doesn't exists", args.imagelist_file) +sys.exit(2) + +out_path = os.path.dirname(args.output_file) +for path in (out_path, args.global_path, args.module_path): +if not os.path.exists(path): +LOGGER.error("Path '%s' doesn't exists", path) +sys.exit(2) +if not os.access(path, os.X_OK): +LOGGER.error("Unable to search path %s", path) +sys.exit(2) + +if not os.access(out_path, os.W_OK): +LOGGER.error("Unable to write into path %s", out_path) + +custom_paths = [] +for path in args.custom_path: +if not os.path.exists(path): +LOGGER.warning("Skipping non-existing path: %s", path) +continue +elif not os.access(path, os.X_OK): +LOGGER.error("Unable to search path %s", path) +sys.exit(2) +continue + +custom_paths.append(path) + +imagelist_filenames = get_imagelist_filenames(args.imagelist_file) +global_image_list, module_image_list = parse_image_list(imagelist_filenames) +custom_image_list = find_custom(custom_paths) + +links = {} +read_links(links, ARGS.global_path) +for path in custom_paths: +read_links(links, path) +check_links(links) + +zip_list = create_zip_list(global_image_list, module_image_list, custom_image_list, + args.global_path, args.module_path) +remove_links_from_zip_list(zip_list, links) + +if check_rebuild(args.output_file, imagelist_filenames, custom_paths, zip_list): +tmp_dir = copy_images(zip_list) +create_zip_archive(zip_list, links, tmp_dir, tmp_output_file, args.sort_file) + +replace_zip_file(tmp_output_file, args.output_file) +try: +LOGGER.info("Remove temporary directory %s", tmp_dir) +shutil.rmtree(tmp_dir) +except Exception as e: +LOGGER.error("Unable to remove temporary directory %s", tmp_dir) +sys.exit(2) +else: +LOGGER.info("No rebuild needed. %s is up to date.", args.output_file) + + +def check_rebuild(zip_file, imagelist_filenames, custom_paths, zip_list): +""" Check if a rebuild is needed. + +:type zip_file: str +:param zip_file: File to check against (use st_mtime). + +
[Libreoffice-commits] core.git: postprocess/CustomTarget_images.mk solenv/bin
postprocess/CustomTarget_images.mk |2 ++ solenv/bin/packimages.pl | 30 -- 2 files changed, 26 insertions(+), 6 deletions(-) New commits: commit d082936c7a2c3fd6a8784fa5a626f545ec904b42 Author: Katarina BehrensDate: Tue Aug 30 22:31:08 2016 +0200 Allow including/packaging help-specific images from other than icon-themes folder Change-Id: Iba1808e642fde8d0370b59550c7bdac1a3e4ac79 Reviewed-on: https://gerrit.libreoffice.org/28513 Reviewed-by: jan iversen Tested-by: jan iversen Reviewed-by: Olivier Hallot diff --git a/postprocess/CustomTarget_images.mk b/postprocess/CustomTarget_images.mk index ecfbe96..def511b 100644 --- a/postprocess/CustomTarget_images.mk +++ b/postprocess/CustomTarget_images.mk @@ -30,6 +30,7 @@ $(packimages_DIR)/%.zip : \ $(SRCDIR)/sfx2/source/sidebar/sidebar.ilst \ $(SRCDIR)/vcl/source/control/throbber.ilst \ $(call gb_Helper_optional,HELP,$(helpimages_DIR)/helpimg.ilst) \ + $(call gb_Helper_optional,HELP,$(helpimages_DIR)/screenshotimg.ilst) \ $(call gb_Helper_optional,DBCONNECTIVITY,$(if $(ENABLE_JAVA),$(SRCDIR)/connectivity/source/drivers/hsqldb/hsqlui.ilst)) \ $(call gb_Helper_get_imagelists) $(call gb_Output_announce,$(subst $(WORKDIR)/,,$@),$(true),PRL,2) @@ -41,6 +42,7 @@ $(packimages_DIR)/%.zip : \ -g $(SRCDIR)/icon-themes/$(subst images_,,$*) -m $(SRCDIR)/icon-themes/$(subst images_,,$*) -c $(SRCDIR)/icon-themes/$(subst images_,,$*) \ ) \ $(INDUSTRIAL_FALLBACK) \ + $(call gb_Helper_optional,HELP,-e $(SRCDIR)/helpcontent2/source) \ -l $${ILSTFILE} \ -s $< -o $@ \ $(if $(findstring s,$(MAKEFLAGS)),> /dev/null) && \ diff --git a/solenv/bin/packimages.pl b/solenv/bin/packimages.pl old mode 100644 new mode 100755 index a768ebb..fb141c0 --- a/solenv/bin/packimages.pl +++ b/solenv/bin/packimages.pl @@ -36,11 +36,13 @@ use File::Temp qw(tempdir); my $img_global = '%GLOBALRES%'; # 'global' image prefix my $img_module = '%MODULE%'; # 'module' image prefix +my $img_help = '%HELPCONTENT%'; # 'help' image prefix my $out_file;# path to output archive my $tmp_out_file;# path to temporary output file my $global_path; # path to global images directory my $module_path; # path to module images directory +my $helpimg_path;# path to help images directory my $sort_file; # path to file containing sorting data my @custom_path; # path to custom images directory my $imagelist_file; # file containing list of image list files @@ -64,7 +66,7 @@ foreach ( @{$image_lists_ref} ) { $image_lists_hash{$_}=""; } $do_rebuild = is_file_newer(\%image_lists_hash) if $do_rebuild == 0; -my ($global_hash_ref, $module_hash_ref, $custom_hash_ref) = iterate_image_lists($image_lists_ref); +my ($global_hash_ref, $module_hash_ref, $custom_hash_ref, $help_hash_ref) = iterate_image_lists($image_lists_ref); # custom_hash filled from filesystem lookup find_custom($custom_hash_ref); @@ -87,7 +89,8 @@ for my $path (@custom_path) { } } -my $zip_hash_ref = create_zip_list($global_hash_ref, $module_hash_ref, $custom_hash_ref); +my $zip_hash_ref = create_zip_list($global_hash_ref, $module_hash_ref, $custom_hash_ref, $help_hash_ref); + remove_links_from_zip_list($zip_hash_ref, \%links); $do_rebuild = is_file_newer($zip_hash_ref) if $do_rebuild == 0; @@ -115,6 +118,7 @@ sub parse_options '-g=s' => \$global_path, '-s=s' => \$sort_file, '-m=s' => \$module_path, + '-e=s' => \$helpimg_path, '-c=s' => \@custom_path_list, '-l=s' => \$imagelist_file, '-v' => \$verbose, @@ -135,7 +139,11 @@ sub parse_options # Check paths. print_error("no such file '$_'", 2) if ! -f $imagelist_file; -foreach ($out_dir, $global_path, $module_path) { + +my @check_directories = ($out_dir, $global_path, $module_path); +push @check_directories, $helpimg_path if ($helpimg_path ne ''); + +foreach (@check_directories) { print_error("no such directory: '$_'", 2) if ! -d $_; print_error("can't search directory: '$_'", 2) if ! -x $_; } @@ -179,12 +187,13 @@ sub iterate_image_lists my %global_hash; my %module_hash; my %custom_hash; +my %help_hash; foreach my $i ( @{$image_lists_ref} ) { -parse_image_list($i, \%global_hash, \%module_hash, \%custom_hash); +
[Libreoffice-commits] core.git: postprocess/CustomTarget_images.mk solenv/bin
postprocess/CustomTarget_images.mk |2 - solenv/bin/sort.pl | 41 - 2 files changed, 1 insertion(+), 42 deletions(-) New commits: commit bc45700b1b8a0579502e09b3a7d6ec4c0c96dc8b Author: Bjoern Michaelsen bjoern.michael...@canonical.com Date: Wed Aug 21 17:35:48 2013 +0200 remove superfluous sort.pl Change-Id: I5d182aa00c4c0488edb52633392f6747772b7176 diff --git a/postprocess/CustomTarget_images.mk b/postprocess/CustomTarget_images.mk index 8c2963d..541941c 100644 --- a/postprocess/CustomTarget_images.mk +++ b/postprocess/CustomTarget_images.mk @@ -61,7 +61,7 @@ $(packimages_DIR)/commandimagelist.ilst : $(call gb_Helper_abbreviate_dirs, \ find $(SRCDIR)/icon-themes/galaxy/cmd -name *.png -o -name *.svg | \ sed s#$(SRCDIR)/icon-themes/galaxy#%MODULE%# | \ - $(PERL) $(SOLARENV)/bin/sort.pl $@.$(INPATH) \ + LC_ALL=C sort $@.$(INPATH) \ $(PERL) $(SOLARENV)/bin/diffmv.pl $@.$(INPATH) $@ \ $(if $(findstring s,$(MAKEFLAGS)),2 /dev/null)) diff --git a/solenv/bin/sort.pl b/solenv/bin/sort.pl deleted file mode 100644 index 01d2cd1..000 --- a/solenv/bin/sort.pl +++ /dev/null @@ -1,41 +0,0 @@ -: -eval 'exec perl -wS $0 ${1+$@}' -if 0; -# -# This file is part of the LibreOffice project. -# -# This Source Code Form is subject to the terms of the Mozilla Public -# License, v. 2.0. If a copy of the MPL was not distributed with this -# file, You can obtain one at http://mozilla.org/MPL/2.0/. -# -# This file incorporates work covered by the following license notice: -# -# Licensed to the Apache Software Foundation (ASF) under one or more -# contributor license agreements. See the NOTICE file distributed -# with this work for additional information regarding copyright -# ownership. The ASF licenses this file to you under the Apache -# License, Version 2.0 (the License); you may not use this file -# except in compliance with the License. You may obtain a copy of -# the License at http://www.apache.org/licenses/LICENSE-2.0 . -# - -# -# sort.pl - Simply sort the input from stdin and pipe it to stdout. -# The sort needs to be *independent* of the settings of -# LC_ALL resp. LC_COLLATE -# - -use strict; -# be explicit: we want the perl standard sorting regardless the locale -no locale; - - -my @buffer; - -while() { -push(@buffer, $_); -} - -foreach (sort @buffer) { -print $_; -} ___ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits