don't use mini_portile2, but build libgumbo.a by normal make

This commit is contained in:
Mamoru TASAKA 2021-08-07 20:00:21 +09:00
parent 4e193aeb64
commit 4d4f491c08

View File

@ -20,6 +20,7 @@ Release: %{?prever:0.}%{mainrel}%{?prever:.%{prerpmver}}%{?dist}
# see gumbo-parser/src/attribute.c and ext/nokogiri/gumbo.c # see gumbo-parser/src/attribute.c and ext/nokogiri/gumbo.c
# also lib/nokogiri/html5 is licensed under ASL 2.0 # also lib/nokogiri/html5 is licensed under ASL 2.0
License: MIT and ASL 2.0 License: MIT and ASL 2.0
Provides: bundled(gumbo-parser) = 0.10.1
URL: https://nokogiri.org URL: https://nokogiri.org
Source0: https://rubygems.org/gems/%{gem_name}-%{mainver}%{?prever}.gem Source0: https://rubygems.org/gems/%{gem_name}-%{mainver}%{?prever}.gem
@ -46,8 +47,6 @@ BuildRequires: glibc-all-langpacks
BuildRequires: gcc BuildRequires: gcc
BuildRequires: libxml2-devel BuildRequires: libxml2-devel
BuildRequires: libxslt-devel BuildRequires: libxslt-devel
# From 1.12.0 need this to compile internal gumbo
BuildRequires: rubygem(mini_portile2) >= 2.6
BuildRequires: ruby-devel BuildRequires: ruby-devel
# ruby27 needs this explicitly # ruby27 needs this explicitly
BuildRequires: rubygem(racc) BuildRequires: rubygem(racc)
@ -107,33 +106,40 @@ sed -i \
lib/nokogiri/extension.rb \ lib/nokogiri/extension.rb \
-e 's@require_relative "@require "nokogiri/@' -e 's@require_relative "@require "nokogiri/@'
# Don't clean up files used when building bundled gumbo, # Don't use mini_portile2, but build libgumbo.a first and
# otherwise debuginfo rpm will become imcomplete # tell extconf.rb the path to the archive
sed -i \ sed -i \
ext/nokogiri/extconf.rb \ ext/nokogiri/extconf.rb \
-e '\@Pathname\.glob.*ports@s@ports@ports_ignore@' -e "s@^\(def process_recipe.*\)\$@\1 ; return true@" \
-e "s@^\(append_cppflags\).*gumbo.*\$@\1(\"-I$(pwd)/gumbo-parser/src\")@" \
# Make gumbo build process verbose -e "\@libs.*gumbo@s@File\.join.*@\"$(pwd)/gumbo-parser/src/libgumbo.a\"@" \
sed -i \ -e "\@LIBPATH.*gumbo@s|^\(.*\)\$|# \1|" \
ext/nokogiri/extconf.rb \ %{nil}
-e '\@execute.*compile.*make_cmd@s@env: env@env: env, debug: true@'
# #line directive can confuse debuginfo, removing for now # #line directive can confuse debuginfo, removing for now
sed -i \ sed -i \
gumbo-parser/src/char_ref.c \ gumbo-parser/src/char_ref.c \
-e '\@^#line [0-9]@s|^\(.*\)$|// \1|' -e '\@^#line [0-9]@s|^\(.*\)$|// \1|'
# Compile libgumbo.a with -fPIC
sed -i \
gumbo-parser/src/Makefile \
-e 's|^\(CFLAGS.*=.*\)$|\1 -fPIC|'
# Ummm... # Ummm...
env LANG=C.UTF-8 gem build %{gem_name}-%{version}.gemspec env LANG=C.UTF-8 gem build %{gem_name}-%{version}.gemspec
%build %build
# 1.6.0 needs this # 1.6.0 needs this
export NOKOGIRI_USE_SYSTEM_LIBRARIES=yes export NOKOGIRI_USE_SYSTEM_LIBRARIES=yes
export V=1
%set_build_flags %set_build_flags
# First build libgumbo.a
pushd gumbo-parser/src/
make libgumbo.a
popd
%gem_install %gem_install
find . -name compile.log | xargs cat
# Permission # Permission
chmod 0644 .%{gem_dir}/cache/%{gem_name}-%{mainver}%{?prever}.gem chmod 0644 .%{gem_dir}/cache/%{gem_name}-%{mainver}%{?prever}.gem
@ -148,6 +154,9 @@ rm -rf .%{gem_instdir}/ext/java
mkdir -p %{buildroot}%{gem_dir} mkdir -p %{buildroot}%{gem_dir}
cp -a ./%{gem_dir}/* %{buildroot}%{gem_dir} cp -a ./%{gem_dir}/* %{buildroot}%{gem_dir}
# Also first copy these, clean up later
cp -a ./gumbo-parser %{buildroot}%{gem_instdir}/
# Remove backup file # Remove backup file
find %{buildroot} -name \*.orig_\* | xargs rm -vf find %{buildroot} -name \*.orig_\* | xargs rm -vf
@ -197,8 +206,6 @@ find src -type f | \
popd popd
rm -f %{buildroot}%{gem_cache} rm -f %{buildroot}%{gem_cache}
# Remove bundled gumbo parser
%check %check
# Ah.... # Ah....
# test_exslt(TestXsltTransforms) [./test/test_xslt_transforms.rb:93] # test_exslt(TestXsltTransforms) [./test/test_xslt_transforms.rb:93]