Created
December 1, 2021 20:20
-
-
Save pauldruziak/1845f1c5ae39be8f7e9e128d2392dc17 to your computer and use it in GitHub Desktop.
./gem-install-libv8-darwin-21.sh 7.3.492.27.1
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# filename: gem-install-libv8-darwin-20.sh | |
set -e | |
set -u | |
set -o pipefail | |
libv8_version="${1:-"8.4.255.0"}" | |
from='19' | |
to='21' | |
gem_home="$(ruby -e 'puts Gem.dir')" | |
ruby_platform="$(ruby -e 'puts Gem.platforms.select { |p| Gem::Platform === p && p.os =~ /darwin/ }')" | |
ruby_platform_prefix="${ruby_platform%-*}" | |
# case "${ruby_platform}" in | |
# *universal*) | |
# ruby_platform_prefix="x86_64-darwin" | |
# ;; | |
# esac | |
ruby_platform_from="${ruby_platform_prefix}-${from}" | |
ruby_platform_to="${ruby_platform_prefix}-${to}" | |
echo " *** detecting" | |
echo "${gem_home}" | |
echo "${ruby_platform}" | |
echo "${ruby_platform_prefix}" | |
echo "libv8 ${libv8_version}: ${ruby_platform_from} => ${ruby_platform_to}" | |
echo " *** downloading" | |
test -f "/tmp/libv8-${libv8_version}-${ruby_platform_from}.gem" \ | |
|| curl --fail --output "/tmp/libv8-${libv8_version}-${ruby_platform_from}.gem" "https://rubygems.org/downloads/libv8-${libv8_version}-${ruby_platform_from}.gem" \ | |
|| curl --fail --output "/tmp/libv8-${libv8_version}-${ruby_platform_from}.gem" "https://rubygems.org/downloads/libv8-${libv8_version}-${ruby_platform_prefix}${from}.gem" | |
echo " *** cleaning" | |
rm -rfv "${gem_home}/specifications/libv8-${libv8_version}-"{"${ruby_platform_from}","${ruby_platform_to}"}".gemspec" | |
rm -rfv "${gem_home}/doc/libv8-${libv8_version}-"{"${ruby_platform_from}","${ruby_platform_to}"} | |
rm -rfv "${gem_home}/gems/libv8-${libv8_version}-"{"${ruby_platform_from}","${ruby_platform_to}"} | |
rm -rfv "${gem_home}/cache/libv8-${libv8_version}-"{"${ruby_platform_from}","${ruby_platform_to}"}".gem" | |
echo " *** installing" | |
gem install "/tmp/libv8-${libv8_version}-${ruby_platform_from}.gem" -- --with-system-v8 | |
echo " *** patching" | |
mv -v "${gem_home}/specifications/libv8-${libv8_version}-"{"${ruby_platform_from}","${ruby_platform_to}"}".gemspec" | |
mv -v "${gem_home}/doc/libv8-${libv8_version}-"{"${ruby_platform_from}","${ruby_platform_to}"} | |
mv -v "${gem_home}/gems/libv8-${libv8_version}-"{"${ruby_platform_from}","${ruby_platform_to}"} | |
mv -v "${gem_home}/cache/libv8-${libv8_version}-"{"${ruby_platform_from}","${ruby_platform_to}"}".gem" | |
sed -i~ \ | |
-e "s/${ruby_platform_prefix}-${from}/${ruby_platform_to}/" \ | |
-e "s/${ruby_platform_prefix}${from}/${ruby_platform_to}/" \ | |
"${gem_home}/specifications/libv8-${libv8_version}-${ruby_platform_to}.gemspec" | |
rm "${gem_home}/specifications/libv8-${libv8_version}-${ruby_platform_to}.gemspec~" | |
echo " *** result" | |
find "${gem_home}"/*/"libv8-${libv8_version}-${ruby_platform_to}" | |
grep --text "${ruby_platform_to}" "${gem_home}/specifications/libv8-${libv8_version}-${ruby_platform_to}.gemspec" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment