diff --git a/package/yast2-rmt.spec b/package/yast2-rmt.spec index f5a574a..ef45b53 100644 --- a/package/yast2-rmt.spec +++ b/package/yast2-rmt.spec @@ -60,6 +60,7 @@ rake install DESTDIR="%{buildroot}" %defattr(-,root,root) %{yast_dir}/clients/*.rb %{yast_dir}/lib/rmt +%{yast_dir}/lib/rmt.rb %{yast_desktopdir}/rmt.desktop %{yast_dir}/data/rmt diff --git a/spec/rmt_spec.rb b/spec/rmt_spec.rb new file mode 100644 index 0000000..7f7f0f2 --- /dev/null +++ b/spec/rmt_spec.rb @@ -0,0 +1,44 @@ +# Copyright (c) 2024 SUSE LLC. +# All Rights Reserved. + +# This program is free software; you can redistribute it and/or +# modify it under the terms of version 2 or 3 of the GNU General +# Public License as published by the Free Software Foundation. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program; if not, contact SUSE LLC. + +# To contact SUSE about this file by physical or electronic mail, +# you may find current contact information at www.suse.com + +require 'rmt' + +describe RMT do + describe '.VERSION' do + subject(:version) { RMT::VERSION } + + let(:package_version) do + filename = './package/yast2-rmt.spec' + version = nil + + File.foreach(filename) do |line| + line.match(/^Version:\s+(?(\d+\.?){3})$/) do |match| + version ||= match.named_captures['version'] + end + end + + raise "'#{filename}' does not include any line matching the expected package version format." if version.nil? + + version + end + + it 'returns the same version as specified in the package spec file' do + expect(version).to eq package_version + end + end +end diff --git a/src/lib/rmt.rb b/src/lib/rmt.rb new file mode 100644 index 0000000..20ced44 --- /dev/null +++ b/src/lib/rmt.rb @@ -0,0 +1,21 @@ +# Copyright (c) 2024 SUSE LLC. +# All Rights Reserved. + +# This program is free software; you can redistribute it and/or +# modify it under the terms of version 2 or 3 of the GNU General +# Public License as published by the Free Software Foundation. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program; if not, contact SUSE LLC. + +# To contact SUSE about this file by physical or electronic mail, +# you may find current contact information at www.suse.com + +module RMT + VERSION = '1.3.5'.freeze +end diff --git a/src/lib/rmt/wizard_scc_page.rb b/src/lib/rmt/wizard_scc_page.rb index 510946b..248844f 100644 --- a/src/lib/rmt/wizard_scc_page.rb +++ b/src/lib/rmt/wizard_scc_page.rb @@ -18,6 +18,7 @@ require 'uri' require 'net/http' +require 'rmt' require 'rmt/utils' require 'ui/event_dispatcher' @@ -26,7 +27,7 @@ module RMT; end class RMT::WizardSCCPage < Yast::Client include ::UI::EventDispatcher - YAST_RMT_USER_AGENT = 'yast2-rmt'.freeze + YAST_RMT_USER_AGENT = "yast2-rmt/#{RMT::VERSION}".freeze def initialize(config) textdomain 'rmt'