slack-utils 0.6.0 → 0.6.1

Sign up to get free protection for your applications and to get access to all the features.
data/README.rdoc CHANGED
@@ -38,7 +38,7 @@ TODO:
38
38
  == Installation
39
39
 
40
40
  To install the gem
41
- sudo gem install pkg/slack-utils-0.6.0.gem
41
+ sudo gem install pkg/slack-utils-0.6.1.gem
42
42
 
43
43
  == Quick Start
44
44
 
data/bin/slf CHANGED
@@ -1,5 +1,7 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
+ $PROGRAM_NAME = File.basename(__FILE__)
4
+
3
5
  require 'optparse'
4
6
  require 'rubygems'
5
7
  require 'slackware/utils'
data/bin/slfindlinked CHANGED
@@ -1,7 +1,10 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
+ $PROGRAM_NAME = File.basename(__FILE__)
4
+
3
5
  require 'rubygems'
4
6
  require 'slackware/utils'
5
7
 
8
+ # XXX needs better boilerplating
6
9
  print_find_linked(ARGV[0])
7
10
 
data/bin/sli ADDED
@@ -0,0 +1,65 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ $PROGRAM_NAME = File.basename(__FILE__)
4
+
5
+ require 'optparse'
6
+ require 'rubygems'
7
+ require 'slackware/utils'
8
+
9
+ options = {}
10
+ begin
11
+ OptionParser.new do |opts|
12
+ opts.banner = <<-EOS
13
+
14
+ List installed Slackware package's information.
15
+
16
+ Usage:
17
+ #{File.basename(__FILE__)} [options] [search flags] [list of names]
18
+
19
+ if no flags are used, then all entries are listed
20
+ if no search flags, only names, then those only those matching entries are listed
21
+
22
+ EOS
23
+ opts.on("-c", "--color", "Colorize output") do |o|
24
+ options[:color] = o
25
+ end
26
+ opts.on("-p", "--pkg [NAME]", "Package PKGNAME (loose match)") do |o|
27
+ options[:pkg] = o
28
+ end
29
+ opts.on("-V", "--Version [VERSION]", "Package VERSION (loose match)") do |o|
30
+ options[:version] = o
31
+ end
32
+ opts.on("-a", "--arch [ARCH]", "Package ARCH (exact match)") do |o|
33
+ options[:arch] = o
34
+ end
35
+ opts.on("-b", "--build [BUILD]", "Package BUILD (exact match)") do |o|
36
+ options[:build] = o
37
+ end
38
+ opts.on("-t", "--tag [TAG]", "Package TAG (loose match)") do |o|
39
+ options[:tag] = o
40
+ end
41
+ opts.on("-v", "--version", "Display version of this software") do |o|
42
+ printf("slack-utils (%s) version: %s, Slackware version: %s\n",
43
+ File.basename(__FILE__),
44
+ Slackware::UTILS_VERSION,
45
+ Slackware::System.version
46
+ )
47
+ exit()
48
+ end
49
+ end.parse!
50
+ rescue OptionParser::InvalidOption => e
51
+ $stderr.write("ERROR: #{e.message}, see --help\n")
52
+ exit 1
53
+ end
54
+
55
+ if (ARGV.count > 0)
56
+ options[:all] = true
57
+ end
58
+
59
+ begin
60
+ print_packages_description(build_packages(options, ARGV))
61
+ rescue Interrupt
62
+ exit 0
63
+ end
64
+
65
+
data/bin/sll CHANGED
@@ -1,5 +1,7 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
+ $PROGRAM_NAME = File.basename(__FILE__)
4
+
3
5
  require 'optparse'
4
6
  require 'rubygems'
5
7
  require 'slackware/utils'
@@ -46,11 +48,6 @@ EOS
46
48
 
47
49
  opts.parse!
48
50
 
49
- if (options[:pkg].nil? && options[:Version].nil? && options[:arch].nil? && options[:build].nil? && options[:tag].nil? && not(options[:force]))
50
- $stderr.write("ERROR: force me if you really want to see all files ...\n")
51
- puts opts
52
- exit 2
53
- end
54
51
  end
55
52
  rescue OptionParser::InvalidOption => e
56
53
  $stderr.write("ERROR: #{e.message}, see --help\n")
@@ -58,8 +55,12 @@ rescue OptionParser::InvalidOption => e
58
55
  end
