[tbb-commits] [builders/tor-browser-build] branch master updated: Bug 34451: Include Tor Browser Manual in packages during build
gitolite role
git at cupani.torproject.org
Thu Jun 9 13:33:54 UTC 2022
This is an automated email from the git hooks/post-receive script.
pierov pushed a commit to branch master
in repository builders/tor-browser-build.
The following commit(s) were added to refs/heads/master by this push:
new 2853461 Bug 34451: Include Tor Browser Manual in packages during build
2853461 is described below
commit 28534614fd06a4422eb5959d153a592347094a27
Author: Pier Angelo Vendrame <pierov at torproject.org>
AuthorDate: Fri May 20 19:55:29 2022 +0200
Bug 34451: Include Tor Browser Manual in packages during build
Include an output of the Tor Browser manual optimized for offline docs
in the browser/omni.ja file.
See also tor-browser#11698.
---
doc/how-to-update-the-manual.txt | 8 +++++++
projects/manual/build | 11 +++++++++
projects/manual/config | 21 +++++++++++++++++
projects/manual/packagemanual.py | 50 ++++++++++++++++++++++++++++++++++++++++
projects/tor-browser/build | 10 ++++++++
projects/tor-browser/config | 3 +++
6 files changed, 103 insertions(+)
diff --git a/doc/how-to-update-the-manual.txt b/doc/how-to-update-the-manual.txt
new file mode 100644
index 0000000..334701c
--- /dev/null
+++ b/doc/how-to-update-the-manual.txt
@@ -0,0 +1,8 @@
+1. Go to https://gitlab.torproject.org/tpo/web/manual/-/jobs/
+2. Open the latest build stage
+3. Download the artifacts (they come in a .zip file).
+4. Rename it to manual_$PIPELINEID.zip
+5. Upload it to people.tpo
+6. Update projects/manual/config
+ 6.1 Change the version to $PIPELINEID
+ 6.2 Update the URL if it was different from the previous uploader
diff --git a/projects/manual/build b/projects/manual/build
new file mode 100644
index 0000000..d569632
--- /dev/null
+++ b/projects/manual/build
@@ -0,0 +1,11 @@
+#!/bin/bash
+[% c("var/set_default_env") -%]
+
+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
+
+[% c('tar', {
+ tar_src => [ 'chrome' ],
+ tar_args => '-czf ' _ dest_dir _ '/' _ c('filename'),
+ }) %]
diff --git a/projects/manual/config b/projects/manual/config
new file mode 100644
index 0000000..fa01356
--- /dev/null
+++ b/projects/manual/config
@@ -0,0 +1,21 @@
+# To update, see doc/how-to-update-the-manual.txt
+version: 40628
+filename: 'manual-[% c("version") %].tar.gz'
+
+var:
+ container:
+ use_container: 1
+ suite: bullseye
+ arch: amd64
+ deps:
+ - python3
+ - unzip
+ pre_pkginst: ''
+
+input_files:
+ - project: container-image
+ - URL: 'https://people.torproject.org/~pierov/tbb_files/manual_[% c("version") %].zip'
+ name: manual
+ sha256sum: 64bab7e8b26014277b55cf2afc4f676f3a164f466fc33e72aa62004318994c3a
+ - filename: packagemanual.py
+ name: package_script
diff --git a/projects/manual/packagemanual.py b/projects/manual/packagemanual.py
new file mode 100755
index 0000000..f4a3b98
--- /dev/null
+++ b/projects/manual/packagemanual.py
@@ -0,0 +1,50 @@
+#!/usr/bin/env python3
+from pathlib import Path
+import re
+import sys
+import shutil
+
+
+PAGE_NAME = 'offline-docs'
+STATIC_PATH = 'chrome://browser/content/manual/static'
+
+if len(sys.argv) < 3:
+ print(f'Usage: {sys.argv[0]} lektor-out-directory target-directory')
+ sys.exit(1)
+
+source = Path(sys.argv[1])
+target = Path(sys.argv[2])
+if not target.exists():
+ target.mkdir(exist_ok=True)
+
+static_re = re.compile('"(?:../)*static/([^"]+)"')
+link_re = re.compile('href="../([^"]+)"')
+
+
+def clean_urls(match):
+ m = re.match(r'(?:../)?([^/#]+)[/]?[#]?(.*)', match.group(1))
+ slug = m.group(1)
+ if m.group(2):
+ anchor = '_' + m.group(2)
+ else:
+ anchor = ''
+ return f'href="#{slug}{anchor}"'
+
+
+htmls = source.rglob(f'{PAGE_NAME}/index.html')
+for page in htmls:
+ with page.open(encoding='utf8') as f:
+ contents = f.read()
+ contents = static_re.sub(f'"{STATIC_PATH}/\\1"', contents)
+ contents = link_re.sub(clean_urls, contents)
+
+ rel = page.relative_to(source)
+ dest_name = str(list(rel.parents)[-2].name)
+ if dest_name == PAGE_NAME:
+ dest_name = 'en'
+ dest_name += '.html'
+ with (target / dest_name).open('w', encoding='utf8') as f:
+ f.write(contents)
+
+shutil.rmtree(target / 'static', ignore_errors=True)
+shutil.copytree(source / 'static', target / 'static')
diff --git a/projects/tor-browser/build b/projects/tor-browser/build
index 049bf1c..e1de23b 100644
--- a/projects/tor-browser/build
+++ b/projects/tor-browser/build
@@ -83,6 +83,16 @@ find chrome/ | sort | zip -X -@ "$TBDIR[% IF c("var/osx") %]/Contents/Resources[
popd
rm -rf $TMP_HTTPS_EVERYWHERE_PATH
+# Include the Tor Browser manual
+TMP_MANUAL_PATH=$rootdir/tmp_manual/
+mkdir $TMP_MANUAL_PATH
+pushd $TMP_MANUAL_PATH
+tar -xf $rootdir/[% c('input_files_by_name/manual') %]
+find . -exec [% c("var/touch") %] {} \;
+find chrome/ | sort | zip -X -@ "$TBDIR[% IF c("var/osx") %]/Contents/Resources[% END %]/browser/omni.ja"
+popd
+rm -rf $TMP_MANUAL_PATH
+
tar -C "$TBDIR[% IF ! c("var/osx") %]/TorBrowser[% END %]" -xf [% c('input_files_by_name/tor') %]/tor.tar.gz
[% IF c("var/namecoin") %]
# Extract Electrum-NMC
diff --git a/projects/tor-browser/config b/projects/tor-browser/config
index d1a889f..9620b6b 100644
--- a/projects/tor-browser/config
+++ b/projects/tor-browser/config
@@ -123,3 +123,6 @@ input_files:
enable: '[% ! c("var/android") %]'
- filename: bridges_list.snowflake.txt
enable: '[% ! c("var/android") %]'
+ - project: manual
+ name: manual
+ enable: '[% ! c("var/android") %]'
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
More information about the tbb-commits
mailing list