1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
|
#!/usr/bin/env python3
# Spdx-License-Identifier: GPL-2.0-or-later
# A wrapper script to generate support files, see #684550 #706786 #968958
# Use upstream's python installer script to generate support files
# This replaces fragile sed commands and handles @@include@@ directives.
# It'll also verify that all substitution markers have been resolved, meaning that
# future changes to templates that add new variables will be caught during the build.
import sys
import argparse
from pathlib import Path
# Add upstream installer script to search path
sys.path.insert(0, str(Path.cwd() / "chrome/installer/linux/common"))
import installer
def main():
parser = argparse.ArgumentParser()
parser.add_argument(
"-i",
"--installdir",
required=True,
help="Installation directory (e.g. /usr/lib/chromium-browser)",
)
parser.add_argument(
"-c",
"--channel",
default="stable",
choices=["stable", "beta", "unstable", "dev", "canary"],
help="Channel to build for (default: stable)",
)
args = parser.parse_args()
# Normalise channel name (upstream uses 'unstable' for dev)
channel = args.channel
if channel == "dev":
channel = "unstable"
# Define suffixes based on channel
channel_suffix = ""
menu_suffix = ""
if channel != "stable":
channel_suffix = f"-{channel}"
menu_suffix = f" ({channel})"
# Configure contexts strictly for file generation
# Common variables used across templates
context = {
"BUGTRACKERURL": "https://bugs.gentoo.org/enter_bug.cgi?product=Gentoo Linux&component=Current packages",
"DEVELOPER_NAME": "The Chromium Authors",
"EXTRA_DESKTOP_ENTRIES": "",
"FULLDESC": "An open-source browser project that aims to build a safer, faster, and more stable way to experience the web.",
"HELPURL": "https://wiki.gentoo.org/wiki/Chromium",
"INSTALLDIR": args.installdir, # Note: We've patched the installer scripts to automatically append the channel suffix, but we'll use the arg since we bypass all that.
"MAINTMAIL": "chromium@gentoo.org", # Must be a bare email address for appstream metadata
"MENUNAME": f"Chromium{menu_suffix}",
"PACKAGE": f"chromium-browser{channel_suffix}",
"PRODUCTURL": "https://www.chromium.org/",
"PROGNAME": "chrome",
"PROJECT_LICENSE": "BSD, LGPL-2, LGPL-2.1, MPL-1.1, MPL-2.0, Apache-2.0, and others",
"SHORTDESC": "Open-source foundation of many web browsers including Google Chrome",
"STARTUP_WM_CLASS": f"chromium-browser{channel_suffix}",
# Use a distinct scheme handler for slotted installs to avoid conflicts
"URI_SCHEME": f"x-scheme-handler/chromium{channel_suffix}",
"USR_BIN_SYMLINK_NAME": f"chromium-browser{channel_suffix}",
}
# upstream is currently (M145) converting from upper to lower case
# we need to support both until we drop old versions _and_ the conversion is complete.
for key in list(context):
context[key.lower()] = context[key]
# Generate Desktop file
installer.process_template(
Path("chrome/installer/linux/common/desktop.template"),
Path(f"out/Release/chromium-browser{channel_suffix}.desktop"),
context,
)
# Generate Manpage
installer.process_template(
Path("chrome/app/resources/manpage.1.in"),
Path(f"out/Release/chromium-browser{channel_suffix}.1"),
context,
)
# Generate AppData (AppStream)
installer.process_template(
Path("chrome/installer/linux/common/appdata.xml.template"),
Path(f"out/Release/chromium-browser{channel_suffix}.appdata.xml"),
context,
)
# Generate GNOME Default Apps entry
installer.process_template(
Path("chrome/installer/linux/common/default-app.template"),
Path(f"out/Release/chromium-browser{channel_suffix}.xml"),
context,
)
if __name__ == "__main__":
main()
|