six-updater 0.19.4 → 0.19.5
Sign up to get free protection for your applications and to get access to all the features.
- data/Rakefile +3 -3
- data/lib/six/cleanup.rb +55 -64
- data/lib/six/updater.rb +1 -1
- metadata +2 -2
data/Rakefile
CHANGED
@@ -13,7 +13,7 @@ require 'rake/testtask'
|
|
13
13
|
spec = Gem::Specification.new do |s|
|
14
14
|
s.platform = "x86-mingw32"
|
15
15
|
s.name = 'six-updater'
|
16
|
-
s.version = '0.19.
|
16
|
+
s.version = '0.19.5'
|
17
17
|
s.has_rdoc = true
|
18
18
|
s.extra_rdoc_files = ['README', 'LICENSE']
|
19
19
|
s.summary = 'Your summary here'
|
@@ -35,7 +35,7 @@ end
|
|
35
35
|
spec3 = Gem::Specification.new do |s|
|
36
36
|
s.platform = "x86-mswin32"
|
37
37
|
s.name = 'six-updater'
|
38
|
-
s.version = '0.19.
|
38
|
+
s.version = '0.19.5'
|
39
39
|
s.has_rdoc = true
|
40
40
|
s.extra_rdoc_files = ['README', 'LICENSE']
|
41
41
|
s.summary = 'Your summary here'
|
@@ -56,7 +56,7 @@ end
|
|
56
56
|
|
57
57
|
spec2 = Gem::Specification.new do |s|
|
58
58
|
s.name = 'six-updater'
|
59
|
-
s.version = '0.19.
|
59
|
+
s.version = '0.19.5'
|
60
60
|
s.has_rdoc = true
|
61
61
|
s.extra_rdoc_files = ['README', 'LICENSE']
|
62
62
|
s.summary = 'Your summary here'
|
data/lib/six/cleanup.rb
CHANGED
@@ -15,95 +15,86 @@ module Six
|
|
15
15
|
r[/\A\w*/]
|
16
16
|
end
|
17
17
|
|
18
|
-
def self.
|
19
|
-
|
20
|
-
entry = File.join(dir, ".repository.yml")
|
21
|
-
if File.exists?(entry)
|
22
|
-
#puts "Processing: #{entry}"
|
23
|
-
config = YAML::load_file(entry)
|
24
|
-
[:pack, :wd].each do |typ|
|
25
|
-
ar = []
|
26
|
-
config[typ].each do |e|
|
27
|
-
sum = if repack && e[0] =~ /.*[A-Z].*\.gz$/
|
28
|
-
Dir.chdir(dir) do
|
29
|
-
puts "Repacking #{e[0]} to #{e[0].downcase} in #{dir}"
|
30
|
-
system "gzip -d \"#{e[0]}\""
|
31
|
-
f = e[0].clone
|
32
|
-
f.sub!(/\.gz$/, "")
|
33
|
-
|
34
|
-
target = if File.dirname(f) == "."
|
35
|
-
f.downcase
|
36
|
-
else
|
37
|
-
"#{File.dirname(f)}/#{File.basename(f).downcase}"
|
38
|
-
end
|
39
|
-
rename(f, target)
|
40
|
-
system "gzip --rsyncable --best \"#{target}\""
|
41
|
-
md5sum(File.join(dir, "#{target}.gz"))
|
42
|
-
end
|
43
|
-
else
|
44
|
-
e[1]
|
45
|
-
end
|
46
|
-
ar << [e[0].downcase, sum]
|
47
|
-
end
|
48
|
-
config[typ] = ar
|
49
|
-
end
|
50
|
-
File.open(entry, 'w') {|f| f.puts config.to_yaml }#.to_s
|
51
|
-
end
|
18
|
+
def self.process(dir, repack = false)
|
19
|
+
return unless File.directory?(dir)
|
52
20
|
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
21
|
+
repos = []
|
22
|
+
# Handle folder and file renames, in reverse, and . and .. excluded
|
23
|
+
Dir.glob(File.join(dir, '**', '*'), File::FNM_DOTMATCH).reject{ |e|
|
24
|
+
["..", "."].include? File.basename(e) }.reverse.each do |entry|
|
25
|
+
r = cleanup(entry)
|
26
|
+
repos << r if r
|
57
27
|
end
|
58
|
-
end
|
59
28
|
|
60
|
-
|
61
|
-
|
62
|
-
|
29
|
+
# Handle all .repository.yml as last
|
30
|
+
repos.each do |e|
|
31
|
+
handle_repo(e, repack)
|
32
|
+
end
|
63
33
|
end
|
64
34
|
|
65
35
|
def self.cleanup(entry, repack = false)
|
66
36
|
dirname = File.dirname(entry)
|
67
37
|
base = File.basename(entry)
|
68
|
-
|
69
|
-
if File.directory?(entry)
|
70
|
-
check_dir(File.join(entry, ".rsync"), false)
|
71
|
-
check_dir(File.join(entry, ".rsync/.pack"), repack)
|
72
|
-
check_dir(File.join(entry, ".pack"), repack)
|
73
|
-
end
|
74
38
|
|
39
|
+
# Rename if the base contains capitals
|
75
40
|
if base =~ /[A-Z]/
|
76
41
|
newentry = File.join(dirname, base.downcase)
|
77
42
|
rename(entry, newentry)
|
78
43
|
entry = newentry
|
79
44
|
base = File.basename(entry)
|
80
45
|
end
|
46
|
+
check_dir(entry) ? entry : nil
|
81
47
|
end
|
82
48
|
|
49
|
+
def self.check_dir(dir)
|
50
|
+
return nil unless File.directory?(dir)
|
51
|
+
entry = File.join(dir, ".repository.yml")
|
52
|
+
return nil unless File.exists?(entry)
|
53
|
+
true
|
54
|
+
end
|
55
|
+
|
56
|
+
def self.handle_repo(dir, repack = false)
|
57
|
+
return unless File.directory?(dir)
|
58
|
+
entry = File.join(dir, ".repository.yml")
|
59
|
+
return unless File.exists?(entry)
|
60
|
+
#puts "Processing: #{entry}"
|
61
|
+
config = YAML::load_file(entry)
|
62
|
+
[:pack, :wd].each do |typ|
|
63
|
+
ar = []
|
64
|
+
config[typ].each do |e|
|
65
|
+
sum = if repack && e[0] =~ /.*[A-Z].*\.gz$/
|
66
|
+
entry = File.join(dir, e[0])
|
67
|
+
entry = repack(entry)
|
68
|
+
md5sum(entry)
|
69
|
+
else
|
70
|
+
e[1]
|
71
|
+
end
|
72
|
+
ar << [e[0].downcase, sum]
|
73
|
+
end
|
74
|
+
config[typ] = ar
|
75
|
+
end
|
76
|
+
File.open(entry, 'w') {|f| f.puts config.to_yaml }#.to_s
|
77
|
+
end
|
78
|
+
|
79
|
+
def self.rename(entry, newentry)
|
80
|
+
FileUtils.mv(entry, "#{entry}_tmp")
|
81
|
+
FileUtils.mv("#{entry}_tmp", newentry)
|
82
|
+
end
|
83
|
+
|
84
|
+
# TODO: take a serious look at repack :) especially with handle_repo
|
83
85
|
def self.repack(entry)
|
84
86
|
dirname = File.dirname(entry)
|
85
87
|
base = File.basename(entry)
|
86
88
|
if base =~ /\.gz$/
|
87
89
|
Dir.chdir(dirname) do
|
88
|
-
|
89
|
-
f = entry.clone
|
90
|
+
f = base.clone
|
90
91
|
f.sub!(/\.gz$/, "")
|
92
|
+
puts "Repacking #{f} to #{f.downcase}"
|
93
|
+
system "gzip -d \"#{base}\""
|
91
94
|
rename(f, f.downcase)
|
92
|
-
|
93
|
-
base = File.basename(f)
|
95
|
+
base = f.downcase
|
94
96
|
system "gzip --rsyncable --best \"#{base}\""
|
95
|
-
|
96
|
-
end
|
97
|
-
end
|
98
|
-
|
99
|
-
def self.process(dir, repack = false)
|
100
|
-
if File.directory?(dir)
|
101
|
-
check_dir(File.join(dir, ".rsync"), false)
|
102
|
-
check_dir(File.join(dir, ".rsync/.pack"), repack)
|
103
|
-
check_dir(File.join(dir, ".pack"), repack)
|
104
|
-
|
105
|
-
Dir.glob(File.join(dir, '**', '*')).each do |entry|
|
106
|
-
cleanup(entry, repack)
|
97
|
+
File.join(dirname, base)
|
107
98
|
end
|
108
99
|
end
|
109
100
|
end
|
data/lib/six/updater.rb
CHANGED