repomate 0.1.7 → 0.1.8

Sign up to get free protection for your applications and to get access to all the features.
data/lib/repomate/base.rb CHANGED
@@ -10,7 +10,7 @@ module RepoMate
10
10
 
11
11
  # Init
12
12
  def initialize
13
- FileUtils.mkdir_p(Cfg.rootdir)
13
+ FileUtils.mkdir_p(Cfg.rootdir) unless File.exists?(Cfg.rootdir)
14
14
 
15
15
  @repository = Repository.new
16
16
  @link = Link.new
@@ -56,67 +56,68 @@ module RepoMate
56
56
 
57
57
  # Publish all staged packages. Packages will be moved from stage to pool and linked to dists
58
58
  def publish(workload)
59
- newworkload = []
60
- workload.each do |entry|
61
- destination = Architecture.new(entry[:architecture], entry[:component], entry[:suitename], "dists")
62
- basename = File.basename(entry[:source_fullname])
63
-
64
- @repository.create(entry[:suitename], entry[:component], entry[:architecture])
65
-
66
- newworkload << {
67
- :source_fullname => entry[:destination_fullname],
68
- :destination_dir => destination.directory,
69
- :component => entry[:component],
70
- :suitename => entry[:suitename],
71
- :architecture => entry[:architecture]
72
- }
73
- FileUtils.move(entry[:source_fullname], entry[:destination_fullname])
74
- end
75
- workload = newworkload
76
- check_versions(workload)
77
- end
78
-
79
- # Does the link job after checking versions through dpkg
80
- def check_versions(workload)
81
59
  link_workload = []
82
60
  unlink_workload = []
83
61
 
84
- dpkg = Cfg.dpkg
85
-
86
62
  workload.each do |entry|
87
- source_package = Package.new(entry[:source_fullname], entry[:suitename], entry[:component])
88
- destination_fullname = File.join(entry[:destination_dir], source_package.newbasename)
89
63
 
90
- Dir.glob("#{entry[:destination_dir]}/#{source_package.name}*.deb") do |target_fullname|
91
- target_package = Package.new(target_fullname, entry[:suitename], entry[:component] )
64
+ action = true
65
+
66
+ @repository.create(entry[:suitename], entry[:component], entry[:architecture])
67
+
68
+ package = Package.new(entry[:source_fullname], entry[:suitename], entry[:component])
69
+ pool = Architecture.new(package.architecture, entry[:component], entry[:suitename], "pool")
70
+ dists = Architecture.new(package.architecture, entry[:component], entry[:suitename], "dists")
71
+ pool_fullname = File.join(pool.directory, package.basename)
72
+ dists_fullname = File.join(dists.directory, package.basename)
73
+ stage_fullname = package.fullname
74
+
75
+ Dir.glob("#{pool.directory}/#{package.name}*.deb") do |pool_fullname|
76
+ pool_package = Package.new(pool_fullname, entry[:suitename], entry[:component] )
77
+ if system("#{Cfg.dpkg} --compare-versions #{package.version} gt #{pool_package.version}")
78
+ puts "Package: #{pool_package.newbasename} will be replaced with #{package.newbasename}"
79
+ elsif system("#{Cfg.dpkg} --compare-versions #{package.version} eq #{pool_package.version}")
80
+ puts "Package: #{pool_package.newbasename} already exists with same version"
81
+ action = false
82
+ next
83
+ elsif system("#{Cfg.dpkg} --compare-versions #{package.version} lt #{pool_package.version}")
84
+ puts "Package: #{pool_package.newbasename} already exists with higher version"
85
+ File.unlink(package.fullname)
86
+ action = false
87
+ next
88
+ end
89
+ end
92
90
 
