Skip to content

Commit

Permalink
Merge 2097084 into 6e4534a
Browse files Browse the repository at this point in the history
  • Loading branch information
teclator committed Jul 17, 2020
2 parents 6e4534a + 2097084 commit 5bf1e9b
Show file tree
Hide file tree
Showing 15 changed files with 326 additions and 161 deletions.
16 changes: 12 additions & 4 deletions .rubocop.yml
Original file line number Diff line number Diff line change
@@ -1,17 +1,25 @@
# use the shared YaST defaults
inherit_from:
/usr/share/YaST2/data/devtools/data/rubocop_yast_style.yml
/usr/share/YaST2/data/devtools/data/rubocop-0.71.0_yast_style.yml

# We need to be sure that everything works fine before enabling it
Style/FrozenStringLiteralComment:
Enabled: false

# Don't enforce any particular name for block params
SingleLineBlockParams:
Enabled: false

# Enforce if/unless at the end only for really short lines
Style/IfUnlessModifier:
MaxLineLength: 60
Metrics/BlockLength:
Max: 90

# Configuration parameters: CountComments.
Metrics/MethodLength:
Max: 40

AllCops:
Exclude:
- 'package/*.spec'
- 'src/modules/**/*'
- 'src/include/**/*'
- 'testsuite/**/*'
Expand Down
6 changes: 6 additions & 0 deletions package/yast2-firstboot.changes
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
-------------------------------------------------------------------
Thu Jul 16 09:15:57 UTC 2020 - Knut Anderssen <kanderssen@suse.com>

