repman 2015.2.28

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. checksums.yaml +7 -0
  2. data/bin/repman +3 -0
  3. data/lib/repman.rb +92 -0
  4. metadata +74 -0
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 768c7b34c181b464e5952321fd1ce23ca7f1e766
4
+ data.tar.gz: fb8df6620412a38a5391a2e490ccc9cf74c595c1
5
+ SHA512:
6
+ metadata.gz: 7e232779fed260b13e3a20085567a66e7bc8e8b8fc247d8c4743cd184efde230530ffc6a4feacd47996eb0340b64be225b1886d4f3df049e54bcb50bbe711888
7
+ data.tar.gz: 02ef928863be054347b39b4268460cceb7f83dddf5124b4bfe476e82e88167c2bcd251e98ee3db4eb4de853d2c41e797415ee0028bde934f628b733652460ddc
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'repman'
@@ -0,0 +1,92 @@
1
+ #!/usr/bin/env ruby
2
+ # Encoding: UTF-8
3
+
4
+ ##
5
+ ## Pacman Repository Manager 2015.2.28
6
+ ## Copyright (c) 2014 Renato Silva
7
+ ## Licensed under BSD
8
+ ##
9
+ ## This program manages pacman repositories. It uses a separate included file
10
+ ## /etc/pacman.d/pacrep.conf instead of /etc/pacman.conf. Usage:
11
+ ##
12
+ ## repman add NAME URL Add a repository and refresh database.
13
+ ## repman remove NAME Remove a repository and refresh database.
14
+ ## repman list List all repositories.
15
+ ##
16
+
17
+ $0 = __FILE__
18
+ require 'inifile'
19
+ require 'easyoptions'
20
+ if ARGV.empty?
21
+ puts EasyOptions.documentation
22
+ exit
23
+ end
24
+
25
+ class Repository
26
+ def initialize(name, url, siglevel)
27
+ @name = name
28
+ @url = url
29
+ @siglevel = siglevel
30
+ end
31
+ def save(config)
32
+ config[@name] = { 'Server' => @url, 'SigLevel' => @siglevel }
33
+ config.write
34
+ end
35
+ def remove(config)
36
+ config.delete_section(@name)
37
+ config.write
38
+ end
39
+ def self.load(config, name)
40
+ return nil unless config.has_section?(name)
41
+ siglevel = config[name]['SigLevel']
42
+ url = config[name]['Server']
43
+ self.new(name, url, siglevel)
44
+ end
45
+ def self.all(config)
46
+ config.sections.map do |name|
47
+ Repository.load(config, name)
48
+ end
49
+ end
50
+ attr_accessor :name
51
+ attr_accessor :url
52
+ attr_accessor :siglevel
53
+ end
54
+
55
+ pacman_file = '/etc/pacman.conf'
56
+ config_file = '/etc/pacman.d/repman.conf'
57
+ pacman_refresh='pacman --sync --refresh'
58
+ command, name, url = EasyOptions.arguments
59
+ include_regex = /^\s*Include\s+=\s+#{config_file}/
60
+ config = (IniFile.load(config_file) or IniFile.new(:filename => config_file).write)
61
+ repository = Repository.new(name, url, 'Optional')
62
+
63
+ begin
64
+ File.open(pacman_file, 'a') do |file|
65
+ file.puts("\n# Automatically included by repman")
66
+ file.puts("Include = #{config_file}")
67
+ end if not File.readlines(pacman_file).grep(include_regex).any?
68
+ rescue
69
+ EasyOptions.finish "could not check #{pacman_file}"
70
+ end
71
+
72
+ case command
73
+ when 'add'
74
+ EasyOptions.finish 'name and URL required' unless url
75
+ repository.save(config)
76
+ system(pacman_refresh)
77
+ when 'remove'
78
+ EasyOptions.finish 'name is required' unless name
79
+ repository = Repository.load(config, name)
80
+ EasyOptions.finish "could not find repository #{name}" unless repository
81
+ repository.remove(config)
82
+ system(pacman_refresh)
83
+ when 'list' then
84
+ EasyOptions.finish "extra arguments to #{command} command" if EasyOptions.arguments[1]
85
+ Repository.all(config).each do |repository|
86
+ puts repository.name
87
+ puts "\tServer: #{repository.url}"
88
+ puts "\tSigLevel: #{repository.siglevel}"
89
+ end
90
+ else
91
+ EasyOptions.finish "unknown command #{command}"
92
+ end
metadata ADDED
@@ -0,0 +1,74 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: repman
3
+ version: !ruby/object:Gem::Version
4
+ version: 2015.2.28
5
+ platform: ruby
6
+ authors:
7
+ - Renato Silva
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-03-01 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: easyoptions
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: 2015.2.28
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: 2015.2.28
27
+ - !ruby/object:Gem::Dependency
28
+ name: inifile
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: 3.0.0
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: 3.0.0
41
+ description:
42
+ email: br.renatosilva@gmail.com
43
+ executables:
44
+ - repman
45
+ extensions: []
46
+ extra_rdoc_files: []
47
+ files:
48
+ - bin/repman
49
+ - lib/repman.rb
50
+ homepage: https://github.com/renatosilva/repman
51
+ licenses:
52
+ - BSD
53
+ metadata: {}
54
+ post_install_message:
55
+ rdoc_options: []
56
+ require_paths:
57
+ - lib
58
+ required_ruby_version: !ruby/object:Gem::Requirement
59
+ requirements:
60
+ - - ">="
61
+ - !ruby/object:Gem::Version
62
+ version: '0'
63
+ required_rubygems_version: !ruby/object:Gem::Requirement
64
+ requirements:
65
+ - - ">="
66
+ - !ruby/object:Gem::Version
67
+ version: '0'
68
+ requirements: []
69
+ rubyforge_project:
70
+ rubygems_version: 2.2.2
71
+ signing_key:
72
+ specification_version: 4
73
+ summary: Pacman repository manager
74
+ test_files: []