Skip to content

Commit

Permalink
Merge branch 'master' into uptime
Browse files Browse the repository at this point in the history
  • Loading branch information
chajain authored Feb 1, 2024
2 parents c52e396 + ecf5efb commit e76c2d4
Show file tree
Hide file tree
Showing 12 changed files with 52 additions and 5 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@
# Ignore the default SQLite database.
/db/*.sqlite3
/db/*.sqlite3-journal
/rmt_development
/rmt_test
/rmt_production


# Ignore all logfiles and tempfiles.
/log/*
Expand Down
1 change: 1 addition & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ end

gem 'puma', '~> 5.6.2'
gem 'mysql2', '~> 0.5.3'
gem 'sqlite3'

gem 'nokogiri', '< 1.13' # Locked because of Ruby >= 2.6 dependency
gem 'thor', '<= 1.2.2' # Locked because of Ruby >= 2.6 dependency
Expand Down
2 changes: 2 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,7 @@ GEM
spring-watcher-listen (2.0.1)
listen (>= 2.7, < 4.0)
spring (>= 1.2, < 3.0)
sqlite3 (1.4.4)
strong_migrations (0.7.9)
activerecord (>= 5)
sync (0.5.0)
Expand Down Expand Up @@ -360,6 +361,7 @@ DEPENDENCIES
spring
spring-commands-rspec
spring-watcher-listen (~> 2.0.0)
sqlite3
strong_migrations
terminal-table (~> 3.0)
thor (<= 1.2.2)
Expand Down
12 changes: 10 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,19 +23,27 @@ Please view our [guide](docs/installation.md) to assist you in the RMT installat
sudo zypper in libxml2-devel libxslt-devel libmariadb-devel gcc
```
2. Install the ruby version specified in the `.ruby-version` [file](.ruby-version).
3. Install and start either the MariaDB or MySQL server:
3. Install and setup the database:
**Default: MariaDB or MySQL server**
```
sudo zypper in mariadb
sudo systemctl enable mariadb
sudo systemctl start mariadb
```
4. Log into the MariaDB or MySQL server as root and create the RMT database user:
Log into the MariaDB or MySQL server as root and create the RMT database user:
```
mysql -u root -p <<EOFF
GRANT ALL PRIVILEGES ON \`rmt%\`.* TO rmt@localhost IDENTIFIED BY 'rmt';
FLUSH PRIVILEGES;
EOFF
```
**Experimental: SQLite**
For development purposes it can be easier to run with SQLite, to avoid extra dependencies.
To run RMT with SQLite, switch the database adapter in `config/rmt.yml` to `sqlite3`.
5. Clone the RMT repository:
```
git clone [email protected]:SUSE/rmt.git
Expand Down
8 changes: 7 additions & 1 deletion app/controllers/services_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,15 @@ def show

builder = Builder::XmlMarkup.new
service_xml = builder.repoindex(ttl: ZYPPER_SERVICE_TTL) do
# NOTE: We only care to add the ?credentials parameter to the repository URL if
# we are *NOT* dealing with plain RMT but the authentication engine of Public Cloud.
# The engine requires to supply the service name to function properly, since repositories
# are authenticated in this case.
service_name = defined?(StrictAuthentication::Engine) ? service.name : nil

repos.each do |repo|
attributes = {
url: make_repo_url(request.base_url, repo.local_path, service.name),
url: make_repo_url(request.base_url, repo.local_path, service_name),
alias: repo.name,
name: repo.name,
autorefresh: repo.autorefresh,
Expand Down
5 changes: 5 additions & 0 deletions bin/rmt-cli
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,11 @@ end
db_config = RMT::Config.db_config
ActiveRecord::Base.establish_connection(db_config)

if ActiveRecord::Base.connection.adapter_name != "Mysql2"
warn "Running with experimental support for #{ActiveRecord::Base.connection.adapter_name}."
warn 'RMT is running without locking operations, make sure not to run it in multipe processes.'
end

begin
RMT::CLI::Main.start(ARGV)
rescue Interrupt
Expand Down
14 changes: 14 additions & 0 deletions db/migrate/20240129140413_remove_obsolete_res7_repositories.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
class RemoveObsoleteRes7Repositories < ActiveRecord::Migration[6.1]
def change
# RES7 was historically a product managed by Novell. With the upcoming
# SUSE Liberty 7, RES7 was moved into IBS (SUSE build service).
# This resulted in repositories being renamed.
# This migration removes the now obsolete repositories, since RMT does
# not remove these automatically.

# Affected repositories are:
# - 1963: https://updates.suse.com/repo/$RCE/RES7/src/
# - 1736: https://updates.suse.com/repo/$RCE/RES7/x86_64/
Repository.where(scc_id: [1963, 1736]).destroy_all
end
end
1 change: 1 addition & 0 deletions lib/rmt/cli/base.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
require 'rmt/lockfile'
require 'rmt/cli/decorators'
require 'etc'
require 'mysql2'

class RMT::CLI::Base < Thor

Expand Down
2 changes: 2 additions & 0 deletions lib/rmt/lockfile.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ class RMT::Lockfile

class << self
def lock(lock_name = nil)
yield and return if ActiveRecord::Base.connection.adapter_name != 'Mysql2'

lock_name = ['rmt-cli', lock_name].compact.join('-')

is_lock_obtained = obtain_lock(lock_name)
Expand Down
3 changes: 3 additions & 0 deletions lib/rmt/misc.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ module RMT
module Misc
def self.make_repo_url(base_url, local_path, service_name = nil)
uri = URI.join(base_url, File.join(RMT::DEFAULT_MIRROR_URL_PREFIX, local_path))
# NOTE: Make sure to only add the credentials where necessary (Pubcloud? or SMT?)
# In all other cases do not add them, since this will break other repository
# managers such as yum!
uri.query = "credentials=#{service_name}" if service_name
uri.to_s
end
Expand Down
3 changes: 2 additions & 1 deletion package/obs/rmt-server.changes
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
-------------------------------------------------------------------
Wed Oct 04 13:23:00 UTC 2023 - Felix Schnizlein <[email protected]>
Thu Jan 25 17:40:00 UTC 2024 - Felix Schnizlein <[email protected]>

- Version 2.15:
* Moving system hardware information to systems database table to
Expand All @@ -8,6 +8,7 @@ Wed Oct 04 13:23:00 UTC 2023 - Felix Schnizlein <[email protected]>
* rmt-client-setup-res script: fix for CentOS8 clients (bsc#1214709)
* Updated supportconfig script (bsc#1216389)
* Support zstd compression for repository metadata (bsc#1218775)
* Do not add credential handling to normal repository URLs (#1219153)

-------------------------------------------------------------------
Thu Jun 06 15:44:00 UTC 2023 - Luís Caparroz <[email protected]>
Expand Down
2 changes: 1 addition & 1 deletion spec/requests/services_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@

let(:model_urls) do
service.repositories.reject(&:installer_updates).map do |repo|
RMT::Misc.make_repo_url('http://www.example.com', repo.local_path, service.name)
RMT::Misc.make_repo_url('http://www.example.com', repo.local_path)
end
end

Expand Down

0 comments on commit e76c2d4

Please sign in to comment.