]> TLD Linux GIT Repositories - packages/rpm-tld-macros.git/commitdiff
- merged 2.066 from PLD master
authorMarcin Krol <hawk@tld-linux.org>
Tue, 19 May 2026 21:00:07 +0000 (23:00 +0200)
committerMarcin Krol <hawk@tld-linux.org>
Tue, 19 May 2026 21:00:07 +0000 (23:00 +0200)
gem_helper.rb
macros.java
macros.php
macros.python
macros.rust
macros.tld
rpm-java-requires
rpm-tld-macros.spec

index 3a82737be6709e0e29e647eb87bce0b095428e66..a9fd7de21e340999f85bc631163167d7dfb5904b 100755 (executable)
@@ -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")
index cdaa677cfe979893fbf488f6ce7471094ced2fb7..f6d15cd77bc0da61e3c7e9f4a6bf50365cbdb417 100644 (file)
 # 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() \
index 7fe74f94b1bf2b62e138a28b7b1e1ea93f797e02..fb9f7e82ab511557f027deb439713b94ad3db64f 100644 (file)
@@ -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}
 
index 48b238fe846c32a03eb56378e4940215f5c593f9..b32fb6f47c178ded0fb48f6105460dc41f805e91 100644 (file)
 
 # "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 { \
index 5f257379bf66fdf61f718b643db4583d2caad452..e644851b04843991508b2172576b25794b5562e6 100644 (file)
@@ -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
index 45acfb21db3c8e69c3d4f4ea3a0c92b6eb4e3f04..d26f7a6b3aea5ee04c3f2e159bb689dbde124930 100644 (file)
@@ -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_<lang> 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}
index 8bbac6f2e53e91ded3f1eb08f3bf49a791ea269c..1951d4f6abc769602fb3771bd45441fd0bdf657c 100755 (executable)
@@ -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
 
index ed1018ce8d9795f1d6cd86c6297796b5c0b9495f..3b22df3fc0c5b7ec808538793cef4b1d3b3a9788 100644 (file)
@@ -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}