slack-utils 0.6.1 → 0.6.2

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 CHANGED
@@ -2,49 +2,74 @@
2
2
 
3
3
  == Summary
4
4
 
5
- A ruby library to access information on the Slackware Linux distribution
5
+ A handful of commands to quickly/easily access information on the Slackware Linux distribution.
6
+ Further, this provides a ruby library for 'slackware'.
6
7
 
7
8
  == Description
8
9
 
9
10
  slack-utils
10
11
 
11
- slp - shows installed slackware packages
12
- with no args, it will show all.
13
- or for each arg it will search the package names.
12
+ <b>slp</b> - shows installed slackware packages
13
+ with no args, it will show all.
14
+ or for each arg it will search the package names.
14
15
 
15
- slf - search installed slackware packages for a file
16
- this expects an arg(s), and will output, in grep fashion
17
- packages matching your search args.
16
+ <b>slf</b> - search installed slackware packages for a file
17
+ this expects an arg(s), and will output, in grep fashion
18
+ packages matching your search args.
18
19
 
19
- slt - mtime/install time of slackware packages
20
- with no args, it will show all.
21
- or for each arg it will search the package names.
20
+ <b>slt</b> - mtime/install time of slackware packages
21
+ with no args, it will show all.
22
+ or for each arg it will search the package names.
22
23
 
23
- sll - list the contents of packages matching the
24
+ <b>sll</b> - list the contents of packages matching the
24
25
 
25
- slo - find files in /etc/, that have been orphaned and left behind
26
- by unistalled/upgraded packages
26
+ <b>slo</b> - find files in /etc/, that have been orphaned and left behind
27
+ by unistalled/upgraded packages
27
28
 
28
- slfindlinked - finds what is linked to your argument, and it's package
29
- expects 1 argument passed.
29
+ <b>sli</b> - display the package information, for matching packages
30
+
31
+ <b>slfindlinked</b> - finds what is linked to your argument, and it's package
32
+ expects 1 argument passed.
30
33
 
31
34
 
32
35
  TODO:
33
36
  * 2010-08-20 09:16 <bailey> which is that I need to run a query to show
34
- me what packages I'm running are different than the slack-current
35
- versions, since I make local ones and forget about it
37
+ me what packages I'm running are different than the slack-current
38
+ versions, since I make local ones and forget about it
36
39
  * enable `slf` to a relative path, and it determine the absolute path
37
40
 
38
41
  == Installation
39
42
 
40
- To install the gem
41
- sudo gem install pkg/slack-utils-0.6.1.gem
43
+ === From git
44
+
45
+ git clone git://github.com/vbatts/slack-utils.git
46
+
47
+ make slackpkg
48
+
49
+ sudo upgradepkg --install-new pkg/slack-utils-0.6.2-$ARCH-1_vb.tgz
50
+
51
+ === From tar ball
52
+
53
+ tar xfz slack-utils-0.6.2.tar.gz
54
+
55
+ cd slack-utils-0.6.2
56
+
57
+ ruby setup.rb config --prefix=/usr --mandir=/usr/man
58
+
59
+ ruby setup.rb install
60
+
61
+ === From the gem
62
+
63
+ sudo gem install pkg/slack-utils-0.6.2.gem
64
+
42
65
 
43
66
  == Quick Start
44
67
 
45
- Install the gem as above.
68
+ === Using the commands
69
+
70
+ See the system manual page slack-utils(8)
46
71
 
47
- Start using the library
72
+ === Using the library
48
73
 
49
74
  $ irb
50
75
  >> require 'rubygems'
@@ -75,3 +100,9 @@ For more complex examples, please see the examples directory
75
100
  (GEM_ROOT/gems/slack-utils-<version>/examples/).
76
101
 
77
102
  You can also contact me for more help or suggestions.
103
+
104
+
105
+ == Bugs and such
106
+
107
+ Open an "issue" here https://github.com/vbatts/slack-utils/issues
108
+
data/bin/slf CHANGED
@@ -1,63 +1,44 @@
1
- #!/usr/bin/env ruby
1
+ #! /usr/bin/ruby
2
+ # Copyright 2010,2011 Vincent Batts, Vienna, VA
3
+ # All rights reserved.
4
+ #
5
+ # Redistribution and use of this source, with or without modification, is
6
+ # permitted provided that the following conditions are met:
7
+ #
8
+ # 1. Redistributions of this source must retain the above copyright
9
+ # notice, this list of conditions and the following disclaimer.
10
+ #
11
+ # THIS SOFTWARE IS PROVIDED BY THE AUTHOR ''AS IS'' AND ANY EXPRESS OR IMPLIED
12
+ # WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
13
+ # MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
14
+ # EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
15
+ # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
16
+ # PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
17
+ # OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
18
+ # WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
19
+ # OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
20
+ # ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
2
21
 
3
22
  $PROGRAM_NAME = File.basename(__FILE__)
4
23
 
5
- require 'optparse'
6
24
  require 'rubygems'
7
25
  require 'slackware/utils'
26
+ require 'slackware/args'
8
27
 
9
- options = {}
10
- begin
11
- OptionParser.new do |opts|
12
- opts.banner = <<-EOS
13
-
28
+ option_banner = <<-EOS
14
29
  Search for a file within installed Slackware package's FILE LIST.
15
-
16
30
  Usage:
