repomate 0.2.0 → 0.2.1

Sign up to get free protection for your applications and to get access to all the features.
data/bin/repomate CHANGED
@@ -17,7 +17,7 @@ options = Slop.parse do
17
17
 
18
18
  Usage: #{$0} add -s squeeze [-c main] <package>
19
19
  #{$0} publish
20
- #{$0} listpackages -r production
20
+ #{$0} listpackages -r stage
21
21
 
22
22
  Actions:
23
23
  add - Add a package to the staging area
@@ -26,7 +26,10 @@ options = Slop.parse do
26
26
  load - Load a checkpoint
27
27
  listpackages - List packages
28
28
  setup - Setup the pool
29
- remove - Removes a package from production
29
+ activate - Activate (link) a package from pool
30
+ deactivate - Deactivate (unlink) a package from production
31
+ remove - Removes a package from production and pool
32
+
30
33
 
31
34
  Options:"
32
35
  on :s, :suitename=, "Set the name of the suite (lenny/squeeze...)", :argument => true
@@ -60,10 +63,14 @@ elsif ARGV.include?("save")
60
63
  cli.save_checkpoint
61
64
  elsif ARGV.include?("load")
62
65
  cli.choose_checkpoint
66
+ elsif ARGV.include?("activate")
67
+ cli.choose_package("activate")
68
+ elsif ARGV.include?("deactivate")
69
+ cli.choose_package("deactivate")
63
70
  elsif ARGV.include?("remove")
64
71
  cli.choose_package("remove")
65
72
  elsif ARGV.include?("listpackages")
66
- cli.list_packages(options)
73
+ cli.listpackages(options)
67
74
  elsif ARGV.include?("setup")
68
75
  cli.setup(options)
69
76
  else
data/lib/repomate/base.rb CHANGED
@@ -104,15 +104,7 @@ module RepoMate
104
104
  :category => 'dists'
105
105
  }
106
106
  end
107
- Dir.glob("#{pool.directory}/#{package.name}*.deb") do |fullname|
108
- unlink_workload << {
109
- :destination_fullname => fullname,
110
- :suitename => package.suitename,
111
- :component => package.component,
112
- :category => 'pool'
113
- }
114
- end
115
- FileUtils.move(stage_fullname, pool_fullname)
107
+ FileUtils.move(stage_fullname, pool_fullname) unless File.exists?(pool_fullname)
116
108
  end
117
109
  end
118
110
  @link.destroy(unlink_workload)
@@ -120,44 +112,40 @@ module RepoMate
120
112
  end
121
113
 
122
114
  # Returns a list of packages
123
- def list_packages(category)
115
+ def listpackages
124
116
  packages = []
125
- number = 0
126
- if category.eql?("stage")
127
- Component.dataset(category).each do |entry|
128
- source = Component.new(entry[:component], entry[:suitename], category)
117
+
118
+ @repository.categories.each do |category|
119
+ Architecture.dataset(category).each do |entry|
120
+ source = Architecture.new(entry[:architecture], entry[:component], entry[:suitename], category)
129
121
  source.files.each do |fullname|
130
122
  package = Package.new(fullname, entry[:suitename], entry[:component])
131
-
132
- number += 1
133
-
134
123
  packages << {
135
- :number => number,
136
124
  :fullname => fullname,
125
+ :category => category,
137
126
  :basename => File.basename(fullname),
138
127
  :controlfile => package.controlfile,
139
128
  :component => entry[:component],
140
- :suitename => entry[:suitename]
129
+ :suitename => entry[:suitename],
130
+ :architecture => entry[:architecture]
141
131
  }
142
132
  end
143
133
  end
144
- else
145
- Architecture.dataset(category).each do |entry|
146
- source = Architecture.new(entry[:architecture], entry[:component], entry[:suitename], category)
147
- source.files.each do |fullname|
148
- package = Package.new(fullname, entry[:suitename], entry[:component])
149
-
150
- number += 1
151
-
152
- packages << {
153
- :number => number,
154
- :fullname => fullname,
155
- :basename => File.basename(fullname),
156
- :controlfile => package.controlfile,
157
- :component => entry[:component],
158
- :suitename => entry[:suitename],
159
- :architecture => entry[:architecture]
160
- }
134
+ if category.eql? "stage"
135
+ Component.dataset(category).each do |entry|
136
+ source = Component.new(entry[:component], entry[:suitename], category)
137
+ source.files.each do |fullname|
138
+ package = Package.new(fullname, entry[:suitename], entry[:component])
139
+ packages << {
140
+ :fullname => fullname,
141
+ :category => category,
142
+ :basename => File.basename(fullname),
143
+ :controlfile => package.controlfile,
144
+ :component => entry[:component],
145
+ :suitename => entry[:suitename],
146
+ :architecture => "unknown"
147
+ }
148
+ end
161
149
  end