59
56
 
60
57
  # handing through that we are listing owned files
58
+ # XXX this is not even jeing used
61
59
  options[:list_files] = true
62
60
 
61
+ if ARGV.count > 0
62
+ options[:all] = true
63
+ end
63
64
 
64
65
  begin
65
66
  print_package_file_list(build_packages(options, ARGV))
data/bin/slo CHANGED
@@ -1,5 +1,7 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
+ $PROGRAM_NAME = File.basename(__FILE__)
4
+
3
5
  require 'rubygems'
4
6
  require 'slackware/utils'
5
7
 
data/bin/slp CHANGED
@@ -1,5 +1,7 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
+ $PROGRAM_NAME = File.basename(__FILE__)
4
+
3
5
  require 'optparse'
4
6
  require 'rubygems'
5
7
  require 'slackware/utils'
data/bin/slt CHANGED
@@ -1,5 +1,7 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
+ $PROGRAM_NAME = File.basename(__FILE__)
4
+
3
5
  require 'optparse'
4
6
  require 'rubygems'
5
7
  require 'slackware/utils'
@@ -93,9 +93,10 @@ module Slackware
93
93
 
94
94
  # +file+ can be a path to a file, or a +File+ object
95
95
  # +opts+ can include
96
- # * :arch - basically '64' or '32'
97
- # * :version - 13.1, 13.2, current, etc.
98
- # * :url - the URL web link to the ChangeLog.txt
96
+ # * :arch - basically '64' or '32'
97
+ # * :version - 13.1, 13.2, current, etc.
98
+ # * :url - the URL web link to the ChangeLog.txt
99
+ # * :image_url - the URL for the loge used in the RSS feed
99
100
  def initialize(file = nil, opts = {})
100
101
  @file = file
101
102
  @opts = opts
@@ -111,14 +112,28 @@ module Slackware
111
112
  def security
112
113
  @updates.map {|u| u.entries.map {|e| {:date => u.date, :entry => e } if e.security } }.flatten.compact
113
114
  end
115
+ def pkgs_removed
116
+ @updates.map {|u| u.entries.map {|e| {:date => u.date, :entry => e } if e.action == "Removed" } }.flatten.compact
117
+ end
118
+ def pkgs_added
119
+ @updates.map {|u| u.entries.map {|e| {:date => u.date, :entry => e } if e.action == "Added" } }.flatten.compact
120
+ end
121
+ def pkgs_upgraded
122
+ @updates.map {|u| u.entries.map {|e| {:date => u.date, :entry => e } if e.action == "Upgraded" } }.flatten.compact
123
+ end
124
+ def pkgs_rebuilt
125
+ @updates.map {|u| u.entries.map {|e| {:date => u.date, :entry => e } if e.action == "Rebuilt" } }.flatten.compact
126
+ end
114
127
  def opts=(hash)
115
128
  if hash.is_a?(Hash)
116
129
  @opts = hash
117
130
  end
118
131
  end
119
132
 
120
- def parse
121
- unless @file.nil?
133
+ def parse(opts = {:file => nil, :data => nil})
134
+ if not(opts[:file].nil?)
135
+ @updates = parse_this_file(opts[:file]).updates
136
+ elsif not(@file.nil?)
122
137
  @updates = parse_this_file(@file).updates
123
138
  end
124
139
  return self
@@ -137,7 +152,7 @@ module Slackware
137
152
  "#<%s:0x%x @file=%s, %d @updates, %d @entries>" % [self.class.name, self.object_id.abs, self.file || '""', self.updates.count || 0, self.entries.count || 0]
138
153
  end
139
154
 
140
- private
155
+ #protected
141
156
  # Parse order is something like:
142
157
  # * if its' a date match, store the date
143
158
  # * take change notes until
@@ -3,30 +3,64 @@ require 'slackware/changelog'
3
3
 
4
4
  module Slackware
5
5
  class ChangeLog
6
- def to_rss
6
+ # or maybe "http://connie.slackware.com/~msimons/slackware/grfx/shared/dobbslack1.jpg"
7
+ IMAGE_URL = "http://connie.slackware.com/~msimons/slackware/grfx/shared/bluepiSW.jpg"
8
+ def to_rss(opts = {})
9
+ # this way we can use the opts from super,
10
+ # or override for this methods
11
+ opts = @opts.merge(opts)
12
+
7
13
  version = "2.0" # ["0.9", "1.0", "2.0"]
