right_publish 0.4.0 → 0.4.2

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.4.0
1
+ 0.4.2
@@ -70,15 +70,13 @@ module RightPublish
70
70
  # @option options [String] :subdir a subdirectory (common prefix); only files matching this prefix will be included
71
71
  # @option options [Array] :filter a whitelist of String glob patterns to filter files, i.e. ["*.rpm", "*.deb"]
72
72
  def annotate(options={})
73
+ Profile.log("Creating HTML directory listing for #{repo_human_name(@repository_type)} files...")
73
74
 
74
75
  options[:subdir] ||= repo_config[:subdir]
75
- storage_type = options[:use_remote_storage] ? :remote_storage : :local_storage
76
-
77
- Profile.log("Creating HTML directory listing from #{storage_type.to_s} storage for #{repo_human_name(@repository_type)} files...")
78
76
 
79
77
  files = []
80
78
  RightPublish::Storage.ls(
81
- get_storage(Profile.config[storage_type][:provider]),
79
+ get_storage(Profile.config[:local_storage][:provider]),
82
80
  :subdir => options[:subdir]) do |file|
83
81
  files << file
84
82
  end
@@ -6,10 +6,10 @@ module RightPublish
6
6
  REPO_KEY = :apt_repo
7
7
 
8
8
  REPO_OPTIONS = {
9
- :dists => :addr_optional,
10
- :description => DEFAULT_DESCRIPTION,
11
- :auto => DEFAULT_APT_AUTO,
12
- :subdir => DEFAULT_APT_DIR,
9
+ :dists => :addr_optional,
10
+ :description => DEFAULT_DESCRIPTION,
11
+ :auto => DEFAULT_APT_AUTO,
12
+ :subdir => DEFAULT_APT_DIR,
13
13
  :gpg_key_id => :attr_optional,
14
14
  :gpg_password => :attr_optional }
15
15
 
@@ -97,14 +97,15 @@ module RightPublish
97
97
  end
98
98
 
99
99
  def auto_repo_remove(repo_path, pkg, target)
100
- sub_command = (pkg.end_with?(BIN_EXTENSION) && 'remove') || 'removesrc'
101
100
  pkg_name = AptRepo.pkg_parts(pkg)[:name]
102
- Profile.log("Removing any existing files for #{pkg_name}")
101
+ filterlist = "'$PackageType (== #{ (pkg.end_with?(BIN_EXTENSION) && 'deb') || 'dsc' }), Package (% #{pkg_name})'"
102
+
103
+ Profile.log("Removing any packages files using filterlist #{filterlist}")
103
104
 
104
105
  targets = (target && Array(target)) || repo_config[:dists]
105
106
  targets.each do |t|
106
107
  ask_passphrase = (repo_config[:gpg_key_id]) ? "--ask-passphrase" : ""
107
- cmd = "reprepro #{ask_passphrase} -b #{repo_path} #{sub_command} #{t} #{pkg_name}"
108
+ cmd = "reprepro #{ask_passphrase} -b #{repo_path} removefilter #{t} #{filterlist}"
108
109
  if repo_config[:gpg_key_id]
109
110
  exited = shellout_with_password(cmd)
110
111
  else
@@ -28,7 +28,6 @@ module RightPublish
28
28
  def annotate(options={})
29
29
  options[:subdir] ||= repo_config[:subdir]
30
30
  options[:filter] = ['*.msi']
31
- options[:use_remote_storage] = true
32
31
  super(options)
33
32
  end
34
33
 
@@ -1,4 +1,5 @@
1
1
  require 'right_publish/profile'
2
+ require 'stringio'
2
3
 
3
4
  module RightPublish
4
5
  class StorageManager
@@ -65,7 +66,8 @@ module RightPublish
65
66
  else
66
67
  remote_file = files.shift
67
68
  Profile.log("Synchronizing: #{remote_file.first}", :debug)
