# 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
if ARGV[0] == "build" or ARGV[0] == "install" or ARGV[0] == "spec"
require 'yaml'
require 'zlib'
+ require 'rubygems/package'
filter = nil
opts = nil
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)
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")
# 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() \
# 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 \
# help the developer out a little: \
if [ -f _noautoreq ]; then \
echo "AutoReqdep detected:" \
- echo "_noautoreq $(cat _noautoreq)" \
+ echo "_noautoreq_pear$(cat _noautoreq)" \
fi \
%{nil}
# "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 { \
%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
#
# 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}
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}
#-----------------------------------------------------------------
#
%{?_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}
[ -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
-%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
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}