From 74b8dd05bbc696e24d469d9c7e5e4f938cf6d028 Mon Sep 17 00:00:00 2001 From: Fabio Valentini Date: Thu, 10 May 2018 17:11:47 +0000 Subject: [PATCH 01/17] do not use modification time of tarball for computing %dist Using the modification time of the snapshot tarball for computing dist is a bad idea, since it's different on different machines. For example, the computed date during the `buildSRPMfromSCM` koji task is likely different from the local date when the package was prepared, and so package builds (especially EVRs and changelog entries) are not reproducible. With this change, the snapshot date is not calculated magically, but the packager has to set "%global date YYYYMMDD" manually. I also adapted the documentation for the macro to reflect that change. This is related to the following FPC issue: https://pagure.io/packaging-committee/issue/719 --- macros.forge | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/macros.forge b/macros.forge index 1bec610..17efa3f 100644 --- a/macros.forge +++ b/macros.forge @@ -8,6 +8,7 @@ # Version if applicable, set it with Version: # tag if applicable # commit if applicable +# date if applicable # # The macro will attempt to compute and set the following variables if they are # not already set by the packager: @@ -255,7 +256,7 @@ if (distprefix == "") then distprefix = string.sub(rpm.expand("%{?commit}"), 1, 7) end if (distprefix ~= "") then - local dist = ".%([ -r %{_sourcedir}/%{archivename}.%{archiveext} ] && date +%Y%m%d -u -r %{_sourcedir}/%{archivename}.%{archiveext})%{scm}" .. string.gsub(distprefix, "-",".") .. rpm.expand("%{?dist}") + local dist = ".%{date}.%{scm}" .. string.gsub(distprefix, "-",".") .. rpm.expand("%{?dist}") explicitset("dist", dist) end -- Final spec variable summary if the macro was called with -i @@ -271,7 +272,7 @@ if informative then rpm.expand("%{echo: scm: %{?scm}\\n}") rpm.expand("%{echo: tag: %{?tag}\\n}") rpm.expand("%{echo: commit: %{?commit}\\n}") - rpm.expand("%{echo: dist: %{?dist} (snapshot date is computed once %%{_sourcedir}/%%{archivename}.%%{archiveext} is available)\\n}") + rpm.expand("%{echo: dist: %{?dist}\\n}") end } @@ -279,4 +280,4 @@ end %forgesetup(a:b:cDn:Tq) %setup %{?forgesetupargs} %{-a} %{-b} %{-c} %{-D} %{-n} %{-T} %{-q} # Convenience macro to relay computed arguments to %autosetup -%forgeautosetup(a:b:cDn:TvNS:p:) %autosetup %{?forgesetupargs} %{-a} %{-b} %{-c} %{-D} %{-n} %{-T} %{-v} %{-N} %{-S} %{-p} +%forgeautosetup(a:b:cDn:TvNS:p:) %autosetup %{?forgesetupargs} %{-a} %{-b} %{-c} %{-D} %{-n} %{-T} %{-v} %{-N} %{-S} %{-p} \ No newline at end of file From 22833277e67bd7f5a58300492e03059edbe03076 Mon Sep 17 00:00:00 2001 From: Fabio Valentini Date: Sat, 26 May 2018 11:59:04 +0200 Subject: [PATCH 02/17] supplying %date for %forge macros optional (backwards compatible) --- macros.forge | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/macros.forge b/macros.forge index 17efa3f..fd703a1 100644 --- a/macros.forge +++ b/macros.forge @@ -8,7 +8,7 @@ # Version if applicable, set it with Version: # tag if applicable # commit if applicable -# date if applicable +# date if applicable (to override the mtime of the Source archive) # # The macro will attempt to compute and set the following variables if they are # not already set by the packager: @@ -256,7 +256,7 @@ if (distprefix == "") then distprefix = string.sub(rpm.expand("%{?commit}"), 1, 7) end if (distprefix ~= "") then - local dist = ".%{date}.%{scm}" .. string.gsub(distprefix, "-",".") .. rpm.expand("%{?dist}") + local dist = ".%{?date}%{!?date:%([ -r %{_sourcedir}/%{archivename}.%{archiveext} ] && date +%Y%m%d -u -r %{_sourcedir}/%{archivename}.%{archiveext})}.%{scm}" .. string.gsub(distprefix, "-",".") .. rpm.expand("%{?dist}") explicitset("dist", dist) end -- Final spec variable summary if the macro was called with -i @@ -272,7 +272,7 @@ if informative then rpm.expand("%{echo: scm: %{?scm}\\n}") rpm.expand("%{echo: tag: %{?tag}\\n}") rpm.expand("%{echo: commit: %{?commit}\\n}") - rpm.expand("%{echo: dist: %{?dist}\\n}") + rpm.expand("%{echo: dist: %{?dist} (snapshot date is either manually supplied or computed once %%{_sourcedir}/%%{archivename}.%%{archiveext} is available)\\n}") end } @@ -280,4 +280,4 @@ end %forgesetup(a:b:cDn:Tq) %setup %{?forgesetupargs} %{-a} %{-b} %{-c} %{-D} %{-n} %{-T} %{-q} # Convenience macro to relay computed arguments to %autosetup -%forgeautosetup(a:b:cDn:TvNS:p:) %autosetup %{?forgesetupargs} %{-a} %{-b} %{-c} %{-D} %{-n} %{-T} %{-v} %{-N} %{-S} %{-p} \ No newline at end of file +%forgeautosetup(a:b:cDn:TvNS:p:) %autosetup %{?forgesetupargs} %{-a} %{-b} %{-c} %{-D} %{-n} %{-T} %{-v} %{-N} %{-S} %{-p} From 30ef72bedf46d2d32156c5d8b6669af3487d713d Mon Sep 17 00:00:00 2001 From: Fabio Valentini Date: Thu, 14 Jun 2018 18:25:25 +0200 Subject: [PATCH 03/17] macros.forge: drop additional dot to match current Guidelines --- macros.forge | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/macros.forge b/macros.forge index fd703a1..18e9dba 100644 --- a/macros.forge +++ b/macros.forge @@ -256,7 +256,7 @@ if (distprefix == "") then distprefix = string.sub(rpm.expand("%{?commit}"), 1, 7) end if (distprefix ~= "") then - local dist = ".%{?date}%{!?date:%([ -r %{_sourcedir}/%{archivename}.%{archiveext} ] && date +%Y%m%d -u -r %{_sourcedir}/%{archivename}.%{archiveext})}.%{scm}" .. string.gsub(distprefix, "-",".") .. rpm.expand("%{?dist}") + local dist = ".%{?date}%{!?date:%([ -r %{_sourcedir}/%{archivename}.%{archiveext} ] && date +%Y%m%d -u -r %{_sourcedir}/%{archivename}.%{archiveext})}%{scm}" .. string.gsub(distprefix, "-",".") .. rpm.expand("%{?dist}") explicitset("dist", dist) end -- Final spec variable summary if the macro was called with -i From 357550f7ba4495b01399c904d389369eb0666837 Mon Sep 17 00:00:00 2001 From: Igor Gnatenko Date: Wed, 15 Aug 2018 07:00:14 +0200 Subject: [PATCH 04/17] Enable --as-needed by default Signed-off-by: Igor Gnatenko --- macros | 4 ++-- redhat-rpm-config.spec | 5 ++++- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/macros b/macros index a6d89de..d7ffc84 100644 --- a/macros +++ b/macros @@ -219,8 +219,8 @@ %_ld_symbols_flags %{?_ld_strict_symbol_defs:-Wl,-z,defs} # https://fedoraproject.org/wiki/Changes/RemoveExcessiveLinking -# use "%define _ld_as_needed 1" to enable. -#%_ld_as_needed 1 +# use "%undefine _ld_as_needed" to disable. +%_ld_as_needed 1 %_ld_as_needed_flags %{?_ld_as_needed:-Wl,--as-needed} %__global_compiler_flags -O2 -g -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -fexceptions -fstack-protector-strong -grecord-gcc-switches %{_hardened_cflags} %{_annotated_cflags} diff --git a/redhat-rpm-config.spec b/redhat-rpm-config.spec index 6fad0e6..4c1b567 100644 --- a/redhat-rpm-config.spec +++ b/redhat-rpm-config.spec @@ -6,7 +6,7 @@ Summary: Red Hat specific rpm configuration files Name: redhat-rpm-config -Version: 117 +Version: 118 Release: 1%{?dist} # No version specified. License: GPL+ @@ -183,6 +183,9 @@ install -p -m 755 -t %{buildroot}%{_rpmconfigdir} kmod.prov %{_rpmconfigdir}/macros.d/macros.kmp %changelog +* Wed Aug 15 2018 Igor Gnatenko - 118-1 +- Enable --as-needed by default + * Mon Jul 16 2018 Miro Hrončok - 117-1 - Mangle /bin shebnags to /usr/bin ones (#1581757) From 92782515316b687981167bf93e1da5ca1cce8e91 Mon Sep 17 00:00:00 2001 From: Kalev Lember Date: Mon, 20 Aug 2018 22:33:04 +0200 Subject: [PATCH 05/17] Add aarch64 to ldc arches --- macros.ldc-srpm | 2 +- redhat-rpm-config.spec | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/macros.ldc-srpm b/macros.ldc-srpm index 2ee111e..571d3f1 100644 --- a/macros.ldc-srpm +++ b/macros.ldc-srpm @@ -1,2 +1,2 @@ # arches that ldc builds on -%ldc_arches %{ix86} x86_64 %{arm} +%ldc_arches %{ix86} x86_64 %{arm} aarch64 diff --git a/redhat-rpm-config.spec b/redhat-rpm-config.spec index 4c1b567..b7c0c77 100644 --- a/redhat-rpm-config.spec +++ b/redhat-rpm-config.spec @@ -6,7 +6,7 @@ Summary: Red Hat specific rpm configuration files Name: redhat-rpm-config -Version: 118 +Version: 119 Release: 1%{?dist} # No version specified. License: GPL+ @@ -183,6 +183,9 @@ install -p -m 755 -t %{buildroot}%{_rpmconfigdir} kmod.prov %{_rpmconfigdir}/macros.d/macros.kmp %changelog +* Mon Aug 20 2018 Kalev Lember - 119-1 +- Add aarch64 to ldc arches + * Wed Aug 15 2018 Igor Gnatenko - 118-1 - Enable --as-needed by default From 31fa384924904f0edafb3a3a084db4e4bb04fd7f Mon Sep 17 00:00:00 2001 From: Nicolas Mailhot Date: Fri, 31 Aug 2018 11:21:57 +0200 Subject: [PATCH 06/17] simplify gitlab processing thanks to https://gitlab.com/gitlab-org/gitlab-ce/issues/38830 --- macros.forge | 37 +++++++++++++++++-------------------- 1 file changed, 17 insertions(+), 20 deletions(-) diff --git a/macros.forge b/macros.forge index 18e9dba..146b8dd 100644 --- a/macros.forge +++ b/macros.forge @@ -91,32 +91,29 @@ if (forgeurl ~= "") then end else explicitset("forgeurl", forgeurl) - if (commit == "") then - rpm.expand("%{error:All Gitlab URLs require commit value knowledge: you need to define %{commit}!\\nPlease vote on https://gitlab.com/gitlab-org/gitlab-ce/issues/38830\\n}") - end safeset("archiveext", "tar.bz2") safeset("forgesetupargs", "-n %{archivename}") - if (commit ~= "") or (tag ~= "") then + -- Packaging a moving branch is quite a bad idea, but since Gitlab + -- uses the same convention for tags and branches in archive downloads, + -- better do it explicitly than have packagers use the branch name in + -- %{tag} + local branch = rpm.expand("%{?branch}") + if (commit ~= "") or (tag ~= "") or (branch ~= "") then safeset("scm", "git") end - local owner = string.match(forgeurl, "^[^:]+://[^/]+/([^/]+)") - local repo = string.match(forgeurl, "^[^:]+://[^/]+/[^/]+/([^/]+)") - local version = rpm.expand("%{?version}") - if (version ~= "") and (version ~= "0") and (tag == "") then - -- GitLab does not have strong versionning semantics - -- Some projects use "version" as release tag, others "v" + "version" - -- Tag value needs to be explicitly declared before calling the macro - -- in the second case - tag = version - safeset("tag", tag) + local owner = string.match(forgeurl, "^[^:]+://[^/]+/([^/]+)") + local repo = string.match(forgeurl, "^[^:]+://[^/]+/[^/]+/([^/]+)") + local ref = "" + if (commit ~= "") then ref = "%{?commit}" + elseif (tag ~= "") then ref = "%{?tag}" + elseif (branch ~= "") then ref = "%{?branch}" + else ref = "%{?version}" end - if (tag ~= "") then - safeset("archivename", repo .. "-%{tag}-%{commit}") - safeset("archiveurl", "%{forgeurl}/repository/%{tag}/archive.%{archiveext}") - else - safeset("archivename", repo .. "-%{commit}") - safeset("archiveurl", "%{forgeurl}/repository/%{commit}/archive.%{archiveext}") + if (rpm.expand(ref) == "") then + rpm.expand("%{error:You need to define %{version}, %{commit} or %{tag} before the macro invocation !\\n}") end + safeset("archivename", repo .. "-" .. ref) + safeset("archiveurl", "%{forgeurl}/-/archive/" .. ref .. "/%{archivename}.%{archiveext}") end end if (string.match(forge, "^github[%.-]") or string.match(forge, "[%.-]github[%.]")) then From ec13f9100788d4ea987ae8a5c06f8445b692af5c Mon Sep 17 00:00:00 2001 From: Nicolas Mailhot Date: Fri, 31 Aug 2018 12:24:10 +0200 Subject: [PATCH 07/17] remove explicit linebreaks, recent rpm versions insert them by default --- macros.forge | 44 ++++++++++++++++++++++---------------------- 1 file changed, 22 insertions(+), 22 deletions(-) diff --git a/macros.forge b/macros.forge index 146b8dd..032e4f2 100644 --- a/macros.forge +++ b/macros.forge @@ -66,7 +66,7 @@ local commit = rpm.expand("%{?commit}") local function explicitset(rpmvariable,value) rpm.define(rpmvariable .. " " .. value) if verbose then - rpm.expand("%{echo:Setting %%{" .. rpmvariable .. "} = " .. value .. "\\n}") + rpm.expand("%{echo:Setting %%{" .. rpmvariable .. "} = " .. value .. "}") end end -- Never ever stomp on a spec variable the packager already set @@ -80,14 +80,14 @@ if (forgeurl ~= "") then local forge = string.match(forgeurl, "^[^:]+://([^/]+)/") if (forge == nil) then if not silent then - rpm.expand("%{error:URLs must include a protocol such as https:// and a path starting with / !\\n}") + rpm.expand("%{error:URLs must include a protocol such as https:// and a path starting with / !}") end else if (string.match(forge, "^gitlab[%.-]") or string.match(forge, "[%.-]gitlab[%.]")) then forgeurl = string.match(forgeurl, "https://[^/]+/[^/]+/[^/#?]+") if (forgeurl == nil) then if not silent then - rpm.expand("%{error:Gitlab URLs must match https://(…[-.])gitlab[-.]…/owner/repo !\\n}") + rpm.expand("%{error:Gitlab URLs must match https://(…[-.])gitlab[-.]…/owner/repo !}") end else explicitset("forgeurl", forgeurl) @@ -110,7 +110,7 @@ if (forgeurl ~= "") then else ref = "%{?version}" end if (rpm.expand(ref) == "") then - rpm.expand("%{error:You need to define %{version}, %{commit} or %{tag} before the macro invocation !\\n}") + rpm.expand("%{error:You need to define %{version}, %{commit} or %{tag} before the macro invocation !}") end safeset("archivename", repo .. "-" .. ref) safeset("archiveurl", "%{forgeurl}/-/archive/" .. ref .. "/%{archivename}.%{archiveext}") @@ -120,7 +120,7 @@ if (forgeurl ~= "") then forgeurl = string.match(forgeurl, "https://[^/]+/[^/]+/[^/#?]+") if (forgeurl == nil) then if not silent then - rpm.expand("%{error:GitHub URLs must match https://(…[-.])github[-.]…/owner/repo !\\n}") + rpm.expand("%{error:GitHub URLs must match https://(…[-.])github[-.]…/owner/repo !}") end else explicitset("forgeurl", forgeurl) @@ -160,7 +160,7 @@ if (forgeurl ~= "") then forgeurl = string.match(forgeurl, "https://code.googlesource.com/[^#?]*[^/#?]+") if (forgeurl == nil) then if not silent then - rpm.expand("%{error:Googlesource URLs must match https://code.googlesource.com/…/repo !\\n}") + rpm.expand("%{error:Googlesource URLs must match https://code.googlesource.com/…/repo !}") end else explicitset("forgeurl", forgeurl) @@ -188,12 +188,12 @@ if (forgeurl ~= "") then forgeurl = string.match(forgeurl, "https://[^/]+/[^/]+/[^/#?]+") if (forgeurl == nil) then if not silent then - rpm.expand("%{error:BitBucket URLs must match https://bitbucket.org/owner/repo !\\n}") + rpm.expand("%{error:BitBucket URLs must match https://bitbucket.org/owner/repo !}") end else explicitset("forgeurl", forgeurl) if (commit == "") then - rpm.expand("%{error:All BitBucket URLs require commit value knowledge: you need to define %{commit}!\\n}") + rpm.expand("%{error:All BitBucket URLs require commit value knowledge: you need to define %{commit}!}") end local shortcommit = string.sub(commit, 1, 12) safeset("archiveext", "tar.bz2") @@ -213,13 +213,13 @@ if (forgeurl ~= "") then end if (forge == "pagure.io") then if not silent then - rpm.expand("%{error:https://pagure.io/pagure/issue/861 needs to be resolved before the “pagure.io”\\nsoftware publishing service can be supported.\\n}") + rpm.expand("%{error:https://pagure.io/pagure/issue/861 needs to be resolved before the “pagure.io”\\nsoftware publishing service can be supported.}") end end -- Final tests to check forgeurl was successfuly parsed if not silent then if (rpm.expand("%{?archivename}") == "") or (rpm.expand("%{?archiveurl}") == "") then - rpm.expand("%{error:Automation for the “" .. forge .. "”\\nsoftware publishing service is not implemented yet.\\nPlease extend the %%forgemeta macro!\\n}") + rpm.expand("%{error:Automation for the “" .. forge .. "”\\nsoftware publishing service is not implemented yet.\\nPlease extend the %%forgemeta macro!}") end end end @@ -258,18 +258,18 @@ if (distprefix ~= "") then end -- Final spec variable summary if the macro was called with -i if informative then - rpm.expand("%{echo:Forge-specific packaging variables\\n}") - rpm.expand("%{echo: forgeurl: %{?forgeurl}\\n}") - rpm.expand("%{echo: forgesource: %{?forgesource}\\n}") - rpm.expand("%{echo: forgesetupargs: %{?forgesetupargs}\\n}") - rpm.expand("%{echo:Generic variables\\n}") - rpm.expand("%{echo: archivename: %{?archivename}\\n}") - rpm.expand("%{echo: archiveext: %{?archiveext}\\n}") - rpm.expand("%{echo: archiveurl: %{?archiveurl}\\n}") - rpm.expand("%{echo: scm: %{?scm}\\n}") - rpm.expand("%{echo: tag: %{?tag}\\n}") - rpm.expand("%{echo: commit: %{?commit}\\n}") - rpm.expand("%{echo: dist: %{?dist} (snapshot date is either manually supplied or computed once %%{_sourcedir}/%%{archivename}.%%{archiveext} is available)\\n}") + rpm.expand("%{echo:Forge-specific packaging variables}") + rpm.expand("%{echo: forgeurl: %{?forgeurl}}") + rpm.expand("%{echo: forgesource: %{?forgesource}}") + rpm.expand("%{echo: forgesetupargs: %{?forgesetupargs}}") + rpm.expand("%{echo:Generic packaging variables}") + rpm.expand("%{echo: archivename: %{?archivename}}") + rpm.expand("%{echo: archiveext: %{?archiveext}}") + rpm.expand("%{echo: archiveurl: %{?archiveurl}}") + rpm.expand("%{echo: scm: %{?scm}}") + rpm.expand("%{echo: tag: %{?tag}}") + rpm.expand("%{echo: commit: %{?commit}}") + rpm.expand("%{echo: dist: %{?dist} (snapshot date is either manually supplied or computed once %%{_sourcedir}/%%{archivename}.%%{archiveext} is available)}") end } From 2c2e13ee0ecf977431579d8f89ee7223d60041d7 Mon Sep 17 00:00:00 2001 From: Nicolas Mailhot Date: Fri, 31 Aug 2018 20:03:31 +0200 Subject: [PATCH 08/17] switch to distprefix, implement branch support, refactor the logic to be simpler to understand and maintain --- macros.forge | 137 +++++++++++++++++++++++++-------------------------- 1 file changed, 66 insertions(+), 71 deletions(-) diff --git a/macros.forge b/macros.forge index 032e4f2..692c52e 100644 --- a/macros.forge +++ b/macros.forge @@ -60,8 +60,22 @@ end if (rpm.expand("%{?-i}") ~= "") then informative = true end -local tag = rpm.expand("%{?tag}") -local commit = rpm.expand("%{?commit}") +-- Packaging a moving branch is quite a bad idea, but since at least Gitlab +-- will treat branches and tags the same way better support branches explicitly +-- than have packagers hijack %{tag} to download branch states +local tag = rpm.expand("%{?tag}") +local commit = rpm.expand("%{?commit}") +local branch = rpm.expand("%{?branch}") +local version = rpm.expand("%{?version}") +local ref = "" +if (tag ~= "") then ref = "%{?tag}" +elseif (commit ~= "") then ref = "%{?commit}" +elseif (branch ~= "") then ref = "%{?branch}" +else ref = "%{?version}" +end +if (rpm.expand(ref) == "") then + rpm.expand("%{error:You need to define Version:, %{commit} or %{tag} before the macro invocation !}") +end -- Be explicit about the spec variables we’re setting local function explicitset(rpmvariable,value) rpm.define(rpmvariable .. " " .. value) @@ -75,6 +89,16 @@ local function safeset(rpmvariable,value) explicitset(rpmvariable,value) end end +-- Computes the suffix of a version string, removing vprefix if it matches +-- For example with vprefix 1.2.3: 1.2.3.rc2 → .rc2 but 1.2.30 → 1.2.30 not 0 +local function getversionsuffix(vstring,vprefix) + if (string.sub(vstring, 1, #vprefix) == vprefix) and + (not string.match(string.sub(vstring, #vprefix + 1), "^%.?%d")) then + return string.sub(vstring, #vprefix + 1) + else + return vstring + end +end -- Set spec variable values for each known software publishing service if (forgeurl ~= "") then local forge = string.match(forgeurl, "^[^:]+://([^/]+)/") @@ -93,25 +117,8 @@ if (forgeurl ~= "") then explicitset("forgeurl", forgeurl) safeset("archiveext", "tar.bz2") safeset("forgesetupargs", "-n %{archivename}") - -- Packaging a moving branch is quite a bad idea, but since Gitlab - -- uses the same convention for tags and branches in archive downloads, - -- better do it explicitly than have packagers use the branch name in - -- %{tag} - local branch = rpm.expand("%{?branch}") - if (commit ~= "") or (tag ~= "") or (branch ~= "") then - safeset("scm", "git") - end - local owner = string.match(forgeurl, "^[^:]+://[^/]+/([^/]+)") - local repo = string.match(forgeurl, "^[^:]+://[^/]+/[^/]+/([^/]+)") - local ref = "" - if (commit ~= "") then ref = "%{?commit}" - elseif (tag ~= "") then ref = "%{?tag}" - elseif (branch ~= "") then ref = "%{?branch}" - else ref = "%{?version}" - end - if (rpm.expand(ref) == "") then - rpm.expand("%{error:You need to define %{version}, %{commit} or %{tag} before the macro invocation !}") - end + if (ref ~= "%{?version}") then safeset("scm", "git") end + local repo = string.match(forgeurl, "^[^:]+://[^/]+/[^/]+/([^/]+)") safeset("archivename", repo .. "-" .. ref) safeset("archiveurl", "%{forgeurl}/-/archive/" .. ref .. "/%{archivename}.%{archiveext}") end @@ -125,35 +132,22 @@ if (forgeurl ~= "") then else explicitset("forgeurl", forgeurl) safeset("archiveext", "tar.gz") - local forgesetupargs = "-n %{archivename}" - if (commit ~= "") or (tag ~= "") then - safeset("scm", "git") - end - local owner = string.match(forgeurl, "^[^:]+://[^/]+/([^/]+)") - local repo = string.match(forgeurl, "^[^:]+://[^/]+/[^/]+/([^/]+)") - if (tag ~= "") then - -- if upstream used a version suffix such as -rc1 or -beta it will not - -- be a valid version string for rpm but github will accept it fine and - -- use the same naming as for other versions: v prefix in the tag and - -- archivename, no v prefix in the topdir naming inside the archive - local version = rpm.expand("%{?version}") - if version ~= "" and - (string.match(tag, "^v" .. version .. "[^%d]") or - string.match(tag, "^v" .. version .. "$")) then - forgesetupargs = "-n " .. repo .. "-" .. string.gsub(tag, "^v", "") - end - safeset("archivename", repo .. "-%{tag}") - safeset("archiveurl", "%{forgeurl}/archive/%{tag}.%{archiveext}") + safeset("forgesetupargs", "-n %{archivename}") + -- Workaround the way GitHub injects "v"s before some version strings (but not all!) + -- To package one of the minority of sane GitHub projects that do not munge their version + -- strings set tag to %{version} in your spec + local fileref = ref + if (ref == "%{?version}") then + ref = "v" .. ref else - if (commit ~= "") then - safeset("archivename", repo .. "-%{commit}") - safeset("archiveurl", "%{forgeurl}/archive/%{commit}/" .. repo .. "-%{commit}.%{archiveext}") - else - safeset("archivename", repo .. "-%{version}") - safeset("archiveurl", "%{forgeurl}/archive/v%{version}.%{archiveext}") + safeset("scm", "git") + if (fileref ~= "%{?commit}") and string.match(rpm.expand(fileref), "^v[%d]") then + fileref = string.gsub(rpm.expand(fileref), "^v", "") end end - safeset("forgesetupargs", forgesetupargs) + local repo = string.match(forgeurl, "^[^:]+://[^/]+/[^/]+/([^/]+)") + safeset("archivename", repo .. "-" .. fileref) + safeset("archiveurl", "%{forgeurl}/archive/" .. ref .. "/%{archivename}.%{archiveext}") end end if (forge == "code.googlesource.com") then @@ -166,22 +160,14 @@ if (forgeurl ~= "") then explicitset("forgeurl", forgeurl) safeset("archiveext", "tar.gz") safeset("forgesetupargs", "-c") - if (commit ~= "") or (tag ~= "") then + if (ref == "%{?version}") then + ref = "v" .. ref + else safeset("scm", "git") end local repo = string.match(forgeurl, "^[^:]+://.+/([^/?#]+)") - if (tag ~= "") then - safeset("archivename", repo .. "-%{tag}") - safeset("archiveurl", "%{forgeurl}/+archive/%{tag}.%{archiveext}") - else - if (commit ~= "") then - safeset("archivename", repo .. "-%{commit}") - safeset("archiveurl", "%{forgeurl}/+archive/%{commit}.%{archiveext}") - else - safeset("archivename", repo .. "-v%{version}") - safeset("archiveurl", "%{forgeurl}/+archive/v%{version}.%{archiveext}") - end - end + safeset("archivename", repo .. "-" .. ref) + safeset("archiveurl", "%{forgeurl}/+archive/" .. ref .. ".%{archiveext}") end end if (forge == "bitbucket.org") then @@ -243,18 +229,25 @@ if (archivename ~= "") and (archiveurl ~= "") then safeset("forgesource", "%{?archiveurl}#/%{?archivename}.%{archiveext}") end end --- dist processing (computing the correct pefix for snapshots) -local distprefix = rpm.expand("%{?tag}") -local version = rpm.expand("%{?version}") -if (distprefix == version) or (distprefix == "v" .. version) then - distprefix = "" -end -if (distprefix == "") then - distprefix = string.sub(rpm.expand("%{?commit}"), 1, 7) +-- dist processing (computing the correct prefix for snapshots) +local distprefix = rpm.expand(ref) +if (ref == "%{?commit}") then + distprefix = string.sub(distprefix, 1, 7) +elseif (ref ~= "%{?branch}") then + distprefix = getversionsuffix(distprefix, version) + distprefix = getversionsuffix(distprefix, "v" .. version) + distprefix = string.gsub(distprefix, "[.-]+", ".") + distprefix = string.gsub(distprefix, "^%.", "") end if (distprefix ~= "") then - local dist = ".%{?date}%{!?date:%([ -r %{_sourcedir}/%{archivename}.%{archiveext} ] && date +%Y%m%d -u -r %{_sourcedir}/%{archivename}.%{archiveext})}%{scm}" .. string.gsub(distprefix, "-",".") .. rpm.expand("%{?dist}") - explicitset("dist", dist) + distprefix = "%{scm}" .. distprefix + date = rpm.expand("%{?date}") + if (date ~= "") then + distprefix = date .. distprefix + else + distprefix = "%([ -r %{_sourcedir}/%{archivename}.%{archiveext} ] && date +%Y%m%d -u -r %{_sourcedir}/%{archivename}.%{archiveext})" .. distprefix + end + safeset ("distprefix", "." .. distprefix) end -- Final spec variable summary if the macro was called with -i if informative then @@ -269,7 +262,9 @@ if informative then rpm.expand("%{echo: scm: %{?scm}}") rpm.expand("%{echo: tag: %{?tag}}") rpm.expand("%{echo: commit: %{?commit}}") - rpm.expand("%{echo: dist: %{?dist} (snapshot date is either manually supplied or computed once %%{_sourcedir}/%%{archivename}.%%{archiveext} is available)}") + rpm.expand("%{echo: branch: %{?branch}}") + rpm.expand("%{echo: date: %{?date}}") + rpm.expand("%{echo: distprefix: %{?distprefix} (snapshot date is either manually supplied or computed once %%{_sourcedir}/%%{archivename}.%%{archiveext} is available)}") end } From b852a706ade9d4fdfc1a46d257961b02b8f4aef1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miro=20Hron=C4=8Dok?= Date: Sun, 9 Sep 2018 22:46:34 +0200 Subject: [PATCH 09/17] Make ambiguous python shebangs error See https://fedoraproject.org/wiki/Changes/Make_ambiguous_python_shebangs_error --- brp-mangle-shebangs | 4 ++-- redhat-rpm-config.spec | 6 +++++- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/brp-mangle-shebangs b/brp-mangle-shebangs index 4fa8daa..67a1a7d 100755 --- a/brp-mangle-shebangs +++ b/brp-mangle-shebangs @@ -129,8 +129,8 @@ while IFS= read -r -d $'\0' f; do py_shebang=$(echo "$shebang" | sed -r -e 's@/usr/bin/python(\s|$)@/usr/bin/python2\1@') if [ "$shebang" != "$py_shebang" ]; then - sed -i -e "1c #!$py_shebang" "$f" - echo >&2 "*** WARNING: mangling shebang in $path from #!$orig_shebang to #!$py_shebang. This will become an ERROR, fix it manually!" + echo >&2 "*** ERROR: ambiguous python shebang in $path: #!$orig_shebang. Change it to python3 (or python2) explicitly." + fail=1 elif [ "#!$shebang" != "#!$orig_shebang" ]; then sed -i -e "1c #!$shebang" "$f" echo "mangling shebang in $path from $orig_shebang to #!$shebang" diff --git a/redhat-rpm-config.spec b/redhat-rpm-config.spec index b7c0c77..a2c9132 100644 --- a/redhat-rpm-config.spec +++ b/redhat-rpm-config.spec @@ -6,7 +6,7 @@ Summary: Red Hat specific rpm configuration files Name: redhat-rpm-config -Version: 119 +Version: 120 Release: 1%{?dist} # No version specified. License: GPL+ @@ -183,6 +183,10 @@ install -p -m 755 -t %{buildroot}%{_rpmconfigdir} kmod.prov %{_rpmconfigdir}/macros.d/macros.kmp %changelog +* Mon Sep 10 2018 Miro Hrončok - 120-1 +- Make ambiguous python shebangs error + https://fedoraproject.org/wiki/Changes/Make_ambiguous_python_shebangs_error + * Mon Aug 20 2018 Kalev Lember - 119-1 - Add aarch64 to ldc arches From e3e0ba6ab7623630683487ddb42dcc37d57e1107 Mon Sep 17 00:00:00 2001 From: Jan Pazdziora Date: Thu, 11 Oct 2018 11:29:00 +0200 Subject: [PATCH 10/17] Add %_swidtagdir for directory for SWID tag files describing the installation. Signed-off-by: Jan Pazdziora --- macros.fedora-misc-srpm | 3 +++ redhat-rpm-config.spec | 6 +++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/macros.fedora-misc-srpm b/macros.fedora-misc-srpm index 1dc5779..98aa6c2 100644 --- a/macros.fedora-misc-srpm +++ b/macros.fedora-misc-srpm @@ -6,3 +6,6 @@ # A directory for appdata metainfo. This has changed between releases so a # macro is useful. %_metainfodir %{_datadir}/metainfo + +# A directory for SWID tag files describing the installation +%_swidtagdir %{_prefix}/lib/swidtag/fedoraproject.org diff --git a/redhat-rpm-config.spec b/redhat-rpm-config.spec index a2c9132..b104b91 100644 --- a/redhat-rpm-config.spec +++ b/redhat-rpm-config.spec @@ -6,7 +6,7 @@ Summary: Red Hat specific rpm configuration files Name: redhat-rpm-config -Version: 120 +Version: 121 Release: 1%{?dist} # No version specified. License: GPL+ @@ -183,6 +183,10 @@ install -p -m 755 -t %{buildroot}%{_rpmconfigdir} kmod.prov %{_rpmconfigdir}/macros.d/macros.kmp %changelog +* Thu Oct 11 2018 Jan Pazdziora - 121-1 +- Add %_swidtagdir for directory for SWID tag files describing the + installation. + * Mon Sep 10 2018 Miro Hrončok - 120-1 - Make ambiguous python shebangs error https://fedoraproject.org/wiki/Changes/Make_ambiguous_python_shebangs_error From c70110c677904a188d66ffd01a9ab024469ca62d Mon Sep 17 00:00:00 2001 From: Nicolas Mailhot Date: Fri, 7 Sep 2018 19:56:46 +0200 Subject: [PATCH 11/17] forge: refactor to allow multiple calls MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit – permit extraction of multiple archives in a single specfile – %forgemeta, %forgesetup, %forgeautosetup: add a “-z ” switch to select a specific set of rpm variables (for example forgeurl and version) – %forgemeta, %forgesetup: add a “-a” switch to process all sets in one go (makes no sense in forgeautosetup, as you need so select specific patches) – %forgemeta: deprecate the “-u” switch, use “-z” it’s better (“-u” was awkward and mainly used by the %gometa macro. %gometa will now call the lua code directly) – %forgesetup: use “-v” for verbose processing, be quiet by default, drop “-q” (align with %forgemeta, %forgeautosetup and %autosetup) – %forgesetup, %forgeautosetup: only pass flags that make sense to %setup/%autosetup; reorder to match what works in el7 – factor out complex or common lua code in separate lua modules, to allow: – code reuse in other macros without cut and pasting – direct lua routine invocation from other macros without going through a rpm macro – rpm syntax errors that point to a line in an actual lua file – %forgemeta: refactor the logic to drop as much forge-specific code as possible, use a single logic flow with tables of constants – %forgemeta: export more computed info in rpm variables, such as the %{_builddir} subdirectory an archive was extracted to (lifesaver when processing multiple archives) – %forgemeta: prepend secondary distprefixes with .S, to make clear they do not apply to the main archive – %forgemeta: add versionx to secondary distprefixes, if relevant – %forgemeta: make tar.bz2 the default archive format Caveats: – forge services implement full-release downloads via tags. However the actual syntax of such tags is not standardised. If the macro does not guess the correct tag an upstream uses for a specific release, you will need to set the tag value explicitly. – GitHub lets upstreams move their projects to new URLs, keeping the old URL active. It all works transparently *except* the top directory inside generated archives always matches the new project name (even when accessed by compatibility URLs, and even for releases that antedate the renaming). Therefore, if macro processing of a GitHub archive suddenly fails, start by checking if upstream didn’t rename itself. Multicall usage example (with “-a”) – to process a specific bloc in one of the macros use “-z ” – suffix 0 and no suffix are synonyms – therefore, calling the macros without “-a” or “-z” just works for the general use case when you have a single archive to process – caveat: forge services implement full-release %<-- %global forgeurl0 https://gitlab.com/osslugaru/lugaru Version: 1.2 %global forgeurl1 https://gitlab.com/osslugaru/lugaru %global tag1 1.1 %global forgeurl2 https://gitlab.com/osslugaru/lugaru %global commit2 68488b0a11df90dca703c67e5592b93c6a269957 %global forgeurl3 https://gitlab.com/osslugaru/lugaru %global branch3 v1.1 %global forgeurl4 https://github.com/google/trillian %global version4 1.0.8 %global forgeurl5 https://github.com/kubernetes/apiextensions-apiserver %global version5 1.9.6 %global tag5 kubernetes-%{version5} %global forgeurl6 https://github.com/jdbranham/grafana-diagram %global version6 1.3 %global commit6 440689793ab6da82019c5ee43b49438dfef976d5 %global forgeurl7 https://github.com/rethinkdb/rethinkdb-go %global version7 1.4.2 %global branch7 v1 %global forgeurl8 https://code.googlesource.com/gocloud %global version8 0.20.0 %global forgeurl9 https://code.googlesource.com/gocloud %global tag9 v0.27.0 %global forgeurl10 https://code.googlesource.com/google-api-go-client %global commit10 24928b980e6919be4c72647aacd53ebcbb8c4bab %global version10 0 %global forgeurl11 https://code.googlesource.com/google-api-go-client %global branch11 dartman %global forgeurl12 https://bitbucket.org/nielsenb/pdfocr %global version12 0.3.0 %global commit12 4f5750d202d33267094621630836f1215a5efa66 %global forgeurl13 https://bitbucket.org/nielsenb/pdfocr %global version13 0.1.4 %global tag13 v0.1.4 %global commit13 c0359843a3420769940e12019ebd68891a053bd8 %global forgeurl14 https://bitbucket.org/creachadair/shell %global commit14 3dcd505a7ca5845388111724cc2e094581e92cc6 %global forgeurl15 https://bitbucket.org/kirbyvisp/vdjpuzzle2/ %global branch15 js-edits %global commit15 36a3850eb4a04c05e0f7e29e7d0c196f373eb672 %forgemeta -ia Name: testing Release: 1%{?dist} Summary: A test package URL: %{forgeurl} License: Public domain Source0: %{forgesource0} Source1: %{forgesource1} Source2: %{forgesource2} Source3: %{forgesource3} Source4: %{forgesource4} Source5: %{forgesource5} Source6: %{forgesource6} Source7: %{forgesource7} Source8: %{forgesource8} Source9: %{forgesource9} Source10: %{forgesource10} Source11: %{forgesource11} Source12: %{forgesource12} Source13: %{forgesource13} Source14: %{forgesource14} Source15: %{forgesource15} %description A test package %prep %forgesetup -a %build exit 1 %install %files %doc %<-- Merges: https://src.fedoraproject.org/rpms/redhat-rpm-config/pull-request/35 --- common.lua | 113 ++++++++++++++++ forge.lua | 252 ++++++++++++++++++++++++++++++++++ macros.forge | 298 +++++++++-------------------------------- redhat-rpm-config.spec | 14 ++ 4 files changed, 439 insertions(+), 238 deletions(-) create mode 100644 common.lua create mode 100644 forge.lua diff --git a/common.lua b/common.lua new file mode 100644 index 0000000..77ebf69 --- /dev/null +++ b/common.lua @@ -0,0 +1,113 @@ +-- Convenience Lua functions that can be used within rpm macros + +-- Set a spec variable +-- Echo the result if verbose +local function explicitset(rpmvar,value,verbose) + local value = value + if (value == nil) or (value == "") then + value = "%{nil}" + end + rpm.define(rpmvar .. " " .. value) + if verbose then + rpm.expand("%{echo:Setting %%{" .. rpmvar .. "} = " .. value .. "}") + end +end + +-- Unset a spec variable if it is defined +-- Echo the result if verbose +local function explicitunset(rpmvar,verbose) + if (rpm.expand("%{" .. rpmvar .. "}") ~= "%{" .. rpmvar .. "}") then + rpm.define(rpmvar .. " %{nil}") + if verbose then + rpm.expand("%{echo:Unsetting %%{" .. rpmvar .. "}}") + end + end +end + +-- Set a spec variable, if not already set +-- Echo the result if verbose +local function safeset(rpmvar,value,verbose) + if (rpm.expand("%{" .. rpmvar .. "}") == "%{" .. rpmvar .. "}") then + explicitset(rpmvar,value,verbose) + end +end + +-- Alias a list of rpm variables to the same variables suffixed with 0 (and vice versa) +-- Echo the result if verbose +local function zalias(rpmvars,verbose) + for _, sfx in ipairs({{"","0"},{"0",""}}) do + for _, rpmvar in ipairs(rpmvars) do + local toalias = "%{?" .. rpmvar .. sfx[1] .. "}" + if (rpm.expand(toalias) ~= "") then + safeset(rpmvar .. sfx[2], toalias, verbose) + end + end + end +end + +-- Echo the list of rpm variables, with suffix, if set +local function echovars(rpmvars, suffix) + for _, rpmvar in ipairs(rpmvars) do + rpmvar = rpmvar .. suffix + local header = string.sub(" " .. rpmvar .. ": ",1,21) + rpm.expand("%{?" .. rpmvar .. ":%{echo:" .. header .. "%{?" .. rpmvar .. "}}}") + end +end + +-- Returns an array, indexed by suffix, containing the non-empy values of +-- , with suffix an integer string or the empty string +local function getsuffixed(rpmvar) + local suffixes = {} + zalias({rpmvar}) + for suffix=0,9999 do + local value = rpm.expand("%{?" .. rpmvar .. suffix .. "}") + if (value ~= "") then + suffixes[tostring(suffix)] = value + end + end + -- rpm convention is to alias no suffix to zero suffix + -- only add no suffix if zero suffix is different + local value = rpm.expand("%{?" .. rpmvar .. "}") + if (value ~= "") and (value ~= suffixes["0"]) then + suffixes[""] = value + end + return suffixes +end + +-- Returns the list of suffixes, including the empty string, for which +-- is set to a non empty value +local function getsuffixes(rpmvar) + suffixes = {} + for suffix in pairs(getsuffixed(rpmvar)) do + table.insert(suffixes,suffix) + end + table.sort(suffixes, + function(a,b) return (tonumber(a) or 0) < (tonumber(b) or 0) end) + return suffixes +end + +-- Returns the suffix for which has a non-empty value that +-- matches best the beginning of the value string +local function getbestsuffix(rpmvar, value) + local best = nil + local currentmatch = "" + for suffix, setvalue in pairs(getsuffixed(rpmvar)) do + if (string.len(setvalue) > string.len(currentmatch)) and + (string.find(value, "^" .. setvalue)) then + currentmatch = setvalue + best = suffix + end + end + return best +end + +return { + explicitset = explicitset, + explicitunset = explicitunset, + safeset = safeset, + zalias = zalias, + echovars = echovars, + getsuffixed = getsuffixed, + getsuffixes = getsuffixes, + getbestsuffix = getbestsuffix, +} diff --git a/forge.lua b/forge.lua new file mode 100644 index 0000000..a812184 --- /dev/null +++ b/forge.lua @@ -0,0 +1,252 @@ +-- Lua code used by macros.forge and derivatives + +-- Computes the suffix of a version string, removing vprefix if it matches +-- For example with vprefix 1.2.3: 1.2.3.rc2 → .rc2 but 1.2.30 → 1.2.30 not 0 +local function getversionsuffix(vstring,vprefix) + if (string.sub(vstring, 1, #vprefix) == vprefix) and + (not string.match(string.sub(vstring, #vprefix + 1), "^%.?%d")) then + return string.sub(vstring, #vprefix + 1) + else + return vstring + end +end + +-- Check if an identified url is sane +local function checkforgeurl(url, id, silent) + local checkedurl = nil + local checkedid = nil + local urlpatterns = { + gitlab = { + pattern = 'https://[^/]+/[^/]+/[^/#?]+', + description = 'https://(…[-.])gitlab[-.]…/owner/repo'}, + github = { + pattern = 'https://[^/]+/[^/]+/[^/#?]+', + description = 'https://(…[-.])github[-.]…/owner/repo'}, + ["code.googlesource.com"] = { + pattern = 'https://code.googlesource.com/[^#?]*[^/#?]+', + description = 'https://code.googlesource.com/…/repo'}, + ["bitbucket.org"] = { + pattern = 'https://[^/]+/[^/]+/[^/#?]+', + description = 'https://bitbucket.org/owner/repo'}} + if (urlpatterns[id] ~= nil) then + checkedurl = string.match(url,urlpatterns[id]["pattern"]) + if (checkedurl == nil) then + if not silent then + rpm.expand("%{error:" .. id .. " URLs must match " .. urlpatterns[id]["description"] .. " !}") + end + else + checkedid = id + end + end + return checkedurl, checkedid +end + +-- Check if an url matches a known forge +local function idforge(url, silent) + local forgeurl = nil + local forge = nil + if (url ~= "") then + forge = string.match(url, "^[^:]+://([^/]+)/") + if (forge == nil) then + if not silent then + rpm.expand("%{error:URLs must include a protocol such as https:// and a path starting with / !}") + end + else + if (string.match(forge, "^gitlab[%.-]") or string.match(forge, "[%.-]gitlab[%.]")) then + forge = "gitlab" + elseif (string.match(forge, "^github[%.-]") or string.match(forge, "[%.-]github[%.]")) then + forge = "github" + end + forgeurl, forge = checkforgeurl(url, forge, silent) + end + end + return forgeurl, forge +end + +-- The forgemeta macro main processing function +-- See the documentation in the macros.forge file for argument description +-- Also called directly by gometa +local function forgemeta(suffix, verbose, informative, silent) + local fedora = require "fedora.common" + local ismain = (suffix == "") or (suffix == "0") + if ismain then + fedora.zalias({"forgeurl", "forgesource", "forgesetupargs", + "archivename", "archiveext", "archiveurl", + "topdir", "extractdir", "repo", "owner", + "scm", "tag", "commit", "shortcommit", "branch", "version", + "date", "distprefix"}, verbose) + end + local variables = { + default = { + scm = "git", + archiveext = "tar.bz2", + repo = '%{lua:print(string.match(rpm.expand("%{forgeurl' .. suffix .. '}"), "^[^:]+://[^/]+/[^/]+/([^/]+)"))}', + archivename = "%{repo" .. suffix .. "}-%{ref" .. suffix .. "}", + topdir = "%{archivename" .. suffix .. "}" }, + gitlab = { + archiveurl = "%{forgeurl" .. suffix .. "}/-/archive/%{ref" .. suffix .. "}/%{archivename" .. suffix .. "}.%{archiveext" .. suffix .. "}" }, + github = { + archiveext = "tar.gz", + archivename = "%{repo" .. suffix .. "}-%{fileref" .. suffix .. "}", + archiveurl = "%{forgeurl" .. suffix .. "}/archive/%{ref" .. suffix .. "}/%{archivename" .. suffix .. "}.%{archiveext" .. suffix .. "}" }, + ["code.googlesource.com"] = { + archiveext = "tar.gz", + repo = '%{lua:print(string.match(rpm.expand("%{forgeurl' .. suffix .. '}"), "^[^:]+://.+/([^/?#]+)"))}', + archiveurl = "%{forgeurl" .. suffix .. "}/+archive/%{ref" .. suffix .. "}.%{archiveext" .. suffix .. "}", + topdir = "" }, + ["bitbucket.org"] = { + shortcommit = '%{lua:print(string.sub(rpm.expand("%{commit' .. suffix .. '}"), 1, 12))}', + owner = '%{lua:print(string.match(rpm.expand("%{forgeurl' .. suffix .. '}"), "^[^:]+://[^/]+/([^/]+)"))}', + archivename = "%{owner" .. suffix .. "}-%{repo" .. suffix .. "}-%{shortcommit" .. suffix .. "}", + archiveurl = "%{forgeurl" .. suffix .. "}/get/%{ref" .. suffix .. "}.%{archiveext" .. suffix .. "}" } } + -- Packaging a moving branch is quite a bad idea, but since at least Gitlab + -- will treat branches and tags the same way better support branches explicitly + -- than have packagers hijack %{tag} to download branch states + local spec = {} + for _, v in ipairs({'forgeurl','tag','commit','branch','version'}) do + spec[v] = rpm.expand("%{?" .. v .. suffix .. "}") + end + -- Compute the reference of the object to fetch + local isrelease = false + if (spec["tag"] ~= "") then ref = "%{?tag" .. suffix .. "}" + elseif (spec["commit"] ~= "") then ref = "%{?commit" .. suffix .. "}" + elseif (spec["branch"] ~= "") then ref = "%{?branch" .. suffix .. "}" + else ref = "%{?version" .. suffix .. "}" + isrelease = true + end + if (rpm.expand(ref) == "") then + if (suffix == "") then + rpm.expand("%{error:You need to define Version:, %{commit} or %{tag} before the macro invocation !}") + else + rpm.expand("%{error:You need to define %{version" .. suffix .. "}, %{commit" .. suffix .. "} or %{tag" .. suffix .. "} before the macro invocation !}") + end + end + local forgeurl = spec["forgeurl"] + -- For backwards compatibility only + local expliciturl = rpm.expand("%{?-u*}") + if (expliciturl ~= "") then + rpm.expand("%{warn:-u use in %%forgemeta is deprecated, use -z instead to select a separate set of rpm variables!}") + forgeurl = expliciturl + end + local forge + forgeurl, forge = idforge(forgeurl, silent) + if (forge ~= nil) then + fedora.explicitset("forgeurl" .. suffix, forgeurl, verbose) + -- Custom processing of quirky forges that can not be handled with simple variables + if (forge == "github") then + -- Workaround the way GitHub injects "v"s before some version strings (but not all!) + -- To package one of the minority of sane GitHub projects that do not munge their version + -- strings set tag to %{version} in your spec + local fileref = ref + if (ref == "%{?version" .. suffix .. "}") then + ref = "v" .. ref + elseif (fileref ~= "%{?commit" .. suffix .. "}") and + string.match(rpm.expand(fileref), "^v[%d]") then + fileref = string.gsub(rpm.expand(fileref), "^v", "") + end + fedora.safeset("fileref" .. suffix, fileref, verbose) + elseif (forge == "code.googlesource.com") then + if (ref == "%{?version" .. suffix .. "}") then + ref = "v" .. ref + end + elseif (forge == "bitbucket.org") then + if (spec["commit"] == "") then + rpm.expand("%{error:All BitBucket URLs require commit value knowledge: you need to define %{commit}!}") + end + end + fedora.safeset("ref" .. suffix, ref, verbose) + -- Mass setting of the remaining variables + for k,v in pairs(variables[forge]) do + fedora.safeset(k .. suffix, variables[forge][k], verbose) + end + for k,v in pairs(variables["default"]) do + if (variables[forge][k] == nil) then + fedora.safeset(k .. suffix, variables["default"][k], verbose) + end + end + end + -- Generic rules + for _, v in ipairs({'archiveurl','archivename','archiveext','topdir'}) do + spec[v] = rpm.expand("%{?" .. v .. suffix .. "}") + end + -- Source URL processing (computing the forgesource spec variable) + local forgesource = "%{archiveurl" .. suffix .. "}" + if (string.match(spec["archiveurl"], "/([^/]+)$") ~= spec["archivename"] .. "." .. spec["archiveext"]) then + forgesource = "%{?archiveurl" .. suffix .. "}#/%{?archivename" .. suffix .. "}.%{archiveext" .. suffix .. "}" + end + fedora.safeset("forgesource" .. suffix, forgesource, verbose) + -- Setup processing (computing the forgesetup and extractdir variables) + local forgesetupargs = "-n %{extractdir" .. suffix .. "}" + local extractdir = "%{topdir" .. suffix .. "}" + if (spec["topdir"] == "") then + forgesetupargs = "-c " .. forgesetupargs + extractdir = "%{archivename" .. suffix .. "}" + end + if not ismain then + if (spec["topdir"] ~= "") then + forgesetupargs = "-T -D -b " .. suffix .. " " .. forgesetupargs + else + forgesetupargs = "-T -D -a " .. suffix .. " " .. forgesetupargs + end + end + fedora.safeset("forgesetupargs" .. suffix, forgesetupargs, verbose) + fedora.safeset("extractdir" .. suffix, extractdir, verbose) + -- dist processing (computing the correct prefix for snapshots) + local distprefix = "" + if not isrelease then + distprefix = rpm.expand(ref) + if (ref == "%{?commit" .. suffix .. "}") then + distprefix = string.sub(distprefix, 1, 7) + elseif (ref ~= "%{?branch" .. suffix .. "}") then + distprefix = string.gsub(distprefix, "[%p%s]+", ".") + local v = string.gsub(spec["version"], "[%p%s]+", ".") + for _, p in ipairs({'','v','v.','version','version.'}) do + distprefix = getversionsuffix(distprefix, p .. v) + end + distprefix = string.gsub(distprefix, "^%.", "") + end + if (distprefix ~= "") then + distprefix = "%{scm" .. suffix .. "}" .. distprefix + date = rpm.expand("%{?date" .. suffix .. "}") + if (date ~= "") then + distprefix = date .. distprefix + else + distprefix = "%([ -r %{_sourcedir}/%{archivename" .. suffix .. "}.%{archiveext" .. suffix .. "} ] && date +%Y%m%d -u -r %{_sourcedir}/%{archivename" .. suffix .. "}.%{archiveext" .. suffix .. "})" .. distprefix + end + distprefix = "." .. distprefix + end + end + if (spec["version"] ~= "") and + (spec["version"] ~= "0") and + (spec["version"] ~= rpm.expand("%{?version}")) then + distprefix = ".%{version" .. suffix .. "}" .. distprefix + end + if (rpm.expand(distprefix) ~= "") then + if not ismain then + distprefix = string.gsub(distprefix, "^%.", ".S") + end + fedora.safeset ("distprefix" .. suffix, distprefix, verbose) + end + if ismain then + fedora.zalias({"forgeurl", "forgesource", "forgesetupargs", + "archivename", "archiveext", "archiveurl", + "topdir", "extractdir", "repo", "owner", + "scm", "shortcommit", "distprefix"}, verbose) + end + -- Final spec variable summary if the macro was called with -i + if informative then + rpm.expand("%{echo:Packaging variables read or set by %%forgemeta}") + fedora.echovars({"forgeurl", "forgesource", "forgesetupargs", + "archivename", "archiveext", "archiveurl", + "topdir", "extractdir", "repo", "owner", + "scm", "tag", "commit", "shortcommit", "branch", "version", + "date", "distprefix"}, suffix) + fedora.echovars({"dist"},"") + rpm.expand("%{echo: (snapshot date is either manually supplied or computed once %%{_sourcedir}/%%{archivename" .. suffix .. "}.%%{archiveext" .. suffix .. "} is available)}") + end +end + +return { + forgemeta = forgemeta, +} + diff --git a/macros.forge b/macros.forge index 692c52e..983e6aa 100644 --- a/macros.forge +++ b/macros.forge @@ -4,12 +4,13 @@ # The following spec variables SHOULD be set before calling the macro: # # forgeurl the project url on the forge, strongly recommended; -# alternatively, use -u # Version if applicable, set it with Version: # tag if applicable # commit if applicable # date if applicable (to override the mtime of the Source archive) # +# Use -z for multiple calls to the macro +# # The macro will attempt to compute and set the following variables if they are # not already set by the packager: # @@ -20,256 +21,77 @@ # archiveext the source archive filename extensions, without leading dot # archiveurl the url that can be used to download the source archive, # without renaming +# topdir the source archive top directory (can be empty) +# extractdir the source directory created inside %{_builddir} after using +# %%forgesetup, %forgeautosetup or %{forgesetupargs} +# repo the repository name +# owner the repository owner (if used by another computed variable) +# shortcommit the commit hash clamping used by the forge, if any # scm the scm type, when packaging code snapshots: commits or tags +# distprefix the prefix that needs adding to dist to trace non-release packaging # -# If the macro is unable to parse your forgeurl value set at least archivename -# and archiveurl before calling it. -# -# Most of the computed variables are both overridable and optional. However, -# the macro WILL REDEFINE %{dist} when packaging a snapshot (commit or tag). -# The previous %{dist} value will be lost. Don’t call the macro if you don’t -# wish %{dist} to be changed. +# Most of the computed variables are both overridable and optional. # # Optional parameters: -# -u Ignore forgeurl even if it exists and use instead. Note -# that the macro will still end up setting as the forgeurl -# spec variable if it manages to parse it. +# -a process all sources in one go, instead of using separate -z calls +# -z suffix all the read and written variable names with +# for example read forgeurl, version… +# and generate forgesetupargs, archiveurl… +# The macro assumes that null or nil suffix is used for the primary +# package source. # -s Silently ignore problems in forgeurl, use it if it can be parsed, # ignore it otherwise. -# -p Restore problem handling, override -s. # -v Be verbose and print every spec variable the macro sets. # -i Print some info about the state of spec variables the macro may use or # set at the end of the processing. -%forgemeta(u:spvi) %{lua: -local forgeurl = rpm.expand("%{?-u*}") -if (forgeurl == "") then - forgeurl = rpm.expand("%{?forgeurl}") -end -local silent = false -local verbose = false -local informative = false -if (rpm.expand("%{?-s}") ~= "") then - silent = true -end -if (rpm.expand("%{?-p}") ~= "") then - silent = false -end -if (rpm.expand("%{?-v}") ~= "") then - verbose = true -end -if (rpm.expand("%{?-i}") ~= "") then - informative = true -end --- Packaging a moving branch is quite a bad idea, but since at least Gitlab --- will treat branches and tags the same way better support branches explicitly --- than have packagers hijack %{tag} to download branch states -local tag = rpm.expand("%{?tag}") -local commit = rpm.expand("%{?commit}") -local branch = rpm.expand("%{?branch}") -local version = rpm.expand("%{?version}") -local ref = "" -if (tag ~= "") then ref = "%{?tag}" -elseif (commit ~= "") then ref = "%{?commit}" -elseif (branch ~= "") then ref = "%{?branch}" -else ref = "%{?version}" -end -if (rpm.expand(ref) == "") then - rpm.expand("%{error:You need to define Version:, %{commit} or %{tag} before the macro invocation !}") -end --- Be explicit about the spec variables we’re setting -local function explicitset(rpmvariable,value) - rpm.define(rpmvariable .. " " .. value) - if verbose then - rpm.expand("%{echo:Setting %%{" .. rpmvariable .. "} = " .. value .. "}") +%forgemeta(az:sviu:) %{lua: +local fedora = require "fedora.common" +local forge = require "fedora.srpm.forge" +local verbose = rpm.expand("%{-v}") ~= "" +local informative = rpm.expand("%{-i}") ~= "" +local silent = rpm.expand("%{-s}") ~= "" +local processall = (rpm.expand("%{-a}") ~= "") and (rpm.expand("%{-z}") == "") +if processall then + for _,s in pairs(fedora.getsuffixes("forgeurl")) do + forge.forgemeta(s,verbose,informative,silent) end -end --- Never ever stomp on a spec variable the packager already set -local function safeset(rpmvariable,value) - if (rpm.expand("%{?" .. rpmvariable .. "}") == "") then - explicitset(rpmvariable,value) - end -end --- Computes the suffix of a version string, removing vprefix if it matches --- For example with vprefix 1.2.3: 1.2.3.rc2 → .rc2 but 1.2.30 → 1.2.30 not 0 -local function getversionsuffix(vstring,vprefix) - if (string.sub(vstring, 1, #vprefix) == vprefix) and - (not string.match(string.sub(vstring, #vprefix + 1), "^%.?%d")) then - return string.sub(vstring, #vprefix + 1) - else - return vstring - end -end --- Set spec variable values for each known software publishing service -if (forgeurl ~= "") then - local forge = string.match(forgeurl, "^[^:]+://([^/]+)/") - if (forge == nil) then - if not silent then - rpm.expand("%{error:URLs must include a protocol such as https:// and a path starting with / !}") - end - else - if (string.match(forge, "^gitlab[%.-]") or string.match(forge, "[%.-]gitlab[%.]")) then - forgeurl = string.match(forgeurl, "https://[^/]+/[^/]+/[^/#?]+") - if (forgeurl == nil) then - if not silent then - rpm.expand("%{error:Gitlab URLs must match https://(…[-.])gitlab[-.]…/owner/repo !}") - end - else - explicitset("forgeurl", forgeurl) - safeset("archiveext", "tar.bz2") - safeset("forgesetupargs", "-n %{archivename}") - if (ref ~= "%{?version}") then safeset("scm", "git") end - local repo = string.match(forgeurl, "^[^:]+://[^/]+/[^/]+/([^/]+)") - safeset("archivename", repo .. "-" .. ref) - safeset("archiveurl", "%{forgeurl}/-/archive/" .. ref .. "/%{archivename}.%{archiveext}") - end - end - if (string.match(forge, "^github[%.-]") or string.match(forge, "[%.-]github[%.]")) then - forgeurl = string.match(forgeurl, "https://[^/]+/[^/]+/[^/#?]+") - if (forgeurl == nil) then - if not silent then - rpm.expand("%{error:GitHub URLs must match https://(…[-.])github[-.]…/owner/repo !}") - end - else - explicitset("forgeurl", forgeurl) - safeset("archiveext", "tar.gz") - safeset("forgesetupargs", "-n %{archivename}") - -- Workaround the way GitHub injects "v"s before some version strings (but not all!) - -- To package one of the minority of sane GitHub projects that do not munge their version - -- strings set tag to %{version} in your spec - local fileref = ref - if (ref == "%{?version}") then - ref = "v" .. ref - else - safeset("scm", "git") - if (fileref ~= "%{?commit}") and string.match(rpm.expand(fileref), "^v[%d]") then - fileref = string.gsub(rpm.expand(fileref), "^v", "") - end - end - local repo = string.match(forgeurl, "^[^:]+://[^/]+/[^/]+/([^/]+)") - safeset("archivename", repo .. "-" .. fileref) - safeset("archiveurl", "%{forgeurl}/archive/" .. ref .. "/%{archivename}.%{archiveext}") - end - end - if (forge == "code.googlesource.com") then - forgeurl = string.match(forgeurl, "https://code.googlesource.com/[^#?]*[^/#?]+") - if (forgeurl == nil) then - if not silent then - rpm.expand("%{error:Googlesource URLs must match https://code.googlesource.com/…/repo !}") - end - else - explicitset("forgeurl", forgeurl) - safeset("archiveext", "tar.gz") - safeset("forgesetupargs", "-c") - if (ref == "%{?version}") then - ref = "v" .. ref - else - safeset("scm", "git") - end - local repo = string.match(forgeurl, "^[^:]+://.+/([^/?#]+)") - safeset("archivename", repo .. "-" .. ref) - safeset("archiveurl", "%{forgeurl}/+archive/" .. ref .. ".%{archiveext}") - end - end - if (forge == "bitbucket.org") then - forgeurl = string.match(forgeurl, "https://[^/]+/[^/]+/[^/#?]+") - if (forgeurl == nil) then - if not silent then - rpm.expand("%{error:BitBucket URLs must match https://bitbucket.org/owner/repo !}") - end - else - explicitset("forgeurl", forgeurl) - if (commit == "") then - rpm.expand("%{error:All BitBucket URLs require commit value knowledge: you need to define %{commit}!}") - end - local shortcommit = string.sub(commit, 1, 12) - safeset("archiveext", "tar.bz2") - -- Default to git even though BitBucket allows choosing between several SCMs - -- Set scm to hg for example before calling the macro if your project does not use git - safeset("scm", "git") - local owner = string.match(forgeurl, "^[^:]+://[^/]+/([^/]+)") - local repo = string.match(forgeurl, "^[^:]+://[^/]+/[^/]+/([^/]+)") - safeset("archivename", owner .. "-" .. repo .. "-" .. shortcommit) - safeset("forgesetupargs", "-n %{archivename}") - if (tag ~= "") then - safeset("archiveurl", "%{forgeurl}/get/%{tag}.%{archiveext}") - else - safeset("archiveurl", "%{forgeurl}/get/%{commit}.%{archiveext}") - end - end - end - if (forge == "pagure.io") then - if not silent then - rpm.expand("%{error:https://pagure.io/pagure/issue/861 needs to be resolved before the “pagure.io”\\nsoftware publishing service can be supported.}") - end - end - -- Final tests to check forgeurl was successfuly parsed - if not silent then - if (rpm.expand("%{?archivename}") == "") or (rpm.expand("%{?archiveurl}") == "") then - rpm.expand("%{error:Automation for the “" .. forge .. "”\\nsoftware publishing service is not implemented yet.\\nPlease extend the %%forgemeta macro!}") - end - end - end -end --- Set defaults if forgeurl is missing or does not parse -local archivename = rpm.expand("%{?archivename}") -safeset("archiveext", "tar.gz") -if (archivename ~= "") then - safeset("forgesetupargs", "-n %{archivename}") -end -if (commit ~= "") or (tag ~= "") then - safeset("scm", "git") -end --- Source URL processing (computing the forgesource spec variable) -local archiveurl = rpm.expand("%{?archiveurl}") -local archiveext = rpm.expand("%{?archiveext}") -if (archivename ~= "") and (archiveurl ~= "") then - if (string.match(archiveurl, "/([^/]+)$") == archivename .. "." .. archiveext) then - safeset("forgesource", "%{archiveurl}") - else - safeset("forgesource", "%{?archiveurl}#/%{?archivename}.%{archiveext}") - end -end --- dist processing (computing the correct prefix for snapshots) -local distprefix = rpm.expand(ref) -if (ref == "%{?commit}") then - distprefix = string.sub(distprefix, 1, 7) -elseif (ref ~= "%{?branch}") then - distprefix = getversionsuffix(distprefix, version) - distprefix = getversionsuffix(distprefix, "v" .. version) - distprefix = string.gsub(distprefix, "[.-]+", ".") - distprefix = string.gsub(distprefix, "^%.", "") -end -if (distprefix ~= "") then - distprefix = "%{scm}" .. distprefix - date = rpm.expand("%{?date}") - if (date ~= "") then - distprefix = date .. distprefix - else - distprefix = "%([ -r %{_sourcedir}/%{archivename}.%{archiveext} ] && date +%Y%m%d -u -r %{_sourcedir}/%{archivename}.%{archiveext})" .. distprefix - end - safeset ("distprefix", "." .. distprefix) -end --- Final spec variable summary if the macro was called with -i -if informative then - rpm.expand("%{echo:Forge-specific packaging variables}") - rpm.expand("%{echo: forgeurl: %{?forgeurl}}") - rpm.expand("%{echo: forgesource: %{?forgesource}}") - rpm.expand("%{echo: forgesetupargs: %{?forgesetupargs}}") - rpm.expand("%{echo:Generic packaging variables}") - rpm.expand("%{echo: archivename: %{?archivename}}") - rpm.expand("%{echo: archiveext: %{?archiveext}}") - rpm.expand("%{echo: archiveurl: %{?archiveurl}}") - rpm.expand("%{echo: scm: %{?scm}}") - rpm.expand("%{echo: tag: %{?tag}}") - rpm.expand("%{echo: commit: %{?commit}}") - rpm.expand("%{echo: branch: %{?branch}}") - rpm.expand("%{echo: date: %{?date}}") - rpm.expand("%{echo: distprefix: %{?distprefix} (snapshot date is either manually supplied or computed once %%{_sourcedir}/%%{archivename}.%%{archiveext} is available)}") +else + forge.forgemeta(rpm.expand("%{-z*}"),verbose,informative,silent) end } # Convenience macro to relay computed arguments to %setup -%forgesetup(a:b:cDn:Tq) %setup %{?forgesetupargs} %{-a} %{-b} %{-c} %{-D} %{-n} %{-T} %{-q} +# Optional parameters: +# -a process all sources in one go, instead of using separate -z calls +# -z read %{?forgesetupargs} +# -v be verbose +%forgesetup(az:v) %{lua: +local fedora = require "fedora.common" +if (rpm.expand("%{-z}") == "") and (rpm.expand("%{-a}") ~= "") then + for _,s in pairs(fedora.getsuffixes("forgesetupargs")) do + print(rpm.expand("%setup %{!-v:-q} %{?forgesetupargs" .. s .. "}\\n")) + end +else + print( rpm.expand("%setup %{!-v:-q} %{?forgesetupargs" .. rpm.expand("%{-z*}") .. "}\\n")) +end +} # Convenience macro to relay computed arguments to %autosetup -%forgeautosetup(a:b:cDn:TvNS:p:) %autosetup %{?forgesetupargs} %{-a} %{-b} %{-c} %{-D} %{-n} %{-T} %{-v} %{-N} %{-S} %{-p} +# Parameters relayed to %autosetup: -v -N -S -p +# Optional parameters: +# -z read %{?forgesetupargs} +%forgeautosetup(z:vNS:p:) %{lua: +print(rpm.expand("%autosetup %{-v} %{-N} %{?-S} %{?-p} %{?forgesetupargs" .. rpm.expand("%{-z*}") .. "}\\n")) +} + +# List files matching inclusion globs, excluding files matching exclusion blogs +# Parameters: +# -i "" include shell globs (also takes all other macro arguments) +# -x "" exclude shell globs +%listfiles(i:x:) %{expand: +while IFS= read -r -d $'\\n' finc ; do + printf "%s\\n" %{?-x*} \\ + | xargs -i realpath --relative-base=. '{}' \\ + | grep "${finc}" >/dev/null || echo "${finc}" +done <<< $(printf "%s\\n" %{?-i*} %* | xargs -i realpath --relative-base=. '{}' | sort -u) +} diff --git a/redhat-rpm-config.spec b/redhat-rpm-config.spec index b104b91..138072c 100644 --- a/redhat-rpm-config.spec +++ b/redhat-rpm-config.spec @@ -73,6 +73,10 @@ Source602: libsymlink.attr # BRPs Source700: brp-ldconfig +# Convenience lua functions +Source800: common.lua +Source801: forge.lua + # Documentation Source900: buildflags.md @@ -150,6 +154,10 @@ mkdir -p %{buildroot}%{_fileattrsdir} install -p -m 644 -t %{buildroot}%{_fileattrsdir} *.attr install -p -m 755 -t %{buildroot}%{_rpmconfigdir} kmod.prov +mkdir -p %{buildroot}%{_rpmluadir}/fedora/{rpm,srpm} +install -p -m 644 -t %{buildroot}%{_rpmluadir}/fedora common.lua +install -p -m 644 -t %{buildroot}%{_rpmluadir}/fedora/srpm forge.lua + %files %dir %{rrcdir} %{rrcdir}/macros @@ -169,6 +177,12 @@ install -p -m 755 -t %{buildroot}%{_rpmconfigdir} kmod.prov %{_rpmconfigdir}/macros.d/macros.forge %{_rpmconfigdir}/macros.d/macros.ldconfig %{_rpmconfigdir}/macros.d/macros.vpath +%dir %{_rpmluadir}/fedora +%dir %{_rpmluadir}/fedora/srpm +%dir %{_rpmluadir}/fedora/rpm +%{_rpmluadir}/fedora/*.lua +%{_rpmluadir}/fedora/srpm/*lua + %doc buildflags.md %files -n kernel-rpm-macros From 39fa88418c95a7943a900a0f68d9fa2691398375 Mon Sep 17 00:00:00 2001 From: Igor Gnatenko Date: Sat, 20 Oct 2018 12:32:45 +0200 Subject: [PATCH 12/17] bump version Signed-off-by: Igor Gnatenko --- redhat-rpm-config.spec | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/redhat-rpm-config.spec b/redhat-rpm-config.spec index 138072c..582d3fe 100644 --- a/redhat-rpm-config.spec +++ b/redhat-rpm-config.spec @@ -6,7 +6,7 @@ Summary: Red Hat specific rpm configuration files Name: redhat-rpm-config -Version: 121 +Version: 122 Release: 1%{?dist} # No version specified. License: GPL+ @@ -197,6 +197,9 @@ install -p -m 644 -t %{buildroot}%{_rpmluadir}/fedora/srpm forge.lua %{_rpmconfigdir}/macros.d/macros.kmp %changelog +* Sat Oct 20 2018 Igor Gnatenko - 122-1 +- Allow multiple calls to forge macros + * Thu Oct 11 2018 Jan Pazdziora - 121-1 - Add %_swidtagdir for directory for SWID tag files describing the installation. From 8ba2a65b5ce1777906d200d0e20e435e02c76a58 Mon Sep 17 00:00:00 2001 From: Nicolas Mailhot Date: Mon, 22 Oct 2018 10:10:19 +0200 Subject: [PATCH 13/17] forge: add back a no-op -q in %forgeautosetup, even though being quiet was always its default behaviour https://lists.fedoraproject.org/archives/users/81059352675829171399634426908237561548/ --- macros.forge | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/macros.forge b/macros.forge index 983e6aa..b11ecec 100644 --- a/macros.forge +++ b/macros.forge @@ -80,7 +80,7 @@ end # Parameters relayed to %autosetup: -v -N -S -p # Optional parameters: # -z read %{?forgesetupargs} -%forgeautosetup(z:vNS:p:) %{lua: +%forgeautosetup(z:vNS:p:q) %{lua: print(rpm.expand("%autosetup %{-v} %{-N} %{?-S} %{?-p} %{?forgesetupargs" .. rpm.expand("%{-z*}") .. "}\\n")) } From 65fc49d91791d1ed4e42caf655a29e6d989a1c39 Mon Sep 17 00:00:00 2001 From: Igor Gnatenko Date: Mon, 22 Oct 2018 11:09:13 +0200 Subject: [PATCH 14/17] bump version Signed-off-by: Igor Gnatenko --- redhat-rpm-config.spec | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/redhat-rpm-config.spec b/redhat-rpm-config.spec index 582d3fe..2d50640 100644 --- a/redhat-rpm-config.spec +++ b/redhat-rpm-config.spec @@ -6,7 +6,7 @@ Summary: Red Hat specific rpm configuration files Name: redhat-rpm-config -Version: 122 +Version: 123 Release: 1%{?dist} # No version specified. License: GPL+ @@ -197,6 +197,9 @@ install -p -m 644 -t %{buildroot}%{_rpmluadir}/fedora/srpm forge.lua %{_rpmconfigdir}/macros.d/macros.kmp %changelog +* Mon Oct 22 2018 Igor Gnatenko - 123-1 +- Add -q option to %%forgesetup + * Sat Oct 20 2018 Igor Gnatenko - 122-1 - Allow multiple calls to forge macros From 455084c511e23fbef6a0732a9c2f4ebc76fde642 Mon Sep 17 00:00:00 2001 From: Nicolas Mailhot Date: Tue, 6 Nov 2018 17:47:28 +0100 Subject: [PATCH 15/17] forge: add more distprefix cleaning (bz1646724) --- forge.lua | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/forge.lua b/forge.lua index a812184..af71c87 100644 --- a/forge.lua +++ b/forge.lua @@ -194,12 +194,13 @@ local function forgemeta(suffix, verbose, informative, silent) -- dist processing (computing the correct prefix for snapshots) local distprefix = "" if not isrelease then - distprefix = rpm.expand(ref) + distprefix = string.lower(rpm.expand(ref)) if (ref == "%{?commit" .. suffix .. "}") then distprefix = string.sub(distprefix, 1, 7) elseif (ref ~= "%{?branch" .. suffix .. "}") then distprefix = string.gsub(distprefix, "[%p%s]+", ".") - local v = string.gsub(spec["version"], "[%p%s]+", ".") + distprefix = string.gsub(distprefix, "^" .. string.lower(rpm.expand("%{?repo}")) .. "%.?", "") + local v = string.gsub(rpm.expand("%{version}"), "[%p%s]+", ".") for _, p in ipairs({'','v','v.','version','version.'}) do distprefix = getversionsuffix(distprefix, p .. v) end From b725d1e38a345546dd837034ff25db9996b14d42 Mon Sep 17 00:00:00 2001 From: Jason Tibbitts Date: Thu, 8 Nov 2018 08:34:28 -0600 Subject: [PATCH 16/17] Bump version/update changelog. --- redhat-rpm-config.spec | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/redhat-rpm-config.spec b/redhat-rpm-config.spec index 2d50640..30b4f8c 100644 --- a/redhat-rpm-config.spec +++ b/redhat-rpm-config.spec @@ -6,7 +6,7 @@ Summary: Red Hat specific rpm configuration files Name: redhat-rpm-config -Version: 123 +Version: 124 Release: 1%{?dist} # No version specified. License: GPL+ @@ -197,6 +197,9 @@ install -p -m 644 -t %{buildroot}%{_rpmluadir}/fedora/srpm forge.lua %{_rpmconfigdir}/macros.d/macros.kmp %changelog +* Thu Nov 08 2018 Jason L Tibbitts III - 124-1 +- forge: add more distprefix cleaning (bz1646724) + * Mon Oct 22 2018 Igor Gnatenko - 123-1 - Add -q option to %%forgesetup From a21217497520df1ab23134e83c0fad44da56a9d1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miro=20Hron=C4=8Dok?= Date: Thu, 15 Nov 2018 12:13:14 +0100 Subject: [PATCH 17/17] Make automagic Python bytecompilation optional https://fedoraproject.org/wiki/Changes/No_more_automagic_Python_bytecompilation_phase_2 --- macros | 2 +- redhat-rpm-config.spec | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/macros b/macros index d7ffc84..d87c0fc 100644 --- a/macros +++ b/macros @@ -184,7 +184,7 @@ ## Should python bytecompilation errors terminate a build? %_python_bytecompile_errors_terminate_build 1 ## Should python bytecompilation compile outisde python specific directories? -%_python_bytecompile_extra 1 +%_python_bytecompile_extra 0 # Use SHA-256 for FILEDIGESTS instead of default MD5 %_source_filedigest_algorithm 8 diff --git a/redhat-rpm-config.spec b/redhat-rpm-config.spec index 30b4f8c..b9735f6 100644 --- a/redhat-rpm-config.spec +++ b/redhat-rpm-config.spec @@ -6,7 +6,7 @@ Summary: Red Hat specific rpm configuration files Name: redhat-rpm-config -Version: 124 +Version: 125 Release: 1%{?dist} # No version specified. License: GPL+ @@ -197,6 +197,10 @@ install -p -m 644 -t %{buildroot}%{_rpmluadir}/fedora/srpm forge.lua %{_rpmconfigdir}/macros.d/macros.kmp %changelog +* Thu Nov 15 2018 Miro Hrončok - 125-1 +- Make automagic Python bytecompilation optional + https://fedoraproject.org/wiki/Changes/No_more_automagic_Python_bytecompilation_phase_2 + * Thu Nov 08 2018 Jason L Tibbitts III - 124-1 - forge: add more distprefix cleaning (bz1646724)