Backport from Fedora to drop python3-ruamel-yaml

Resolves: RHEL-39673
This commit is contained in:
Akira TAGOH 2024-06-28 18:57:26 +09:00
parent 46a4e8907b
commit 39dd1ce9c2
3 changed files with 120 additions and 2 deletions

View File

@ -0,0 +1,46 @@
diff -pruN fonts-rpm-macros-2.0.5.orig/bin/gen-fontconf fonts-rpm-macros-2.0.5/bin/gen-fontconf
--- fonts-rpm-macros-2.0.5.orig/bin/gen-fontconf 2020-04-03 07:55:50.000000000 +0900
+++ fonts-rpm-macros-2.0.5/bin/gen-fontconf 2024-06-03 14:07:58.244902559 +0900
@@ -23,7 +23,11 @@ from lxml import etree
from operator import itemgetter
import os
from pathlib import PurePath
-import ruamel.yaml
+yaml_supported = True
+try:
+ import ruamel.yaml
+except ModuleNotFoundError:
+ yaml_supported = False
import subprocess
import sys
@@ -36,14 +40,17 @@ oneormore = ['fullname', 'family', 'styl
parser = argparse.ArgumentParser(
description='Generate traditional fontconfig syntax from a high-level configuration file')
cgroup = parser.add_mutually_exclusive_group(required=True)
-cgroup.add_argument("-y", "--yaml", "-c", "--config", type=str,
- help="YAML configuration file to process")
+mode = ['xml', 'legacy']
+if yaml_supported:
+ mode.append('yaml')
+ cgroup.add_argument("-y", "--yaml", "-c", "--config", type=str,
+ help="YAML configuration file to process")
cgroup.add_argument("-x", "--xml", type=str,
help="XML configuration file to process")
parser.add_argument("-l", "--license", metavar="SPDX ID", type=str, nargs='?', default="MIT",
help="SPDX license identifier for the generated files")
parser.add_argument("-m", "--mode", metavar="MODE", type=str, nargs='?',
- default="legacy", choices=['xml', 'yaml', 'legacy'],
+ default="legacy", choices=mode,
help="Output format: current fontconfig syntax, or XML/YAML syntax proposals")
parser.add_argument("-w", "--write", action="store_true",
help="Write output to disk")
@@ -685,7 +692,7 @@ ext = '.conf'
if args.mode == 'xml':
ext = '.xml'
-if args.yaml != None:
+if yaml_supported and args.yaml != None:
groups = readyaml(args.yaml)
if args.write and output == None:
output = PurePath(PurePath(args.yaml).name).with_suffix(ext)

View File

@ -0,0 +1,57 @@
diff -pruN fonts-rpm-macros-2.0.5.orig/rpm/lua/srpm/fonts.lua fonts-rpm-macros-2.0.5/rpm/lua/srpm/fonts.lua
--- fonts-rpm-macros-2.0.5.orig/rpm/lua/srpm/fonts.lua 2024-06-19 16:39:41.814323447 +0900
+++ fonts-rpm-macros-2.0.5/rpm/lua/srpm/fonts.lua 2024-06-19 16:42:07.095849192 +0900
@@ -172,13 +172,31 @@ local function pkg(forcemain, forcesub,
end
end
+-- Output Requires(meta) line
+local function output_requires(fontpkg)
+ if tonumber(rpm.expand("0%{?epoch}")) == 0 then
+ print(rpm.expand( "Requires(meta): " .. fontpkg .. " = %{version}-%{release}\n"))
+ else
+ print(rpm.expand( "Requires(meta): " .. fontpkg .. " = %{epoch}:%{version}-%{release}\n"))
+ end
+end
+
-- Create a font (sub)metapackage header
local function metapkg(name, summary, description, suffixes)
local fedora = require "fedora.common"
local fontpkgs = fedora.getsuffixed("fontpkgname")
+ local hsuffix
if (name == "") then
name, _ = string.gsub(rpm.expand("%{name}"), "-fonts$", "")
name = name .. "-fonts-all"
+ hsuffix = "all"
+ else
+ hsuffix = norm(name)
+ end
+ if (rpm.expand("%{?fontpkgheader" .. hsuffix .. "}") ~= "") then
+ fedora.explicitset( "currentfontpkgheader", "%{fontpkgheader" .. hsuffix .. "}", false)
+ else
+ fedora.explicitunset( "currentfontpkgheader", false)
end
if (summary == "") then
summary = "All the font packages, generated from %{name}"
@@ -192,18 +210,19 @@ local function metapkg(name, summary, de
"Summary: " .. summary .. "\n"))
if (suffixes == "") then
for _, fontpkg in pairs(fontpkgs) do
- print(rpm.expand( "Requires(meta): " .. fontpkg .. " = %{version}-%{release}\n"))
+ output_requires(fontpkg)
end
else
for suffix in string.gmatch(rpm.expand(suffixes), "[^%s%p]+") do
local fontpkg = fontpkgs[suffix]
if (fontpkg ~= nil) then
- print(rpm.expand("Requires(meta): " .. fontpkg .. " = %{version}-%{release}\n"))
+ output_requires(fontpkg)
end
end
end
print(rpm.expand(
"BuildArch: noarch\n" ..
+ "%{?currentfontpkgheader}\n" ..
"%description -n " .. name .. "\n" ..
description .. "\n" ..
"%files -n " .. name .. "\n\n"))

View File

@ -18,13 +18,15 @@ Version: 2.0.5
BuildArch: noarch BuildArch: noarch
Name: fonts-rpm-macros Name: fonts-rpm-macros
Release: 15%{?dist} Release: 16%{?dist}
Summary: Build-stage rpm automation for fonts packages Summary: Build-stage rpm automation for fonts packages
License: GPL-3.0-or-later License: GPL-3.0-or-later
URL: https://docs.fedoraproject.org/en-US/packaging-guidelines/FontsPolicy/ URL: https://docs.fedoraproject.org/en-US/packaging-guidelines/FontsPolicy/
Source: %{forgesource} Source: %{forgesource}
Patch0: %{name}-omit-foundry-in-family.patch Patch0: %{name}-omit-foundry-in-family.patch
Patch1: %{name}-drop-yaml.patch
Patch2: %{name}-epoch-in-req.patch
Requires: fonts-srpm-macros = %{?epoch:%{epoch}:}%{version}-%{release} Requires: fonts-srpm-macros = %{?epoch:%{epoch}:}%{version}-%{release}
Requires: fonts-filesystem = %{?epoch:%{epoch}:}%{version}-%{release} Requires: fonts-filesystem = %{?epoch:%{epoch}:}%{version}-%{release}
@ -39,7 +41,9 @@ Requires: libappstream-glib
Requires: uchardet Requires: uchardet
# For the experimental generator # For the experimental generator
%if 0%{?fedora} || 0%{?rhel} < 10
Requires: python3-ruamel-yaml Requires: python3-ruamel-yaml
%endif
Requires: python3-lxml Requires: python3-lxml
%description %description
@ -99,7 +103,11 @@ for template in templates/rpm/*\.spec ; do
grep -v '^%%dnl' "${template}" > "${target}" grep -v '^%%dnl' "${template}" > "${target}"
touch -r "${template}" "${target}" touch -r "${template}" "${target}"
done done
%patch0 -p1 -b .1-omit-foundry-in-family %patch -P0 -p1 -b .0-omit-foundry-in-family
%if 0%{?rhel} >= 10
%patch -P1 -p1 -b .1-drop-yaml
%endif
%patch -P2 -p1 -b .2-epoch-in-req
%install %install
install -m 0755 -d %{buildroot}%{_fontbasedir} \ install -m 0755 -d %{buildroot}%{_fontbasedir} \
@ -155,6 +163,13 @@ install -m 0755 -vp bin/* %{buildroot}%{_bindir}
%doc %{ftcgtemplatedir}/*txt %doc %{ftcgtemplatedir}/*txt
%changelog %changelog
* Wed Jun 19 2024 Akira TAGOH <tagoh@redhat.com> - 1:2.0.5-16
- Add %%{epoch} in Requires line if needed
- Support fontpkgheader macro for meta packages.
* Mon Jun 3 2024 Akira TAGOH <tagoh@redhat.com> - 1:2.0.5-15
- Drop YAML support in gen-fontconf for RHEL10 or later.
* Mon Jun 24 2024 Troy Dawson <tdawson@redhat.com> - 1:2.0.5-15 * Mon Jun 24 2024 Troy Dawson <tdawson@redhat.com> - 1:2.0.5-15
- Bump release for June 2024 mass rebuild - Bump release for June 2024 mass rebuild