This is an automated email from the git hooks/post-receive script.
pierov pushed a commit to branch main in repository builders/tor-browser-build.
The following commit(s) were added to refs/heads/main by this push: new 2fd9760 Bug 40585: Prune the manual more 2fd9760 is described below
commit 2fd9760aa3982e58a2b8c6881cea9046bac49326 Author: Pier Angelo Vendrame pierov@torproject.org AuthorDate: Mon Oct 10 18:45:02 2022 +0200
Bug 40585: Prune the manual more --- projects/manual/build | 14 +++++++++++--- projects/manual/config | 2 +- projects/manual/packagemanual.py | 21 ++++++++++++++++++++- 3 files changed, 32 insertions(+), 5 deletions(-)
diff --git a/projects/manual/build b/projects/manual/build index d569632..d6d5c74 100644 --- a/projects/manual/build +++ b/projects/manual/build @@ -5,7 +5,15 @@ mkdir -p chrome/browser/content/browser/manual unzip $rootdir/[% c('input_files_by_name/manual') %] python3 $rootdir/[% c('input_files_by_name/package_script') %] public chrome/browser/content/browser/manual
+pushd chrome/browser/content/browser/manual/static +find -name '*.map' -delete +rm -rf fonts +rm -rf css/digital-climate-strike css/images +# We prune unused images in the Python script, but empty directories remain +find images -type d -empty -delete +popd + [% c('tar', { - tar_src => [ 'chrome' ], - tar_args => '-czf ' _ dest_dir _ '/' _ c('filename'), - }) %] + tar_src => [ 'chrome' ], + tar_args => '-czf ' _ dest_dir _ '/' _ c('filename'), + }) %] diff --git a/projects/manual/config b/projects/manual/config index 4fe9356..9112864 100644 --- a/projects/manual/config +++ b/projects/manual/config @@ -2,7 +2,7 @@ # To update, see doc/how-to-update-the-manual.txt # Remember to update also the package's hash, with the version! version: 50953 -filename: 'manual-[% c("version") %].tar.gz' +filename: 'manual-[% c("version") %]-[% c("var/build_id") %].tar.gz' container: use_container: 1
diff --git a/projects/manual/packagemanual.py b/projects/manual/packagemanual.py index f4a3b98..7af5104 100755 --- a/projects/manual/packagemanual.py +++ b/projects/manual/packagemanual.py @@ -31,10 +31,20 @@ def clean_urls(match): return f'href="#{slug}{anchor}"'
+remove_images = [] +for p in (source / 'static/images').glob('**/*'): + if p.is_file(): + rel = p.relative_to(source) + remove_images.append(rel) + htmls = source.rglob(f'{PAGE_NAME}/index.html') for page in htmls: with page.open(encoding='utf8') as f: contents = f.read() + + remove_images = list(filter( + lambda im: contents.find(str(im)) == -1, remove_images)) + contents = static_re.sub(f'"{STATIC_PATH}/\1"', contents) contents = link_re.sub(clean_urls, contents)
@@ -46,5 +56,14 @@ for page in htmls: with (target / dest_name).open('w', encoding='utf8') as f: f.write(contents)
+ +def ignore_images(path, names): + return [ + n + for n in names + if Path(path, n).relative_to(source) in remove_images + ] + + shutil.rmtree(target / 'static', ignore_errors=True) -shutil.copytree(source / 'static', target / 'static') +shutil.copytree(source / 'static', target / 'static', ignore=ignore_images)
tbb-commits@lists.torproject.org