mirror of
https://github.com/chromebrew/chromebrew.git
synced 2026-01-08 15:13:56 -05:00
Gem install fixes. (#13077)
Signed-off-by: Satadru Pramanik <satadru@gmail.com>
This commit is contained in:
committed by
GitHub
parent
e259c5cc9a
commit
c17682e919
35
install.sh
35
install.sh
@@ -441,6 +441,10 @@ function extract_install () {
|
||||
mv ./filelist "${CREW_META_PATH}/${1}.filelist"
|
||||
}
|
||||
|
||||
function get_pkg_version () {
|
||||
grep "\ \ version" "${1}" | head -n 1 | sed "s/#{LIBC_VERSION}/$LIBC_VERSION/g" | sed "s/#{@gcc_libc_version}/$LIBC_VERSION/g" | sed "s/#{CREW_PY_VER}/py$CREW_PY_VER/g"| sed "s/#{CREW_RUBY_VER}/$CREW_RUBY_VER/g"| awk '{print substr($2,2,length($2)-2)}'
|
||||
}
|
||||
|
||||
function update_device_json () {
|
||||
cd "${CREW_CONFIG_PATH}"
|
||||
echo_intra "Adding new information on ${1} ${2} to device.json..."
|
||||
@@ -450,9 +454,28 @@ function update_device_json () {
|
||||
|
||||
function install_ruby_gem () {
|
||||
for gem in "$@"; do
|
||||
ruby_gem="${gem}"
|
||||
if gem search --local -q --no-versions --no-details -e "${gem//_/-}" | grep -q "${gem//_/-}" ;then
|
||||
ruby_gem="${gem//_/-}"
|
||||
else
|
||||
ruby_gem="${gem}"
|
||||
fi
|
||||
echo_intra "Installing ${ruby_gem^} gem..."
|
||||
gem install -N "${ruby_gem}" --conservative
|
||||
gem_file="/usr/local/lib/crew/packages/ruby_${ruby_gem//-/_}.rb"
|
||||
|
||||
curdir=$(pwd)
|
||||
if grep -q gem_compile_needed "${gem_file}"; then
|
||||
cd "$CREW_BREW_DIR"
|
||||
version=$(get_pkg_version "${gem_file}")
|
||||
url="https://gitlab.com/api/v4/projects/26210301/packages/generic/ruby_${gem}/${version}_${ARCH}/ruby_${gem}-${version}-chromeos-${ARCH}.gem"
|
||||
sha256=$(sed -n "s/.*${ARCH}: '\([^']*\)'.*/\1/p" "${gem_file}")
|
||||
gemfile=$(basename "${url}")
|
||||
if download_check "ruby_${gem}" "${url}" "${gemfile}" "${sha256}" '1'; then
|
||||
gem install --no-update-sources -N --local "ruby_${gem}-${version}-chromeos-${ARCH}.gem" --conservative
|
||||
fi
|
||||
else
|
||||
gem install -N "${ruby_gem}" --conservative
|
||||
fi
|
||||
cd "$curdir"
|
||||
gem_version="$(ruby -e "gem('${ruby_gem}')" -e "puts Gem.loaded_specs['${ruby_gem}'].version.to_s")"
|
||||
json_gem_version="${gem_version}-${CREW_RUBY_VER}"
|
||||
crew_gem_package="ruby_${ruby_gem//-/_}"
|
||||
@@ -481,7 +504,7 @@ echo -e "# Generated by install.sh\nLD_LIBRARY_PATH=$LD_LIBRARY_PATH" >> "$CREW_
|
||||
# Extract, install and register packages.
|
||||
for package in $BOOTSTRAP_PACKAGES; do
|
||||
cd "${CREW_LIB_PATH}/packages"
|
||||
version=$(grep "\ \ version" "${package}.rb" | head -n 1 | sed "s/#{LIBC_VERSION}/$LIBC_VERSION/g" | sed "s/#{@gcc_libc_version}/$LIBC_VERSION/g" | sed "s/#{CREW_PY_VER}/py$CREW_PY_VER/g"| awk '{print substr($2,2,length($2)-2)}')
|
||||
version=$(get_pkg_version "${CREW_LIB_PATH}"/packages/"${package}".rb)
|
||||
binary_compression=$(sed -n "s/.*binary_compression '\([^']*\)'.*/\1/p" "${package}.rb")
|
||||
if [[ -z "$binary_compression" ]]; then
|
||||
binary_compression='tar.zst'
|
||||
@@ -512,13 +535,15 @@ ln -sfv "../lib/crew/bin/crew" "${CREW_PREFIX}/bin/"
|
||||
|
||||
echo "export CREW_PREFIX=${CREW_PREFIX}" >> "${CREW_PREFIX}/etc/env.d/profile"
|
||||
|
||||
CREW_RUBY_VER="ruby$(ruby -e 'puts RUBY_VERSION.slice(/(?:.*(?=\.))/)')"
|
||||
echo_info 'Updating RubyGems...'
|
||||
${PREFIX_CMD} gem sources -u
|
||||
${PREFIX_CMD} gem outdated | cut -d " " -f 1 | xargs -I % bash -c 'grep -q no_compile_needed /usr/local/lib/crew/packages/ruby_%.rb && (echo "Updating % gem" ; gem update % --no-update-sources -N) || echo "Not updating % gem, since it needs a gem compile and buildessential has not been installed yet."'
|
||||
# Avoid repl_type_completor, which pulls in the rbs gem, which needs a build.
|
||||
# shellcheck disable=SC2016
|
||||
${PREFIX_CMD} gem outdated | cut -d " " -f 1 | grep -v repl_type_completor | xargs -I % bash -c 'export pkg=% ; grep -q no_compile_needed /usr/local/lib/crew/packages/ruby_${pkg//-/_}.rb && (echo "Updating % gem" ; gem update % --no-update-sources -N) || echo "Not updating % gem, since it needs a gem compile and buildessential has not been installed yet."'
|
||||
|
||||
# Mark packages as installed for pre-installed gems.
|
||||
mapfile -t installed_gems < <(gem list | awk -F ' \(' '{print $1, $2}' | sed -e 's/default://' -e 's/)//' -e 's/,//' | awk '{print $1, $2}')
|
||||
CREW_RUBY_VER="ruby$(ruby -e 'puts RUBY_VERSION.slice(/(?:.*(?=\.))/)')"
|
||||
for i in "${!installed_gems[@]}"
|
||||
do
|
||||
j="${installed_gems[$i]}"
|
||||
|
||||
Reference in New Issue
Block a user