six-rsync 0.4.3 → 0.4.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/Rakefile +1 -1
- data/lib/six/rsync/lib.rb +23 -12
- data/lib/six/rsync.rb +16 -17
- metadata +2 -2
data/Rakefile
CHANGED
data/lib/six/rsync/lib.rb
CHANGED
@@ -3,14 +3,10 @@
|
|
3
3
|
module Six
|
4
4
|
module Repositories
|
5
5
|
module Rsync
|
6
|
-
|
7
|
-
KEY = "C:/users/sb/documents/keys/id_rsa.ppk"
|
8
|
-
# TODO: Linux
|
9
|
-
RSH = "-r --rsh=\"'#{File.join(BASE_PATH, "tools", "bin", "cygnative.exe")}' plink.exe -i #{KEY}\""
|
10
|
-
|
6
|
+
REGEX_FOLDER = /(.*)[\\|\/](.*)/
|
11
7
|
DIR_RSYNC = '.rsync'
|
12
8
|
DIR_PACK = File.join(DIR_RSYNC, '.pack')
|
13
|
-
|
9
|
+
|
14
10
|
class RsyncExecuteError < StandardError; end
|
15
11
|
class RsyncError < StandardError; end
|
16
12
|
|
@@ -34,6 +30,15 @@ module Six
|
|
34
30
|
@verbose = true
|
35
31
|
@logger = logger
|
36
32
|
|
33
|
+
case RUBY_PLATFORM
|
34
|
+
when /-mingw32$/, /-mswin32$/
|
35
|
+
key = CONFIG[:key] ? CONFIG[:key] : ""
|
36
|
+
@rsh = "-r --rsh=\"'cygnative.exe' plink.exe#{" -i #{key}" unless key.empty?}\""
|
37
|
+
puts @rsh
|
38
|
+
else
|
39
|
+
@rsh = ""
|
40
|
+
end
|
41
|
+
|
37
42
|
@repos_local = {:pack => Hash.new, :wd => Hash.new, :version => 0}
|
38
43
|
@repos_remote = {:pack => Hash.new, :wd => Hash.new, :version => 0}
|
39
44
|
|
@@ -92,7 +97,7 @@ module Six
|
|
92
97
|
end
|
93
98
|
if File.exists? @rsync_work_dir
|
94
99
|
unless Dir[File.join(@rsync_work_dir, '*')].empty?
|
95
|
-
@logger.error "
|
100
|
+
@logger.error "Folder not empty, Aborting!"
|
96
101
|
raise RsyncError
|
97
102
|
end
|
98
103
|
end
|
@@ -173,7 +178,7 @@ module Six
|
|
173
178
|
arr_opts << PARAMS
|
174
179
|
arr_opts += x_opts
|
175
180
|
if host[/\A(\w)*\@/]
|
176
|
-
arr_opts <<
|
181
|
+
arr_opts << @rsh #"-e ssh"
|
177
182
|
end
|
178
183
|
arr_opts << esc(File.join(host, '.pack/.'))
|
179
184
|
arr_opts << esc(pack_path)
|
@@ -350,7 +355,7 @@ module Six
|
|
350
355
|
|
351
356
|
# Upload .pack changes
|
352
357
|
if host[/\A(\w)*\@/]
|
353
|
-
arr_opts <<
|
358
|
+
arr_opts << @rsh
|
354
359
|
end
|
355
360
|
arr_opts << esc(pack_path('.'))
|
356
361
|
arr_opts << esc(File.join(host, '.pack'))
|
@@ -405,7 +410,7 @@ module Six
|
|
405
410
|
arr_opts = []
|
406
411
|
arr_opts << PARAMS
|
407
412
|
if host[/\A(\w)*\@/]
|
408
|
-
arr_opts <<
|
413
|
+
arr_opts << @rsh
|
409
414
|
end
|
410
415
|
|
411
416
|
arr_opts << esc(File.join(host, '.pack/.'))
|
@@ -421,7 +426,7 @@ module Six
|
|
421
426
|
end
|
422
427
|
arr_opts = []
|
423
428
|
arr_opts << PARAMS
|
424
|
-
arr_opts <<
|
429
|
+
arr_opts << @rsh if host[/\A(\w)*\@/]
|
425
430
|
|
426
431
|
cyg_slist = "\"#{slist}\""
|
427
432
|
|
@@ -545,7 +550,7 @@ module Six
|
|
545
550
|
arr_opts = []
|
546
551
|
arr_opts << PARAMS
|
547
552
|
if host[/\A(\w)*\@/]
|
548
|
-
arr_opts <<
|
553
|
+
arr_opts << @rsh
|
549
554
|
end
|
550
555
|
arr_opts << esc(File.join(host, path))
|
551
556
|
arr_opts << esc(rsync_path(folder))
|
@@ -666,13 +671,19 @@ module Six
|
|
666
671
|
def zip7(file)
|
667
672
|
out = %x[7z x #{esc(file)} -y]
|
668
673
|
@logger.debug out
|
674
|
+
raise RsyncError if $? != 0
|
669
675
|
out
|
670
676
|
end
|
671
677
|
|
672
678
|
def gzip(file)
|
679
|
+
unless @gzip_installed ||= begin; %x[gzip --rsyncable]; $? == 0; rescue; false; end
|
680
|
+
puts "gzip command not found, or doesn't support --rsyncable"
|
681
|
+
raise RsyncError
|
682
|
+
end
|
673
683
|
@logger.debug "Gzipping #{file}"
|
674
684
|
out = %x[gzip -f --best --rsyncable --keep #{esc(file)}]
|
675
685
|
@logger.debug out
|
686
|
+
raise RsyncError if $? != 0
|
676
687
|
end
|
677
688
|
|
678
689
|
def unpack_file(file, path)
|
data/lib/six/rsync.rb
CHANGED
@@ -30,12 +30,11 @@ module Six
|
|
30
30
|
end
|
31
31
|
|
32
32
|
module Rsync
|
33
|
-
VERSION = '0.4.
|
33
|
+
VERSION = '0.4.4'
|
34
34
|
FOLDER = /(.*)\/(.*)/
|
35
35
|
|
36
36
|
case RUBY_PLATFORM
|
37
|
-
when
|
38
|
-
HOME_PATH = File.join(ENV['APPDATA'])
|
37
|
+
when /-mingw32$/, /-mswin32$/
|
39
38
|
TEMP_PATH = if ENV['TEMP']
|
40
39
|
if ENV['TEMP'].size > 0
|
41
40
|
if File.directory?(ENV['TEMP'])
|
@@ -49,29 +48,29 @@ module Six
|
|
49
48
|
else
|
50
49
|
BASE_PATH
|
51
50
|
end
|
52
|
-
|
53
|
-
TOOLS_PATH = File.join(BASE_PATH, 'tools')
|
54
|
-
ENV['PATH'] = "#{TOOLS_PATH};#{File.join(TOOLS_PATH, 'bin')};#{ENV['PATH']}"
|
55
|
-
|
56
|
-
etc = File.join(TOOLS_PATH, 'etc')
|
57
|
-
FileUtils.mkdir_p etc
|
58
|
-
fstab = File.join(etc, 'fstab')
|
59
|
-
str = ""
|
60
|
-
str = File.open(fstab) {|file| file.read} if File.exists?(fstab)
|
61
|
-
unless str[/cygdrive/]
|
62
|
-
str += "\nnone /cygdrive cygdrive user,noacl,posix=0 0 0\n"
|
63
|
-
File.open(fstab, 'w') {|file| file.puts str}
|
64
|
-
end
|
51
|
+
HOME_PATH = File.exists?(File.join(ENV['APPDATA'])) ? File.join(ENV['APPDATA']) : TEMP_PATH
|
65
52
|
else
|
66
53
|
HOME_PATH = '~'
|
67
54
|
TEMP_PATH = '/tmp'
|
68
55
|
end
|
69
56
|
DATA_PATH = File.join(HOME_PATH, 'six-rsync')
|
57
|
+
CONFIG_FILE = File.join(DATA_PATH, 'config.yml')
|
58
|
+
if File.exists?(DATA_PATH)
|
59
|
+
unless File.directory?(DATA_PATH)
|
60
|
+
puts "#{DATA_PATH} is a file instead of folder"
|
61
|
+
raise StandardError
|
62
|
+
end
|
63
|
+
else
|
64
|
+
FileUtils.mkdir_p DATA_PATH
|
65
|
+
end
|
66
|
+
config = File.exists?(CONFIG_FILE) ? YAML::load_file(CONFIG_FILE) : nil
|
67
|
+
CONFIG = config ? config : Hash.new
|
70
68
|
|
69
|
+
# which rsync - should return on linux the bin location
|
71
70
|
rsync_installed = begin; %x[rsync --version]; true; rescue; false; end
|
72
71
|
unless rsync_installed
|
73
72
|
puts "rsync command not found"
|
74
|
-
|
73
|
+
raise RsyncError
|
75
74
|
end
|
76
75
|
|
77
76
|
# No meaning on Cygwin 1.7
|