8
14
  content = RSS::Maker.make(version) do |m|
9
- added_title = ""
10
- if @opts[:arch]
11
- added_title = added_title + "slackware#{@opts[:arch]}"
15
+ if (opts[:title])
16
+ m.channel.title = opts[:title]
17
+ else
18
+ added_title = ""
19
+ if opts[:arch]
20
+ added_title = added_title + "slackware#{opts[:arch]}"
21
+ end
22
+ if opts[:version]
23
+ added_title = added_title + "-#{opts[:version]}"
24
+ end
25
+
26
+ if added_title.empty?
27
+ m.channel.title = "Slackware ChangeLog.txt"
28
+ else
29
+ m.channel.title = "#{added_title} ChangeLog.txt"
30
+ end
12
31
  end
13
- if @opts[:version]
14
- added_title = added_title + "-#{@opts[:version]}"
32
+
33
+ if (opts[:url])
34
+ m.channel.link = "%s#slackagg" % [opts[:url]]
35
+ else
36
+ m.channel.link = "http://www.slackware.com/#slackagg"
15
37
  end
16
38
 
17
- if added_title.empty?
18
- m.channel.title = "Slackware ChangeLog.txt feed"
39
+ if (opts[:description])
40
+ m.channel.description = opts[:description]
19
41
  else
20
- m.channel.title = "Slackware ChangeLog.txt feed for #{added_title}"
42
+ m.channel.description = "a parsed ChangeLog.txt, is an extendable ChangeLog.txt"
21
43
  end
22
- if @opts[:url]
23
- m.channel.link = "%s#slackagg" % [@opts[:url]]
44
+
45
+ if opts[:image_url]
46
+ m.channel.logo = opts[:image_url]
24
47
  else
25
- m.channel.link = "http://www.slackware.com/#slackagg"
48
+ m.channel.logo = IMAGE_URL
49
+ end
50
+
51
+ if (opts[:noimage])
52
+ else
53
+ image = m.image
54
+ if opts[:image_url]
55
+ image.url = opts[:image_url]
56
+ else
57
+ image.url = IMAGE_URL
58
+ end
59
+ image.title = "Slackware Linux"
60
+ image.width = "144"
61
+ image.height = "144"
26
62
  end
27
- #m.channel.logo = "http://connie.slackware.com/~msimons/slackware/grfx/shared/bluepiSW.jpg"
28
- m.channel.logo = "http://connie.slackware.com/~msimons/slackware/grfx/shared/dobbslack1.jpg"
29
- m.channel.description = "a parsed ChangeLog.txt, is an extendable ChangeLog.txt"
63
+
30
64
  m.items.do_sort = true # sort items by date
31
65
 