17
31
  #{File.basename(__FILE__)} [options] [pkg search flags] <one or more files>
18
32
 
19
33
  one or more files must be list
20
34
  if no search flags, only names, then those only those matching entries are listed
21
35
  EOS
22
- opts.on("-c", "--color", "Colorize output") do |o|
23
- options[:color] = o
24
- end
25
- opts.on("-p", "--pkg [NAME]", "Package PKGNAME (loose match)") do |o|
26
- options[:pkg] = o
27
- end
28
- opts.on("-V", "--Version [VERSION]", "Package VERSION (loose match)") do |o|
29
- options[:version] = o
30
- end
31
- opts.on("-a", "--arch [ARCH]", "Package ARCH (exact match)") do |o|
32
- options[:arch] = o
33
- end
34
- opts.on("-b", "--build [BUILD]", "Package BUILD (exact match)") do |o|
35
- options[:build] = o
36
- end
37
- opts.on("-t", "--tag [TAG]", "Package TAG (loose match)") do |o|
38
- options[:tag] = o
39
- end
40
- opts.on("-v", "--version", "Display version of this software") do |o|
41
- printf("slack-utils (%s) version: %s, Slackware version: %s\n",
42
- File.basename(__FILE__),
43
- Slackware::UTILS_VERSION,
44
- Slackware::System.version
45
- )
46
- exit()
47
- end
36
+ # This is all the flags we want to use, from Slackware::Args
37
+ option_flags = [:color, :case_insensitive, :pkg_name, :pkg_version,
38
+ :pkg_arch, :pkg_build, :pkg_tag]
48
39
 
49
- opts.parse!
40
+ options = Slackware::Args.parse(ARGV, option_flags, option_banner)
50
41
 
51
- if (ARGV.count == 0)
52
- $stderr.write("ERROR: one of more file must be specified\n")
53
- puts opts
54
- exit 2
55
- end
56
- end
57
- rescue OptionParser::InvalidOption => e
58
- $stderr.write("ERROR: #{e.message}, see --help\n")
59
- exit 1
60
- end
61
42
 
62
43
  if (ARGV.count > 0)
63
44
  options[:all] = true
data/bin/slfindlinked CHANGED
@@ -1,9 +1,42 @@
1
- #!/usr/bin/env ruby
1
+ #! /usr/bin/ruby
2
+ # Copyright 2010,2011 Vincent Batts, Vienna, VA
3
+ # All rights reserved.
4
+ #
5
+ # Redistribution and use of this source, with or without modification, is
6
+ # permitted provided that the following conditions are met:
7
+ #
8
+ # 1. Redistributions of this source must retain the above copyright
9
+ # notice, this list of conditions and the following disclaimer.
10
+ #
11
+ # THIS SOFTWARE IS PROVIDED BY THE AUTHOR ''AS IS'' AND ANY EXPRESS OR IMPLIED
12
+ # WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
13
+ # MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
14
+ # EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
15
+ # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
16
+ # PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
17
+ # OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
18
+ # WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
19
+ # OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
20
+ # ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
2
21
 
3
22
  $PROGRAM_NAME = File.basename(__FILE__)
4
23
 
5
24
  require 'rubygems'
6
25
  require 'slackware/utils'
26
+ require 'slackware/args'
27
+
28
+ option_banner = <<-EOS
29
+ Attempt to find the files
30
+ Usage:
31
+ #{File.basename(__FILE__)} [libname or path]
32
+ EOS
33
+ options = Slackware::Args.parse(ARGV, [], option_banner)
34
+
35
+ if (ARGV.count == 0)
36
+ $stderr.write("ERROR: a library name is needed to search for\n")
37
+ exit(2)
38
+ end
39
+
7
40
 
8
41
  # XXX needs better boilerplating
9
42
  print_find_linked(ARGV[0])
data/bin/sli CHANGED
@@ -1,18 +1,32 @@
1
- #!/usr/bin/env ruby
1
+ #! /usr/bin/ruby
2
+ # Copyright 2010,2011 Vincent Batts, Vienna, VA
3
+ # All rights reserved.
4
+ #
5
+ # Redistribution and use of this source, with or without modification, is
6
+ # permitted provided that the following conditions are met:
7
+ #
8
+ # 1. Redistributions of this source must retain the above copyright
9
+ # notice, this list of conditions and the following disclaimer.
10
+ #
11
+ # THIS SOFTWARE IS PROVIDED BY THE AUTHOR ''AS IS'' AND ANY EXPRESS OR IMPLIED
12
+ # WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
13
+ # MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
14
+ # EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
15
+ # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
16
+ # PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
17
+ # OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
18
+ # WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
19
+ # OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
20
+ # ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
2
21
 
3
22
  $PROGRAM_NAME = File.basename(__FILE__)
4
23
 
5
- require 'optparse'
6
24
  require 'rubygems'
7
25
  require 'slackware/utils'
26
+ require 'slackware/args'
8
27
 
9
- options = {}
10
- begin
11
- OptionParser.new do |opts|
12
- opts.banner = <<-EOS
13
-
28
+ option_banner = <<-EOS
14
29
  List installed Slackware package's information.
15
-
16
30
  Usage:
17
31
  #{File.basename(__FILE__)} [options] [search flags] [list of names]
18
32
 
@@ -20,37 +34,11 @@ Usage:
20
34
  if no search flags, only names, then those only those matching entries are listed