162
150
  end
163
151
  end
@@ -165,23 +153,47 @@ module RepoMate
165
153
  end
166
154
 
167
155
  # Removes a package
168
- def remove(package)
156
+ def activate(entry)
157
+ link_workload = []
158
+
159
+ package = Package.new(entry[:fullname], entry[:suitename], entry[:component])
160
+ dists = Architecture.new(package.architecture, entry[:component], entry[:suitename], "dists")
161
+ dists_fullname = File.join(dists.directory, package.basename)
162
+
163
+ link_workload << {
164
+ :source_fullname => entry[:fullname],
165
+ :destination_fullname => dists_fullname,
166
+ :suitename => package.suitename,
167
+ :component => package.component,
168
+ :architecture => package.architecture
169
+ }
170
+ if File.exists?(dists_fullname)
171
+ puts "Package already activated"
172
+ else
173
+ @link.create(link_workload)
174
+ end
175
+ end
176
+
177
+ # Removes a package
178
+ def deactivate(entry, mode)
169
179
  unlink_workload = []
170
180
 
171
181
  @repository.categories.each do |category|
172
- path = Dir.glob(File.join(Cfg.rootdir, category, package[:suitename], package[:component], "*", package[:basename]))
182
+ next if mode.eql?("deactivate") && category.eql?("pool")
183
+
184
+ path = Dir.glob(File.join(Cfg.rootdir, category, entry[:suitename], entry[:component], "*", entry[:basename]))
173
185
 
174
186
  Dir.glob(path).each do |fullname|
175
187
  unlink_workload << {
176
188
  :destination_fullname => fullname,
177
189
  :category => category,
178
- :suitename => package[:suitename],
179
- :component => package[:component]
190
+ :suitename => entry[:suitename],
191
+ :component => entry[:component]
180
192
  }
181
193
  end
182
194
  end
183
195
 
184
- @checkpoint.delete_package(package)
196
+ @checkpoint.delete_package(entry) if mode.eql?("remove")
185
197
  @link.destroy(unlink_workload)
186
198
  end
187
199
  end
@@ -96,12 +96,12 @@ module RepoMate
96
96
  end
97
97
 
98
98
  # Deletes a package from checkpoint table
99
- def delete_package(package)
99
+ def delete_package(entry)
100
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]}'"
101
+ basename = '#{entry[:basename]}' and
102
+ suitename = '#{entry[:suitename]}' and
103
+ component = '#{entry[:component]}' and
104
+ architecture = '#{entry[:architecture]}'"
105
105
 
106
106
  @cpdb.query(sql)
107
107
  end
data/lib/repomate/cli.rb CHANGED
@@ -73,26 +73,9 @@ module RepoMate
73
73
 
74
74
  # Save a checkpoint
75
75
  def save_checkpoint
76
- # Add verification and some output here
77
76
  @checkpoint.create
78
77
  end
79
78
 
80
- # List all packages, see cli output
81
- def list_packages(options)
82
- if options.category?
83
- architecture = "unknown"
84
-
85
- packages = @repomate.list_packages(options[:category])
86
- packages.each do |package|
87
- architecture = package[:architecture] if package[:architecture]
88
- printf "%-50s%-20s%s\n", package[:controlfile]['Package'], package[:controlfile]['Version'], "#{package[:suitename]}/#{package[:component]}/#{architecture}"
89
- end
90
- else
91
- STDERR.puts "Specify a category with [-r|--category]"
92
- exit 1
93
- end
94
- end
95
-
96
79
  # Choose a checkpoint to restore.
97
80
  def choose_checkpoint
98
81
  list = @checkpoint.list
@@ -126,24 +109,68 @@ Everything between the last two \"publish (-P) commands\" will be lost if you pr
126
109
  end
127
110
  end
128
111
 
129
- # Choose a package
130
- def choose_package(action)
131
- packages = @repomate.list_packages("dists")
132
- packages.each do |package|
133
- printf "%-7s%-50s%-20s%s\n", "#{package[:number]})", package[:controlfile]['Package'], package[:controlfile]['Version'], "#{package[:suitename]}/#{package[:component]}"
112
+ # List all packages, see cli output
113
+ def listpackages(options)
114
+ @repomate.listpackages.each do |entry|
115
+ next unless entry[:category].eql?(options[:category])
116
+ architecture = entry[:architecture] if entry[:architecture]
117
+ printf "%-50s%-20s%-10s%s\n", entry[:controlfile]['Package'], entry[:controlfile]['Version'], "#{entry[:category]}", "#{entry[:suitename]}/#{entry[:component]}/#{architecture}"
134
118
  end
119
+ end
135
120
 
136
- printf "\n%s", "Enter number or [q|quit] to abord: "
137
- input = STDIN.gets
138
- number = input.to_i
121
+ # Choose a package
122
+ def choose_package(mode)
123
+ packages = []
124
+ number = 0
125
+
126
+ @repomate.listpackages.each do |entry|
127
+ next if entry[:category].eql?("stage")
128
+ if mode.eql?("activate")
129
+ file = File.join(Cfg.rootdir, "dists", entry[:suitename], entry[:component], "binary-#{entry[:architecture]}", entry[:basename])
130
+ next if File.exists?(file)
131
+ elsif mode.eql?("deactivate")
132
+ next unless entry[:category].eql?("dists")
133
+ elsif mode.eql?("remove")
134
+ next unless entry[:category].eql?("pool")
135
+ end
136
+ number += 1
137
+ packages << {
138
+ :number => number,
139
+ :basename => entry[:basename],
140
+ :fullname => entry[:fullname],
141
+ :category => entry[:category],
142
+ :suitename => entry[:suitename],
143
+ :component => entry[:component],
144
+ :architecture => entry[:architecture],
145
+ :controlfile => entry[:controlfile]
146
+ }
147
+ end
139
148
 
140
- if input =~ /(q|quit)/
141
- puts "Aborting..."
142
- exit 0
149
+ if number.zero?
150
+ puts "There are no packages to #{mode}"
143
151
  else
144
- packages.each do |package|
145
- if package[:number].eql?(number)
146
- @repomate.remove(package) if action.eql?("remove")
152
+ puts "Select a package by entering the appropriate number\n\n"
153
+
154
+ packages.each do |entry|
155
+ printf "%-6s%-50s%-20s%s\n", "#{entry[:number]})", entry[:controlfile]['Package'], entry[:controlfile]['Version'], "#{entry[:suitename]}/#{entry[:component]}"
156
+ end
157
+
158
+ printf "\n%s", "Enter number or [q|quit] to abord: "
159
+ input = STDIN.gets
160
+ number = input.to_i
161
+
162
+ if input =~ /(q|quit)/
163
+ puts "Aborting..."
164
+ exit 0
165
+ else
166
+ packages.each do |entry|
167
+ if entry[:number].eql?(number)
168
+ if mode.eql?("activate")
169
+ @repomate.activate(entry)
170
+ else
171
+ @repomate.deactivate(entry, mode)
172
+ end
173
+ end
147
174
  end
148
175
  end
149
176
  end
@@ -34,9 +34,10 @@ module RepoMate
34
34
  :architectures => [ "all", "amd64" ],
35
35
  :origin => 'Repository',
36
36
  :label => 'Repository',
37
- :gpg_enable => 'no',
37
+ :gpg => false,
38
+ :gpg_enable => false, # obsolete in a while
38
39
  :gpg_email => 'someone@example.net',
39
- :gpg_password => 'secret',
40
+ :gpg_password => 'secret'
40
41
  }
41
42
 
42
43
  unless filecontent.empty?
@@ -45,7 +45,7 @@ module RepoMate
45
45
  destroy
46
46
  create_packages
47
47
 
48
- if Cfg.gpg_enable.eql?(true)
48
+ if Cfg.gpg
49
49
  if Cfg.gpg_password.nil? || Cfg.gpg_email.nil?
50
50
  puts "Configure password and email for GPG!"
51
51
  exit 1
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.2.0
4
+ version: 0.2.1
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-07 00:00:00.000000000Z
13
+ date: 2012-06-09 00:00:00.000000000Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: slop
17
- requirement: &70097650765320 !ruby/object:Gem::Requirement
17
+ requirement: &70335555719140 !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: *70097650765320
25
+ version_requirements: *70335555719140
26
26
  - !ruby/object:Gem::Dependency
27
27
  name: gpgme
28
- requirement: &70097650764720 !ruby/object:Gem::Requirement
28
+ requirement: &70335555718620 !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: *70097650764720
36
+ version_requirements: *70335555718620
37
37
  - !ruby/object:Gem::Dependency
38
38
  name: sqlite3
39
- requirement: &70097650763720 !ruby/object:Gem::Requirement
39
+ requirement: &70335555718120 !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: *70097650763720
47
+ version_requirements: *70335555718120
48
48
  description: A tool to manage Debian repositories
49
49
  email:
50
50
  - flo@doobie.cc