Skip to content

Commit

Permalink
WIP code review fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
lslezak committed Feb 17, 2020
1 parent fe28390 commit db41c2b
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 16 deletions.
34 changes: 20 additions & 14 deletions bin/yupdate
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,9 @@ Commands:
https://github.com/yast/yast-rake/#server),
the default port is 8000
servers <host[:port]> List the rake servers running on the remote machine
servers <host[:port]> List the rake servers running on the remote machine,
ask the specified server to report all `rake server`
instances
overlay create [<dir>] Create a new writable overlay for directory <dir>,
if no directory is specified it creates overlays
Expand Down Expand Up @@ -188,6 +190,7 @@ HELP
attr_reader :dir, :orig_dir

# manage the OverlayFS for this directory
# @param directory [String] the directory
def initialize(directory)
@orig_dir = directory
# expand symlinks
Expand Down Expand Up @@ -247,13 +250,6 @@ HELP
yast_overlays.map { |o| new(o) }
end

private

def dir_name
# escape (double) underscores for correct reverse conversion
dir.gsub("_", "__").tr("/", "_")
end

def upperdir
File.join(OVERLAY_PREFIX, "upper", dir_name)
end
Expand All @@ -266,6 +262,18 @@ HELP
File.join(OVERLAY_PREFIX, "original", dir_name)
end

def unescape_path(path)
Pathname.new(path).basename.to_s.gsub(/([^_])_([^_])/, "\\1/\\2")
.sub(/\A_/, "/").gsub("__", "_").gsub("//", "/")
end

private

def dir_name
# escape (double) underscores for correct reverse conversion
dir.gsub("_", "__").tr("/", "_")
end

# find the modified files in this directory
def modified_files(&block)
return unless block_given?
Expand Down Expand Up @@ -349,7 +357,7 @@ HELP
# pipe the response body directly to the tar process
IO.popen(["tar", "-C", dir, "--warning=no-timestamp", "-xz"], "wb") do |io|
response.read_body do |chunk|
io.write chunk
io.write(chunk)
end
end
end
Expand Down Expand Up @@ -563,9 +571,8 @@ HELP
# the script might not work as expected in an installed system
# and using OverlayFS is potentially dangerous
def self.check!
mounts = `mount`
# the inst-sys uses tmpfs (RAM disk) for the root
return if mounts =~ /^tmpfs on \/ type tmpfs/
# the inst-sys contains the /.packages.initrd file with a list of packages
return if File.exist?("/.packages.initrd")

# exit immediately if running in an installed system
$stderr.puts "ERROR: This script can only work in the installation system (inst-sys)!"
Expand Down Expand Up @@ -612,8 +619,7 @@ HELP

def run
host = @argv.shift

return 1 unless host
raise "Missing server name argument" unless host

servers = RemoteServer.find(host)
servers.each do |s|
Expand Down
6 changes: 4 additions & 2 deletions doc/yupdate.md
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ more details.*

#### Patching Multiple Packages

The `yast patch` command installs the sources from all running `rake server`
The `yupdate patch` command installs the sources from all running `rake server`
servers. If you need to update sources from several packages you can just
run `rake server` in all of them and install them with a single `yupdate`
call.
Expand Down Expand Up @@ -226,7 +226,9 @@ state.
3. Run a server, eg. with `ruby -run -e httpd -- -p 8888 .`
4. Type a loooong boot line to pass them all as DUD=http://....rpm
(or write that into a file and use the [info](
https://en.opensuse.org/SDB:Linuxrc#p_info) option)
https://en.opensuse.org/SDB:Linuxrc#p_info) option
or build a single DUD file from the RPMs with the [`mkdud`](
https://github.com/wfeldt/mkdud) script)

## Implementation Details

Expand Down

0 comments on commit db41c2b

Please sign in to comment.