Skip to content

Commit

Permalink
Merge pull request #425 from SUSE/remove-i18n_boot_initializer
Browse files Browse the repository at this point in the history
Remove i18n boot initializer
  • Loading branch information
Sergeykot authored Jun 26, 2019
2 parents 7553c20 + e2862f7 commit f06fa3c
Show file tree
Hide file tree
Showing 15 changed files with 44 additions and 13 deletions.
9 changes: 1 addition & 8 deletions bin/rmt-cli
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,12 @@ require 'active_record'
require 'erb'
require 'yaml'
require 'rmt/config'
require 'fast_gettext'
require 'initializers/rmt_fast_gettext'
require 'initializers/rmt_fast_gettext_cli_locale'

relative_load_paths = %w[lib lib/rmt app/models app/services].map { |dir| File.join(rmt_path, dir) }
ActiveSupport::Dependencies.autoload_paths += relative_load_paths

# rubocop:disable Style/MixinUsage
include FastGettext::Translation
# rubocop:enable Style/MixinUsage

locale = (ENV['LANG'] || ENV['LC_CTYPE']).to_s.match(/^([a-z]{2,}(_[A-Z]{2,})?)/).to_a[1] || :en
FastGettext.set_locale(locale.to_sym)

if RMT::CLI::Base.process_user_name == 'root'
# set group and then user, otherwise user cannot change group
Process::Sys.setegid(Etc.getgrnam(RMT::DEFAULT_GROUP).gid)
Expand Down
3 changes: 2 additions & 1 deletion bin/rmt-data-import
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ RMT_PATH = File.expand_path('..', __dir__)

# Load initial configuration for rmt
require_relative "#{RMT_PATH}/config/boot"
require_relative "#{RMT_PATH}/config/boot_cli_i18n"

# Add rmt_path to library load path
$LOAD_PATH.unshift File.join(RMT_PATH, 'lib')
Expand All @@ -19,6 +18,8 @@ require 'yaml'
require 'rmt/config'
require 'csv'
require 'json'
require 'initializers/rmt_fast_gettext'
require 'initializers/rmt_fast_gettext_cli_locale'
require 'rmt/cli/smt_importer'

no_systems = false
Expand Down
1 change: 1 addition & 0 deletions docker-compose-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ services:
privileged: true
volumes:
- /space/oscbuild:/oscbuild:cached
- ./:/tmp/workdir:ro
build:
context: .
dockerfile: integration/Dockerfile.test
Expand Down
15 changes: 15 additions & 0 deletions features/import_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
require File.expand_path('../support/command_rspec_helper', __FILE__)

describe 'rmt data importer' do
describe 'import repo from smt' do
before do
command '/usr/bin/rmt-data-import --no-systems --no-hwinfo -d /tmp/rmt-server/spec/fixtures/files/dummy_export'
end
after do
`/usr/bin/rmt-cli repos disable 3114`
end
it do
expect(`/usr/bin/rmt-cli repos list`).to include('3114', '| Mirror')
end
end
end
2 changes: 1 addition & 1 deletion integration/Dockerfile.test
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ RUN sh integration/create-rmt-conf.sh
RUN mkdir -p /var/lib/rmt/
RUN printf "$SYSTEM_UUID" >> /var/lib/rmt/system_uuid

ADD . /tmp/rmt-server
COPY ./ /tmp/rmt-server
RUN NOKOGIRI_USE_SYSTEM_LIBRARIES=1 bundle install

CMD dockerize -wait tcp://$MYSQL_HOST:3306 -timeout 60s true
6 changes: 6 additions & 0 deletions integration/run.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
#!/bin/sh -xe

# update project
rm -r /tmp/rmt-server/*
cp -r /tmp/workdir/* /tmp/rmt-server
chown -R scc /tmp/rmt-server

make dist
mkdir ~/obs
cd ~/obs
Expand Down
6 changes: 6 additions & 0 deletions lib/initializers/rmt_fast_gettext.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
# Configure fast_gettext for i18n.
require 'fast_gettext'

# rubocop:disable Style/MixinUsage
include FastGettext::Translation
# rubocop:enable Style/MixinUsage

rmt_path = File.expand_path('../../', __dir__)
FastGettext.add_text_domain('rmt', path: File.join(rmt_path, 'locale'), type: :po, ignore_fuzzy: true, report_warning: false)
FastGettext.default_locale = :en
Expand Down
4 changes: 4 additions & 0 deletions lib/initializers/rmt_fast_gettext_cli_locale.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# :nocov:
locale = (ENV['LANG'] || ENV['LC_CTYPE']).to_s.match(/^([a-z]{2,}(_[A-Z]{2,})?)/).to_a[1] || :en
FastGettext.set_locale(locale.to_sym)
# :nocov:
2 changes: 1 addition & 1 deletion lib/rmt.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
module RMT
VERSION ||= '2.2.0'.freeze
VERSION ||= '2.2.1'.freeze

DEFAULT_USER = '_rmt'.freeze
DEFAULT_GROUP = 'nginx'.freeze
Expand Down
1 change: 0 additions & 1 deletion lib/rmt/cli/smt_importer.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
require 'csv'
require 'ostruct'


class SMTImporter
attr_accessor :data_dir
attr_accessor :no_systems
Expand Down
5 changes: 5 additions & 0 deletions package/obs/rmt-server.changes
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
-------------------------------------------------------------------
Wed Jun 26 12:14:44 UTC 2019 - Serhii Kotov <[email protected]>
- Version 2.2.1
- Fix dependency to removed boot_cli_i18n file (bsc#1136020)

-------------------------------------------------------------------
Fri Jun 14 14:37:57 UTC 2019 - Ivan Kapelyukhin <[email protected]>

Expand Down
2 changes: 1 addition & 1 deletion package/obs/rmt-server.spec
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
%define ruby_version %{rb_default_ruby_suffix}

Name: rmt-server
Version: 2.2.0
Version: 2.2.1
Release: 0
Summary: Repository mirroring tool and registration proxy for SCC
License: GPL-2.0-or-later
Expand Down
Empty file.
Empty file.
1 change: 1 addition & 0 deletions spec/fixtures/files/dummy_export/enabled_repos.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
3114

0 comments on commit f06fa3c

Please sign in to comment.