From 6c9b665e77d64e92c49bc5ac0b69a7e818842830 Mon Sep 17 00:00:00 2001 From: Tibbs Date: Apr 30 2018 19:08:54 +0000 Subject: Writeup "Patching required gem versions" section. https://pagure.io/packaging-committee/issue/710 --- diff --git a/Packaging:Ruby.mw b/Packaging:Ruby.mw index 44ba4cd..8aa38ea 100644 --- a/Packaging:Ruby.mw +++ b/Packaging:Ruby.mw @@ -204,17 +204,17 @@ Next we build the gem. Because %gem_install only operates on gem ar Here we actually install into the %{buildroot}. We create the directories that we need and then copy what was installed into the temporary directories into the %{buildroot} hierarchy. Finally, if this ruby gem creates shared objects the shared objects are moved into the arch specific %{gem_extdir_mri} path. ==== Patching required gem versions ==== -One common patching need is to change overly strict version requirements in the upstream gemspec. This may be because upstream's gemspec only mentions versions that they've explicitly tested against but we know that a different version will also work or because we know that the packages we ship have applied fixes for problematic behaviour without bumping the version number (for instance, backported fixes). To fix these issues, find the add_runtime_dependency call in the gemspec and patch it with the corrected version similar to this: +One common patching need is to change overly strict version requirements in the upstream .gemspec. This may be because upstream's .gemspec only mentions versions that they've explicitly tested against but we know that a different version will also work or because we know that the packages we ship have applied fixes for problematic behavior without bumping the version number (for instance, backported fixes). To adjust such dependencies, you can use the %gemspec_add_dep and %gemspec_remove_dep macros. + +For example, if you wanted to use any version of Aruba instead of the overly specific version requested by upstream, you could use in %prep section following two lines:
-Gem::Specification.new do |s|
-  # [...]
--  s.add_runtime_dependency(%q, ["~> 2.2.19"])
-+  s.add_runtime_dependency(%q, [">= 2.3.0"])
-  # [...]
-end
+%gemspec_remove_dep -g aruba "~> 0.14.2"
+%gemspec_add_dep -g aruba
 
+{{admon/warning|Use macros only on top of generated .gemspec|The %gemspec_add_dep and %gemspec_remove_dep macros work reliably only on .gemspec generated using the ruby spec command. Please don't use the macros on upstream .gemspec files.}} + {{admon/warning|Be sure to test|Do not simply change versions without testing that the new version works. There are times the upstream is overly strict but there are also times when the version requirement was specified because a specific bug was encountered or the API changed in a minor release.}} === Packaging for Gem and non-Gem use ===