File obs-server-2.10-0002-api-Use-bundler_ext-instead-of-bundler-if-Gemfile.in.patch of Package obs-server

From 6bdd234f91b4e1c9b2600f4ba92afc085e6fbcb0 Mon Sep 17 00:00:00 2001
From: Oleg Girko <ol@infoserver.lv>
Date: Sun, 18 May 2014 01:39:45 +0100
Subject: [PATCH] [api] Use bundler_ext instead of bundler if Gemfile.in file
 present.

This is needed for installations where Ruby gems are managed
by system package manager (like RPM or APT),
so bundler should not interfere with that and refuse to start application
if gems with versions slightly different than ones mentioned in Gemfile.lock
are installed in the system.

Signed-off-by: Oleg Girko <ol@infoserver.lv>
---
 src/api/config/application.rb | 10 ++++++++--
 src/api/config/boot.rb        |  6 ++++--
 2 files changed, 12 insertions(+), 4 deletions(-)

diff --git a/src/api/config/application.rb b/src/api/config/application.rb
index 0e27d9553d..ce7547a6c3 100644
--- a/src/api/config/application.rb
+++ b/src/api/config/application.rb
@@ -2,8 +2,14 @@ require_relative 'boot'
 
 require 'rails/all'
 
-# Assets should be precompiled for production (so we don't need the gems loaded then)
-Bundler.require(*Rails.groups(assets: ['development', 'test']))
+gemfile_in = File.expand_path('../../Gemfile.in', __FILE__)
+if File.exist?(gemfile_in)
+  require 'bundler_ext'
+  BundlerExt.system_require(gemfile_in, *Rails.groups(assets: ['development', 'test']))
+else
+  # Assets should be precompiled for production (so we don't need the gems loaded then)
+  Bundler.require(*Rails.groups(assets: ['development', 'test']))
+end
 require_relative '../lib/engines/base.rb'
 require_relative '../lib/rabbitmq_bus.rb'
 OBSEngine.load_engines
diff --git a/src/api/config/boot.rb b/src/api/config/boot.rb
index 30f5120df6..086c477cfa 100644
--- a/src/api/config/boot.rb
+++ b/src/api/config/boot.rb
@@ -1,3 +1,5 @@
-ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../Gemfile', __dir__)
+if !File.exist?(File.expand_path('../Gemfile.in', __dir__))
+  ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../Gemfile', __dir__)
 
-require 'bundler/setup' # Set up gems listed in the Gemfile.
+  require 'bundler/setup' # Set up gems listed in the Gemfile.
+end
-- 
2.31.1