Skip to content

Commit

Permalink
feat(ruby): Make coinstallable
Browse files Browse the repository at this point in the history
This makes Ruby 3.1-3.3 coinstallable, allowing for multiple versions of
Ruby to be installed at the same time. This will help us simplifiy a lot
of package manifests we have for Ruby as we'll be able to build gems for
multiple Ruby versions within the same definition, without creating an
entirely separate manifest

To full leverage this, we'll need to make SCA changes:

chainguard-dev/melange#1676

And then rebuild the world for Ruby (purging the cmd:ruby dependency
that all packages have right now, causing the resolver to fail unless
you explicitly request a version of Ruby that aligns with the gem)

Signed-off-by: RJ Sampson <[email protected]>
  • Loading branch information
EyeCantCU committed Dec 5, 2024
1 parent 5a37b8a commit 32eb352
Show file tree
Hide file tree
Showing 3 changed files with 204 additions and 72 deletions.
90 changes: 68 additions & 22 deletions ruby-3.1.yaml
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
package:
name: ruby-3.1
version: 3.1.6
epoch: 6
epoch: 7
description: "the Ruby programming language"
copyright:
- license: Ruby
- license: BSD-2-Clause
dependencies:
provides:
- ruby=${{package.full-version}}
runtime:
- ${{package.name}}-base=${{package.full-version}}

environment:
contents:
Expand All @@ -34,10 +36,15 @@ environment:
- xz-dev
- zlib-dev

vars:
prefix: /usr

var-transforms:
- from: ${{package.version}}
match: ^(\d+\.\d+)\.\d+
replace: $1
to: major-minor-version
- from: ${{package.version}}
match: ^(\d+\.\d+)\.\d+
replace: $1.0
to: stdlib-version
- from: ${{package.version}}
match: \.
replace: _
Expand All @@ -61,7 +68,11 @@ pipeline:
--host=${{host.triplet.gnu}} \
--build=${{host.triplet.gnu}} \
--target=${{host.triplet.gnu}} \
--prefix=${{vars.prefix}} \
--prefix=/usr \
--bindir=/usr/libexec/ruby/${{vars.stdlib-version}} \
--datadir=/usr/share/ruby/${{vars.stdlib-version}} \
--docdir=/usr/share/ruby/${{vars.stdlib-version}}/doc \
--mandir=/usr/share/ruby/${{vars.stdlib-version}}/man \
--enable-ipv6 \
--enable-loadable-sqlite-extensions \
--enable-optimizations \
Expand All @@ -81,39 +92,74 @@ pipeline:
- uses: strip