32
66
  @updates.each {|update|
@@ -39,8 +73,8 @@ module Slackware
39
73
  else
40
74
  i.title = update.date.utc.to_s
41
75
  end
42
- if @opts[:url]
43
- i.link = "%s#%s" % [@opts[:url], update.date.to_i]
76
+ if opts[:url]
77
+ i.link = "%s#%s" % [opts[:url], update.date.to_i]
44
78
  else
45
79
  i.link = "http://slackware.com/#slackagg#%s" % [update.date.to_i]
46
80
  end
@@ -49,9 +83,9 @@ module Slackware
49
83
  i.description = ""
50
84
  if (update.entries.count > 0)
51
85
  if (security > 0)
52
- i.description = "%d new update(s), %d security update(s)\n\n" % [update.entries.count, security]
86
+ i.description = i.description + "%d new update(s), %d security update(s)\n\n" % [update.entries.count, security]
53
87
  else
54
- i.description = "%d new update(s)\n\n" % [update.entries.count]
88
+ i.description = i.description + "%d new update(s)\n\n" % [update.entries.count]
55
89
  end
56
90
  end
57
91
  i.description = i.description + "<pre><blockquote>\n"
@@ -1,4 +1,3 @@
1
-
2
1
  require 'time'
3
2
 
4
3
  module Slackware
@@ -133,8 +132,8 @@ module Slackware
133
132
  # Accessor for the FILE LIST from the package file
134
133
  # unless the :owned_files symbol is populated
135
134
  def get_owned_files
136
- if not(@owned_files.nil?)
137
- return @owned_files
135
+ unless self.owned_files.nil?
136
+ return self.owned_files
138
137
  else
139
138
  f = File.open(self.path + '/' + self.fullname)
140
139
  files = f.drop_while {|l| not( l =~ /^FILE LIST:/) }[2..-1].map {|l| l.chomp }
@@ -145,8 +144,8 @@ module Slackware
145
144
 
146
145
  # Set the file list in the package object in memory
147
146
  def set_owned_files
148
- if @owned_files.nil?
149
- @owned_files = @get_owned_files
147
+ if self.owned_files.nil?
148
+ self.owned_files = get_owned_files()
150
149
  return true
151
150
  else
152
151
  return false
@@ -176,7 +175,7 @@ module Slackware
176
175
  end
177
176
 
178
177
  def inspect
179
- "#<%s:0x%x name=%s version=%s arch=%s build=%s tag=%s>" % [
178
+ "#<%s:0x%x name=\"%s\" version=\"%s\" arch=\"%s\" build=%s tag=\"%s\">" % [
180
179
  self.class.name,
181
180
  self.object_id,
182
181
  self.name,
@@ -0,0 +1,42 @@
1
+ module Slackware
2
+ class PackageBundle < Package
3
+ attr_accessor :archive
4
+
5
+ def initialize(name = nil)
6
+ super
7
+ end
8
+
9
+ def parse(name)
10
+ super(name)
11
+ if self.build =~ /^(\d+.*)\.(t[gx]z)$/
12
+ self.build = $1
13
+ self.archive = $2
14
+ end
15
+ end
16
+
17
+ def self::get_file_list(pkg)
18
+ e_flag = ""
19
+ if pkg =~ /txz$/
20
+ e_flag = "J"
21
+ elsif pkg =~ /tgz$/
22
+ e_flag = "z"
23
+ elsif pkg =~ /tbz$/
24
+ e_flag = "j"
25
+ end
26
+ IO.popen("tar #{e_flag}wtf #{pkg}") {|f|
27
+ f.readlines.map {|l| l.chomp }
28
+ }
29
+ end
30
+ def get_slack_desc(pkg,file)
31
+ e_flag = ""
32
+ if pkg =~ /txz$/
33
+ e_flag = "J"
34
+ elsif pkg =~ /tgz$/
35
+ e_flag = "z"
36
+ elsif pkg =~ /tbz$/
37
+ e_flag = "j"
38
+ end
39
+ IO.popen("tar #{e_flag}xOf #{pkg} #{file}") {|f| f.readlines.map {|l| l.chomp } }
40
+ end
41
+ end
42
+ end
@@ -40,7 +40,7 @@ module Slackware
40
40
  a
41
41
  end
42
42
  else
43
- ## do some hot parsing of repo
43
+ ## TODO do some hot parsing of 'repo'
44
44
  end
45
45
  end
46
46
 
@@ -57,7 +57,7 @@ module Slackware
57
57
  if (file.nil?)
58
58
  data = ftp.list('*')
59
59
  else
60
- data = ftp.gettextfile(file, nil)
60
+ data = ftp.get(file, nil)
61
61
  end
62
62
  ftp.close
63
63
  return data
@@ -86,29 +86,7 @@ module Slackware
86
86
  def get_changelog
87
87
  if (@changelog.nil?)
88
88
  changelog = {}
89
- changelog_date = fetch("ChangeLog.txt").split(/\n/)
90
- actions = %w{removed added upgraded rebuilt}
91
- actions.each {|action|
92
- changelog[:"#{action}"] = changelog_date.map {|line|
93
- if line =~ /^(\w+)\/(.*)\.t[gx]z:\s+#{action}\.?$/i
94
- s = Slackware::Package.parse($2)
95
- s.path = $1
96
- if (self.mirror.nil?)
97
- base_path= self.path
98
- else
99
- base_path= self.mirror + self.path
100
- end
101
- s.package_location = self.proto +
102
- base_path +
103
- "slackware" +
104
- self.arch +
105
- "-" +
106
- self.version +
107
- "/"
108
- s
109
- end
110
- }.compact
111
- }
89
+ changelog_data = fetch("ChangeLog.txt")
112
90
  return changelog
113
91
  else
114
92
  return @changelog
@@ -155,7 +133,7 @@ module Slackware
155
133
 
156
134
  def set_packages
157
135
  @packages = get_packages
158
- return nil
136
+ return @packages.count
159
137
  end
160
138
 
161
139
  end
@@ -10,12 +10,7 @@ module Slackware
10
10
  RE_REMOVED_NAMES = /^(.*)-upgraded-(\d{4}-\d{2}-\d{2}),(\d{2}:\d{2}:\d{2})$/
11
11
  RE_BUILD_TAG = /^([[:digit:]]+)([[:alpha:]]+)$/
12
12
 
13
- def self::version
14
- Slackware::VERSION
15
- end
16
-
17
13
  class System
18
-
19
14
  def self::installed_packages
20
15
  return Dir.glob(DIR_INSTALLED_PACKAGES + "/*").sort.map {|p| Slackware::Package.parse(p) }
21
16
  end
@@ -157,7 +152,7 @@ module Slackware
157
152
 
158
153
  # Return the version of Slackware Linux currently installed
159
154
  def self::version
160
- Slackware::VERSION
155
+ SLACKWARE_VERSION
161
156
  end
162
157
  end
163
158
 
@@ -108,6 +108,18 @@ def print_packages_times(pkgs, epoch = false)
108
108
  end
109
109
  end
110
110
 
111
+ def print_packages_description(pkgs)
112
+ if (pkgs.count > 0 && pkgs.first.class == Slackware::Package)
113
+ pkgs.each {|pkg|
114
+ printf("%s: COMPRESSED SIZE: %s\n", pkg.fullname, pkg.compressed_size )
115
+ printf("%s: UNCOMPRESSED SIZE: %s\n", pkg.fullname, pkg.uncompressed_size )
116
+ pkg.package_description.each {|line|
117
+ printf("%s: %s\n", pkg.fullname, line )
118
+ }
119
+ }
120
+ end
121
+ end
122
+
111
123
  # package file listing
112
124
  def print_package_file_list(pkgs)
113
125
  if (pkgs.count > 1)
@@ -1,12 +1,12 @@
1
1
 
2
2
  module Slackware
3
- VERSION = begin
3
+ SLACKWARE_VERSION = begin
4
4
  data = File.read("/etc/slackware-version")
5
5
  data =~ /Slackware\s(.*)/
6
6
  $1
7
7
  rescue
8
8
  nil
9
9
  end
10
- UTILS_VERSION = "0.6.0"
10
+ UTILS_VERSION = "0.6.1"
11
11
  end
12
12
 
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: slack-utils
3
3
  version: !ruby/object:Gem::Version
4
- hash: 7
4
+ hash: 5
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 6
9
- - 0
10
- version: 0.6.0
9
+ - 1
10
+ version: 0.6.1
11
11
  platform: ruby
12
12
  authors:
13
13
  - Vincent Batts
@@ -24,6 +24,7 @@ description: " slack-utils is a means by which to access \n\
24
24
  See the examples/ for more information.\n "
25
25
  email: vbatts@hashbangbash.com
26
26
  executables:
27
+ - sli
27
28
  - slf
28
29
  - slo
29
30
  - sll
@@ -41,6 +42,7 @@ files:
41
42
  - bin/slp
42
43
  - bin/slo
43
44
  - bin/sll
45
+ - bin/sli
44
46
  - bin/slfindlinked
45
47
  - examples/list_packages.rb
46
48
  - examples/repo_difference.rb
@@ -51,6 +53,7 @@ files:
51
53
  - lib/slackware/changelog.rb
52
54
  - lib/slackware/changelog/rss.rb
53
55
  - lib/slackware/package.rb
56
+ - lib/slackware/package_bundle.rb
54
57
  - lib/slackware/repo.rb
55
58
  - lib/slackware/version.rb
56
59
  - lib/slackware/system.rb
@@ -63,7 +66,7 @@ rdoc_options:
63
66
  - --main=README.rdoc
64
67
  - --line-numbers
65
68
  - --inline-source
66
- - --title=Slackware utils (slack-utils) 0.6.0 Documentation
69
+ - --title=Slackware utils (slack-utils) 0.6.1 Documentation
67
70
  require_paths:
68
71
  - lib
69
72
  required_ruby_version: !ruby/object:Gem::Requirement