Skip to content

Commit

Permalink
Merge pull request #12319 from hennevogel/bugfix/interpreter-rewriting
Browse files Browse the repository at this point in the history
shebang replacement was too greedy
  • Loading branch information
hennevogel committed Mar 16, 2022
2 parents 77f36d9 + 6c89672 commit 3747428
Showing 1 changed file with 7 additions and 12 deletions.
19 changes: 7 additions & 12 deletions dist/obs-bundled-gems.spec
Expand Up @@ -147,28 +147,23 @@ rm -rf %{buildroot}%_libdir/obs-api/ruby/*/gems/selenium-webdriver-*/lib/seleniu
# remove all gitignore files to fix rpmlint version-control-internal-file
find %{buildroot}%_libdir/obs-api -name .gitignore | xargs rm -rf

# use the ruby interpreter set by this spec file in all installed binaries.
# use the ruby interpreter set by this spec file in all installed ruby scripts
for bin in %{buildroot}%_libdir/obs-api/ruby/*/bin/*; do
sed -i -e 's,/usr/bin/env ruby.ruby3.1,%{__obs_ruby_interpreter},' $bin
sed -i -e 's,/usr/bin/env ruby,%{__obs_ruby_interpreter},' $bin
sed -i -e 's,/usr/bin/ruby,%{__obs_ruby_interpreter},' $bin
%{__obs_ruby_interpreter} -r rubygems -p -i -e \
'$_.gsub!(/\A#!.*ruby.*$/, "#!#{Gem.ruby}")' \
$(grep '#!.*ruby' -rl .)
done
for bin in %{buildroot}%_libdir/obs-api/ruby/*/gems/*/bin/*; do
sed -i -e 's,/usr/bin/env ruby.ruby3.1,%{__obs_ruby_interpreter},' $bin
sed -i -e 's,/usr/bin/env ruby,%{__obs_ruby_interpreter},' $bin
sed -i -e 's,/usr/bin/ruby,%{__obs_ruby_interpreter},' $bin
%{__obs_ruby_interpreter} -r rubygems -p -i -e \
'$_.gsub!(/\A#!.*ruby.*$/, "#!#{Gem.ruby}")' \
$(grep '#!.*ruby' -rl .)
done

# remove exec bit from all other files still containing /usr/bin/env - mostly helper scripts
find %{buildroot} -type f -print0 | xargs -0 grep -l /usr/bin/env | while read file; do
chmod a-x $file
done

# remove exec bit from all other files still containing /usr/bin/ruby
find %{buildroot} -type f -print0 | xargs -0 grep -l /usr/bin/ruby | while read file; do
chmod a-x $file
done

# remove the rpath entry from the shared lib in the mysql2 rubygem
chrpath -d %{buildroot}%_libdir/obs-api/ruby/*/extensions/*/*/mysql2-*/mysql2/mysql2.so || true
chrpath -d %{buildroot}%_libdir/obs-api/ruby/*/gems/mysql2-*/lib/mysql2/mysql2.so || true
Expand Down

0 comments on commit 3747428

Please sign in to comment.