21
35
 
22
36
  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
37
+ # This is all the flags we want to use, from Slackware::Args
38
+ option_flags = [:color, :case_insensitive, :pkg_name, :pkg_version,
39
+ :pkg_arch, :pkg_build, :pkg_tag]
40
+
41
+ options = Slackware::Args.parse(ARGV, option_flags, option_banner)
54
42
 
55
43
  if (ARGV.count > 0)
56
44
  options[:all] = true
data/bin/sll CHANGED
@@ -1,64 +1,56 @@
1
- #!/usr/bin/env ruby
1
+ #! /usr/bin/ruby
2
+ # Copyright 2010,2011 Vincent Batts, Vienna, VA
3
+ # All rights reserved.
4
+ #
5
+ # Redistribution and use of this source, with or without modification, is
6
+ # permitted provided that the following conditions are met:
7
+ #
8
+ # 1. Redistributions of this source must retain the above copyright
9
+ # notice, this list of conditions and the following disclaimer.
10
+ #
11
+ # THIS SOFTWARE IS PROVIDED BY THE AUTHOR ''AS IS'' AND ANY EXPRESS OR IMPLIED
12
+ # WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
13
+ # MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
14
+ # EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
15
+ # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
16
+ # PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
17
+ # OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
18
+ # WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
19
+ # OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
20
+ # ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
2
21
 
3
22
  $PROGRAM_NAME = File.basename(__FILE__)
4
23
 
5
- require 'optparse'
6
24
  require 'rubygems'
7
25
  require 'slackware/utils'
26
+ require 'slackware/args'
8
27
 
9
- options = {}
10
- begin
11
- OptionParser.new do |opts|
12
- opts.banner = <<-EOS
13
-
28
+ option_banner = <<-EOS
14
29
  List owned for files for a given Slackware package.
15
-
16
30
  Usage:
17
31
  #{File.basename(__FILE__)} [search flags] [list of names]
18
32
 
19
33
  if no search flags, only names, then those only those matching entries are listed
20
34
 
21
35
  EOS
22
- opts.on("-p", "--pkg [NAME]", "Package PKGNAME (loose match)") do |o|
23
- options[:pkg] = o
24
- end
25
- opts.on("-V", "--Version [VERSION]", "Package VERSION (loose match)") do |o|
26
- options[:version] = o
27
- end
28
- opts.on("-a", "--arch [ARCH]", "Package ARCH (exact match)") do |o|
29
- options[:arch] = o
30
- end
31
- opts.on("-b", "--build [BUILD]", "Package BUILD (exact match)") do |o|
32
- options[:build] = o
33
- end
34
- opts.on("-t", "--tag [TAG]", "Package TAG (loose match)") do |o|
35
- options[:tag] = o
36
- end
37
- opts.on("-f", "--force", "force me to show all files") do |o|
38
- options[:force] = o
39
- end
40
- opts.on("-v", "--version", "Display version of this software") do |o|
41
- printf("slack-utils (%s) version: %s, Slackware version: %s\n",
42
- File.basename(__FILE__),
43
- Slackware::UTILS_VERSION,
44
- Slackware::System.version
45
- )
46
- exit()
47
- end
48
-
49
- opts.parse!
50
-
51
- end
52
- rescue OptionParser::InvalidOption => e
53
- $stderr.write("ERROR: #{e.message}, see --help\n")
54
- exit 1
36
+ # This is all the flags we want to use, from Slackware::Args
37
+ option_flags = [:force_all, :case_insensitive, :pkg_name, :pkg_version,
38
+ :pkg_arch, :pkg_build, :pkg_tag]
39
+
40
+ options = Slackware::Args.parse(ARGV, option_flags, option_banner)
41
+
42
+ if ((ARGV.count == 0) &&
43
+ (options[:pkg].nil?) &&
44
+ (options[:version].nil?) &&
45
+ (options[:arch].nil?) &&
46
+ (options[:build].nil?) &&
47
+ (options[:tag].nil?) &&
48
+ not(options[:force]) )
49
+ $stderr.write("WARNING: If you really want to see *ALL* files, use the --force flag\n")
50
+ exit(2)
55
51
  end
56
52
 
57
- # handing through that we are listing owned files
58
- # XXX this is not even jeing used
59
- options[:list_files] = true
60
-
61
- if ARGV.count > 0
53
+ if (ARGV.count > 0)
62
54
  options[:all] = true
63
55
  end
64
56
 
data/bin/slo CHANGED
@@ -1,4 +1,23 @@
1
- #!/usr/bin/env ruby
1
+ #! /usr/bin/ruby
2
+ # Copyright 2010,2011 Vincent Batts, Vienna, VA
3
+ # All rights reserved.
4
+ #
5
+ # Redistribution and use of this source, with or without modification, is
6
+ # permitted provided that the following conditions are met:
7
+ #
8
+ # 1. Redistributions of this source must retain the above copyright
9
+ # notice, this list of conditions and the following disclaimer.
10
+ #
11
+ # THIS SOFTWARE IS PROVIDED BY THE AUTHOR ''AS IS'' AND ANY EXPRESS OR IMPLIED
12
+ # WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
13
+ # MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
14
+ # EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
15
+ # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
16
+ # PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
17
+ # OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
18
+ # WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
19
+ # OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
20
+ # ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
2
21
 
