@@ -70,15 +70,8 @@ RUN true "${REPRO_RUN_KEY}" && yum makecache -y
7070# fun: CentOS 8 has `yum list glibc-langpack-\*` but not CentOS 7 :'(
7171RUN yum reinstall -y glibc-common
7272
73- RUN yum install -y curl gcc gcc-c++ gettext make patchutils patch libtool pkgconfig gettext file zip unzip git
74-
75- # fun: this has to be after `yum install curl gcc make`... but only on aarch64; go figure
76- # extra fun: table is botched, localedef not happy, swallow result and test `locale` for errors
77- RUN <<SHELL
78- localedef -v -c -i en_US -f UTF-8 en_US.UTF-8 || true
79- if locale 2>&1 | grep -e 'locale: Cannot set LC_.* to default locale: No such file or directory'; then exit 1; fi
80- SHELL
81-
73+ # Install runtime packages only (no compiler or build tools)
74+ RUN yum install -y curl gettext file zip unzip git
8275# Skip installing gem documentation
8376COPY <<GEMRC /usr/local/etc/gemrc
8477install: --no-document
@@ -96,7 +89,24 @@ ENV LANG="en_US.UTF-8"
9689RUN <<SHELL
9790set -eux
9891
99- yum install -y xz gcc automake bison zlib-devel libyaml-devel openssl-devel gdbm-devel readline-devel ncurses-devel libffi-devel
92+ # --- Install compiler and build dependencies ---
93+ # Install runtime libraries that Ruby links against; these must be present
94+ # BEFORE the checkpoint so they survive the rollback.
95+ yum install -y zlib libyaml gdbm readline ncurses-libs libffi openssl-libs
96+
97+ # Record checkpoint: everything after this transaction will be rolled back.
98+ yum_checkpoint=$(yum history list all 2>/dev/null | awk '$1 ~ /^[0-9]+$/ {print $1; exit}')
99+
100+ yum install -y \
101+ gcc gcc-c++ make patchutils patch libtool pkgconfig xz automake autoconf bison \
102+ zlib-devel libyaml-devel openssl-devel gdbm-devel readline-devel ncurses-devel libffi-devel
103+
104+ # fun: locale setup has to be after installing gcc/make... but only on aarch64; go figure
105+ # extra fun: table is botched, localedef not happy, swallow result and test 'locale' for errors
106+ localedef -v -c -i en_US -f UTF-8 en_US.UTF-8 || true
107+ if locale 2>&1 | grep -e 'locale: Cannot set LC_.* to default locale: No such file or directory'; then exit 1; fi
108+
109+ # --- Build Ruby ---
100110
101111curl -L -o ruby.tar.gz "https://github.com/ruby/ruby/archive/f48ae0d10c5b586db5748b0d4b645c7e9ff5d52e.tar.gz"
102112echo "$RUBY_DOWNLOAD_SHA256 *ruby.tar.gz" | sha256sum --check --strict
@@ -158,32 +168,6 @@ gnuArch="$(uname -m)-linux-gnu"
158168make
159169make install
160170
161- # find /usr/local -type f -executable -not \( -name '*tkinter*' \) -exec ldd '{}' ';' \
162- # | awk '/=>/ { print $(NF-1) }' \
163- # | sort -u \
164- # | grep -vE '^/usr/local/lib/' \
165- # | xargs -r dpkg-query --search \
166- # | cut -d: -f1 \
167- # | sort -u \
168- # | xargs -r apt-mark manual \
169- #
170- # apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false; \
171- #
172- # find /usr/local -type f -executable -not \( -name '*tkinter*' \) -exec ldd '{}' ';' \
173- # | awk '/=>/ { print $(NF-1) }' \
174- # | grep -v '=>' \
175- # | sort -u \
176- # | grep -vE '^/usr/local/lib/' \
177- # | xargs -r rpm -qf \
178- # | sort -u \
179- # | xargs -r yum ?mark-manual?
180- #
181- # yum autoremove -y
182- # yum remove --setopt=clean_requirements_on_remove=1
183- # package-cleanup --leaves && yum autoremove # yum-utils
184- # sudo yum history list pdftk
185- # sudo yum history undo 88
186-
187171cd /
188172rm -r /usr/src/ruby
189173if yum list installed ruby; then exit 1; fi
@@ -239,6 +223,14 @@ ruby --version
239223gem --version
240224bundle --version
241225
226+ # --- Clean up compiler and build dependencies ---
227+ # Roll back to the checkpoint: removes compilers, build tools, and -devel
228+ # packages while preserving the runtime libraries installed before
229+ # the checkpoint.
230+ yum -y history rollback "${yum_checkpoint}"
231+ yum clean all
232+
233+
242234SHELL
243235
244236# don't create ".bundle" in all our apps
0 commit comments