Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow adding build number to compiled gem version #63

Merged
merged 1 commit into from
Apr 10, 2021

Conversation

luislavena
Copy link
Owner

@luislavena luislavena commented Apr 10, 2021

Introduce an optional --build-number compile option to increase the compiled gem version from the original one.

This is useful since local compilation might be trial and error about compilation options and gems pushed to RubyGems or Gemstash are immutable and cannot be replaced.

With this change, you can append this build number to the version and remain compatible with any existing gem requirement like ~> X.Y or ~> X.Y.Z.

Imagine compiling nokogiri 1.11.3 using system libraries:

$ gem compile nokogiri-1.11.3.gem --prune -- --use-system-libraries
...

Then, realizing that your OS system libraries are vulnerable to a reported CVE, you can build and push a compatible 1.11.3 version that uses the bundled dependencies instead:

$ gem compile nokogiri-1.11.3.gem --prune --build-number 1
Unpacking gem: 'nokogiri-1.11.3' in temporary directory...
Building native extensions. This could take a while...
...
    Successfully built RubyGem
    Name: nokogiri
    Version: 1.11.3.1
    File: nokogiri-1.11.3.1-x86_64-linux.gem

This new version 1.11.3.1 will satisfy most of pessimistic dependency constraints:

v1 = Gem::Version.create("1.11.3")
# => #<Gem::Version "1.11.3">

v2 = Gem::Version.create("1.11.3.1")
# => #<Gem::Version "1.11.3.1">

r1 = Gem::Requirement.create("~> 1.11.3")
r2 = Gem::Requirement.create("~> 1.11")

r1.satisfied_by? v1
# => true

r1.satisfied_by? v2
# => true

r2.satisfied_by? v1
# => true

r2.satisfied_by? v2
# => true

Giving you build flexibility and remain compatible.

Closes #57
Closes #59

Introduce an optional `--build-number` compile option to increase the
compiled gem version from the original one.

This is useful since local compilation might be trial and error about
compilation options and gems pushed to RubyGems or Gemstash are immutable
and cannot be replaced.

With this change, you can append this build number to the version and
remain compatible with any existing gem requirement like `~> X.Y` or
`~> X.Y.Z`.

Imagine compiling `nokogiri` `1.11.3` using system libraries:

    $ gem compile nokogiri-1.11.3.gem --prune -- --use-system-libraries
    ...

Then, realizing that your OS system libraries are vulnerable to a
reported CVE, you can build and push a compatible `1.11.3` version that
uses the bundled dependencies instead:

    $ gem compile nokogiri-1.11.3.gem --prune --build-number 1
    Unpacking gem: 'nokogiri-1.11.3' in temporary directory...
    Building native extensions. This could take a while...
    ...
      Successfully built RubyGem
      Name: nokogiri
      Version: 1.11.3.1
      File: nokogiri-1.11.3.1-x86_64-linux.gem

This new version `1.11.3.1` will satisfy most of pessimistic dependency
constraints:

    v1 = Gem::Version.create("1.11.3")
    # => #<Gem::Version "1.11.3">

    v2 = Gem::Version.create("1.11.3.1")
    # => #<Gem::Version "1.11.3.1">

    r1 = Gem::Requirement.create("~> 1.11.3")
    r2 = Gem::Requirement.create("~> 1.11")

    r1.satisfied_by? v1
    # => true

    r1.satisfied_by? v2
    # => true

    r2.satisfied_by? v1
    # => true

    r2.satisfied_by? v2
    # => true

Giving you build flexibility and remain compatible.

Closes #57
Closes #59
@luislavena luislavena force-pushed the feature/add-build-number-version branch from ca0800b to dc1a594 Compare April 10, 2021 14:44
@luislavena luislavena merged commit 217480a into master Apr 10, 2021
@luislavena luislavena deleted the feature/add-build-number-version branch April 15, 2021 20:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

modify the version of the gem
1 participant