Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master' into extend_firewall_api
Browse files Browse the repository at this point in the history
  • Loading branch information
jreidinger committed Nov 27, 2018
2 parents 38f0b7f + da0dadb commit 22ee11f
Show file tree
Hide file tree
Showing 128 changed files with 6,918 additions and 3,698 deletions.
4 changes: 4 additions & 0 deletions .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,10 @@ Style/AccessorMethodName:
Exclude:
- library/systemd/src/modules/systemd_target.rb

# set reasonable ruby version
AllCops:
TargetRubyVersion: 2.2

# UI_ID module is not camel case
Style/ClassAndModuleCamelCase:
Enabled: false
Expand Down
2 changes: 1 addition & 1 deletion .yardopts
Original file line number Diff line number Diff line change
@@ -1 +1 @@
--no-private --markup markdown --protected library/*/src/**/*.rb --readme README.md --output-dir ./doc/autodocs - library/cwm/doc/CWM.md library/systemd/doc/services_and_sockets.md
--no-private --markup markdown --protected library/*/src/**/*.rb --readme README.md --output-dir ./doc/autodocs - library/cwm/doc/CWM.md library/systemd/doc/services_and_sockets.md library/system/doc/system_services.md
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Use this base image
# - built: https://hub.docker.com/r/yastdevel/ruby/
# - source: https://github.com/yast/docker-yast-ruby
FROM yastdevel/ruby:sle15
FROM yastdevel/ruby
COPY . /usr/src/app
# English messages, UTF-8, "C" locale for numeric formatting tests
ENV LC_ALL= LANG=en_US.UTF-8 LC_NUMERIC=C
Expand Down
2 changes: 0 additions & 2 deletions Rakefile
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
require "yast/rake"

Yast::Tasks.submit_to :sle15

Yast::Tasks.configuration do |conf|
# lets ignore license check for now
conf.skip_license_check << /.*/
Expand Down
19 changes: 14 additions & 5 deletions library/control/src/modules/Installation.rb
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@

module Yast
class InstallationClass < Module
# usual mountpoint for the source (i.e. CD)
SOURCEDIR = "/run/YaST2/mount".freeze

def main
Yast.import "Stage"
Yast.import "Linuxrc"
Expand All @@ -56,10 +59,6 @@ def main
# set to "/" when the SCR is restarted in the target system.
@scr_destdir = "/"

# usual mountpoint for the source (i.e. CD)

@sourcedir = "/var/adm/mount"

@yast2dir = "/var/lib/YaST2"

@mountlog = Ops.add(Directory.logdir, "/y2logMount")
Expand Down Expand Up @@ -287,10 +286,19 @@ def no_x11
@_no_x11
end

# Gets directory suitable for source mount. It ensures that directory exists.
# It does not ensure unmounting previous content.
#
# @return [String]
def sourcedir
::FileUtils.mkdir_p(SOURCEDIR) unless ::File.exist?(SOURCEDIR)

SOURCEDIR
end

publish variable: :scr_handle, type: "integer"
publish variable: :destdir, type: "string"
publish variable: :scr_destdir, type: "string"
publish variable: :sourcedir, type: "string"
publish variable: :yast2dir, type: "string"
publish variable: :mountlog, type: "string"
publish variable: :encoding, type: "string"
Expand Down Expand Up @@ -326,6 +334,7 @@ def no_x11
publish function: :x11_setup_needed, type: "boolean ()"
publish function: :text_fallback, type: "boolean ()"
publish function: :no_x11, type: "boolean ()"
publish function: :sourcedir, type: "string ()"
end