3
22
  $PROGRAM_NAME = File.basename(__FILE__)
4
23
 
data/bin/slp CHANGED
@@ -1,18 +1,32 @@
1
- #!/usr/bin/env ruby
1
+ #! /usr/bin/ruby
2
+ # Copyright 2010,2011 Vincent Batts, Vienna, VA
3
+ # All rights reserved.
4
+ #
5
+ # Redistribution and use of this source, with or without modification, is
6
+ # permitted provided that the following conditions are met:
7
+ #
8
+ # 1. Redistributions of this source must retain the above copyright
9
+ # notice, this list of conditions and the following disclaimer.
10
+ #
11
+ # THIS SOFTWARE IS PROVIDED BY THE AUTHOR ''AS IS'' AND ANY EXPRESS OR IMPLIED
12
+ # WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
13
+ # MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
14
+ # EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
15
+ # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
16
+ # PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
17
+ # OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
18
+ # WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
19
+ # OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
20
+ # ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
2
21
 
3
22
  $PROGRAM_NAME = File.basename(__FILE__)
4
23
 
5
- require 'optparse'
6
24
  require 'rubygems'
7
25
  require 'slackware/utils'
26
+ require 'slackware/args'
8
27
 
9
- options = {}
10
- begin
11
- OptionParser.new do |opts|
12
- opts.banner = <<-EOS
13
-
28
+ option_banner = <<-EOS
14
29
  List installed Slackware packages.
15
-
16
30
  Usage:
17
31
  #{File.basename(__FILE__)} [options] [search flags] [list of names]
18
32
 
@@ -20,37 +34,11 @@ Usage:
20
34
  if no search flags, only names, then those only those matching entries are listed
21
35
 
22
36
  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
37
+ # This is all the flags we want to use, from Slackware::Args
38
+ option_flags = [:color, :case_insensitive, :pkg_name,
39
+ :pkg_version, :pkg_arch, :pkg_build, :pkg_tag]
40
+
41
+ options = Slackware::Args.parse(ARGV, option_flags, option_banner)
54
42
 
55
43
  if (ARGV.count > 0)
56
44
  options[:all] = true
data/bin/slt CHANGED
@@ -1,18 +1,32 @@
1
- #!/usr/bin/env ruby
1
+ #! /usr/bin/ruby
2
+ # Copyright 2010,2011 Vincent Batts, Vienna, VA
3
+ # All rights reserved.
4
+ #
5
+ # Redistribution and use of this source, with or without modification, is
6
+ # permitted provided that the following conditions are met:
7
+ #
8
+ # 1. Redistributions of this source must retain the above copyright
9
+ # notice, this list of conditions and the following disclaimer.
10
+ #
11
+ # THIS SOFTWARE IS PROVIDED BY THE AUTHOR ''AS IS'' AND ANY EXPRESS OR IMPLIED
12
+ # WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
13
+ # MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
14
+ # EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
15
+ # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
16
+ # PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
17
+ # OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
18
+ # WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
19
+ # OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
20
+ # ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
2
21
 
3
22
  $PROGRAM_NAME = File.basename(__FILE__)
4
23
 
5
- require 'optparse'
6
24
  require 'rubygems'
7
25
  require 'slackware/utils'
26
+ require 'slackware/args'
8
27
 
9
- options = {}
10
- begin
11
- OptionParser.new do |opts|
12
- opts.banner = <<-EOS
13
-
28
+ option_banner = <<-EOS
14
29
  List (and search) installed Slackware package's times.
15
-
16
30
  Usage:
17
31
  #{File.basename(__FILE__)} [pkg search flags] [list of names]
18
32
 
@@ -20,42 +34,13 @@ Usage:
20
34
  if no search flags, only names, then those only those matching entries are listed
21
35
 
22
36
  EOS
23
- opts.on("-c", "--color", "Colorize output") do |o|
24
- options[:color] = o
25
- end
26
- opts.on("-e", "--epock", "") do |o|
27
- options[:epoch] = o
28
- end
29
- opts.on("-p", "--pkg [NAME]", "Package PKGNAME (loose match)") do |o|
30
- options[:pkg] = o
31
- end
32
- opts.on("-V", "--Version [VERSION]", "Package VERSION (loose match)") do |o|
33
- options[:version] = o
34
- end
35
- opts.on("-a", "--arch [ARCH]", "Package ARCH (exact match)") do |o|
36
- options[:arch] = o
37
- end
38
- opts.on("-b", "--build [BUILD]", "Package BUILD (exact match)") do |o|
39
- options[:build] = o
40
- end
41
- opts.on("-t", "--tag [TAG]", "Package TAG (loose match)") do |o|
42
- options[:tag] = o
43
- end
44
- opts.on("-v", "--version", "Display version of this software") do |o|
45
- printf("slack-utils (%s) version: %s, Slackware version: %s\n",
46
- File.basename(__FILE__),
47
- Slackware::UTILS_VERSION,
48
- Slackware::System.version
49
- )
50
- exit()
51
- end
52
- end.parse!
53
- rescue OptionParser::InvalidOption => e
54
- $stderr.write("ERROR: #{e.message}, see --help\n")
55
- exit 1
56
- end
37
+ # This is all the flags we want to use, from Slackware::Args
38
+ option_flags = [:color, :epoch, :case_insensitive, :pkg_name, :pkg_version,
39
+ :pkg_arch, :pkg_build, :pkg_tag]
40
+
41
+ options = Slackware::Args.parse(ARGV, option_flags, option_banner)
57
42
 