- runs: |
# Ignore the patch version of ruby since ruby will install under the
# version of the latest standard library. Should produce the string 3.1.*
RUBYWILD="$(echo ${{package.version}} | cut -d. -f-2).*"
rm ${{targets.destdir}}/usr/lib/libruby.so
RUBYDIR=${{targets.destdir}}${{vars.prefix}}/lib/ruby/$RUBYWILD
rm -rf ${RUBYDIR}/bundler
RUBYDIR=${{targets.destdir}}/usr/lib/ruby/${{vars.stdlib-version}}
rm -r ${RUBYDIR}/bundler
rm ${RUBYDIR}/bundler.rb
GEMDIR=${{targets.destdir}}${{vars.prefix}}/lib/ruby/gems/$RUBYWILD
rm -rf ${GEMDIR}/gems/bundler-*
GEMDIR=${{targets.destdir}}/usr/lib/ruby/gems/${{vars.stdlib-version}}
rm -r ${GEMDIR}/gems/bundler-*
rm ${GEMDIR}/specifications/default/bundler-*.gemspec
rm ${{targets.destdir}}/usr/bin/bundle \
${{targets.destdir}}/usr/bin/bundler
rm ${{targets.destdir}}/usr/libexec/ruby/${{vars.stdlib-version}}/bundle \
${{targets.destdir}}/usr/libexec/ruby/${{vars.stdlib-version}}/bundler
- runs: |
find ${{targets.destdir}} -name 'mkmf.log' -exec rm {} \;
subpackages:
- name: "ruby-3.1-doc"
description: "ruby documentation"
- name: "${{package.name}}-base"
description: "Ruby ${{vars.major-minor-version}} base"
pipeline:
- runs: |
mkdir -p ${{targets.contextdir}}
mv ${{targets.destdir}}/* ${{targets.contextdir}}
mkdir -p ${{targets.destdir}}/usr/bin
mkdir -p ${{targets.contextdir}}/usr/bin
for bin in ${{targets.contextdir}}/usr/libexec/ruby/${{vars.stdlib-version}}/*; do
bn="$(basename $bin)"
ln -s /usr/libexec/ruby/${{vars.stdlib-version}}/$bn ${{targets.destdir}}/usr/bin/
ln -s /usr/libexec/ruby/${{vars.stdlib-version}}/$bn ${{targets.contextdir}}/usr/bin/$bn\${{vars.major-minor-version}}
done
- name: "${{package.name}}-doc"
description: "Ruby ${{vars.major-minor-version}} documentation"
pipeline:
- uses: split/manpages
- runs: |
mkdir -p "${{targets.subpkgdir}}"/usr/share
mv "${{targets.destdir}}"/usr/share/doc "${{targets.subpkgdir}}"/usr/share/
mv "${{targets.destdir}}"/usr/share/ri "${{targets.subpkgdir}}"/usr/share/
datadir="/usr/share/ruby/${{vars.stdlib-version}}"
- name: "ruby-3.1-dev"
description: "ruby development headers"
mkdir -p "${{targets.contextdir}}/$datadir"
mv "${{targets.outdir}}/${{package.name}}-base/$datadir/doc" "${{targets.contextdir}}/$datadir/"
mv "${{targets.outdir}}/${{package.name}}-base/$datadir/man" "${{targets.contextdir}}/$datadir/"
mv "${{targets.outdir}}/${{package.name}}-base/usr/share/ri" "${{targets.contextdir}}/usr/share/"
- name: "${{package.name}}-base-dev"
description: "Ruby ${{vars.major-minor-version}} development headers"
dependencies:
runtime:
- ${{package.name}}-base=${{package.full-version}}
pipeline:
- uses: split/dev
with:
package: "${{package.name}}-base"
test:
pipeline:
- uses: test/pkgconf

# Empty package, ensures ruby-dev always installs development files for latest ruby version
- name: "${{package.name}}-dev"
description: "Ruby ${{vars.major-minor-version}} development headers"
dependencies:
provides:
- ruby-dev=${{package.full-version}}
runtime:
- ${{package.name}}-base=${{package.full-version}}

update:
enabled: true
version-transform:
Expand Down
93 changes: 68 additions & 25 deletions ruby-3.2.yaml
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
package:
name: ruby-3.2
version: 3.2.6
epoch: 1
description: "the Ruby programming language"
epoch: 2
description: "The Ruby ${{vars.major-minor-version}} programming language"
copyright:
- license: Ruby
- license: BSD-2-Clause
dependencies:
provides:
- ruby=${{package.full-version}}
runtime:
- ${{package.name}}-base=${{package.full-version}}

environment:
contents:
Expand Down Expand Up @@ -41,10 +43,15 @@ environment:
- yaml-dev
- zlib-dev

vars:
prefix: /usr

var-transforms:
- from: ${{package.version}}
match: ^(\d+\.\d+)\.\d+
replace: $1
to: major-minor-version
- from: ${{package.version}}
match: ^(\d+\.\d+)\.\d+
replace: $1.0
to: stdlib-version
- from: ${{package.version}}
match: \.
replace: _
Expand All @@ -68,7 +75,11 @@ pipeline:
--host=${{host.triplet.gnu}} \
--build=${{host.triplet.gnu}} \
--target=${{host.triplet.gnu}} \
--prefix=${{vars.prefix}} \
--prefix=/usr \
--bindir=/usr/libexec/ruby/${{vars.stdlib-version}} \
--datadir=/usr/share/ruby/${{vars.stdlib-version}} \
--docdir=/usr/share/ruby/${{vars.stdlib-version}}/doc \
--mandir=/usr/share/ruby/${{vars.stdlib-version}}/man \
--enable-shared \
--disable-rpath \
--sysconfdir=/etc \
Expand All @@ -90,42 +101,74 @@ pipeline:
- uses: autoconf/make-install

- runs: |
# Ignore the patch version of ruby since ruby will install under the
# version of the latest standard library. Should produce the string 3.2.*
RUBYWILD="$(echo ${{package.version}} | cut -d. -f-2).*"
rm ${{targets.destdir}}/usr/lib/libruby.so
RUBYDIR=${{targets.destdir}}${{vars.prefix}}/lib/ruby/$RUBYWILD
rm -rf ${RUBYDIR}/bundler
rm -f ${RUBYDIR}/bundler.rb
RUBYDIR=${{targets.destdir}}/usr/lib/ruby/${{vars.stdlib-version}}
rm -r ${RUBYDIR}/bundler
rm ${RUBYDIR}/bundler.rb
GEMDIR=${{targets.destdir}}${{vars.prefix}}/lib/ruby/gems/$RUBYWILD
rm -rf ${GEMDIR}/gems/bundler-*
rm -f ${GEMDIR}/specifications/default/bundler-*.gemspec
GEMDIR=${{targets.destdir}}/usr/lib/ruby/gems/${{vars.stdlib-version}}
rm -r ${GEMDIR}/gems/bundler-*
rm ${GEMDIR}/specifications/default/bundler-*.gemspec
rm -f ${{targets.destdir}}/usr/bin/bundle \
${{targets.destdir}}/usr/bin/bundler
rm ${{targets.destdir}}/usr/libexec/ruby/${{vars.stdlib-version}}/bundle \
${{targets.destdir}}/usr/libexec/ruby/${{vars.stdlib-version}}/bundler
- runs: |
find ${{targets.destdir}} -name 'mkmf.log' -exec rm {} \;
subpackages:
- name: "ruby-3.2-doc"
description: "ruby documentation"
- name: "${{package.name}}-base"
description: "Ruby ${{vars.major-minor-version}} base"
pipeline:
- runs: |
mkdir -p ${{targets.contextdir}}
mv ${{targets.destdir}}/* ${{targets.contextdir}}
mkdir -p ${{targets.destdir}}/usr/bin
mkdir -p ${{targets.contextdir}}/usr/bin
for bin in ${{targets.contextdir}}/usr/libexec/ruby/${{vars.stdlib-version}}/*; do
bn="$(basename $bin)"
ln -s /usr/libexec/ruby/${{vars.stdlib-version}}/$bn ${{targets.destdir}}/usr/bin/
ln -s /usr/libexec/ruby/${{vars.stdlib-version}}/$bn ${{targets.contextdir}}/usr/bin/$bn\${{vars.major-minor-version}}
done
- name: "${{package.name}}-doc"
description: "Ruby ${{vars.major-minor-version}} documentation"
pipeline:
- uses: split/manpages
- runs: |
mkdir -p "${{targets.subpkgdir}}"/usr/share
mv "${{targets.destdir}}"/usr/share/doc "${{targets.subpkgdir}}"/usr/share/
mv "${{targets.destdir}}"/usr/share/ri "${{targets.subpkgdir}}"/usr/share/
datadir="/usr/share/ruby/${{vars.stdlib-version}}"
- name: "ruby-3.2-dev"
description: "ruby development headers"
mkdir -p "${{targets.contextdir}}/$datadir"
mv "${{targets.outdir}}/${{package.name}}-base/$datadir/doc" "${{targets.contextdir}}/$datadir/"
mv "${{targets.outdir}}/${{package.name}}-base/$datadir/man" "${{targets.contextdir}}/$datadir/"
mv "${{targets.outdir}}/${{package.name}}-base/usr/share/ri" "${{targets.contextdir}}/usr/share/"
- name: "${{package.name}}-base-dev"
description: "Ruby ${{vars.major-minor-version}} development headers"
dependencies:
runtime:
- ${{package.name}}-base=${{package.full-version}}
pipeline:
- uses: split/dev
with:
package: "${{package.name}}-base"
test:
pipeline:
- uses: test/pkgconf

# Empty package, ensures ruby-dev always installs development files for latest ruby version
- name: "${{package.name}}-dev"
description: "Ruby ${{vars.major-minor-version}} development headers"
dependencies:
provides:
- ruby-dev=${{package.full-version}}
runtime:
- ${{package.name}}-base=${{package.full-version}}

update:
enabled: true
version-transform:
Expand Down
Loading

0 comments on commit 32eb352

Please sign in to comment.