Installation = InstallationClass.new
Expand Down
28 changes: 27 additions & 1 deletion library/control/src/modules/ProductFeatures.rb
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,12 @@ def main
"vendor_url" => "",
"enable_clone" => false,
"disable_os_prober" => false,
"enable_local_users" => true,
# FATE #304865
"base_product_license_directory" => "/etc/YaST2/licenses/base/"
"base_product_license_directory" => "/etc/YaST2/licenses/base/",
"full_system_media_name" => "",
"full_system_download_url" => "",
"save_y2logs" => true
},
"partitioning" => {
"use_flexible_partitioning" => false,
Expand Down Expand Up @@ -238,6 +242,27 @@ def GetBooleanFeature(section, feature)
Ops.is_string?(value) && Builtins.tolower(Convert.to_string(value)) == "yes"
end

# Get value of a boolean feature with a fallback value.
#
# @note This is a stable API function
# @param [String] section string section of the feature
# @param [String] feature feature name
# @param [Boolean] fallback
#
# @return [Boolean] the feature value or fallback if not specified
def GetBooleanFeatureWithFallback(section, feature, fallback)
value = GetFeature(section, feature)
return fallback if value.nil?
return value if Ops.is_boolean?(value)

if value.respond_to?(:downcase)
return true if ["yes", "true"].include?(value.downcase)
return false if ["no", "false"].include?(value.downcase)
end

fallback
end

# Get value of a feature
# @note This is a stable API function
# @param [String] section string section of the feature
Expand Down Expand Up @@ -355,6 +380,7 @@ def ClearOverlay
publish function: :InitIfNeeded, type: "void ()"
publish function: :GetFeature, type: "any (string, string)"
publish function: :GetBooleanFeature, type: "boolean (string, string)"
publish function: :GetBooleanFeatureWithFallback, type: "boolean (string, string, boolean)"
publish function: :GetIntegerFeature, type: "integer (string, string)"
publish function: :SetFeature, type: "void (string, string, any)"
publish function: :SetStringFeature, type: "void (string, string, string)"
Expand Down
33 changes: 27 additions & 6 deletions library/control/src/modules/WorkflowManager.rb
Original file line number Diff line number Diff line change
Expand Up @@ -439,7 +439,18 @@ def control_file(source)
dir = addon_control_dir(src, cleanup: true)
fetch_package(src, package, dir)

path = File.join(dir, "installation.xml")
# lets first try FHS compliant path (bsc#1114573)
# sadly no glob escaping - https://bugs.ruby-lang.org/issues/8258
# but as we generate directory, it should be ok
files = Dir.glob("#{dir}/usr/share/system-roles/*.xml")
if files.size == 1
path = files.first
elsif files.size > 1
log.error "more then one file in system role #{files.inspect}"
path = files.first
else
path = File.join(dir, "installation.xml")
end
return nil unless File.exist?(path)

log.info("installation.xml path: #{path}")
Expand Down Expand Up @@ -1494,10 +1505,14 @@ def merge_product_workflow(product)
log.info "Merging #{product.label} workflow"

if merged_base_product
Yast::WorkflowManager.RemoveWorkflow(:package, 0, merged_base_product.installation_package)
Yast::WorkflowManager.RemoveWorkflow(
:package,
merged_base_product.installation_package_repo,
merged_base_product.installation_package
)
end

AddWorkflow(:package, 0, product.installation_package)
AddWorkflow(:package, product.installation_package_repo, product.installation_package)
MergeWorkflows()
RedrawWizardSteps()
self.merged_base_product = product
Expand Down Expand Up @@ -1604,12 +1619,18 @@ def package_repository(package_name)
if pkgs.empty?
log.warn("The installer extension package #{package_name} was not found")
return nil
elsif pkgs.size > 1
end

latest_package = pkgs.reduce(nil) do |a, p|
!a || (Pkg.CompareVersions(a["version"], p["version"]) < 0) ? p : a
end

if pkgs.size > 1
log.warn("More than one control package found: #{pkgs}")
log.warn("Using the first one: #{pkgs.first}")
log.info("Using the latest package: #{latest_package}")
end

pkgs.first["source"]
latest_package["source"]
end

# Download and extract a package from a repository.
Expand Down
1 change: 1 addition & 0 deletions library/control/test/Makefile.am
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
TESTS = \
InstExtensionImage_test.rb \
installation_test.rb \
ProductFeatures_test.rb \
workflow_manager_test.rb

Expand Down

0 comments on commit 22ee11f

Please sign in to comment.