58
- # handing through that we are gathering times too
43
+ # handing through that we are gathering times
59
44
  options[:time] = true
60
45
 
61
46
  if (ARGV.count > 0)
data/lib/slackware.rb CHANGED
@@ -4,3 +4,4 @@ require 'slackware/package'
4
4
  require 'slackware/system'
5
5
  require 'slackware/changelog'
6
6
  require 'slackware/repo'
7
+ require 'slackware/package_bundle'
@@ -0,0 +1,99 @@
1
+ # Copyright 2010,2011 Vincent Batts, Vienna, VA
2
+ # All rights reserved.
3
+ #
4
+ # Redistribution and use of this source, with or without modification, is
5
+ # permitted provided that the following conditions are met:
6
+ #
7
+ # 1. Redistributions of this source must retain the above copyright
8
+ # notice, this list of conditions and the following disclaimer.
9
+ #
10
+ # THIS SOFTWARE IS PROVIDED BY THE AUTHOR ''AS IS'' AND ANY EXPRESS OR IMPLIED
11
+ # WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
12
+ # MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
13
+ # EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
14
+ # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
15
+ # PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
16
+ # OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
17
+ # WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
18
+ # OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
19
+ # ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
20
+
21
+ require 'optparse'
22
+
23
+ module Slackware
24
+ class Args
25
+ def self.parse(args,flags = nil, banner = nil)
26
+ flags = [] unless flags.is_a?(Array)
27
+ options = {}
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
89
+
90
+ opts.parse!
91
+ return options
92
+
93
+ rescue OptionParser::InvalidOption => ex
94
+ $stderr.write("ERROR: #{e.message}, see --help\n")
95
+ exit(1)
96
+ end
97
+ end
98
+ end
99
+ end
@@ -1,3 +1,22 @@
1
+ # Copyright 2010,2011 Vincent Batts, Vienna, VA
2
+ # All rights reserved.
3
+ #
4
+ # Redistribution and use of this source, with or without modification, is
5
+ # permitted provided that the following conditions are met:
6
+ #
7
+ # 1. Redistributions of this source must retain the above copyright
8
+ # notice, this list of conditions and the following disclaimer.
9
+ #
10
+ # THIS SOFTWARE IS PROVIDED BY THE AUTHOR ''AS IS'' AND ANY EXPRESS OR IMPLIED
11
+ # WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
12
+ # MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
13
+ # EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
14
+ # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
15
+ # PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
16
+ # OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
17
+ # WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
18
+ # OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
19
+ # ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
1
20
 
2
21
  require 'slackware/package'
3
22
  require 'date'
@@ -1,3 +1,23 @@
1
+ # Copyright 2010,2011 Vincent Batts, Vienna, VA
2
+ # All rights reserved.
3
+ #
4
+ # Redistribution and use of this source, with or without modification, is
5
+ # permitted provided that the following conditions are met:
6
+ #
7
+ # 1. Redistributions of this source must retain the above copyright
8
+ # notice, this list of conditions and the following disclaimer.
9
+ #
10
+ # THIS SOFTWARE IS PROVIDED BY THE AUTHOR ''AS IS'' AND ANY EXPRESS OR IMPLIED
11
+ # WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
12
+ # MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
13
+ # EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
14
+ # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
15
+ # PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
16
+ # OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
17
+ # WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
18
+ # OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
19
+ # ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
20
+
1
21
  require 'rss/maker'
2
22
  require 'slackware/changelog'
3
23
 
@@ -109,7 +129,7 @@ module Slackware
109
129
  }
110
130
  end
111
131
  i.description = i.description + "</blockquote></pre>\n"
112
- i.description.gsub!(/\n/, "<br/>\n")
132
+ #i.description.gsub!(/\n/, "<br/>\n")
113
133
  }
114
134
  end
115
135
  return content
@@ -1,3 +1,23 @@
1
+ # Copyright 2010,2011 Vincent Batts, Vienna, VA
2
+ # All rights reserved.
3
+ #
4
+ # Redistribution and use of this source, with or without modification, is
5
+ # permitted provided that the following conditions are met:
6
+ #
7
+ # 1. Redistributions of this source must retain the above copyright
8
+ # notice, this list of conditions and the following disclaimer.
9
+ #
10
+ # THIS SOFTWARE IS PROVIDED BY THE AUTHOR ''AS IS'' AND ANY EXPRESS OR IMPLIED
11
+ # WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
12
+ # MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
13
+ # EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
14
+ # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
15
+ # PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
16
+ # OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
17
+ # WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
18
+ # OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
19
+ # ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
20
+
1
21
  require 'time'
2
22
 
3
23
  module Slackware
@@ -61,7 +81,11 @@ module Slackware
61
81
  f = File.open(self.path + '/' + self.fullname)
62
82
  while true
63
83
  if (f.readline =~ /^PACKAGE DESCRIPTION:\s+(.*)$/)
