Skip to content

Commit

Permalink
feat(ruby)!: drop gem-install support and redirect .gem
Browse files Browse the repository at this point in the history
  • Loading branch information
viceice committed Jul 4, 2024
1 parent eb4a893 commit 11577c9
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 43 deletions.
39 changes: 28 additions & 11 deletions src/usr/local/containerbase/tools/v2/ruby.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
function prepare_tool() {
local version_codename
local tool_path
local cp_home
local path

version_codename="$(get_distro)"
case "${version_codename}" in
Expand All @@ -23,18 +23,35 @@ function prepare_tool() {
;
tool_path=$(create_tool_path)

# Redirect gemrc
path="$(get_home_path)/.gemrc"
{
printf -- "gem: --bindir %s/bin --no-document\n" "${USER_HOME}"
} > "${USER_HOME}"/.gemrc
chown -R "${USER_ID}" "${USER_HOME}"/.gemrc
chmod -R g+w "${USER_HOME}"/.gemrc
printf -- "gem: --no-document\n"
} > "${path}"
chown "${USER_ID}" "${path}"
chmod g+w "${path}"
ln -sf "${path}" "${USER_HOME}/.gemrc"

# Redirect gem home
path="$(get_home_path)/.gem"
create_folder "${path}" 775
chown "${USER_ID}" "${path}"
chmod g+w "${path}"
ln -sf "${path}" "${USER_HOME}/.gem"

# Redirect cocoapods home
cp_home="$(get_home_path)/.cocoapods"
create_folder "${cp_home}" 775
chown "${USER_ID}" "${cp_home}"
chmod g+w "${cp_home}"
ln -sf "${cp_home}" "${USER_HOME}/.cocoapods"
path="$(get_home_path)/.cocoapods"
create_folder "${path}" 775
chown "${USER_ID}" "${path}"
chmod g+w "${path}"
ln -sf "${path}" "${USER_HOME}/.cocoapods"

# Redirect Library home
path="$(get_home_path)/Library"
create_folder "${path}" 775
chown "${USER_ID}" "${path}"
chmod g+w "${path}"
ln -sf "${path}" "${USER_HOME}/Library"

# Workaround for compatibillity for Ruby hardcoded paths
if [ "${tool_path}" != "${ROOT_DIR_LEGACY}/ruby" ]; then
Expand Down Expand Up @@ -76,7 +93,7 @@ function install_tool () {
# System settings
mkdir -p "$versioned_tool_path/etc"
{
printf -- "gem: --bindir /usr/local/bin --no-document\n"
printf -- "gem: --no-document\n"
printf -- ":benchmark: false\n"
printf -- ":verbose: true\n"
printf -- ":update_sources: true\n"
Expand Down
44 changes: 12 additions & 32 deletions test/ruby/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -34,36 +34,6 @@ FROM base AS build
# renovate: datasource=github-releases packageName=containerbase/ruby-prebuild
RUN install-tool ruby 3.3.3

#--------------------------------------
# test: bundler (gem)
#--------------------------------------
FROM build AS test-bundler-a

ENV PATH=/home/ubuntu/bin:$PATH

# fix perms
RUN chown -R 1005:0 /test

# openshift
USER 1005

RUN ruby --version
RUN gem env

# renovate: datasource=rubygems depName=bundler
ENV BUNDLER_VERSION=2.5.14
RUN gem install bundler -v $BUNDLER_VERSION

RUN bundle env

RUN set -ex; \
[ "$(command -v bundle)" = "/home/${USER_NAME}/bin/bundle" ] && echo "works" || exit 1; \
bundler env

RUN set -ex; \
cd a; \
bundler lock

#--------------------------------------
# test: global bundler
#--------------------------------------
Expand All @@ -89,7 +59,6 @@ RUN ruby --version
#--------------------------------------
FROM build AS test-bundler-c


USER 1000

# renovate: datasource=rubygems depName=bundler
Expand All @@ -108,6 +77,11 @@ RUN set -ex; \
cd a; \
bundler lock;

RUN set -ex; \
ls -la $USER_HOME; \
ls -la $USER_HOME/.gem/; \
true

#--------------------------------------
# test: bundler install root - install rootless
#--------------------------------------
Expand Down Expand Up @@ -145,6 +119,13 @@ RUN set -ex; \
cd b/Project; \
pod install;

RUN set -ex; \
ls -la $USER_HOME; \
ls -la $USER_HOME/.gem/; \
ls -la $USER_HOME/.cocoapods/; \
ls -la $USER_HOME/Library/; \
true

#--------------------------------------
# test: install-gem
#--------------------------------------
Expand All @@ -163,7 +144,6 @@ RUN rake --help
#--------------------------------------
FROM base

COPY --from=test-bundler-a /.dummy /.dummy
COPY --from=test-bundler-b /.dummy /.dummy
COPY --from=test-bundler-c /.dummy /.dummy
COPY --from=test-bundler-d /.dummy /.dummy
Expand Down

0 comments on commit 11577c9

Please sign in to comment.