93
- if system("#{dpkg} --compare-versions #{source_package.version} gt #{target_package.version}")
94
- puts "Package: #{target_package.newbasename} will be replaced with #{source_package.newbasename}"
91
+ if action
92
+ link_workload << {
93
+ :source_fullname => pool_fullname,
94
+ :destination_fullname => dists_fullname,
95
+ :suitename => package.suitename,
96
+ :component => package.component,
97
+ :architecture => package.architecture
98
+ }
99
+ Dir.glob("#{dists.directory}/#{package.name}*.deb") do |fullname|
95
100
  unlink_workload << {
96
- :destination_fullname => target_fullname,
97
- :newbasename => target_package.newbasename,
98
- :suitename => target_package.suitename,
99
- :component => target_package.component
101
+ :destination_fullname => fullname,
102
+ :suitename => package.suitename,
103
+ :component => package.component,
104
+ :architecture => package.architecture,
105
+ :category => 'dists'
100
106
  }
101
- elsif system("#{dpkg} --compare-versions #{source_package.version} eq #{target_package.version}")
102
- puts "Package: #{source_package.newbasename} already exists with same version"
103
- return
104
- elsif system("#{dpkg} --compare-versions #{source_package.version} lt #{target_package.version}")
105
- puts "Package: #{source_package.newbasename} already exists with higher version"
106
- return
107
107
  end
108
+ Dir.glob("#{pool.directory}/#{package.name}*.deb") do |fullname|
109
+ unlink_workload << {
110
+ :destination_fullname => fullname,
111
+ :suitename => package.suitename,
112
+ :component => package.component,
113
+ :category => 'pool'
114
+ }
115
+ end
116
+ FileUtils.move(stage_fullname, pool_fullname)
108
117
  end
109
-
110
- link_workload << {
111
- :source_fullname => source_package.fullname,
112
- :destination_fullname => destination_fullname,
113
- :suitename => source_package.suitename,
114
- :component => source_package.component,
115
- :newbasename => source_package.newbasename
116
- }
117
118
  end
118
- @link.destroy(unlink_workload)
119
- @link.create(link_workload)
119
+ @link.destroy(unlink_workload)
120
+ @link.create(link_workload)
120
121
  end
121
122
 
122
123
  # Returns a list of packages
@@ -174,9 +175,9 @@ module RepoMate
174
175
  Dir.glob(path).each do |fullname|
175
176
  unlink_workload << {
176
177
  :destination_fullname => fullname,
177
- :category => category,
178
- :suitename => package[:suitename],
179
- :component => package[:component]
178
+ :category => category,
179
+ :suitename => package[:suitename],
180
+ :component => package[:component]
180
181
  }
181
182
  end
182
183
  end
@@ -24,8 +24,8 @@ module RepoMate
24
24
  suitename varchar(10),
25
25
  component varchar(10),
26
26
  architecture varchar(10),
27
- basename varchar(70)
28
- )"
27
+ basename varchar(70))"
28
+
29
29
  @cpdb.query(sql)
30
30
  end
31
31
 
@@ -38,7 +38,15 @@ module RepoMate
38
38
  source = Architecture.new(entry[:architecture], entry[:component], entry[:suitename], source_category)
39
39
  source.files.each do |fullname|
40
40
  basename = File.basename(fullname)
41
- @cpdb.query("insert into checkpoints values ( '#{datetime}', '#{entry[:suitename]}', '#{entry[:component]}', '#{entry[:architecture]}', '#{basename}' )")
41
+
42
+ sql = "insert into checkpoints values (
43
+ '#{datetime}',
44
+ '#{entry[:suitename]}',
45
+ '#{entry[:component]}',
46
+ '#{entry[:architecture]}',
47
+ '#{basename}')"
48
+
49
+ @cpdb.query(sql)
42
50
  end
43
51
  end
44
52
 
@@ -89,7 +97,13 @@ module RepoMate
89
97
 
90
98
  # Deletes a package from checkpoint table
91
99
  def delete_package(package)