64
- desc = f.take_while {|l| not(l =~ /FILE LIST:/) }.map {|l| l.sub(/^#{self.name}:\s*/, '').chomp }
84
+ desc = f.take_while {|l|
85
+ not(l =~ /FILE LIST:/)
86
+ }.map {|l|
87
+ l.sub(/^#{self.name}:\s?/, '').chomp
88
+ }
65
89
  return desc
66
90
  end
67
91
  end
@@ -1,20 +1,46 @@
1
+ # Copyright 2010,2011 Vincent Batts, Vienna, VA
2
+ # All rights reserved.
3
+ #
4
+ # Redistribution and use of this source, with or without modification, is
5
+ # permitted provided that the following conditions are met:
6
+ #
7
+ # 1. Redistributions of this source must retain the above copyright
8
+ # notice, this list of conditions and the following disclaimer.
9
+ #
10
+ # THIS SOFTWARE IS PROVIDED BY THE AUTHOR ''AS IS'' AND ANY EXPRESS OR IMPLIED
11
+ # WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
12
+ # MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
13
+ # EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
14
+ # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
15
+ # PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
16
+ # OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
17
+ # WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
18
+ # OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
19
+ # ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
20
+
1
21
  module Slackware
2
22
  class PackageBundle < Package
3
- attr_accessor :archive
23
+ attr_accessor :archive
4
24
 
5
25
  def initialize(name = nil)
6
26
  super
7
27
  end
8
28
 
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
29
+ def parse(name)
30
+ super(name)
31
+ if self.build =~ /^(\d+.*)\.(t[gx]z)$/
32
+ self.build = $1
33
+ self.archive = $2
34
+ elsif self.tag =~ /^(.*)\.(t[gx]z)$/
35
+ self.tag = $1
36
+ self.archive = $2
37
+ end
38
+ end
39
+
40
+ def get_file_list
41
+ pkg = "%s/%s.%s" % [self.path, self.fullname, self.archive]
42
+ return nil unless File.exist?(pkg)
16
43
 
17
- def self::get_file_list(pkg)
18
44
  e_flag = ""
19
45
  if pkg =~ /txz$/
20
46
  e_flag = "J"
@@ -27,7 +53,11 @@ module Slackware
27
53
  f.readlines.map {|l| l.chomp }
28
54
  }
29
55
  end
30
- def get_slack_desc(pkg,file)
56
+
57
+ def read_file(file)
58
+ pkg = "%s/%s.%s" % [self.path, self.fullname, self.archive]
59
+ return nil unless File.exist?(pkg)
60
+
31
61
  e_flag = ""
32
62
  if pkg =~ /txz$/
33
63
  e_flag = "J"
@@ -36,7 +66,20 @@ module Slackware
36
66
  elsif pkg =~ /tbz$/
37
67
  e_flag = "j"
38
68
  end
39
- IO.popen("tar #{e_flag}xOf #{pkg} #{file}") {|f| f.readlines.map {|l| l.chomp } }
69
+ IO.popen("tar #{e_flag}xOf #{pkg} #{file}") {|f| f.read }
70
+ end
71
+
72
+ def inspect
73
+ "#<%s:0x%x name=%s version=%s arch=%s build=%s tag=%s archive=%s>" % [
74
+ self.class.name,
75
+ self.object_id,
76
+ self.name.inspect,
77
+ self.version.inspect,
78
+ self.arch.inspect,
79
+ self.build,
80
+ self.tag.inspect,
81
+ self.archive.inspect
82
+ ]
40
83
  end
41
84
  end
42
85
  end
@@ -1,3 +1,22 @@
1
+ # Copyright 2010,2011 Vincent Batts, Vienna, VA
2
+ # All rights reserved.
3
+ #
4
+ # Redistribution and use of this source, with or without modification, is
5
+ # permitted provided that the following conditions are met:
6
+ #
7
+ # 1. Redistributions of this source must retain the above copyright
8
+ # notice, this list of conditions and the following disclaimer.
9
+ #
10
+ # THIS SOFTWARE IS PROVIDED BY THE AUTHOR ''AS IS'' AND ANY EXPRESS OR IMPLIED
11
+ # WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
12
+ # MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
13
+ # EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
14
+ # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
15
+ # PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
16
+ # OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
17
+ # WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
18
+ # OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
19
+ # ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
1
20
 
2
21
  require 'slackware/package'
3
22
  require 'slackware/changelog'
@@ -1,3 +1,22 @@
1
+ # Copyright 2010,2011 Vincent Batts, Vienna, VA
2
+ # All rights reserved.
3
+ #
4
+ # Redistribution and use of this source, with or without modification, is
5
+ # permitted provided that the following conditions are met:
6
+ #
7
+ # 1. Redistributions of this source must retain the above copyright
8
+ # notice, this list of conditions and the following disclaimer.
9
+ #
10
+ # THIS SOFTWARE IS PROVIDED BY THE AUTHOR ''AS IS'' AND ANY EXPRESS OR IMPLIED
11
+ # WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
12
+ # MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
13
+ # EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
14
+ # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
15
+ # PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
16
+ # OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
17
+ # WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
18
+ # OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
19
+ # ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
1
20
 
2
21
  require 'slackware/version'
3
22
  require 'slackware/package'
@@ -1,4 +1,23 @@
1
- #!/usr/bin/env ruby
1
+ # Copyright 2010,2011 Vincent Batts, Vienna, VA
2
+ # All rights reserved.
3
+ #
4
+ # Redistribution and use of this source, with or without modification, is
5
+ # permitted provided that the following conditions are met:
6
+ #
7
+ # 1. Redistributions of this source must retain the above copyright
8
+ # notice, this list of conditions and the following disclaimer.
9
+ #
10
+ # THIS SOFTWARE IS PROVIDED BY THE AUTHOR ''AS IS'' AND ANY EXPRESS OR IMPLIED
11
+ # WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
12
+ # MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
13
+ # EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
14
+ # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
15
+ # PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
16
+ # OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
17
+ # WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
18
+ # OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
19
+ # ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
20
+
2
21
  # started - Fri Oct 9 15:48:43 CDT 2009
3
22
  # updated for args - Tue Mar 23 14:54:19 CDT 2010
4
23
  # Copyright 2009, 2010 Vincent Batts, http://hashbangbash.com/
@@ -13,29 +32,39 @@ require 'slackware'
13
32
 
14
33
 
15
34
  # Functions
35
+
36
+ # This is base builder of the packe list
16
37
  def build_packages(opts = {}, args = [])
17
38
  pkgs = Slackware::System.installed_packages
18
39
 
40
+ # separated this little thing out, since it adds a little more time
19
41
  if (opts[:time])
20
42
  pkgs = pkgs.each {|p| p.get_time }
21
43
  end
44
+
22
45
  if (opts[:all])
23
46
  if (args.count > 0)
24
- selected_pkgs = []
25
47
  args.each {|arg|
26
- pkgs.each {|pkg|
27
- if pkg.fullname =~ /#{arg}/
28
- selected_pkgs << pkg
29
- end
30
- }
48
+ # about 0.012s performance improvement,
49
+ # by compiling it here, instead of inside the iteration.
50
+ if (opts[:case_insensitive])
51
+ re = Regexp.compile(/#{arg}/i)
52
+ else
53
+ re = Regexp.compile(/#{arg}/)
54
+ end
55
+
56
+ pkgs = pkgs.find_all {|pkg| pkg.fullname =~ re }
31
57
  }
32
- pkgs = selected_pkgs.uniq
33
- selected_pkgs = nil
34
58
  end
59
+ re = nil
35
60
  end
36
61
  if (opts[:pkg])
62
+ if (opts[:case_insensitive])
63
+ re = Regexp.compile(/#{opts[:pkg]}/i)
64
+ else
65
+ re = Regexp.compile(/#{opts[:pkg]}/)
66
+ end
37
67
  pkgs = pkgs.map {|p|
38
- re = /#{opts[:pkg]}/i
39
68
  if p.name =~ re
40
69
  if (opts[:color])
41
70
  p.name = p.name.gsub(re, "#{@st}\\&#{@en}")
@@ -43,10 +72,15 @@ def build_packages(opts = {}, args = [])
43
72
  p
44
73
  end
45
74
  }.compact
75
+ re = nil
46
76
  end
47
77
  if (opts[:Version])
78
+ if (opts[:case_insensitive])
79
+ re = Regexp.compile(Regexp.escape(/#{opts[:Version]}/i))
80
+ else
81
+ re = Regexp.compile(Regexp.escape(/#{opts[:Version]}/))
82
+ end
48
83
  pkgs = pkgs.map {|p|
49
- re = Regexp.new(Regexp.escape(opts[:Version]))
50
84
  if p.version =~ re
51
85
  if (opts[:color])
52
86
  p.version = p.version.gsub(re, "#{@st}\\&#{@en}")
@@ -54,10 +88,15 @@ def build_packages(opts = {}, args = [])
54
88
  p
55
89
  end
56
90
  }.compact
91
+ re = nil
57
92
  end
58
93
  if (opts[:arch])
94
+ if (opts[:case_insensitive])
95
+ re = Regexp.compile(/#{opts[:arch]}/i)
96
+ else
97
+ re = Regexp.compile(/#{opts[:arch]}/)
98
+ end
59
99
  pkgs = pkgs.map {|p|
60
- re = /#{opts[:arch]}/
61
100
  if p.arch =~ re
62
101
  if (opts[:color])
63
102
  p.arch = p.arch.gsub(re, "#{@st}\\&#{@en}")
@@ -65,10 +104,15 @@ def build_packages(opts = {}, args = [])
65
104
  p
66
105
  end
67
106
  }.compact
107
+ re = nil
68
108
  end
69
109
  if (opts[:build])
110
+ if (opts[:case_insensitive])
111
+ re = Regexp.compile(/#{opts[:build]}/i)
112
+ else
113
+ re = Regexp.compile(/#{opts[:build]}/)
114
+ end
70
115
  pkgs = pkgs.map {|p|
71
- re = /#{opts[:build]}/
72
116
  if p.build =~ re
73
117
  if (opts[:color])
74
118
  p.build = p.build.gsub(re, "#{@st}\\&#{@en}")
@@ -76,10 +120,15 @@ def build_packages(opts = {}, args = [])
76
120
  p
77
121
  end
78
122
  }.compact
123
+ re = nil
79
124
  end
80
125
  if (opts[:tag])
126
+ if (opts[:case_insensitive])
127
+ re = Regexp.compile(/#{opts[:tag]}/i)
128
+ else
129
+ re = Regexp.compile(/#{opts[:tag]}/)
130
+ end
81
131
  pkgs = pkgs.map {|p|
82
- re = /#{opts[:tag]}/i
83
132
  if p.tag =~ re
84
133
  if (opts[:color])
85
134
  p.tag = p.tag.gsub(re, "#{@st}\\&#{@en}")
@@ -87,6 +136,7 @@ def build_packages(opts = {}, args = [])
87
136
  p
88
137
  end
89
138
  }.compact
139
+ re = nil
90
140
  end
91
141
 
92
142
  return pkgs
@@ -1,3 +1,22 @@
1
+ # Copyright 2010,2011 Vincent Batts, Vienna, VA
2
+ # All rights reserved.
3
+ #
4
+ # Redistribution and use of this source, with or without modification, is
5
+ # permitted provided that the following conditions are met:
6
+ #
7
+ # 1. Redistributions of this source must retain the above copyright
8
+ # notice, this list of conditions and the following disclaimer.
9
+ #
10
+ # THIS SOFTWARE IS PROVIDED BY THE AUTHOR ''AS IS'' AND ANY EXPRESS OR IMPLIED
11
+ # WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
12
+ # MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
13
+ # EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
14
+ # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
15
+ # PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
16
+ # OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
17
+ # WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
18
+ # OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
19
+ # ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
1
20
 
2
21
  module Slackware
3
22
  SLACKWARE_VERSION = begin
@@ -7,6 +26,6 @@ module Slackware
7
26
  rescue
8
27
  nil
9
28
  end
10
- UTILS_VERSION = "0.6.1"
29
+ UTILS_VERSION = "0.6.2"
11
30
  end
12
31
 
metadata CHANGED
@@ -1,29 +1,20 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: slack-utils
3
- version: !ruby/object:Gem::Version
4
- hash: 5
5
- prerelease: false
6
- segments:
7
- - 0
8
- - 6
9
- - 1
10
- version: 0.6.1
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.6.2
5
+ prerelease:
11
6
  platform: ruby
12
- authors:
7
+ authors:
13
8
  - Vincent Batts
14
9
  autorequire: slack-utils
15
10
  bindir: bin
16
11
  cert_chain: []
17
-
18
- date: 2011-11-19 00:00:00 -05:00
19
- default_executable:
12
+ date: 2011-11-19 00:00:00.000000000 Z
20
13
  dependencies: []
21
-
22
- description: " slack-utils is a means by which to access \n\
23
- package information on the Slackware Linux OS. \n\
24
- See the examples/ for more information.\n "
14
+ description: ! " slack-utils is a means by which to access \npackage information on
15
+ the Slackware Linux OS. \nSee the examples/ for more information.\n "
25
16
  email: vbatts@hashbangbash.com
26
- executables:
17
+ executables:
27
18
  - sli
28
19
  - slf
29
20
  - slo
@@ -32,10 +23,9 @@ executables:
32
23
  - slt
33
24
  - slfindlinked
34
25
  extensions: []
35
-
36
- extra_rdoc_files:
26
+ extra_rdoc_files:
37
27
  - README.rdoc
38
- files:
28
+ files:
39
29
  - README.rdoc
40
30
  - bin/slf
41
31
  - bin/slt
@@ -50,6 +40,7 @@ files:
50
40
  - examples/repo.rb
51
41
  - lib/slackware.rb
52
42
  - lib/slackware/utils.rb
43
+ - lib/slackware/args.rb
53
44
  - lib/slackware/changelog.rb
54
45
  - lib/slackware/changelog/rss.rb
55
46
  - lib/slackware/package.rb
@@ -57,42 +48,32 @@ files:
57
48
  - lib/slackware/repo.rb
58
49
  - lib/slackware/version.rb
59
50
  - lib/slackware/system.rb
60
- has_rdoc: true
61
51
  homepage: https://github.com/vbatts/slack-utils/
62
52
  licenses: []
63
-
64
53
  post_install_message:
65
- rdoc_options:
54
+ rdoc_options:
66
55
  - --main=README.rdoc
67
56
  - --line-numbers
68
57
  - --inline-source
69
- - --title=Slackware utils (slack-utils) 0.6.1 Documentation
70
- require_paths:
58
+ - --title=Slackware utils (slack-utils) 0.6.2 Documentation
59
+ require_paths:
71
60
  - lib
72
- required_ruby_version: !ruby/object:Gem::Requirement
61
+ required_ruby_version: !ruby/object:Gem::Requirement
73
62
  none: false
74
- requirements:
75
- - - ">="
76
- - !ruby/object:Gem::Version
77
- hash: 3
78
- segments:
79
- - 0
80
- version: "0"
81
- required_rubygems_version: !ruby/object:Gem::Requirement
63
+ requirements:
64
+ - - ! '>='
65
+ - !ruby/object:Gem::Version
66
+ version: '0'
67
+ required_rubygems_version: !ruby/object:Gem::Requirement
82
68
  none: false
83
- requirements:
84
- - - ">="
85
- - !ruby/object:Gem::Version
86
- hash: 3
87
- segments:
88
- - 0
89
- version: "0"
69
+ requirements:
70
+ - - ! '>='
71
+ - !ruby/object:Gem::Version
72
+ version: '0'
90
73
  requirements: []
91
-
92
74
  rubyforge_project:
93
- rubygems_version: 1.3.7
75
+ rubygems_version: 1.8.6
94
76
  signing_key:
95
77
  specification_version: 3
96
78
  summary: Accessing information for the Slackware Linux distribution
97
79
  test_files: []
98
-