diff options
author | Sam James <sam@gentoo.org> | 2023-03-31 02:57:23 +0100 |
---|---|---|
committer | Sam James <sam@gentoo.org> | 2023-03-31 18:59:33 +0100 |
commit | 6774d07f7d7e4e48b5c14fc1c056ebc1d614a8b7 (patch) | |
tree | f05bbbcf392ff8b7acfac0808e856c661bfec5da /www-servers | |
parent | dev-ruby/websocket-driver: EAPI 8, enable ruby32 (diff) | |
download | gentoo-6774d07f7d7e4e48b5c14fc1c056ebc1d614a8b7.tar.gz gentoo-6774d07f7d7e4e48b5c14fc1c056ebc1d614a8b7.tar.bz2 gentoo-6774d07f7d7e4e48b5c14fc1c056ebc1d614a8b7.zip |
www-servers/thin: enable ruby32
Backport an upstream patch for ruby32. It's not too big at least.
I've also asked upstream if they'll consider making a new release.
Bug: https://github.com/macournoyer/thin/pull/392
Bug: https://github.com/macournoyer/thin/issues/393
Signed-off-by: Sam James <sam@gentoo.org>
Diffstat (limited to 'www-servers')
-rw-r--r-- | www-servers/thin/files/thin-1.8.1-ruby32.patch | 99 | ||||
-rw-r--r-- | www-servers/thin/thin-1.8.1-r3.ebuild | 99 |
2 files changed, 198 insertions, 0 deletions
diff --git a/www-servers/thin/files/thin-1.8.1-ruby32.patch b/www-servers/thin/files/thin-1.8.1-ruby32.patch new file mode 100644 index 000000000000..808ebc2a45db --- /dev/null +++ b/www-servers/thin/files/thin-1.8.1-ruby32.patch @@ -0,0 +1,99 @@ +https://github.com/macournoyer/thin/commit/829c3aaa48efcd0c289d856f068f5d0fb16edaac + +From 829c3aaa48efcd0c289d856f068f5d0fb16edaac Mon Sep 17 00:00:00 2001 +From: Vasily Fedoseyev <github@vasfed.ru> +Date: Wed, 1 Feb 2023 00:03:48 +0300 +Subject: [PATCH] Update code base for Ruby v3.2 (#392) + +* `File.exists?` is removed in ruby 3.2 + +* Fix deprecated rspec expectation syntax + +* Fix `Socket.gethostbyname` deprecation + +* Test on ruby 3.2 and rack 2. +--- a/lib/thin/backends/swiftiply_client.rb ++++ b/lib/thin/backends/swiftiply_client.rb +@@ -50,7 +50,17 @@ def swiftiply_handshake(key) + + # For some reason Swiftiply request the current host + def host_ip +- Socket.gethostbyname(@backend.host)[3].unpack('CCCC') rescue [0, 0, 0, 0] ++ begin ++ if defined?(Addrinfo) ++ # ruby 2.0+ ++ # TODO: ipv6 support here? ++ Addrinfo.getaddrinfo(@backend.host, @backend.port, :PF_INET, :STREAM).first.ip_address.split('.').map(&:to_i) ++ else ++ Socket.gethostbyname(@backend.host)[3].unpack('CCCC') ++ end ++ rescue ++ [0, 0, 0, 0] ++ end + end + end + end +\ No newline at end of file +--- a/lib/thin/daemonizing.rb ++++ b/lib/thin/daemonizing.rb +@@ -78,7 +78,7 @@ def change_privilege(user, group=user) + + if uid != target_uid || gid != target_gid + # Change PID file ownership +- File.chown(target_uid, target_gid, @pid_file) if File.exists?(@pid_file) ++ File.chown(target_uid, target_gid, @pid_file) if File.exist?(@pid_file) + + # Change process ownership + Process.initgroups(user, target_gid) +@@ -174,7 +174,7 @@ def read_pid_file(file) + + protected + def remove_pid_file +- File.delete(@pid_file) if @pid_file && File.exists?(@pid_file) ++ File.delete(@pid_file) if @pid_file && File.exist?(@pid_file) + end + + def write_pid_file +--- a/spec/connection_spec.rb ++++ b/spec/connection_spec.rb +@@ -37,7 +37,7 @@ + end + + it "should process at most once when request is larger than expected" do +- @connection.should_receive(:process).at_most(1) ++ expect(@connection).to receive(:process).at_most(1) + @connection.receive_data("POST / HTTP/1.1\r\nHost: localhost:3000\r\nContent-Length: 300\r\n\r\n") + 10.times { @connection.receive_data('X' * 1_000) } + end +--- a/spec/rails_app/config/boot.rb ++++ b/spec/rails_app/config/boot.rb +@@ -26,7 +26,7 @@ def vendor_rails? + + # FIXME : Ruby 1.9 + def preinitialize +- load(preinitializer_path) if File.exists?(preinitializer_path) ++ load(preinitializer_path) if File.exist?(preinitializer_path) + end + + def preinitializer_path +--- a/spec/request/parser_spec.rb ++++ b/spec/request/parser_spec.rb +@@ -210,7 +210,7 @@ + end + + it "should fail when total request vastly exceeds specified CONTENT_LENGTH" do +- proc do ++ expect do + R(<<-EOS, true) + POST / HTTP/1.1 + Host: localhost:3000 +@@ -218,7 +218,7 @@ + + #{'X' * 300_000} + EOS +- end.should raise_error(InvalidRequest) ++ end.to raise_error(InvalidRequest) + end + + it "should default SERVER_NAME to localhost" do + diff --git a/www-servers/thin/thin-1.8.1-r3.ebuild b/www-servers/thin/thin-1.8.1-r3.ebuild new file mode 100644 index 000000000000..9f3dce90094e --- /dev/null +++ b/www-servers/thin/thin-1.8.1-r3.ebuild @@ -0,0 +1,99 @@ +# Copyright 1999-2023 Gentoo Authors +# Distributed under the terms of the GNU General Public License v2 + +EAPI=8 + +USE_RUBY="ruby27 ruby30 ruby31 ruby32" + +RUBY_FAKEGEM_RECIPE_TEST="rspec3" +RUBY_FAKEGEM_GEMSPEC="${PN}.gemspec" + +inherit ruby-fakegem + +DESCRIPTION="A fast and very simple Ruby web server" +HOMEPAGE="http://code.macournoyer.com/thin/" +SRC_URI="https://github.com/macournoyer/thin/archive/v${PV}.tar.gz -> ${P}.tar.gz" + +LICENSE="Ruby" +SLOT="0" +KEYWORDS="~amd64 ~ppc64 ~x86" +IUSE="doc test" + +DEPEND="${DEPEND} + dev-util/ragel" +RDEPEND="${RDEPEND}" + +# The runtime dependencies are used at build-time as well since the +# Rakefile loads thin! +mydeps=">=dev-ruby/daemons-1.0.9 + >=dev-ruby/rack-1.0.0:* <dev-ruby/rack-3:* + >=dev-ruby/eventmachine-1.0.4:0 + virtual/ruby-ssl" + +ruby_add_rdepend "${mydeps}" +ruby_add_bdepend "${mydeps} + dev-ruby/rake-compiler" + +PATCHES=( + "${FILESDIR}"/${P}-ruby32.patch +) + +all_ruby_prepare() { + # Fix Ragel-based parser generation (uses a *very* old syntax that + # is not supported in Gentoo) + sed -i -e 's: | rlgen-cd::' Rakefile || die + + # Fix specs' dependencies so that the extension is not rebuilt + # when running tests + rm tasks/spec.rake || die + + # Fix rspec version to allow newer 2.x versions + sed -i -e '/gem "rspec"/ s/1.2.9/3.0/ ; 2igem "rack", "<3"' spec/spec_helper.rb || die + + # Avoid CLEAN since it may not be available and we don't need it. + sed -i -e '/CLEAN/ s:^:#:' tasks/*.rake || die + + # Disable a test that is known for freezing the testsuite, + # reported upstream. In thin 1.5.1 this just fails. + sed -i \ + -e '/should force kill process in pid file/,/^ end/ s:^:#:' \ + spec/daemonizing_spec.rb || die + + sed -i \ + -e '/tracing routines (with NO custom logger)/,/^ end/ s:^:#:'\ + spec/logging_spec.rb || die + + find spec/perf -name "*_spec.rb" -exec \ + sed -i '/be_faster_then/ i \ skip' {} \; + + sed -i -e "s/Spec::Runner/Rspec/" spec/spec_helper.rb || die + # nasty but too complex to fix up for now :( + use doc || rm tasks/rdoc.rake +} + +each_ruby_compile() { + ${RUBY} -S rake compile || die "rake compile failed" +} + +all_ruby_install() { + all_fakegem_install + + keepdir /etc/thin + newinitd "${FILESDIR}"/${PN}.initd-r4 ${PN} + newconfd "${FILESDIR}"/${PN}.confd-2 ${PN} + + einfo + elog "Thin is now shipped with init scripts." + elog "The default script (/etc/init.d/thin) will start all servers that have" + elog "configuration files in /etc/thin/. You can symlink the init script to" + elog "files of the format 'thin.SERVER' to be able to start individual servers." + elog "See /etc/conf.d/thin for more configuration options." + einfo +} + +each_ruby_install() { + each_fakegem_install + + # Ensure that newer rubygems version see the extention as installed + ruby_fakegem_extensions_installed +} |