From c7c945f00ef0578008977f8db0e258493acab052 Mon Sep 17 00:00:00 2001 From: Marcin Krol Date: Tue, 19 May 2026 23:00:07 +0200 Subject: [PATCH] - merged 2.066 from PLD --- gem_helper.rb | 26 +++++++++------- macros.java | 19 +++++++++--- macros.php | 4 +-- macros.python | 8 ++++- macros.rust | 2 +- macros.tld | 72 +++++++++++++++++++++++++++++++++------------ rpm-java-requires | 2 +- rpm-tld-macros.spec | 5 ++-- 8 files changed, 97 insertions(+), 41 deletions(-) diff --git a/gem_helper.rb b/gem_helper.rb index 3a82737..a9fd7de 100755 --- a/gem_helper.rb +++ b/gem_helper.rb @@ -10,7 +10,7 @@ require 'rubygems' # Write the .gemspec specification (in Ruby) def writespec(spec) - file_name = spec.full_name.untaint + '.gemspec' + file_name = spec.full_name + '.gemspec' File.open(file_name, "w") do |file| file.puts spec.to_ruby_for_cache end @@ -27,6 +27,7 @@ end if ARGV[0] == "build" or ARGV[0] == "install" or ARGV[0] == "spec" require 'yaml' require 'zlib' + require 'rubygems/package' filter = nil opts = nil @@ -74,16 +75,21 @@ if ARGV[0] == "build" or ARGV[0] == "install" or ARGV[0] == "spec" argv.delete_at(0) end - file_data = Zlib::GzipReader.open("metadata.gz") {|io| io.read} - header = YAML::load(file_data) + if File.exist?("metadata.gz") + file_data = Zlib::GzipReader.open("metadata.gz") {|io| io.read} + spec = Gem::Specification.from_yaml(file_data) + elsif File.exist?("metadata") + spec = Gem::Specification.from_yaml(File.read("metadata")) + elsif (gemspec = (Dir["*.gemspec"] + Dir[File.join(File.dirname(Dir.pwd), "*.gemspec")]).first) + spec = Gem::Specification.load(gemspec) + else + raise "No metadata.gz, metadata, or .gemspec found" + end body = {} - # I don't know any better.. :/ - header.instance_variables.each do |iv| - body[iv.to_s.sub(/^@/,'')] = header.instance_variable_get(iv) + spec.instance_variables.each do |iv| + body[iv.to_s.sub(/^@/,'')] = spec.instance_variable_get(iv) end - spec = Gem::Specification.from_yaml(YAML.dump(header)) - if ARGV[0] == "spec" writespec(spec) exit(0) @@ -186,9 +192,9 @@ if ARGV[0] == "build" or ARGV[0] == "install" or ARGV[0] == "spec" end end - spec = Gem::Specification.from_yaml(YAML.dump(header)) + require 'rubygems/package' unless dry_run - Gem::Builder.new(spec).build + Gem::Package.build(spec) else files.concat(spec.files) print "%s\n" % files.join("\n") diff --git a/macros.java b/macros.java index cdaa677..f6d15cd 100644 --- a/macros.java +++ b/macros.java @@ -68,20 +68,31 @@ # expands to the value with right jdk for BuildRequires header # 'jdk' if %%use_jdk is not defined, jdk(%%use_jdk) otherwise # The requirement will not replace current 'default' JDK -%required_jdk jdk%{?use_jdk:(%{use_jdk})} +%required_jdk jdk%{?use_jdk:(%{use_jdk})} -%buildrequires_jdk BuildRequires: %required_jdk +%buildrequires_jdk BuildRequires: %required_jdk +%buildrequires_jre_x11 BuildRequires: jre-X11%{?use_jdk:(%{use_jdk})} -%java_home %{expand:%%global java_home %([ -f %{_javadir}-utils/java-functions ] || { echo ERROR; exit 0; }; %{!?use_jdk:unset JAVA_HOME; . %{_javadir}-utils/java-functions; set_jvm}%{?use_jdk:JAVA_HOME=%{_jvmdir}/%{use_jdk}}; echo ${JAVA_HOME:-ERROR})}%java_home +%java_home %{expand:%%global java_home %([ -f %{_javadir}-utils/java-functions ] || { echo ERROR; exit 0; }; %{!?use_jdk:unset JAVA_HOME; . %{_javadir}-utils/java-functions >/dev/null 2>&1 && set_jvm >/dev/null 2>&1}%{?use_jdk:JAVA_HOME=%{_jvmdir}/%{use_jdk}}; echo ${JAVA_HOME:-ERROR})}%java_home %_javasrcdir %{_usrsrc}/java %ant JAVA_HOME=%{java_home} CLASSPATH=$CLASSPATH ant %jar %{java_home}/bin/jar -%java %{expand:%%global java %([ -f %{_javadir}-utils/java-functions ] || { echo ERROR; exit 0; }; %{!?use_jdk:unset JAVACMD; . %{_javadir}-utils/java-functions; set_javacmd}%{?use_jdk:JAVACMD=%{java_home}/bin/java}; echo $JAVACMD)}%java +%java %{expand:%%global java %([ -f %{_javadir}-utils/java-functions ] || { echo ERROR; exit 0; }; %{!?use_jdk:unset JAVACMD; . %{_javadir}-utils/java-functions >/dev/null 2>&1 && set_javacmd >/dev/null 2>&1}%{?use_jdk:JAVACMD=%{java_home}/bin/java}; echo ${JAVACMD:-ERROR})}%java %javac %{java_home}/bin/javac %javadoc %{java_home}/bin/javadoc +%java_env \ + if [ -n "%{java_home}" ] && [ "%{java_home}" != "ERROR" ]; then \ + JAVA_HOME="${JAVA_HOME:-%{java_home}}"; export JAVA_HOME; \ + JAVA="${JAVA:-%{java}}"; export JAVA; \ + JAVAC="${JAVAC:-%{javac}}"; export JAVAC; \ + JAVADOC="${JAVADOC:-%{javadoc}}"; export JAVADOC; \ + JAR="${JAR:-%{jar}}"; export JAR; \ + PATH="$PATH:%{java_home}/bin"; export PATH; \ + fi + %add_jvm_extension JAVA_LIBDIR=%{buildroot}/%{_javadir} %{_bindir}/jvmjar -l %jpackage_script() \ diff --git a/macros.php b/macros.php index 7fe74f9..fb9f7e8 100644 --- a/macros.php +++ b/macros.php @@ -112,7 +112,7 @@ tee install.log \ # make post message of optional packages \ grep -E 'can optionally use|Optional feature' install.log | sed -e 's,package "pear/,package "php-pear-,g;s,^pear/,php-pear-,;s,^pear/,php-pear-,' > optional-packages.txt \ if [ -s optional-packages.txt ]; then \ - awk -F'"' '/use package/{print $2}' optional-packages.txt | sed -e "s,_,/,g;s,php-pear-, 'pear(,;s,$,.*)'," | tr -d '\\\n' > _noautoreq \ + awk -F'"' '/use package/{print $2}' optional-packages.txt | sed -e "s,_,/,g;s,php-pear-, ,;s,$,.*," | tr -d '\\\n' > _noautoreq \ else \ rm -f optional-packages.txt \ fi \ @@ -172,7 +172,7 @@ find $RPM_BUILD_ROOT%{php_pear_dir} '(' -name '*~' -o -name '*.orig' ')' | xargs # help the developer out a little: \ if [ -f _noautoreq ]; then \ echo "AutoReqdep detected:" \ - echo "_noautoreq $(cat _noautoreq)" \ + echo "_noautoreq_pear$(cat _noautoreq)" \ fi \ %{nil} diff --git a/macros.python b/macros.python index 48b238f..b32fb6f 100644 --- a/macros.python +++ b/macros.python @@ -139,9 +139,15 @@ # "shrink" filter to keep this macro without newlines, # so it could be used as make arguments +# Note: unlike setup.py's --optimize=N which always generates level 0 bytecode +# plus the requested level, python3 -m installer --compile-bytecode=N generates +# ONLY the specified level(s). We need 0 (used by default python3 invocation), +# 1 (used by python3 -O) and 2 (used by python3 -OO). Without level 0, Python +# has to recompile from .py source on every import since it won't use .opt-N.pyc +# files for non-optimized runs. %py3_install_pyproject_opts() %{shrink: \ --prefix=%{_prefix} \ - --compile-bytecode=2 \ + --compile-bytecode=0 --compile-bytecode=1 --compile-bytecode=2 \ } %py3_install_pyproject { \ diff --git a/macros.rust b/macros.rust index 5f25737..e644851 100644 --- a/macros.rust +++ b/macros.rust @@ -31,7 +31,7 @@ thumbv7neon-unknown-linux-gnueabihf\\\ %cargo_target %rust_target %cargo_targetdir target -%cargo_objdir %{?buildsubdir:%{_builddir}/%{buildsubdir}/}%{cargo_targetdir}/%{rust_target}/%{!?debug:release}%{?debug:debug} +%cargo_objdir %{cargo_targetdir}/%{rust_target}/%{!?debug:release}%{?debug:debug} %__rustc /usr/bin/rustc %__cargo /usr/bin/cargo diff --git a/macros.tld b/macros.tld index 45acfb2..d26f7a6 100644 --- a/macros.tld +++ b/macros.tld @@ -225,7 +225,9 @@ pakietu oraz przy odpluskwianiu samego pakietu.\ # # if you want to disable parallel build do: # echo '%__jobs %{nil}' >> ~/.rpmmacros -%__jobs %{expand:%%global __jobs %(_NCPUS=$(/usr/bin/getconf _NPROCESSORS_ONLN); [ "$_NCPUS" -gt 3 ] && echo $(($_NCPUS / 2)))%%{nil}}%__jobs +# +# to cap parallelism in a spec: %define _smp_ncpus_max 16 +%__jobs %{expand:%%global __jobs %{__smp_use_ncpus}}%__jobs %_smp_build_ncpus %{__jobs} %_smp_build_nthreads %{__jobs} @@ -408,7 +410,8 @@ print(tmpdir) CPPFLAGS="${CPPFLAGS:-%rpmcppflags}" ; export CPPFLAGS ; \ LDFLAGS="${LDFLAGS:-%rpmldflags}" ; export LDFLAGS ; \ RUSTC="${RUSTC:-%__rustc}" ; export RUSTC ; \ - RUSTFLAGS="${RUSTFLAGS:-%rpmrustflags}" ; export RUSTFLAGS + RUSTFLAGS="${RUSTFLAGS:-%rpmrustflags}" ; export RUSTFLAGS; \ + %{java_env} #----------------------------------------------------------------- # @@ -1126,24 +1129,55 @@ fi; \ %{?_noautoreq_py3egg: %{__noauto_regexp_helper -p python3egg %{_noautoreq_py3egg}}} \ %{nil} -%__noautodep_helper() %(echo '%*' | awk 'BEGIN { - RS = "\n([ \t]+\n)+"; - FS = " "; +# Convert whitespace-separated list of dependency patterns into a single +# alternation regex: "pat1 pat2 pat3" → "(pat1|pat2|pat3)" +# Used by __requires_exclude / __provides_exclude to filter auto-dependencies. +# Strips single quotes from patterns (some specs quote _noautoreq values) +# and skips #-comment tokens. +# +# Each token is normalized so that the common PLD usage forms work as +# packagers actually expect: +# 1. prefix(content) - escape outer parens, keep content as regex +# 'pear(Foo.*)' → pear\(Foo.*\) +# 'pear(a|.*b|c)' → pear\((a|.*b|c)\) +# 'libc.so.6(GLIBC_..)' → libc.so.6\(GLIBC_..\) +# The prefix must be alphanumeric/dot/dash; this +# excludes coq's 'ocamlx?\(...\)' (has '?') and +# audio plugin paths '%{_libdir}/(...)' (has '/'), +# which fall through to step 2 or 3. +# 2. token without '|' - escape unescaped parens (already-escaped \( stays) +# '(GLIBC_PRIVATE)' → \(GLIBC_PRIVATE\) +# 3. token with '|' - left intact for regex alternation grouping +# '%{_libdir}/(dssi|lv2|vst)' unchanged +# 'ocamlx?\((A|B|C)\)' unchanged +# +# This diverges from upstream RPM's pure-regex contract for +# __requires_exclude but matches how every PLD spec already uses +# _noautoreq in practice. The typed _noautoreq_ variants +# auto-escape via __noauto_regexp_helper and remain the preferred form. +%__noautodep_helper() %{lua: +local args = rpm.expand("%*") +local result = {} +for token in args:gmatch("%S+") do + token = token:gsub("'", "") + if token ~= "" and not token:match("^#") then + local prefix, content = token:match("^([%w._-]+)[(](.*)[)]$") + if prefix then + if content:match("|") then + token = prefix .. "\\\\((" .. content .. ")\\\\)" + else + token = prefix .. "\\\\(" .. content .. "\\\\)" + end + elseif not token:match("|") then + token = token:gsub("\\\\?[(]", "\\\\("):gsub("\\\\?[)]", "\\\\)") + end + table.insert(result, token) + end +end +if #result > 0 then + print("(" .. table.concat(result, "|") .. ")") +end } -{ - split($0, F); - if (length(F) > 0) { - printf("("); - for (i=1; i<=length(F); i++) { - s = F[i]; - sub(/#.*/, "z&z", s); - if (s ~ /^$/) { continue; }; - printf(s); - if (i != length(F)) { printf("|"); }; - }; - printf(")"); - } -}') %__requires_exclude_from %{__noautodep_helper %{__noautoreqfiles}}%{nil} %__provides_exclude_from %{__noautodep_helper %{__noautoprovfiles}}%{nil} %__requires_exclude %{__noautodep_helper %{__noautoreq}}%{nil} diff --git a/rpm-java-requires b/rpm-java-requires index 8bbac6f..1951d4f 100755 --- a/rpm-java-requires +++ b/rpm-java-requires @@ -62,7 +62,7 @@ javajarversion() { [ -f "$jar" -a ! -L "$jar" ] || return $ret tmp=$(mktemp -d) - unzip -q -d $tmp $jar >&2 + unzip -q -n -d $tmp $jar >&2 # workaround for .jar files with stupid permissions chmod -R u+rwX $tmp diff --git a/rpm-tld-macros.spec b/rpm-tld-macros.spec index ed1018c..3b22df3 100644 --- a/rpm-tld-macros.spec +++ b/rpm-tld-macros.spec @@ -1,4 +1,4 @@ -%define rpm_macros_rev 2.052 +%define rpm_macros_rev 2.066 %define find_lang_rev 1.42 # split into individual X_prov_ver if there is a reason to desync %define prov_ver 4.15 @@ -137,10 +137,9 @@ Summary: Additional utilities for checking Java provides/requires in RPM package Summary(pl.UTF-8): Dodatkowe narzędzia do sprawdzania zależności kodu w Javie w pakietach RPM Group: Applications/File Requires: %{name}-build = %{version}-%{release} -Requires: jar -Requires: jre Requires: file Requires: findutils >= 1:4.2.26 +Requires: libxslt-progs Requires: mktemp Requires: unzip Provides: rpm-javaprov = %{prov_ver} -- 2.52.0