Skip to content

Commit

Permalink
Merge pull request #148 from joseivanlopez/fix_user_commit
Browse files Browse the repository at this point in the history
Adapt the user client to the new Y2Users API
  • Loading branch information
joseivanlopez committed Jul 27, 2023
2 parents c074652 + 3dd967c commit a51f818
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 19 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Expand Up @@ -23,7 +23,7 @@ jobs:
uses: actions/checkout@v2

- name: Install Dependencies
run: zypper --non-interactive install --no-recommends yast2-configuration-management
run: zypper --non-interactive install --no-recommends yast2-configuration-management yast2-users

# just for easier debugging...
- name: Inspect Installed Packages
Expand Down
8 changes: 7 additions & 1 deletion package/yast2-firstboot.changes
@@ -1,9 +1,15 @@
-------------------------------------------------------------------
Thu Jul 27 08:28:30 UTC 2023 - José Iván López González <jlopez@suse.com>

- Adapt users client to the changes in yast2-users (related to
bsc#1206627).
- 4.6.1

-------------------------------------------------------------------
Mon Mar 13 09:42:19 UTC 2023 - Ladislav Slezák <lslezak@suse.com>

- Removed unnecessary executable flag from several files
(bsc#1209094)
- 4.6.1

-------------------------------------------------------------------
Fri Mar 03 14:44:07 UTC 2023 - Ladislav Slezák <lslezak@suse.cz>
Expand Down
5 changes: 4 additions & 1 deletion package/yast2-firstboot.spec
Expand Up @@ -17,7 +17,7 @@


Name: yast2-firstboot
Version: 4.6.0
Version: 4.6.1
Release: 0
Summary: YaST2 - Initial System Configuration
License: GPL-2.0-only
Expand Down Expand Up @@ -47,6 +47,9 @@ Recommends: (icewm if libyui-qt)
Supplements: autoyast(firstboot)
BuildArch: noarch

# New API for Y2Users::CommitConfig
Conflicts: yast2-users < 4.6.3

%description
The YaST firstboot utility runs after installation is completed. It
guides the user through a series of steps that allows for easier
Expand Down
18 changes: 9 additions & 9 deletions src/lib/y2firstboot/clients/user.rb
@@ -1,4 +1,4 @@
# Copyright (c) [2016-2021] SUSE LLC
# Copyright (c) [2016-2023] SUSE LLC
#
# All Rights Reserved.
#
Expand All @@ -21,7 +21,7 @@
require "y2users/password"
require "y2users/linux/writer"
require "y2users/config_manager"
require "y2users/commit_config_collection"
require "y2users/user_commit_config"
require "y2users/commit_config"
require "users/dialogs/inst_user_first"
require "pathname"
Expand Down Expand Up @@ -79,7 +79,7 @@ def write_config
writer = Y2Users::Linux::Writer.new(
config,
Y2Users::ConfigManager.instance.system,
commit_configs
commit_config
)

writer.write
Expand Down Expand Up @@ -147,11 +147,11 @@ def root_user
@root_user ||= config.users.root
end

# Builds the commit configs to use when writing users
# Builds the commit config to use when writing users
#
# @return [Y2Users::CommitConfigCollection]
def commit_configs
Y2Users::CommitConfigCollection.new.tap do |collection|
# @return [Y2Users::CommitConfig]
def commit_config
Y2Users::CommitConfig.new.tap do |commit_config|
# Configure the actions to perform when committing a user.
#
# - If the user is being created, its home should content the skel files
Expand All @@ -162,7 +162,7 @@ def commit_configs
# should be set as owner of the existing directory (#adapt_home_ownership option).
# - When deleting the user (i.e., when going back to skip the user creation after
# creating it), its home must be removed too (#remove_home).
commit_config = Y2Users::CommitConfig.new.tap do |config|
user_config = Y2Users::UserCommitConfig.new.tap do |config|
config.username = user.name
config.home_without_skel = false
config.move_home = true
Expand All @@ -173,7 +173,7 @@ def commit_configs
config.remove_home = true
end

collection.add(commit_config)
commit_config.user_configs.add(user_config)
end
end

Expand Down
14 changes: 7 additions & 7 deletions test/y2firstboot/clients/user_test.rb
@@ -1,6 +1,6 @@
#!/usr/bin/env rspec

# Copyright (c) [2018-2021] SUSE LLC
# Copyright (c) [2018-2023] SUSE LLC
#
# All Rights Reserved.
#
Expand Down Expand Up @@ -125,15 +125,15 @@
let(:writer) { instance_double(Y2Users::Linux::Writer) }

it "writes the config to the system" do
expect(Y2Users::Linux::Writer).to receive(:new) do |target, system, commit_configs|
expect(Y2Users::Linux::Writer).to receive(:new) do |target, system, commit_config|
expect(target).to eql(config)
expect(system).to eql(system_config)

commit_config = commit_configs.by_username(user.name)
expect(commit_config.move_home?).to eq(true)
expect(commit_config.remove_home?).to eq(true)
expect(commit_config.adapt_home_ownership?).to eq(true)
expect(commit_config.home_without_skel?).to eq(false)
user_config = commit_config.user_configs.by_username(user.name)
expect(user_config.move_home?).to eq(true)
expect(user_config.remove_home?).to eq(true)
expect(user_config.adapt_home_ownership?).to eq(true)
expect(user_config.home_without_skel?).to eq(false)
end.and_return(writer)

expect(writer).to receive(:write)
Expand Down

0 comments on commit a51f818

Please sign in to comment.