Skip to content

Instantly share code, notes, and snippets.

@mvidner
Created November 2, 2018 11:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mvidner/0f4844437169e6669d2b72ece0c0485a to your computer and use it in GitHub Desktop.
Save mvidner/0f4844437169e6669d2b72ece0c0485a to your computer and use it in GitHub Desktop.
diff --git a/src/clients/inst_kickoff.rb b/src/clients/inst_kickoff.rb
index 581f3554..ba4a2ff4 100644
--- a/src/clients/inst_kickoff.rb
+++ b/src/clients/inst_kickoff.rb
@@ -78,11 +78,11 @@ module Yast
# make some directories
SCR.Execute(
path(".target.mkdir"),
- Ops.add(Installation.destdir, "/etc")
+ Installation.destdir + "/etc"
)
SCR.Execute(
path(".target.mkdir"),
- Ops.add(Installation.destdir, Directory.logdir)
+ Installation.destdir + Directory.logdir
)
# fake mtab on target system
@@ -102,7 +102,7 @@ module Yast
SCR.Execute(
path(".target.mkdir"),
- Ops.add(Installation.destdir, Installation.update_backup_path)
+ Installation.destdir + Installation.update_backup_path
)
backup_stuff
createmdadm
@@ -113,11 +113,11 @@ module Yast
# make some directories
SCR.Execute(
path(".target.mkdir"),
- Ops.add(Installation.destdir, Directory.logdir)
+ Installation.destdir + Directory.logdir
)
SCR.Execute(
path(".target.mkdir"),
- Ops.add(Installation.destdir, Installation.update_backup_path)
+ Installation.destdir + Installation.update_backup_path
)
# backup some stuff
@@ -126,12 +126,12 @@ module Yast
# set update mode to yes
SCR.Write(
path(".target.string"),
- Ops.add(Installation.destdir, "/var/lib/YaST2/update_mode"),
+ Installation.destdir + "/var/lib/YaST2/update_mode",
"YES"
)
SCR.Execute(
path(".target.remove"),
- Ops.add(Installation.destdir, "/var/lib/YaST/update.inf")
+ Installation.destdir + "/var/lib/YaST/update.inf"
)
# create /etc/mdadm.conf if it does not exist
@@ -156,14 +156,14 @@ module Yast
Pkg.SetBackupPath(Installation.update_backup_path)
SCR.Write(
path(".target.string"),
- Ops.add(Installation.destdir, "/var/lib/YaST2/backup_path"),
+ Installation.destdir + "/var/lib/YaST2/backup_path",
Installation.update_backup_path
)
else
Pkg.CreateBackups(false)
SCR.Execute(
path(".target.remove"),
- Ops.add(Installation.destdir, "/var/lib/YaST2/backup_path")
+ Installation.destdir + "/var/lib/YaST2/backup_path"
)
end
@@ -175,19 +175,7 @@ module Yast
)
SCR.Execute(
path(".target.bash"),
- Ops.add(
- Ops.add(
- Ops.add(
- Ops.add(
- Ops.add("cd '", String.Quote(Installation.destdir)),
- "'; "
- ),
- "/bin/rm -f "
- ),
- Installation.update_backup_path
- ),
- "/*-*-*.tar.{gz,bz2}"
- )
+ "cd '" + String.Quote(Installation.destdir) + "'; " + "/bin/rm -f " + Installation.update_backup_path + "/*-*-*.tar.{gz,bz2}"
)
end
@@ -199,27 +187,15 @@ module Yast
filename = ""
num = 0
- while Ops.less_than(num, 42)
- filename = Ops.add(
- Ops.add(
- Ops.add(
- Ops.add(
- Ops.add(Installation.update_backup_path, "/YaST2-"),
- date
- ),
- "-"
- ),
- Builtins.sformat("%1", num)
- ),
- ".tar.gz"
- )
+ while num < 42
+ filename = Installation.update_backup_path + "/YaST2-" + date + "-" + Builtins.sformat("%1", num) + ".tar.gz"
if SCR.Read(
path(".target.size"),
- Ops.add(Installation.destdir, filename)
+ Installation.destdir + filename
) == -1
break
end
- num = Ops.add(num, 1)
+ num += 1
end
if SCR.Execute(
@@ -237,77 +213,38 @@ module Yast
Builtins.sformat(
_("Backup of %1 failed. See %2 for details."),
Directory.logdir,
- Ops.add(Directory.logdir, "/y2log")
+ Directory.logdir + "/y2log"
)
)
else
SCR.Execute(
path(".target.bash"),
- Ops.add(
- Ops.add(
- Ops.add("cd '", String.Quote(Installation.destdir)),
- "'; "
- ),
- "/bin/rm -rf var/log/YaST2/*"
- )
+ "cd '" + String.Quote(Installation.destdir) + "'; " + "/bin/rm -rf var/log/YaST2/*"
)
end
if Installation.update_backup_sysconfig
# backup /etc/sysconfig
- if Ops.greater_than(
- SCR.Read(
- path(".target.size"),
- Ops.add(Installation.destdir, "/etc/sysconfig")
- ),
- 0
- )
+ if SCR.Read(path(".target.size"), Installation.destdir + "/etc/sysconfig") > 0
Builtins.y2milestone("backup of /etc/sysconfig")
filename = ""
num = 0
- while Ops.less_than(num, 42)
- filename = Ops.add(
- Ops.add(
- Ops.add(
- Ops.add(
- Ops.add(Installation.update_backup_path, "/etc.sysconfig-"),
- date
- ),
- "-"
- ),
- Builtins.sformat("%1", num)
- ),
- ".tar.gz"
- )
+ while num < 42
+ filename = Installation.update_backup_path + "/etc.sysconfig-" + date + "-" + Builtins.sformat("%1", num) + ".tar.gz"
if SCR.Read(
path(".target.size"),
- Ops.add(Installation.destdir, filename)
+ Installation.destdir + filename
) == -1
break
end
- num = Ops.add(num, 1)
+ num += 1
end
if SCR.Execute(
path(".target.bash"),
- Ops.add(
- Ops.add(
- Ops.add(
- Ops.add(
- Ops.add(
- Ops.add("cd '", String.Quote(Installation.destdir)),
- "'; "
- ),
- "/bin/tar czf ."
- ),
- filename
- ),
- " "
- ),
- "etc/sysconfig"
- )
+ "cd '" + String.Quote(Installation.destdir) + "'; " + "/bin/tar czf ." + filename + " " + "etc/sysconfig"
).nonzero?
Builtins.y2error(
"backup of %1 to %2 failed",
@@ -319,71 +256,32 @@ module Yast
Builtins.sformat(
_("Backup of %1 failed. See %2 for details."),
"/etc/sysconfig",
- Ops.add(Directory.logdir, "/y2log")
+ Directory.logdir + "/y2log"
)
)
end
# backup of /etc/rc.config*
- elsif Ops.greater_than(
- SCR.Read(
- path(".target.size"),
- Ops.add(Installation.destdir, "/etc/rc.config")
- ),
- 0
- ) &&
- Ops.greater_than(
- SCR.Read(
- path(".target.size"),
- Ops.add(Installation.destdir, "/etc/rc.config.d")
- ),
- 0
- )
+ elsif SCR.Read(path(".target.size"), Installation.destdir + "/etc/rc.config") > 0 &&
+ SCR.Read(path(".target.size"), Installation.destdir + "/etc/rc.config.d") > 0
Builtins.y2milestone("backup of /etc/rc.config.d")
filename = ""
num = 0
- while Ops.less_than(num, 42)
- filename = Ops.add(
- Ops.add(
- Ops.add(
- Ops.add(
- Ops.add(Installation.update_backup_path, "/etc.rc.config-"),
- date
- ),
- "-"
- ),
- Builtins.sformat("%1", num)
- ),
- ".tar.gz"
- )
+ while num < 42
+ filename = Installation.update_backup_path + "/etc.rc.config-" + date + "-" + Builtins.sformat("%1", num) + ".tar.gz"
if SCR.Read(
path(".target.size"),
- Ops.add(Installation.destdir, filename)
+ Installation.destdir + filename
) == -1
break
end
- num = Ops.add(num, 1)
+ num += 1
end
if SCR.Execute(
path(".target.bash"),
- Ops.add(
- Ops.add(
- Ops.add(
- Ops.add(
- Ops.add(
- Ops.add("cd '", String.Quote(Installation.destdir)),
- "'; "
- ),
- "/bin/tar czf ."
- ),
- filename
- ),
- " "
- ),
- "etc/rc.config etc/rc.config.d"
- )
+ "cd '" + String.Quote(Installation.destdir) + "'; " + "/bin/tar czf ." + filename + " " + "etc/rc.config etc/rc.config.d"
).nonzero?
Builtins.y2error(
"backup of %1 to %2 failed",
@@ -395,7 +293,7 @@ module Yast
Builtins.sformat(
_("Backup of %1 failed. See %2 for details."),
"/etc/rc.config",
- Ops.add(Directory.logdir, "/y2log")
+ Directory.logdir + "/y2log"
)
)
end
@@ -408,24 +306,12 @@ module Yast
filename = ""
num = 0
- while Ops.less_than(num, 42)
- filename = Ops.add(
- Ops.add(
- Ops.add(
- Ops.add(
- Ops.add(Installation.update_backup_path, "/etc.pam.d-"),
- date
- ),
- "-"
- ),
- Builtins.sformat("%1", num)
- ),
- ".tar.gz"
- )
+ while num < 42
+ filename = Installation.update_backup_path + "/etc.pam.d-" + date + "-" + Builtins.sformat("%1", num) + ".tar.gz"
# avoid from filename conflicts
- break if !FileUtils.Exists(Ops.add(Installation.destdir, filename))
- num = Ops.add(num, 1)
+ break if !FileUtils.Exists(Installation.destdir + filename)
+ num += 1
end
what_to_backup = "etc/pam.d etc/security etc/securetty etc/environment"
@@ -442,7 +328,7 @@ module Yast
Builtins.y2milestone(
"Creating backup of %1 in %2",
what_to_backup,
- Ops.add(Installation.destdir, filename)
+ Installation.destdir + filename
)
if SCR.Execute(path(".target.bash"), cmd).nonzero?
@@ -452,7 +338,7 @@ module Yast
Builtins.sformat(
_("Backup of %1 failed. See %2 for details."),
"/etc/pam.d",
- Ops.add(Directory.logdir, "/y2log")
+ Directory.logdir + "/y2log"
)
)
end
@@ -464,7 +350,7 @@ module Yast
# Create /etc/mdadm.conf if it does not exist and it's needed
# bugs: #169710 and #146304
def createmdadm
- mdamd_configfile = Ops.add(Installation.destdir, "/etc/mdadm.conf")
+ mdamd_configfile = Installation.destdir + "/etc/mdadm.conf"
# File exists, no need to create it
if FileUtils.Exists(mdamd_configfile)
Builtins.y2milestone(
@@ -477,13 +363,7 @@ module Yast
out = Convert.to_map(
SCR.Execute(
path(".target.bash_output"),
- Ops.add(
- Ops.add(
- Ops.add("chroot '", String.Quote(Installation.destdir)),
- "' "
- ),
- "mdadm -Ds"
- )
+ "chroot '" + String.Quote(Installation.destdir) + "' " + "mdadm -Ds"
)
)
if Ops.get_integer(out, "exit", -1).nonzero?
@@ -502,10 +382,7 @@ module Yast
end
# File format defined in bug #146304
- mdadm_content = Ops.add(
- Ops.add("DEV partitions\n", Ops.get_string(out, "stdout", "")),
- "\n"
- )
+ mdadm_content = "DEV partitions\n" + Ops.get_string(out, "stdout", "") + "\n"
Builtins.y2milestone("/etc/mdadm.conf doesn't exist, creating it")
if !SCR.Write(path(".target.string"), mdamd_configfile, mdadm_content)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment