Browse code

chromium: initial version

open-sans-fonts: initial version.

support/package-builder:
add capability to build extra packages like chromium on the need basis.
These packages are big and take a lot of time for building and there is
no need to build them upon every build.

`sudo BUILD_EXTRA_PKGS=yes make <target>`
The above command will override <target> with "extra-packages"

Change-Id: Ib6cb592587ae0bf67d0bbc4920310e6642482f85
Signed-off-by: Shreenidhi Shedi <sshedi@vmware.com>
Reviewed-on: http://photon-jenkins.eng.vmware.com:8082/c/photon/+/21206
Tested-by: Michelle Wang <michellew@vmware.com>

Shreenidhi Shedi authored on 2023/07/07 06:23:28
Showing 9 changed files
... ...
@@ -3,4 +3,8 @@ ifndef CONF
3 3
 endif
4 4
 
5 5
 %:
6
-	@python3 ./build.py -c $(CONF) -t $@
6
+	@if [ -n "$(shell echo $(BUILD_EXTRA_PKGS) | grep -Ew "enable|yes|True")" ]; then\
7
+		python3 build.py -c $(CONF) -t extra-packages;\
8
+	else\
9
+		python3 build.py -c $(CONF) -t $@;\
10
+	fi
7 11
new file mode 100644
... ...
@@ -0,0 +1,86 @@
0
+%global debug_package       %{nil}
1
+%define chromium_path       %{_libdir}/%{name}-browser
2
+%define builddir            out/headless
3
+
4
+Summary:        chromium
5
+Name:           chromium
6
+# Don't bump or upgrade version of this spec
7
+# This is a special package & needs some manual effort
8
+Version:        113.0.5672.95
9
+Release:        1%{?dist}
10
+License:        BSD 3
11
+URL:            https://chromium.googlesource.com/chromium/src
12
+Group:          System Utility
13
+Vendor:         VMware, Inc.
14
+Distribution:   Photon
15
+
16
+Source0: https://github.com/chromium/chromium/archive/%{name}-%{version}.tar.gz
17
+%define sha512 %{name}=a65de82d8a4392693440e861d62b80b23fc0730d57b3cdb63f4f307a9ed63eca4805def9a4dd0edce0ec258e8c2b38517ab5ed67ef02b62b5f6c673ade6b2563
18
+
19
+# git clone --depth 1 https://chromium.googlesource.com/chromium/tools/depot_tools.git
20
+# tar cJf depot_tools-<short-commit-hash>.tar.xz depot_tools
21
+Source1: depot_tools-872ac9bd3d.tar.xz
22
+%define sha512 depot_tools=fdab499da273784dbe645cea6e178a5ea2910d8d2e26450a8be75df73f0fa97de60a27b5bcca77aad8e6e1f95653cebecf98ba9b6cd26351b920b1f3d71a9f0d
23
+
24
+Source2: headless.gn
25
+
26
+BuildRequires: git
27
+BuildRequires: nss-devel
28
+BuildRequires: dbus-devel
29
+BuildRequires: glib-devel
30
+BuildRequires: glibc-devel
31
+BuildRequires: nspr-devel
32
+BuildRequires: ninja-build
33
+BuildRequires: gperf
34
+
35
+# TODO: need to revisit for aarch64
36
+BuildArch: x86_64
37
+
38
+Requires: glibc
39
+Requires: nspr
40
+Requires: nss-libs
41
+Requires: open-sans-fonts
42
+
43
+%description
44
+Chromium is an open-source browser project that aims to build a safer, faster, and more stable way for all users to experience the web.
45
+
46
+%prep
47
+%autosetup -a0 -a1 -p1 -n src
48
+
49
+%build
50
+pushd %{_builddir}/src/build/linux/debian_bullseye_amd64-sysroot%{_libdir}/pkgconfig
51
+
52
+cp glib-2.0.pc \
53
+   dbus-1.pc \
54
+   nss.pc \
55
+   nspr.pc \
56
+   %{_libdir}/pkgconfig
57
+
58
+popd
59
+
60
+mkdir -p %{builddir}
61
+cp %{SOURCE2} %{builddir}/args.gn
62
+
63
+%{_builddir}/src/depot_tools/gn gen %{builddir}
64
+
65
+ninja -C %{builddir} headless_shell -j $(nproc)
66
+
67
+%install
68
+mkdir -p %{buildroot}%{chromium_path}
69
+cp -pr %{builddir}/headless_lib_data.pak \
70
+       %{builddir}/headless_lib_strings.pak \
71
+       %{builddir}/headless_shell \
72
+       %{builddir}/libvk_swiftshader.so* \
73
+       %{builddir}/libvulkan.so* \
74
+       %{builddir}/libEGL.so* \
75
+       %{builddir}/libGLESv2.so* \
76
+       %{builddir}/vk_swiftshader_icd.json \
77
+       %{buildroot}%{chromium_path}
78
+
79
+%files
80
+%defattr(-,root,root)
81
+%{chromium_path}
82
+
83
+%changelog
84
+* Wed May 31 2023 Shreenidhi Shedi <sshedi@vmware.com> 113.0.5672.95-1
85
+- Initial packaging with Photon OS
0 86
new file mode 100644
... ...
@@ -0,0 +1,53 @@
0
+# GN args template for the Headless Chrome library
1
+#
2
+# Add import to arg.gn in out directory and run gn gen on the directory to use.
3
+# E.g. for out directory out/foo:
4
+# echo 'import("//build/args/headless.gn")' > out/foo/args.gn
5
+# gn gen out/foo
6
+#
7
+# Use gn args to add your own build preference args.
8
+use_ozone = true
9
+ozone_auto_platforms = false
10
+ozone_platform = "headless"
11
+ozone_platform_headless = true
12
+angle_enable_vulkan = true
13
+angle_enable_swiftshader = true
14
+# Embed resource.pak into binary to simplify deployment.
15
+headless_use_embedded_resources = true
16
+# Disable headless commands support.
17
+headless_enable_commands = false
18
+# Don't use Prefs component, disabling access to Local State prefs.
19
+headless_use_prefs = false
20
+# Don't use Policy component, disabling all policies.
21
+headless_use_policy = false
22
+# Remove a dependency on a system fontconfig library.
23
+use_bundled_fontconfig = true
24
+# In order to simplify deployment we build ICU data file
25
+# into binary.
26
+icu_use_data_file = false
27
+# Use embedded data instead external files for headless in order
28
+# to simplify deployment.
29
+v8_use_external_startup_data = false
30
+enable_nacl = false
31
+enable_print_preview = false
32
+enable_remoting = false
33
+use_alsa = false
34
+use_bluez = false
35
+use_cups = false
36
+use_dbus = false
37
+use_gio = false
38
+use_kerberos = false
39
+use_libpci = false
40
+use_pulseaudio = false
41
+use_udev = false
42
+rtc_use_pipewire = false
43
+v8_enable_lazy_source_positions = false
44
+use_glib = false
45
+use_gtk = false
46
+use_pangocairo = false
47
+
48
+is_debug=false
49
+is_official_build=true
50
+symbol_level=0
51
+blink_symbol_level=0
52
+chrome_pgo_phase=0
0 53
new file mode 100644
... ...
@@ -0,0 +1,16 @@
0
+<?xml version="1.0" encoding="UTF-8"?>
1
+<!DOCTYPE fontconfig SYSTEM "../fonts.dtd">
2
+<fontconfig>
3
+  <alias>
4
+    <family>sans-serif</family>
5
+    <prefer>
6
+      <family>Open Sans</family>
7
+    </prefer>
8
+  </alias>
9
+  <alias>
10
+    <family>Open Sans</family>
11
+    <default>
12
+      <family>sans-serif</family>
13
+    </default>
14
+  </alias>
15
+</fontconfig>
0 16
new file mode 100644
... ...
@@ -0,0 +1,67 @@
0
+%global fontname    open-sans
1
+%global fontconf    60-%{fontname}.conf
2
+%define _fontdir    %{_datadir}/fonts/%{fontname}
3
+
4
+%define _fontconfig_confdir %{_sysconfdir}/fonts/conf.d
5
+%define _fontconfig_templatedir %{_datadir}/fontconfig/conf.avail
6
+
7
+Name:       open-sans-fonts
8
+# Don't bump or upgrade version of this spec
9
+# This is a special package & needs some manual effort
10
+Version:    1.10
11
+Release:    1%{?dist}
12
+Summary:    Open Sans is a humanist sans-serif typeface designed by Steve Matteson
13
+License:    ASL 2.0
14
+URL:        http://www.google.com/fonts/specimen/Open+Sans
15
+Group:      System Utility
16
+Vendor:     VMware, Inc.
17
+Distribution: Photon
18
+
19
+# Since the font doesn't have clear upstream, the source zip package is
20
+# downloaded from Google Fonts. It is then converted to tar.gz.
21
+Source0: %{name}-%{version}.tar.xz
22
+%define sha512 %{name}=7e49f5ec6eeb6f7c95ca28ec9ebf170b126e1d1e07bc42a15029374ecb594756a7cf130d1da435f28df37e1385e183ccc07f08dd0f0dd468b830cdccd33c0b71
23
+
24
+Source1: %{name}-fontconfig.conf
25
+
26
+BuildArch: noarch
27
+
28
+%description
29
+Open Sans is a humanist sans serif typeface designed by Steve Matteson, Type
30
+Director of Ascender Corp. This version contains the complete 897 character
31
+set, which includes the standard ISO Latin 1, Latin CE, Greek and Cyrillic
32
+character sets. Open Sans was designed with an upright stress, open forms and
33
+a neutral, yet friendly appearance. It was optimized for print, web, and mobile
34
+interfaces, and has excellent legibility characteristics in its letter forms.
35
+
36
+%prep
37
+%autosetup -p1
38
+
39
+%build
40
+
41
+%install
42
+install -m 0755 -d %{buildroot}%{_fontdir}
43
+install -m 0644 -p *.ttf %{buildroot}%{_fontdir}
44
+
45
+install -m 0755 -d \
46
+    %{buildroot}%{_fontconfig_templatedir} \
47
+    %{buildroot}%{_fontconfig_confdir}
48
+
49
+install -m 0644 -p %{SOURCE1} \
50
+    %{buildroot}%{_fontconfig_templatedir}/%{fontconf}
51
+
52
+ln -sv %{_fontconfig_templatedir}/%{fontconf} \
53
+    %{buildroot}%{_fontconfig_confdir}/%{fontconf}
54
+
55
+%clean
56
+rm -rf %{buildroot}/*
57
+
58
+%files
59
+%defattr(-,root,root)
60
+%{_fontdir}/*
61
+%{_fontconfig_confdir}/*
62
+%{_fontconfig_templatedir}/*
63
+
64
+%changelog
65
+* Thu Jun 01 2023 Shreenidhi Shedi <sshedi@vmware.com> 1.10-1
66
+- Initial version, needed by chromium.
... ...
@@ -20,6 +20,9 @@
20 20
             "glibc",
21 21
             "linux"
22 22
         ],
23
+        "extra-packages-list": [
24
+            "chromium"
25
+        ],
23 26
         "target": "iso",
24 27
         "compression-macro": "w19.zstdio",
25 28
 
... ...
@@ -70,6 +70,7 @@ targetDict = {
70 70
         "generate-yaml-files",
71 71
         "create-repo",
72 72
         "distributed-build",
73
+        "extra-packages",
73 74
     ],
74 75
     "buildEnvironment": [
75 76
         "packages-cached",
... ...
@@ -767,6 +768,8 @@ class RpmBuildTarget:
767 767
 
768 768
     def package(self, pkgName):
769 769
         self.logger.debug(f"Package to build: {pkgName}")
770
+        if pkgName in constants.extraPackagesList:
771
+            constants.extraPackagesList.remove(pkgName)
770 772
         Builder.buildSpecifiedPackages(
771 773
             [pkgName], Build_Config.buildThreads, Build_Config.pkgBuildType
772 774
         )
... ...
@@ -857,6 +860,21 @@ class RpmBuildTarget:
857 857
         )
858 858
         check_prerequesite["check-packages"] = True
859 859
 
860
+    def extra_packages(self):
861
+        if check_prerequesite["extra-packages"]:
862
+            return
863
+
864
+        Builder.buildSpecifiedPackages(
865
+            constants.extraPackagesList,
866
+            Build_Config.buildThreads,
867
+            Build_Config.pkgBuildType,
868
+            Build_Config.pkgInfoFile,
869
+            self.logger,
870
+            build_extra_pkgs=True,
871
+        )
872
+
873
+        check_prerequesite["extra-packages"] = True
874
+
860 875
     def distributed_build():
861 876
         # TODO: should be moved to top
862 877
         import DistributedBuilder
... ...
@@ -1491,6 +1509,8 @@ def initialize_constants():
1491 1491
     ):
1492 1492
         constants.enable_fips_in_make_check()
1493 1493
 
1494
+    constants.extraPackagesList = configdict["photon-build-param"]["extra-packages-list"]
1495
+
1494 1496
     constants.initialize()
1495 1497
 
1496 1498
     check_prerequesite["initialize-constants"] = True
... ...
@@ -1539,6 +1559,7 @@ def process_env_build_params(ph_build_param):
1539 1539
         "BUILD_DBGINFO_RPM": "build-dbginfo-rpm",
1540 1540
         "RPMCHECK": "rpm-check-flag",
1541 1541
         "SCHEDULER_SERVER": "start-scheduler-server",
1542
+        "BUILD_EXTRA_PKGS": "build-extra-pkgs",
1542 1543
     }
1543 1544
 
1544 1545
     os.environ["PHOTON_RELEASE_VER"] = ph_build_param["photon-release-version"]
... ...
@@ -1563,6 +1584,7 @@ def process_env_build_params(ph_build_param):
1563 1563
             "BUILDDEPS",
1564 1564
             "SCHEDULER_SERVER",
1565 1565
             "CANISTER_BUILD",
1566
+            "BUILD_EXTRA_PKGS",
1566 1567
         }:
1567 1568
             val = cmdUtils.strtobool(val)
1568 1569
         elif k == "RPMCHECK":
... ...
@@ -1675,6 +1697,16 @@ def main():
1675 1675
 
1676 1676
     initialize_constants()
1677 1677
 
1678
+    """
1679
+    Special case.
1680
+    If BUILD_EXTRA_PKGS environment variable is set
1681
+    Override everything else and build extra packages.
1682
+    """
1683
+    if configdict["photon-build-param"].get("build-extra-pkgs", False):
1684
+        # incase if build.py is invoked directly
1685
+        if targetName != "extra-packages":
1686
+            targetName = "extra-packages"
1687
+
1678 1688
     if not targetName:
1679 1689
         targetName = ph_build_param["target"]
1680 1690
 
... ...
@@ -1,12 +1,12 @@
1 1
 #!/usr/bin/env python3
2 2
 
3
-from argparse import ArgumentParser
4 3
 import os.path
5 4
 import collections
6 5
 import traceback
7 6
 import sys
8 7
 import json
9 8
 import copy
9
+
10 10
 from CommandUtils import CommandUtils
11 11
 from Logger import Logger
12 12
 from constants import constants
... ...
@@ -14,12 +14,25 @@ from PackageManager import PackageManager
14 14
 from SpecData import SPECS
15 15
 from PackageInfo import PackageInfo
16 16
 
17
+
17 18
 class Builder:
18 19
 
19
-    def buildSpecifiedPackages(listPackages, buildThreads, pkgBuildType, pkgInfoJsonFile=None, logger=None):
20
+    def buildSpecifiedPackages(
21
+        listPackages,
22
+        buildThreads,
23
+        pkgBuildType,
24
+        pkgInfoJsonFile=None,
25
+        logger=None,
26
+        build_extra_pkgs=False,
27
+    ):
20 28
         if constants.rpmCheck:
21 29
             constants.setTestForceRPMS(copy.copy(listPackages))
30
+
22 31
         pkgManager = PackageManager(pkgBuildType=pkgBuildType)
32
+
33
+        if not build_extra_pkgs:
34
+            listPackages = set(listPackages) - set(constants.extraPackagesList)
35
+
23 36
         pkgManager.buildPackages(listPackages, buildThreads)
24 37
 
25 38
         if pkgInfoJsonFile is not None:
... ...
@@ -47,6 +47,7 @@ class constants(object):
47 47
     buildSrcRpm = 0
48 48
     buildDbgInfoRpm = 0
49 49
     buildDbgInfoRpmList = []
50
+    extraPackagesList = []
50 51
 
51 52
     noDepsPackageList = [
52 53
         "texinfo",