slack-utils 0.6.2 → 0.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/README.rdoc +9 -20
- data/bin/slf +23 -11
- data/bin/slfindlinked +1 -1
- data/bin/sli +22 -10
- data/bin/sll +22 -9
- data/bin/slo +17 -5
- data/bin/slp +22 -10
- data/bin/slt +21 -11
- data/examples/before_then.rb +1 -0
- data/examples/list_packages.rb +4 -3
- data/examples/repo.rb +1 -0
- data/examples/repo_difference.rb +1 -0
- data/lib/slackware/args.rb +80 -73
- data/lib/slackware/changelog/rss.rb +3 -0
- data/lib/slackware/changelog.rb +15 -12
- data/lib/slackware/log.rb +53 -0
- data/lib/slackware/package.rb +232 -203
- data/lib/slackware/package_bundle.rb +43 -40
- data/lib/slackware/paths.rb +57 -0
- data/lib/slackware/repo.rb +134 -129
- data/lib/slackware/system.rb +179 -153
- data/lib/slackware/utils.rb +247 -244
- data/lib/slackware/version.rb +12 -9
- data/lib/slackware.rb +24 -0
- metadata +5 -3
data/examples/repo_difference.rb
CHANGED
data/lib/slackware/args.rb
CHANGED
@@ -1,4 +1,6 @@
|
|
1
|
-
#
|
1
|
+
# encoding: UTF-8
|
2
|
+
|
3
|
+
# Copyright 2010,2011,2012 Vincent Batts, Vienna, VA
|
2
4
|
# All rights reserved.
|
3
5
|
#
|
4
6
|
# Redistribution and use of this source, with or without modification, is
|
@@ -21,79 +23,84 @@
|
|
21
23
|
require 'optparse'
|
22
24
|
|
23
25
|
module Slackware
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
opts = OptionParser.new do |opts|
|
30
|
-
if banner
|
31
|
-
opts.banner = banner
|
32
|
-
end
|
33
|
-
if flags.include?(:color)
|
34
|
-
opts.on("-c", "--color", "Colorize output") do |o|
|
35
|
-
options[:color] = o
|
36
|
-
end
|
37
|
-
end
|
38
|
-
if flags.include?(:epoch)
|
39
|
-
opts.on("-e", "--epoch", "Print the time stamp in seconds since 1970-01-01 00:00:00 UTC ") do |o|
|
40
|
-
options[:epoch] = o
|
41
|
-
end
|
42
|
-
end
|
43
|
-
if flags.include?(:pkg_name)
|
44
|
-
opts.on("-p", "--pkg [NAME]", "Package PKGNAME (loose match)") do |o|
|
45
|
-
options[:pkg] = o
|
46
|
-
end
|
47
|
-
end
|
48
|
-
if flags.include?(:pkg_version)
|
49
|
-
opts.on("-V", "--Version [VERSION]", "Package VERSION (loose match)") do |o|
|
50
|
-
options[:version] = o
|
51
|
-
end
|
52
|
-
end
|
53
|
-
if flags.include?(:pkg_arch)
|
54
|
-
opts.on("-a", "--arch [ARCH]", "Package ARCH (exact match)") do |o|
|
55
|
-
options[:arch] = o
|
56
|
-
end
|
57
|
-
end
|
58
|
-
if flags.include?(:pkg_build)
|
59
|
-
opts.on("-b", "--build [BUILD]", "Package BUILD (exact match)") do |o|
|
60
|
-
options[:build] = o
|
61
|
-
end
|
62
|
-
end
|
63
|
-
if flags.include?(:pkg_tag)
|
64
|
-
opts.on("-t", "--tag [TAG]", "Package TAG (loose match)") do |o|
|
65
|
-
options[:tag] = o
|
66
|
-
end
|
67
|
-
end
|
68
|
-
if flags.include?(:case_insensitive)
|
69
|
-
opts.on("-i", "When searching, do a case insensitive match") do |o|
|
70
|
-
options[:case_insensitive] = o
|
71
|
-
end
|
72
|
-
end
|
73
|
-
if flags.include?(:force_all)
|
74
|
-
opts.on("-f", "--force", "force me to show all files") do |o|
|
75
|
-
options[:force] = o
|
76
|
-
end
|
77
|
-
end
|
78
|
-
|
79
|
-
opts.on("-v", "--version", "Display version of this software") do |o|
|
80
|
-
printf("slack-utils version: %s, Slackware version: %s\n",
|
81
|
-
Slackware::UTILS_VERSION,
|
82
|
-
Slackware::System.version
|
83
|
-
)
|
84
|
-
exit(0)
|
85
|
-
end
|
86
|
-
end
|
87
|
-
|
88
|
-
begin
|
26
|
+
# Args is the unified arguement parser for the slack-utils utilities.
|
27
|
+
class Args
|
28
|
+
def self.parse(args,flags = nil, banner = nil)
|
29
|
+
flags = [] unless flags.is_a?(Array)
|
30
|
+
options = {}
|
89
31
|
|
90
|
-
|
91
|
-
|
32
|
+
opts = OptionParser.new do |opts|
|
33
|
+
if banner
|
34
|
+
opts.banner = banner
|
35
|
+
end
|
36
|
+
if flags.include?(:color)
|
37
|
+
opts.on("-c", "--color", "Colorize output") do |o|
|
38
|
+
options[:color] = o
|
39
|
+
end
|
40
|
+
end
|
41
|
+
if flags.include?(:epoch)
|
42
|
+
opts.on("-e", "--epoch", "Print the time stamp in seconds since 1970-01-01 00:00:00 UTC ") do |o|
|
43
|
+
options[:epoch] = o
|
44
|
+
end
|
45
|
+
end
|
46
|
+
if flags.include?(:pkg_name)
|
47
|
+
opts.on("-p", "--pkg [NAME]", "Package PKGNAME (loose match)") do |o|
|
48
|
+
options[:pkg] = o
|
49
|
+
end
|
50
|
+
end
|
51
|
+
if flags.include?(:pkg_version)
|
52
|
+
opts.on("-V", "--Version [VERSION]", "Package VERSION (loose match)") do |o|
|
53
|
+
options[:version] = o
|
54
|
+
end
|
55
|
+
end
|
56
|
+
if flags.include?(:pkg_arch)
|
57
|
+
opts.on("-a", "--arch [ARCH]", "Package ARCH (exact match)") do |o|
|
58
|
+
options[:arch] = o
|
59
|
+
end
|
60
|
+
end
|
61
|
+
if flags.include?(:pkg_build)
|
62
|
+
opts.on("-b", "--build [BUILD]", "Package BUILD (exact match)") do |o|
|
63
|
+
options[:build] = o
|
64
|
+
end
|
65
|
+
end
|
66
|
+
if flags.include?(:pkg_tag)
|
67
|
+
opts.on("-t", "--tag [TAG]", "Package TAG (loose match)") do |o|
|
68
|
+
options[:tag] = o
|
69
|
+
end
|
70
|
+
end
|
71
|
+
if flags.include?(:case_insensitive)
|
72
|
+
opts.on("-i", "When searching, do a case insensitive match") do |o|
|
73
|
+
options[:case_insensitive] = o
|
74
|
+
end
|
75
|
+
end
|
76
|
+
if flags.include?(:force_all)
|
77
|
+
opts.on("-f", "--force", "force me to show all files") do |o|
|
78
|
+
options[:force] = o
|
79
|
+
end
|
80
|
+
end
|
81
|
+
if flags.include?(:debug)
|
82
|
+
opts.on("-D", "--debug", "show debugging output") do |o|
|
83
|
+
options[:debug] = o
|
84
|
+
end
|
85
|
+
end
|
92
86
|
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
87
|
+
opts.on("-v", "--version", "Display version of this software") do |o|
|
88
|
+
printf("slack-utils version: %s, Slackware version: %s\n",
|
89
|
+
Slackware::UTILS_VERSION,
|
90
|
+
Slackware::System.version
|
91
|
+
)
|
92
|
+
exit(0)
|
98
93
|
end
|
94
|
+
end
|
95
|
+
|
96
|
+
begin
|
97
|
+
opts.parse!
|
98
|
+
return options
|
99
|
+
rescue OptionParser::InvalidOption => ex
|
100
|
+
$stderr.write("ERROR: #{e.message}, see --help\n")
|
101
|
+
exit(1)
|
102
|
+
end
|
103
|
+
end
|
104
|
+
end
|
99
105
|
end
|
106
|
+
# vim : set sw=2 sts=2 et :
|
data/lib/slackware/changelog.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# encoding: UTF-8
|
2
|
+
|
1
3
|
# Copyright 2010,2011 Vincent Batts, Vienna, VA
|
2
4
|
# All rights reserved.
|
3
5
|
#
|
@@ -41,16 +43,16 @@ module Slackware
|
|
41
43
|
|
42
44
|
# The regular entry, accounting for usb-and-pxe-installers directory,
|
43
45
|
# and notes after the action
|
44
|
-
re_package_entry0 =
|
46
|
+
re_package_entry0 = /^(([\w+-]+).*\/.*):\s+(\w+).*\.?$/
|
45
47
|
# Some didn't have an action after the name
|
46
|
-
re_package_entry1 =
|
48
|
+
re_package_entry1 = /^(([\w+-]+).*\/.*):/
|
47
49
|
# and some didn't have the ':' or an action
|
48
|
-
re_package_entry2 =
|
50
|
+
re_package_entry2 = /^(([\w+-]+).*\/.*\.t[gbx]z)/
|
49
51
|
# combine them
|
50
52
|
RE_PACKAGE_ENTRY = Regexp.union(re_package_entry0, re_package_entry1, re_package_entry2)
|
51
53
|
|
52
54
|
# (* Security fix *)
|
53
|
-
RE_SECURITY_FIX =
|
55
|
+
RE_SECURITY_FIX = /\(\*\s+security\s+fix\s+\*\)/i
|
54
56
|
|
55
57
|
# for hacks sake, make these usbable elsewhere
|
56
58
|
def self::re_date ; RE_DATE ; end
|
@@ -150,21 +152,21 @@ module Slackware
|
|
150
152
|
end
|
151
153
|
|
152
154
|
def parse(opts = {:file => nil, :data => nil})
|
153
|
-
|
154
|
-
|
155
|
+
if not(opts[:file].nil?)
|
156
|
+
@updates = parse_this_file(opts[:file]).updates
|
155
157
|
elsif not(@file.nil?)
|
156
|
-
|
157
|
-
|
158
|
-
|
158
|
+
@updates = parse_this_file(@file).updates
|
159
|
+
end
|
160
|
+
return self
|
159
161
|
end
|
160
162
|
|
161
163
|
# Class method
|
162
164
|
def self::parse(file)
|
163
|
-
|
165
|
+
return parse_this_file(file)
|
164
166
|
end
|
165
167
|
|
166
168
|
def self::open(file)
|
167
|
-
|
169
|
+
return parse_this_file(file)
|
168
170
|
end
|
169
171
|
|
170
172
|
def inspect
|
@@ -180,7 +182,7 @@ module Slackware
|
|
180
182
|
# * take packge notes until
|
181
183
|
# * next package or entry separator
|
182
184
|
# * separator creates next change entry
|
183
|
-
def parse_this_file(file)
|
185
|
+
def self::parse_this_file(file)
|
184
186
|
f_handle = ""
|
185
187
|
if file.is_a?(File)
|
186
188
|
f_handle = file
|
@@ -270,3 +272,4 @@ module Slackware
|
|
270
272
|
|
271
273
|
end
|
272
274
|
end
|
275
|
+
# vim : set sw=2 sts=2 et :
|
@@ -0,0 +1,53 @@
|
|
1
|
+
# encoding: UTF-8
|
2
|
+
|
3
|
+
# Copyright 2012 Vincent Batts, Vienna, VA
|
4
|
+
# All rights reserved.
|
5
|
+
#
|
6
|
+
# Redistribution and use of this source, with or without modification, is
|
7
|
+
# permitted provided that the following conditions are met:
|
8
|
+
#
|
9
|
+
# 1. Redistributions of this source must retain the above copyright
|
10
|
+
# notice, this list of conditions and the following disclaimer.
|
11
|
+
#
|
12
|
+
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ''AS IS'' AND ANY EXPRESS OR IMPLIED
|
13
|
+
# WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
14
|
+
# MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
|
15
|
+
# EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
16
|
+
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
17
|
+
# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
18
|
+
# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
19
|
+
# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
20
|
+
# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
21
|
+
# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
22
|
+
|
23
|
+
require 'logger'
|
24
|
+
require 'singleton'
|
25
|
+
|
26
|
+
module Slackware
|
27
|
+
|
28
|
+
# Log is a subclass of Logger, but is implemented as a singleton,
|
29
|
+
# so it can be used across library in a somewhat unified manner.
|
30
|
+
# Example:
|
31
|
+
# require 'slackware/log'
|
32
|
+
#
|
33
|
+
# slog = Slackware::Log.instance
|
34
|
+
# slog.info("LOG ALL THE THINGS!")
|
35
|
+
# slog.debug('my_app') { ex.backtrace }
|
36
|
+
#
|
37
|
+
class Log < Logger
|
38
|
+
include Singleton
|
39
|
+
|
40
|
+
# Since Singleton does a lazy loader, this will not get initialized
|
41
|
+
# until it is first used. So it'll be nil, or you can set $logdev early on.
|
42
|
+
# It defaults to WARN level and STDERR
|
43
|
+
def initialize(*args)
|
44
|
+
if $logdev
|
45
|
+
super($logdev, args)
|
46
|
+
else
|
47
|
+
super(STDERR, args)
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end # class Log
|
51
|
+
end # module Slackware
|
52
|
+
|
53
|
+
# vim : set sw=2 sts=2 et :
|
data/lib/slackware/package.rb
CHANGED
@@ -1,4 +1,6 @@
|
|
1
|
-
#
|
1
|
+
# encoding: UTF-8
|
2
|
+
|
3
|
+
# Copyright 2010,2011,2012 Vincent Batts, Vienna, VA
|
2
4
|
# All rights reserved.
|
3
5
|
#
|
4
6
|
# Redistribution and use of this source, with or without modification, is
|
@@ -19,211 +21,238 @@
|
|
19
21
|
# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
20
22
|
|
21
23
|
require 'time'
|
24
|
+
require 'slackware/log'
|
25
|
+
require 'slackware/paths'
|
22
26
|
|
23
27
|
module Slackware
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
28
|
+
class Package
|
29
|
+
RE_FILE_LIST = /^FILE LIST:/
|
30
|
+
RE_COMPRESSED_PACKAGE_SIZE = /^COMPRESSED PACKAGE SIZE:\s+(.*)$/
|
31
|
+
RE_UNCOMPRESSED_PACKAGE_SIZE = /^UNCOMPRESSED PACKAGE SIZE:\s+(.*)$/
|
32
|
+
RE_PACKAGE_LOCATION = /^PACKAGE LOCATION:\s+(.*)$/
|
33
|
+
RE_PACKAGE_DESCRIPTION = /^PACKAGE DESCRIPTION:\s+(.*)$/
|
34
|
+
|
35
|
+
FMT_UPGRADE_TIME = "%F %H:%M:%S"
|
36
|
+
|
37
|
+
attr_accessor :time, :path, :file, :name, :version, :arch, :build, :tag, :tag_sep, :upgrade_time, :owned_files
|
38
|
+
def initialize(name = nil)
|
39
|
+
self.name = name
|
40
|
+
end
|
41
|
+
|
42
|
+
# pkg.parse instance method for parsing the package information
|
43
|
+
def parse(name)
|
44
|
+
if name.include?("/")
|
45
|
+
self.path = File.dirname(name)
|
46
|
+
name = File.basename(name)
|
47
|
+
end
|
48
|
+
if (name =~ RE_REMOVED_NAMES)
|
49
|
+
name = $1
|
50
|
+
self.upgrade_time = Time.strptime($2 + ' ' + $3, fmt=FMT_UPGRADE_TIME)
|
51
|
+
end
|
52
|
+
arr = name.split('-')
|
53
|
+
build = arr.pop
|
54
|
+
if (build.include?("_"))
|
55
|
+
self.tag_sep = "_"
|
56
|
+
self.build = build.split(self.tag_sep)[0]
|
57
|
+
self.tag = build.split(self.tag_sep)[1..-1].join(self.tag_sep)
|
58
|
+
elsif (build =~ RE_BUILD_TAG)
|
59
|
+
self.build = $1
|
60
|
+
self.tag = $2
|
61
|
+
else
|
62
|
+
self.build = build
|
63
|
+
self.tag = ""
|
64
|
+
end
|
65
|
+
self.arch = arr.pop
|
66
|
+
self.version = arr.pop
|
67
|
+
self.name = arr.join('-')
|
68
|
+
end
|
69
|
+
|
70
|
+
# Package.parse class method
|
71
|
+
def self::parse(name)
|
72
|
+
p = self.new()
|
73
|
+
p.parse(name)
|
74
|
+
return p
|
75
|
+
end
|
76
|
+
|
77
|
+
# Reassemble the package name as it would be in file form
|
78
|
+
def fullname
|
79
|
+
if (self.upgrade_time)
|
80
|
+
time = self.upgrade_time.strftime("%F,%H:%M:%S")
|
81
|
+
return [self.name, self.version, self.arch, [self.build, self.tag].join(self.tag_sep), "upgraded", time].join("-")
|
82
|
+
else
|
83
|
+
return [self.name, self.version, self.arch, [self.build, self.tag].join(self.tag_sep)].join("-")
|
84
|
+
end
|
85
|
+
end
|
86
|
+
|
87
|
+
# Accessor for the PACKAGE DESCRIPTION from the package file
|
88
|
+
def package_description
|
89
|
+
if not(@package_description.nil?)
|
90
|
+
return @package_description
|
91
|
+
end
|
92
|
+
|
93
|
+
f = File.open(self.path + '/' + self.fullname)
|
94
|
+
while true
|
95
|
+
if (f.readline =~ RE_PACKAGE_DESCRIPTION)
|
96
|
+
desc = f.take_while {|l|
|
97
|
+
not(l =~ RE_FILE_LIST)
|
86
98
|
}.map {|l|
|
87
99
|
l.sub(/^#{self.name}:\s?/, '').chomp
|
88
100
|
}
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
101
|
+
return desc
|
102
|
+
end
|
103
|
+
end
|
104
|
+
end
|
105
|
+
|
106
|
+
# Setter for the PACKAGE DESCRIPTION, in the event you are parsing a repo file
|
107
|
+
def package_description=(desc)
|
108
|
+
@package_description = desc
|
109
|
+
end
|
110
|
+
|
111
|
+
# Accessor for the PACKAGE LOCATION from the package file
|
112
|
+
def package_location
|
113
|
+
if not(@package_location.nil?)
|
114
|
+
return @package_location
|
115
|
+
end
|
116
|
+
|
117
|
+
f = File.open(self.path + '/' + self.fullname)
|
118
|
+
while true
|
119
|
+
if (f.readline =~ RE_PACKAGE_LOCATION)
|
120
|
+
return $1
|
121
|
+
end
|
122
|
+
end
|
123
|
+
end
|
124
|
+
|
125
|
+
# Setter for the PACKAGE LOCATION, in the event you are parsing a repo file
|
126
|
+
def package_location=(path)
|
127
|
+
@package_location = path
|
128
|
+
end
|
129
|
+
|
130
|
+
# Accessor for the UNCOMPRESSED PACKAGE SIZE from the package file
|
131
|
+
def uncompressed_size
|
132
|
+
if not(@uncompressed_size.nil?)
|
133
|
+
return @uncompressed_size
|
134
|
+
end
|
135
|
+
|
136
|
+
f = File.open(self.path + '/' + self.fullname)
|
137
|
+
while true
|
138
|
+
if (f.readline =~ RE_UNCOMPRESSED_PACKAGE_SIZE)
|
139
|
+
return $1
|
140
|
+
end
|
141
|
+
end
|
142
|
+
end
|
143
|
+
|
144
|
+
# Setter for the UNCOMPRESSED PACKAGE SIZE, in the event you are parsing a repo file
|
145
|
+
def uncompressed_size=(size)
|
146
|
+
@uncompressed_size = size
|
147
|
+
end
|
148
|
+
|
149
|
+
# Accessor for the COMPRESSED PACKAGE SIZE from the package file
|
150
|
+
def compressed_size
|
151
|
+
if not(@compressed_size.nil?)
|
152
|
+
return @compressed_size
|
153
|
+
end
|
154
|
+
|
155
|
+
f = File.open(self.path + '/' + self.fullname)
|
156
|
+
while true
|
157
|
+
if (f.readline =~ RE_COMPRESSED_PACKAGE_SIZE)
|
158
|
+
return $1
|
159
|
+
end
|
160
|
+
end
|
161
|
+
end
|
162
|
+
|
163
|
+
# Setter for the COMPRESSED PACKAGE SIZE, in the event you are parsing a repo file
|
164
|
+
def compressed_size=(size)
|
165
|
+
@compressed_size = size
|
166
|
+
end
|
167
|
+
|
168
|
+
# Accessor for the FILE LIST from the package file
|
169
|
+
# unless the :owned_files symbol is populated
|
170
|
+
def get_owned_files
|
171
|
+
unless self.owned_files.nil?
|
172
|
+
return self.owned_files
|
173
|
+
else
|
174
|
+
files = []
|
175
|
+
File.open(self.path + '/' + self.fullname) do |f|
|
176
|
+
while true
|
177
|
+
break if f.eof?
|
178
|
+
line = f.readline()
|
179
|
+
if line.force_encoding("US-ASCII") =~ RE_FILE_LIST # FIXME ArgumentError: invalid byte sequence in US-ASCII
|
180
|
+
f.seek(2, IO::SEEK_CUR)
|
181
|
+
break
|
182
|
+
end
|
183
|
+
end
|
184
|
+
begin
|
185
|
+
files = f.readlines().map {|line| line.rstrip.force_encoding("US-ASCII") }
|
186
|
+
rescue ArgumentError
|
187
|
+
Log.instance.debug("Slackware::Package") {
|
188
|
+
"encoding in : " + self.path + '/' + self.fullname
|
189
|
+
}
|
190
|
+
end
|
191
|
+
end
|
192
|
+
return files
|
193
|
+
end
|
194
|
+
end
|
195
|
+
|
196
|
+
# Set the file list in the package object in memory
|
197
|
+
def set_owned_files
|
198
|
+
if self.owned_files.nil?
|
199
|
+
self.owned_files = get_owned_files()
|
200
|
+
return true
|
201
|
+
else
|
202
|
+
return false
|
203
|
+
end
|
204
|
+
end
|
205
|
+
|
206
|
+
# populates and returns self.time
|
207
|
+
def get_time
|
208
|
+
if (self.time.nil? && self.path)
|
209
|
+
if (File.exist?(self.path + "/" + self.fullname))
|
210
|
+
self.time = File.mtime(self.path + "/" + self.fullname)
|
211
|
+
end
|
212
|
+
elsif (not(self.path) && (self.time.nil?))
|
213
|
+
if (File.exist?(Paths::installed_packages() + "/" + self.fullname))
|
214
|
+
self.time = File.mtime(Paths::installed_packages() + "/" + self.fullname)
|
215
|
+
end
|
216
|
+
end
|
217
|
+
return self.time
|
218
|
+
end
|
219
|
+
|
220
|
+
# Fill in the path information
|
221
|
+
def get_path
|
222
|
+
if (self.path.nil? && File.exist?(Paths::installed_packages() + "/" + self.name))
|
223
|
+
self.path = Paths::installed_packages()
|
224
|
+
return Paths::installed_packages()
|
225
|
+
end
|
226
|
+
end
|
227
|
+
|
228
|
+
def inspect
|
229
|
+
"#<%s:0x%x name=\"%s\" version=\"%s\" arch=\"%s\" build=%s tag=\"%s\">" % [
|
230
|
+
self.class.name,
|
231
|
+
self.object_id,
|
232
|
+
self.name,
|
233
|
+
self.version,
|
234
|
+
self.arch,
|
235
|
+
self.build,
|
236
|
+
self.tag
|
237
|
+
]
|
238
|
+
end
|
239
|
+
|
240
|
+
end
|
241
|
+
|
242
|
+
class Script < Package
|
243
|
+
attr_accessor :script
|
244
|
+
|
245
|
+
def initialize(name = nil)
|
246
|
+
self.script = true
|
247
|
+
super
|
248
|
+
end
|
249
|
+
|
250
|
+
def parse(name)
|
251
|
+
super
|
252
|
+
self.script = true
|
253
|
+
end
|
254
|
+
|
255
|
+
end
|
229
256
|
end
|
257
|
+
|
258
|
+
# vim:sw=2:sts=2:et:
|