From cf0846acd3d413e9eeafb5290042a863185ef502 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ladislav=20Slez=C3=A1k?= Date: Wed, 4 Jan 2023 16:40:17 +0100 Subject: [PATCH 1/5] yupdate - allow patching the D-Installer --- bin/yupdate | 42 ++++++++++++++++++++++++++++++----- test/yupdate/inst_sys_test.rb | 20 +++++++++++++++-- 2 files changed, 54 insertions(+), 8 deletions(-) diff --git a/bin/yupdate b/bin/yupdate index 3e40be234..c9babc27c 100755 --- a/bin/yupdate +++ b/bin/yupdate @@ -109,10 +109,16 @@ module YUpdate # a simple /etc/install.inf parser/writer, # we need to disable the YaST self-update feature to avoid conflicts class InstallInf + PATH = "/etc/install.inf".freeze + attr_reader :path + def self.exist?(path = PATH) + File.exist?(path) + end + # read the file - def initialize(path = "/etc/install.inf") + def initialize(path = PATH) @path = path @values = File.read(path).lines.map(&:chomp) end @@ -566,8 +572,8 @@ module YUpdate end end - # inst-sys test - class InstSys + # inst-sys or live medium test + class System # check if the script is running in the inst-sys, # the script might not work as expected in an installed system # and using OverlayFS is potentially dangerous @@ -575,8 +581,11 @@ module YUpdate # the inst-sys contains the /.packages.initrd file with a list of packages return if File.exist?("/.packages.initrd") + # live medium uses overlay FS for the root + return if `mount`.match?(/^\w+ on \/ type overlay/) + # exit immediately if running in an installed system - warn "ERROR: This script can only work in the installation system (inst-sys)!" + warn "ERROR: This script can only work in the installation system (inst-sys) or Live medium!" exit 1 end end @@ -590,10 +599,10 @@ module YUpdate when "version" VersionCommand.new when "overlay" - InstSys.check! + System.check! OverlayCommand.new(argv) when "patch" - InstSys.check! + System.check! PatchCommand.new(argv) when "servers" ServersCommand.new(argv) @@ -700,10 +709,29 @@ module YUpdate g.install_required_gems end + def run_pre_script(download_dir) + script = File.join(download_dir, ".yupdate.pre") + run_script(script) + end + + def run_post_script(download_dir) + script = File.join(download_dir, ".yupdate.post") + run_script(script) + end + + def run_script(script) + return unless File.exist?(script) + + puts "Running script #{File.basename(script)}..." + raise "Script #{File.basename(script)} failed" unless system(script) + end + def install_tar(downloader) Dir.mktmpdir do |download_dir| downloader.extract_to(download_dir) + run_pre_script(download_dir) install_sources(download_dir) + run_post_script(download_dir) end end @@ -712,6 +740,8 @@ module YUpdate # disable the self update in the install.inf file def disable_self_update + return unless InstallInf.exist? + inf = InstallInf.new return if inf[SELF_UPDATE_KEY] == "0" diff --git a/test/yupdate/inst_sys_test.rb b/test/yupdate/inst_sys_test.rb index 1375256bd..47d486534 100755 --- a/test/yupdate/inst_sys_test.rb +++ b/test/yupdate/inst_sys_test.rb @@ -3,9 +3,14 @@ require_relative "../test_helper" require_yupdate -describe YUpdate::InstSys do +describe YUpdate::System do let(:file) { "/.packages.initrd" } + before do + allow(File).to receive(:exist?).with(file).and_return(false) + allow(described_class).to receive(:`).with("mount").and_return("") + end + describe ".check!" do context "when running in an inst-sys" do before do @@ -18,9 +23,20 @@ end end + context "when running on a live medium" do + before do + expect(described_class).to receive(:`).with("mount") + .and_return("LiveOS_rootfs on / type overlay (rw,relatime)") + end + + it "does not exit" do + expect(described_class).to_not receive(:exit) + described_class.check! + end + end + context "when running in a normal system" do before do - expect(File).to receive(:exist?).with(file).and_return(false) allow(described_class).to receive(:exit).with(1) end From 4c25dbeee803dfd965b89269fd395cfc3aeb5425 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ladislav=20Slez=C3=A1k?= Date: Fri, 6 Jan 2023 13:27:00 +0100 Subject: [PATCH 2/5] yupdate - allow verbose installation --- bin/yupdate | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/bin/yupdate b/bin/yupdate index c9babc27c..109598ed3 100755 --- a/bin/yupdate +++ b/bin/yupdate @@ -482,7 +482,10 @@ module YUpdate src_dir = File.dirname(rakefile) Dir.chdir(src_dir) do - `rake install DESTDIR=#{target.shellescape} 2> /dev/null` + redir = ENV["VERBOSE"] == "1" ? "" : " > /dev/null 2>&1" + unless system("rake install DESTDIR=#{target.shellescape} #{redir}") + raise "rake install failed" + end end end From ced89d79fb65b96dc0c980ab26bfe3e32d521712 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ladislav=20Slez=C3=A1k?= Date: Fri, 6 Jan 2023 13:35:50 +0100 Subject: [PATCH 3/5] 4.5.12 --- package/yast2-installation.changes | 7 +++++++ package/yast2-installation.spec | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/package/yast2-installation.changes b/package/yast2-installation.changes index a4cba2b0e..0590591af 100644 --- a/package/yast2-installation.changes +++ b/package/yast2-installation.changes @@ -1,3 +1,10 @@ +------------------------------------------------------------------- +Fri Jan 6 12:33:29 UTC 2023 - Ladislav Slezák + +- yupdate - added suport for patching the D-Installer + (bsc#1206927) +- 4.5.12 + ------------------------------------------------------------------- Mon Dec 5 10:13:28 UTC 2022 - Stefan Hundhammer diff --git a/package/yast2-installation.spec b/package/yast2-installation.spec index 5c7914667..03aca70dd 100644 --- a/package/yast2-installation.spec +++ b/package/yast2-installation.spec @@ -16,7 +16,7 @@ # Name: yast2-installation -Version: 4.5.11 +Version: 4.5.12 Release: 0 Summary: YaST2 - Installation Parts License: GPL-2.0-only From cd99063a0f630af6aca79653b086fd6a71e034db Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ladislav=20Slez=C3=A1k?= Date: Fri, 6 Jan 2023 13:58:49 +0100 Subject: [PATCH 4/5] yupdate - update documentation --- doc/yupdate.md | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/doc/yupdate.md b/doc/yupdate.md index 575d61b40..57ff08835 100644 --- a/doc/yupdate.md +++ b/doc/yupdate.md @@ -223,6 +223,28 @@ state. AutoYaST second stage cannot be fixed by `yupdate`, you need to build a DUD, see below. +## Hooks + +The source code might contain several callback scripts which are executed +at specific points. The goal is to allow adjusting the target system before +or after installing new files. + +- `.yupdate.pre` - This script is executed *before* installing the package (before + running `rake install`). It can prepare the system for installation, install + required packages. +- `.yupdate.post` - This script is executed *after* installing the package (after + running `rake install`). It can activate the changes, restart services. + +When a hook script fails then yupdate aborts the update process immediately. + +## Environment Variables + +The yupdate script uses these environment variables: + +- `VERBOSE` - When set to `1` the output of the `rake install` command is + displayed in the terminal. By default it is hidden because the output is too + long and verbose. Use this option for debugging installation problems. + ## Alternative 1. For all repos, run `rake osc:build` From a9e06fba27d6749f3b9d16f58787e5be13c2c0a2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ladislav=20Slez=C3=A1k?= Date: Fri, 6 Jan 2023 14:02:59 +0100 Subject: [PATCH 5/5] bump yupdate version --- bin/yupdate | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bin/yupdate b/bin/yupdate index 109598ed3..b9cfc7854 100755 --- a/bin/yupdate +++ b/bin/yupdate @@ -34,8 +34,8 @@ module YUpdate # version of the script class Version MAJOR = 0 - MINOR = 1 - PATCH = 3 + MINOR = 2 + PATCH = 0 STRING = "#{MAJOR}.#{MINOR}.#{PATCH}".freeze end