- Fix firsboot_hostname client crash (bsc#1173298)
- 4.2.15

-------------------------------------------------------------------
Wed Apr 8 15:15:32 UTC 2020 - Stefan Hundhammer <shundhammer@suse.com>

Expand Down
6 changes: 3 additions & 3 deletions package/yast2-firstboot.spec
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
#

Name: yast2-firstboot
Version: 4.2.14
Version: 4.2.15
Release: 0
Summary: YaST2 - Initial System Configuration
Group: System/YaST
Expand All @@ -38,8 +38,8 @@ Requires: yast2 >= 2.16.23
Requires: yast2-country >= 2.19.5
# Rely on the YaST2-Firstboot.service for halting the system on failure
Requires: yast2-installation >= 4.1.2
# Updated DNS API (unneeded write_hostname= method does not exist anymore)
Requires: yast2-network >= 4.2.14
# Use Yast::Lan.write_config to write hostname changes
Requires: yast2-network >= 4.2.74
Requires: yast2-ruby-bindings >= 1.0.0
Requires: yast2-configuration-management >= 4.1.3

Expand Down
1 change: 1 addition & 0 deletions src/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ ylibclientdir = "${yast2dir}/lib/y2firstboot/clients"
ylibclient_DATA = \
lib/y2firstboot/clients/configuration_management.rb \
lib/y2firstboot/clients/firstboot_ssh.rb \
lib/y2firstboot/clients/hostname.rb \
lib/y2firstboot/clients/root.rb \
lib/y2firstboot/clients/user.rb \
lib/y2firstboot/clients/licenses.rb
Expand Down
145 changes: 2 additions & 143 deletions src/clients/firstboot_hostname.rb
Original file line number Diff line number Diff line change
@@ -1,144 +1,3 @@
# encoding: utf-8
require "y2firstboot/clients/hostname"

#***************************************************************************
#
# Copyright (c) 2015 SUSE LLC
# All Rights Reserved.
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of version 2 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 Novell, Inc.
#
# To contact SUSE about this file by physical or electronic mail,
# you may find current contact information at www.suse.com
#
#**************************************************************************
#
module Yast
# Client to set the hostname during first boot
#
# This is just a renamed version of InstHostnameClient, which was removed from
# YaST2-Network when the second stage was removed from the installation
# process
class FirstbootHostnameClient < Client
class << self
# @!method valid_dns_proposal=(value)
# @param [Boolean] Whether a valid DNS proposal was done
attr_writer :valid_dns_proposal

# Determines whether a valid DNS proposal was done
#
# @return [Boolean] Returns true if a DNS proposal was done
def valid_dns_proposal
@valid_dns_proposal ||= false
end
end

def main
Yast.import "UI"

textdomain "firstboot"

Yast.import "Arch"
Yast.import "DNS"
Yast.import "Host"
Yast.import "NetworkConfig"
Yast.import "String"
Yast.import "Wizard"
Yast.import "ProductControl"
Yast.import "ProductFeatures"
Yast.import "GetInstArgs"

Yast.include self, "network/services/dns.rb"

# only once, do not re-propose if user gets back to this dialog from
# the previous screen - bnc#438124
if !self.class.valid_dns_proposal
DNS.Read # handles NetworkConfig too
DNS.ProposeHostname # generate random hostname, if none known so far

# propose settings
DNS.dhcp_hostname = !Arch.is_laptop
end

Wizard.SetDesktopIcon("org.opensuse.yast.DNS")
ret = HostnameDialog()

if ret == :next
Host.Read
Host.ResolveHostnameToStaticIPs
Host.Write

# do not let Lan override us, #152218
self.class.valid_dns_proposal = true

# In InstHostname writing was delayed to do it with the rest of
# network configuration in lan_proposal.
# In FirstbootHostname it's probably safer to do it right away.
DNS.Write
end

ret
end

def HostnameDialog
@has_dhcp = true

@hn_settings = InitSettings()

functions = {
"init" => fun_ref(method(:InitHnWidget), "void (string)"),
"store" => fun_ref(method(:StoreHnWidget), "void (string, map)"),
:abort => fun_ref(method(:ReallyAbortInst), "boolean ()")
}
contents = HSquash(
# Frame label
Frame(
_("Hostname and Domain Name"),
VBox(
Left("HOSTNAME"),
Left("DHCP_HOSTNAME")
)
)
)

ret = CWM.ShowAndRun(
"widget_descr" => @widget_descr_dns,
"contents" => contents,
# dialog caption
"caption" => _("Hostname and Domain Name"),
"back_button" => Label.BackButton,
"next_button" => Label.NextButton,
"fallback_functions" => functions,
"disable_buttons" => GetInstArgs.enable_back ? [] : ["back_button"]
)

if ret == :next
# Pre-populate resolv.conf search list with current domain name
# but only if none exists so far
current_domain = Ops.get_string(@hn_settings, "DOMAIN", "")

# Need to modify hn_settings explicitly as SEARCHLIST_S widget
# does not exist in this dialog, thus StoreHnWidget won't do it
# #438167
if DNS.searchlist == [] && current_domain != "site"
Ops.set(@hn_settings, "SEARCHLIST_S", current_domain)
end

StoreSettings(@hn_settings)
end

ret
end
end
end

Yast::FirstbootHostnameClient.new.main
Y2Firstboot::Clients::Hostname.new.run
8 changes: 5 additions & 3 deletions src/lib/y2firstboot/clients/configuration_management.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
# encoding: utf-8

# Copyright (c) [2018] SUSE LLC
#
# All Rights Reserved.
Expand Down Expand Up @@ -36,6 +34,7 @@ def run
configurator = Y2ConfigurationManagement::Configurators::Base.for(config)
result = configurator.prepare(reverse: Yast::GetInstArgs.going_back)
return result unless result == :finish

provision ? :next : :abort
end

Expand All @@ -48,6 +47,7 @@ def provision
if !Yast::PackageSystem.CheckAndInstallPackages(configurator.packages.fetch("install", []))
return false
end

Y2ConfigurationManagement::Clients::Provision.new.run
end

Expand All @@ -63,15 +63,17 @@ def provision
def config
current_config = Y2ConfigurationManagement::Configurations::Base.current
return current_config if current_config

settings = Yast::ProductFeatures.GetSection("configuration_management")
.merge(FIXED_SETTINGS)
.merge(FIXED_SETTINGS)
Y2ConfigurationManagement::Configurations::Base.current =
Y2ConfigurationManagement::Configurations::Base.import(settings)
end

def configurator
current_configurator = Y2ConfigurationManagement::Configurators::Base.current
return current_configurator if current_configurator

Y2ConfigurationManagement::Configurators::Base.current =
Y2ConfigurationManagement::Configurators::Base.for(config)
end
Expand Down

0 comments on commit 5bf1e9b

Please sign in to comment.