68
- local_copy = dest_dir.files.create(:key=>remote_file.first, :body=>remote_file.last.body,
69
+ # Need to wrap the raw data in a stringio object or the call will fail on windows
70
+ local_copy = dest_dir.files.create(:key=>remote_file.first, :body=>StringIO.new(remote_file.last.body),
69
71
  :acl=>'public-read',
70
72
  :content_type => guess_mime_type(remote_file.first))
71
73
  end
@@ -1,5 +1,41 @@
1
- require 'fog'
2
1
  require 'digest/md5'
2
+ require 'fog'
3
+ # Fog loads these on demand. Preload this so we can monkey patch it below
4
+ require 'fog/local/models/storage/files'
5
+
6
+ module Fog
7
+ module Storage
8
+ class Local
9
+ class Files < Fog::Collection
10
+ # This method is exactly like the stock one except for using "rb" (force binary mode)
11
+ # instead of "r" for reading the file. On windows it defaults to text mode which
12
+ # messes everything up.
13
+ def get(key, &block)
14
+ requires :directory
15
+ path = file_path(key)
16
+ if ::File.exists?(path)
17
+ data = {
18
+ :content_length => ::File.size(path),
19
+ :key => key,
20
+ :last_modified => ::File.mtime(path)
21
+ }
22
+ if block_given?
23
+ file = ::File.open(path, "rb")
24
+ while (chunk = file.read(Excon::CHUNK_SIZE)) && yield(chunk); end
25
+ file.close
26
+ new(data)
27
+ else
28
+ body = ::File.open(path,"rb") { |io| io.read }
29
+ new(data.merge!(:body => body))
30
+ end
31
+ else
32
+ nil
33
+ end
34
+ end
35
+ end
36
+ end
37
+ end
38
+ end
3
39
 
4
40
  module RightPublish
5
41
  module LocalStorage
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = "right_publish"
8
- s.version = "0.4.0"
8
+ s.version = "0.4.2"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Brian Szmyd", "Tony Spataro"]
@@ -37,7 +37,7 @@ describe RightPublish::AptRepo do
37
37
  expected_dists.each do |dist|
38
38
  @remove_expectations[dist] ||= []
39
39
  @remove_expectations[dist] << RightPublish::AptRepo.pkg_parts(pkg)[:name]
40
-
40
+
41
41
  @install_expectations[dist] ||= []
42
42
  @install_expectations[dist] << pkg
43
43
  end
@@ -47,13 +47,16 @@ describe RightPublish::AptRepo do
47
47
 
48
48
  system_calls = (pkgs.size * expected_dists.size) * 2
49
49
  @repo.should_receive(@system_func).times(system_calls).and_return do |cmd|
50
- path, subcmd, distro, pkg = /reprepro\s+(?:--ask-passphrase )?(?:-C main )?-b\s+(.+)\s+(includedeb|includedsc|removesrc|remove)\s+([^\s]+)\s+([^\s]+)/.match(cmd).captures
50
+ path, subcmd, distro, pkg = /reprepro\s+(?:--ask-passphrase )?(?:-C main )?-b\s+(.+)\s+(includedeb|includedsc|removefilter)\s+([^\s]+)\s+(.+)$/.match(cmd).captures
51
51
  path.should be_eql(File.join(@cache_dir,@repo_subdir))
52
-
53
- if @remove_expectations.has_key?(distro) && @remove_expectations[distro].include?(pkg)
54
- subcmd.should include('remove') #can be remove or removesrc
52
+ # Now we are using listfilter, that is why our package name is really filter.
53
+ # reprepro -b somedir/fake/ removefilter quantal '$PackageType (== deb), Package (% foo)'
54
+ # We need to extract package name from '$PackageType (== deb), Package (% foo)'
55
+ real_pkg = pkg[35..-3] # 35 is an index of space after '%', and -3 is a index of ')'
56
+ if @remove_expectations.has_key?(distro) && @remove_expectations[distro].include?(real_pkg)
57
+ subcmd.should == 'removefilter'
55
58
  @remove_expectations.should be_has_key(distro)
56
- @remove_expectations[distro].delete(pkg)
59
+ @remove_expectations[distro].delete(real_pkg)
57
60
  @remove_expectations.delete(distro) if @remove_expectations[distro].empty?
58
61
  else
59
62
  subcmd.should be_eql((pkg.end_with?(RightPublish::AptRepo::SRC_EXTENSION) && 'includedsc') || 'includedeb')
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: right_publish
3
3
  version: !ruby/object:Gem::Version
4
- hash: 15
4
+ hash: 11
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 4
9
- - 0
10
- version: 0.4.0
9
+ - 2
10
+ version: 0.4.2
11
11
  platform: ruby
12
12
  authors:
13
13
  - Brian Szmyd
@@ -16,7 +16,7 @@ autorequire:
16
16
  bindir: bin
17
17
  cert_chain: []
18
18
 
19
- date: 2013-11-12 00:00:00 Z
19
+ date: 2013-11-18 00:00:00 Z
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
22
22
  version_requirements: &id001 !ruby/object:Gem::Requirement