Skip to content

Commit e13cab6

Browse files
authored
Deal with frozen string literals (#2620)
In future Ruby is going to encourage frozen string literals
1 parent 0b8f703 commit e13cab6

30 files changed

+176
-185
lines changed

.github/workflows/main.yml

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ jobs:
5555
cp test/config.json.github-ci-linux test/config.json
5656
5757
- name: Build C++ tests
58-
run: bundle exec drake -j4 test:cxx:build
58+
run: bundle exec rake -m -j4 test:cxx:build
5959
timeout-minutes: 5
6060

6161
- name: Run C++ tests
@@ -134,7 +134,7 @@ jobs:
134134
cp test/config.json.github-ci-linux test/config.json
135135
136136
- name: Build C++ tests
137-
run: bundle exec drake -j4 test:cxx:build
137+
run: bundle exec rake -m -j4 test:cxx:build
138138
timeout-minutes: 5
139139

140140
- name: Run C++ tests
@@ -240,7 +240,7 @@ jobs:
240240
sed "s|_USER_|$(whoami)|" test/config.json.github-ci-macos > test/config.json
241241
242242
- name: Build C++ tests
243-
run: bundle exec drake -j4 test:cxx:build
243+
run: bundle exec rake -m -j4 test:cxx:build
244244
timeout-minutes: 5
245245

246246
- name: Run C++ tests
@@ -397,7 +397,7 @@ jobs:
397397
SCCACHE_AZURE_CONNECTION_STRING: ${{ secrets.AZURE_CI_STORAGE_CONNECTION_STRING }}
398398

399399
- name: Test module installation as normal user
400-
run: ./bin/passenger-install-apache2-module --auto --force-colors --rake-command 'bundle exec drake -j4'
400+
run: ./bin/passenger-install-apache2-module --auto --force-colors --rake-command 'bundle exec rake -m -j4'
401401
timeout-minutes: 5
402402

403403
- name: Teardown sccache
@@ -517,7 +517,7 @@ jobs:
517517
--force-colors
518518
--prefix=/tmp/nginx
519519
--auto-download
520-
--rake-command 'bundle exec drake -j4'
520+
--rake-command 'bundle exec rake -m -j4'
521521
--make-concurrency 4
522522
timeout-minutes: 5
523523

@@ -596,7 +596,7 @@ jobs:
596596
echo "NGINX_ADDON_DIR=$NGINX_ADDON_DIR" >> "$GITHUB_ENV"
597597
598598
- name: Compile module
599-
run: bundle exec drake -j4 nginx:as_dynamic_module
599+
run: bundle exec rake -m -j4 nginx:as_dynamic_module
600600
timeout-minutes: 5
601601

602602
- name: Download Nginx source
@@ -674,11 +674,11 @@ jobs:
674674
timeout-minutes: 2
675675

676676
- name: Compile prerequisites
677-
run: bundle exec drake -j4 nginx
677+
run: bundle exec rake -m -j4 nginx
678678
timeout-minutes: 5
679679

680680
- name: Integration test
681-
run: bundle exec drake -j4 test:integration:standalone
681+
run: bundle exec rake -m -j4 test:integration:standalone
682682
timeout-minutes: 8
683683

684684
- name: Teardown sccache
@@ -745,7 +745,7 @@ jobs:
745745
timeout-minutes: 2
746746

747747
- name: Compile
748-
run: bundle exec drake -j4 agent
748+
run: bundle exec rake -m -j4 agent
749749
timeout-minutes: 5
750750

751751
- name: Test
@@ -821,8 +821,8 @@ jobs:
821821
- name: Check whether formula is up-to-date
822822
run: >
823823
./packaging/homebrew/verify-oss-formula-uptodate
824-
-c homebrew-core.git
825-
-r upstream
824+
-c /opt/homebrew/Library/Taps/homebrew/homebrew-core
825+
-r origin
826826
timeout-minutes: 5
827827

828828
- name: Modify formula
@@ -840,7 +840,7 @@ jobs:
840840
-p .
841841
-f pkg/passenger.rb
842842
-t pkg/*.tar.gz
843-
timeout-minutes: 6
843+
timeout-minutes: 7
844844

845845
source_packaging:
846846
name: Source packaging tests

CHANGELOG

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
Release 6.1.1 (Not yet released)
22
-------------
3+
* [Ruby] Improve support for Ruby 4 and Frozen String Literals. Closes GH-2619.
34
* [Ubuntu] Add packages for Ubuntu 25.10 "questing", remove packages for Ubuntu 25.04 "plucky".
45
* Upgrade Boost from 1.87 -> 1.89.
56
* [Nginx] Upgrades preferred Nginx to 1.28.0 from 1.26.3.

Gemfile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,10 @@ ruby '>= 2.5'
88
gemspec
99

1010
group :development do
11+
gem 'cgi'
12+
gem 'logger'
1113
gem 'json'
1214
gem 'mime-types', '~> 3.5.1'
13-
gem 'drake'
1415
gem 'rspec', '~> 3.12.0'
1516
gem 'rspec-collection_matchers'
1617
gem 'webrick', '~> 1.8.1'

Gemfile.lock

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -9,21 +9,20 @@ PATH
99
GEM
1010
remote: https://rubygems.org/
1111
specs:
12-
comp_tree (1.1.3)
13-
diff-lcs (1.5.1)
14-
drake (0.9.2.0.3.1)
15-
comp_tree (>= 1.1.3)
16-
gpgme (2.0.24)
12+
cgi (0.5.1)
13+
diff-lcs (1.6.2)
14+
gpgme (2.0.25)
1715
mini_portile2 (~> 2.7)
18-
json (2.7.2)
16+
json (2.18.0)
17+
logger (1.7.0)
1918
mime-types (3.5.2)
2019
mime-types-data (~> 3.2015)
21-
mime-types-data (3.2024.1001)
20+
mime-types-data (3.2025.0924)
2221
mini_portile2 (2.8.9)
23-
rack (3.1.8)
24-
rackup (2.2.1)
22+
rack (3.2.4)
23+
rackup (2.3.1)
2524
rack (>= 3)
26-
rake (13.2.1)
25+
rake (13.3.1)
2726
rspec (3.12.0)
2827
rspec-core (~> 3.12.0)
2928
rspec-expectations (~> 3.12.0)
@@ -47,9 +46,10 @@ PLATFORMS
4746
x86_64-linux
4847

4948
DEPENDENCIES
50-
drake
49+
cgi
5150
gpgme
5251
json
52+
logger
5353
mime-types (~> 3.5.1)
5454
passenger!
5555
rspec (~> 3.12.0)

bin/passenger-install-apache2-module

Lines changed: 15 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -421,7 +421,7 @@ private
421421
# Running apache2:clean deletes some object files needed
422422
# by passenger-install-nginx-module, so we ensure those
423423
# object files are compiled.
424-
command << " nginx"
424+
command += " nginx"
425425
end
426426
return sh(command)
427427
else
@@ -435,14 +435,14 @@ private
435435
end
436436

437437
def config_snippet
438-
result = "<IfModule mod_passenger.c>\n" +
439-
" PassengerRoot #{PhusionPassenger.install_spec}\n" +
440-
" PassengerDefaultRuby #{PlatformInfo.ruby_command}\n"
438+
result = ["<IfModule mod_passenger.c>",
439+
" PassengerRoot #{PhusionPassenger.install_spec}",
440+
" PassengerDefaultRuby #{PlatformInfo.ruby_command}"]
441441
if PhusionPassenger.packaging_method == "rpm"
442-
result << " PassengerInstanceRegistryDir /var/run/passenger-instreg\n"
442+
result << " PassengerInstanceRegistryDir /var/run/passenger-instreg"
443443
end
444444
result << "</IfModule>"
445-
result
445+
result.join("\n")
446446
end
447447

448448
def apache2_config_snippets
@@ -574,18 +574,14 @@ private
574574
end
575575

576576
def remove_duplicate_comment_blocks(filename, begin_marker, end_marker)
577-
contents = File.open(filename, "rb") do |f|
578-
f.read
579-
end
577+
contents = File.binread(filename)
580578
regexp = /#{Regexp.escape begin_marker}.*?#{Regexp.escape end_marker}\n?/m
581579
if m = regexp.match(contents)
582580
offset = m.end(0)
583-
rest = contents.slice!(m.end(0) .. -1)
581+
rest = contents.slice!(offset .. -1)
584582
rest.gsub!(regexp, '')
585583
contents << rest
586-
File.open(filename, "wb") do |f|
587-
f.write(contents)
588-
end
584+
File.binwrite(filename, contents)
589585
end
590586
end
591587

@@ -916,9 +912,9 @@ parser = OptionParser.new do |opts|
916912

917913
indent = ' ' * 37
918914
opts.separator "Options:"
919-
opts.on("-a", "--auto", String, "Automatically build the Apache module,\n" <<
920-
"#{indent}without interactively asking for user\n" <<
921-
"#{indent}input.") do
915+
opts.on("-a", "--auto", String, ["Automatically build the Apache module,",
916+
"#{indent}without interactively asking for user",
917+
"#{indent}input."].join("\n")) do
922918
options[:auto] = true
923919
end
924920
opts.on("--apxs2-path PATH", String, "Path to 'apxs2' command.") do |value|
@@ -927,9 +923,9 @@ parser = OptionParser.new do |opts|
927923
opts.on("--apr-config-path PATH", String, "Path to 'apr-config' command.") do |value|
928924
ENV['APR_CONFIG'] = value
929925
end
930-
opts.on("--languages NAMES", "Comma-separated list of interested\n" <<
931-
"#{indent}languages (e.g.\n" <<
932-
"#{indent}'ruby,python,nodejs,meteor')") do |value|
926+
opts.on("--languages NAMES", ["Comma-separated list of interested",
927+
"#{indent}languages (e.g.",
928+
"#{indent}'ruby,python,nodejs,meteor')"].join("\n")) do |value|
933929
options[:languages] = value.split(",")
934930
end
935931
opts.on("--no-compile", "Skip compilation.") do

bin/passenger-install-nginx-module

Lines changed: 42 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -525,10 +525,7 @@ private
525525
def insert_passenger_config_snippets(prefix)
526526
config_file = locate_nginx_config_file(prefix)
527527
contents = File.read(config_file)
528-
contents.sub!(/^http \{/,
529-
"http {\n" <<
530-
" passenger_root #{PhusionPassenger.install_spec};\n" <<
531-
" passenger_ruby #{PlatformInfo.ruby_command};\n")
528+
contents.sub!(/^http \{/, "http {\n passenger_root #{PhusionPassenger.install_spec};\n passenger_ruby #{PlatformInfo.ruby_command};\n")
532529
File.open(config_file, 'w') do |f|
533530
f.write(contents)
534531
end
@@ -556,20 +553,20 @@ private
556553
].compact.join(" ").strip
557554

558555
command = "sh ./configure --prefix='#{prefix}' "
559-
command << "--with-http_ssl_module "
560-
command << "--with-http_v2_module "
561-
command << "--with-http_realip_module "
562-
command << "--with-http_gzip_static_module "
563-
command << "--with-http_stub_status_module "
564-
command << "--with-http_addition_module "
565-
command << "--with-cc-opt=#{Shellwords.escape extra_cflags} "
566-
command << "--with-ld-opt=#{Shellwords.escape extra_ldflags} "
556+
command += "--with-http_ssl_module "
557+
command += "--with-http_v2_module "
558+
command += "--with-http_realip_module "
559+
command += "--with-http_gzip_static_module "
560+
command += "--with-http_stub_status_module "
561+
command += "--with-http_addition_module "
562+
command += "--with-cc-opt=#{Shellwords.escape extra_cflags} "
563+
command += "--with-ld-opt=#{Shellwords.escape extra_ldflags} "
567564
if @pcre_source_dir
568-
command << "--with-pcre='#{@pcre_source_dir}' "
565+
command += "--with-pcre='#{@pcre_source_dir}' "
569566
elsif !pcre_is_installed?
570-
command << "--without-http_rewrite_module "
567+
command += "--without-http_rewrite_module "
571568
end
572-
command << "--add-module='#{PhusionPassenger.nginx_module_source_dir}' #{extra_configure_flags}"
569+
command += "--add-module='#{PhusionPassenger.nginx_module_source_dir}' #{extra_configure_flags}"
573570
command.strip!
574571
return command
575572
end
@@ -583,11 +580,15 @@ private
583580
end
584581
Dir.chdir("#{safe_tmpdir}") do
585582
# Nginx checks for PCRE in multiple places...
586-
system("(gcc -I/usr/local/include -I/usr/include/pcre2 " <<
587-
"-I/usr/pkg/include -I/opt/local/include " <<
588-
"-I/opt/homebrew/include " <<
589-
"-DPCRE2_CODE_UNIT_WIDTH=8 " <<
590-
"-c passenger-check.c) >/dev/null 2>/dev/null")
583+
system(["gcc",
584+
"-I/usr/local/include",
585+
"-I/usr/include/pcre2",
586+
"-I/usr/pkg/include",
587+
"-I/opt/local/include",
588+
"-I/opt/homebrew/include",
589+
"-DPCRE2_CODE_UNIT_WIDTH=8",
590+
"-c", "passenger-check.c",
591+
">/dev/null", "2>/dev/null"].join(' '))
591592
end
592593
ensure
593594
File.unlink("#{safe_tmpdir}/passenger-check.c") rescue nil
@@ -602,8 +603,7 @@ private
602603
# We do this instead of using #file, for Ruby 1.8.5 support.
603604
digest = Digest::SHA256.new
604605
File.open(path, "rb") do |f|
605-
buf = ''
606-
buf.force_encoding('binary') if buf.respond_to?(:force_encoding)
606+
buf = String.new(encoding: Encoding::BINARY)
607607
while !f.eof?
608608
f.read(1024 * 16, buf)
609609
digest.update(buf)
@@ -625,33 +625,31 @@ parser = OptionParser.new do |opts|
625625

626626
indent = ' ' * 37
627627
opts.separator "Options:"
628-
opts.on("--auto", "Automatically confirm 'Press ENTER to\n" <<
629-
"#{indent}continue' prompts.") do
628+
opts.on("--auto", "Automatically confirm 'Press ENTER to\n#{indent}continue' prompts.") do
630629
options[:auto] = true
631630
end
632-
opts.on("--prefix=DIR", String, "Use the given Nginx install prefix instead\n" <<
633-
"#{indent}of asking for it interactively.") do |dir|
631+
opts.on("--prefix=DIR", String, "Use the given Nginx install prefix instead\n#{indent}of asking for it interactively.") do |dir|
634632
options[:prefix] = dir
635633
end
636-
opts.on("--auto-download", "Download and install Nginx automatically,\n" <<
637-
"#{indent}instead of asking interactively whether to\n" <<
638-
"#{indent}download+install or to use an existing\n" <<
639-
"#{indent}Nginx source directory.") do
634+
opts.on("--auto-download", ["Download and install Nginx automatically,",
635+
"#{indent}instead of asking interactively whether to",
636+
"#{indent}download+install or to use an existing",
637+
"#{indent}Nginx source directory."].join("\n")) do
640638
options[:auto_download] = true
641639
end
642-
opts.on("--nginx-source-dir=DIR", String, "Compile and install Nginx using the given\n" <<
643-
"#{indent}Nginx source directory, instead of\n" <<
644-
"#{indent}interactively asking to download+install\n" <<
645-
"#{indent}or to use an existing Nginx source\n" <<
646-
"#{indent}directory. Conflicts with --auto-download.") do |dir|
640+
opts.on("--nginx-source-dir=DIR", String, ["Compile and install Nginx using the given",
641+
"#{indent}Nginx source directory, instead of",
642+
"#{indent}interactively asking to download+install",
643+
"#{indent}or to use an existing Nginx source",
644+
"#{indent}directory. Conflicts with --auto-download."].join("\n")) do |dir|
647645
options[:nginx_source_dir] = dir
648646
end
649-
opts.on("--extra-configure-flags=STRING", String, "Pass these extra flags to Nginx's\n" <<
650-
"#{indent}'configure' script, instead of asking for\n" <<
651-
"#{indent}it interactively. Specify 'none' if you\n" <<
652-
"#{indent}do not want to pass additional flags but do\n" <<
653-
"#{indent}not want this installer to ask\n" <<
654-
"#{indent}interactively either.") do |flags|
647+
opts.on("--extra-configure-flags=STRING", String, ["Pass these extra flags to Nginx's",
648+
"#{indent}'configure' script, instead of asking for",
649+
"#{indent}it interactively. Specify 'none' if you",
650+
"#{indent}do not want to pass additional flags but do",
651+
"#{indent}not want this installer to ask",
652+
"#{indent}interactively either."].join("\n")) do |flags|
655653
options[:extra_configure_flags] = flags
656654
end
657655
opts.on("--rake-command COMMAND", String, "Customize Rake command to use") do |value|
@@ -660,9 +658,9 @@ parser = OptionParser.new do |opts|
660658
opts.on("--make-concurrency N", Integer, "Use N parallel jobs when running 'make'.") do |n|
661659
options[:make_concurrency] = n
662660
end
663-
opts.on("--languages NAMES", "Comma-separated list of interested\n" <<
664-
"#{indent}languages (e.g.\n" <<
665-
"#{indent}'ruby,python,nodejs,meteor')") do |value|
661+
opts.on("--languages NAMES", ["Comma-separated list of interested",
662+
"#{indent}languages (e.g.",
663+
"#{indent}'ruby,python,nodejs,meteor')"].join("\n")) do |value|
666664
options[:languages] = value.split(",")
667665
end
668666
opts.on("--force-colors", "Display colors even if stdout is not a TTY") do

0 commit comments

Comments
 (0)