92
- @cpdb.query("delete from checkpoints where basename = '#{package[:basename]}' and suitename = '#{package[:suitename]}' and component = '#{package[:component]}' and architecture = '#{package[:architecture]}'")
100
+ sql = "delete from checkpoints where
101
+ basename = '#{package[:basename]}' and
102
+ suitename = '#{package[:suitename]}' and
103
+ component = '#{package[:component]}' and
104
+ architecture = '#{package[:architecture]}'"
105
+
106
+ @cpdb.query(sql)
93
107
  end
94
108
 
95
109
  # Returns a list of checkpoints for the cli
data/lib/repomate/link.rb CHANGED
@@ -49,7 +49,7 @@ module RepoMate
49
49
 
50
50
  if File.exists?(entry[:destination_fullname])
51
51
  File.unlink(entry[:destination_fullname])
52
- puts "Package: #{package.newbasename} unlinked from category #{entry[:category]}"
52
+ puts "Package: #{package.newbasename} unlinked from #{entry[:category]} => #{entry[:suitename]}/#{entry[:component]}"
53
53
  action = true
54
54
  else
55
55
  puts "Package: #{package.newbasename} was not linked"
@@ -91,7 +91,6 @@ module RepoMate
91
91
  end
92
92
  end
93
93
  if action
94
- puts "Cleaning structure"
95
94
  @metafile.create
96
95
  end
97
96
  end
@@ -66,7 +66,7 @@ module RepoMate
66
66
  source.files.each do |fullname|
67
67
  package = Package.new(fullname, entry[:suitename], entry[:component])
68
68
 
69
- checksums = package.get_checksums
69
+ checksums = package.load_checksums
70
70
 
71
71
  packagesfile = File.join(entry[:fullpath], "Packages")
72
72
  size = File.size(fullname)
@@ -47,12 +47,11 @@ module RepoMate
47
47
  end
48
48
 
49
49
  # Gets checksums for the given package
50
- def get_checksums
50
+ def load_checksums
51
51
  result = []
52
52
 
53
53
  @pkgdb.query("select md5, sha1, sha256 from checksums where basename = '#{@basename}' and mtime = '#{@mtime.iso8601}'").each do |row|
54
54
  result = row
55
- # puts "Hit: #{@basename} #{result}"
56
55
  end
57
56
  result
58
57
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: repomate
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.7
4
+ version: 0.1.8
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -10,11 +10,11 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2012-06-06 00:00:00.000000000Z
13
+ date: 2012-06-07 00:00:00.000000000Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: slop
17
- requirement: &70268983483820 !ruby/object:Gem::Requirement
17
+ requirement: &70348239830880 !ruby/object:Gem::Requirement
18
18
  none: false
19
19
  requirements:
20
20
  - - ~>
@@ -22,10 +22,10 @@ dependencies:
22
22
  version: 3.0.4
23
23
  type: :runtime
24
24
  prerelease: false
25
- version_requirements: *70268983483820
25
+ version_requirements: *70348239830880
26
26
  - !ruby/object:Gem::Dependency
27
27
  name: gpgme
28
- requirement: &70268983483220 !ruby/object:Gem::Requirement
28
+ requirement: &70348239829620 !ruby/object:Gem::Requirement
29
29
  none: false
30
30
  requirements:
31
31
  - - ~>
@@ -33,10 +33,10 @@ dependencies:
33
33
  version: 2.0.0
34
34
  type: :runtime
35
35
  prerelease: false
36
- version_requirements: *70268983483220
36
+ version_requirements: *70348239829620
37
37
  - !ruby/object:Gem::Dependency
38
38
  name: sqlite3
39
- requirement: &70268983482620 !ruby/object:Gem::Requirement
39
+ requirement: &70348239828560 !ruby/object:Gem::Requirement
40
40
  none: false
41
41
  requirements:
42
42
  - - ~>
@@ -44,7 +44,7 @@ dependencies:
44
44
  version: 1.3.6
45
45
  type: :runtime
46
46
  prerelease: false
47
- version_requirements: *70268983482620
47
+ version_requirements: *70348239828560
48
48
  description: A tool to manage Debian repositories
49
49
  email:
50
50
  - flo@doobie.cc