DebianPackageDownloader 0.6.0
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/History.txt +6 -0
- data/Manifest.txt +7 -0
- data/README.txt +52 -0
- data/Rakefile +12 -0
- data/bin/dpkg_download +3 -0
- data/lib/debian_package_downloader.rb +68 -0
- data/test/test_debian_package_downloader.rb +54 -0
- metadata +72 -0
data/History.txt
ADDED
data/Manifest.txt
ADDED
data/README.txt
ADDED
@@ -0,0 +1,52 @@
|
|
1
|
+
= DebianPackageDownloader
|
2
|
+
|
3
|
+
http://rubyforge.org/projects/uwruby/
|
4
|
+
http://uwruby/rubyforge.org/debian_package_downloader
|
5
|
+
|
6
|
+
== DESCRIPTION:
|
7
|
+
|
8
|
+
Debian Package Downloader is (going to be when completed) a useful tool for
|
9
|
+
embedded developers working on embedded linux.
|
10
|
+
|
11
|
+
When working on embedded linux it can be
|
12
|
+
|
13
|
+
== FEATURES/PROBLEMS:
|
14
|
+
|
15
|
+
* FIX (list of features or problems)
|
16
|
+
|
17
|
+
== SYNOPSIS:
|
18
|
+
|
19
|
+
FIX (code sample of usage)
|
20
|
+
|
21
|
+
== REQUIREMENTS:
|
22
|
+
|
23
|
+
* FIX (list of requirements)
|
24
|
+
|
25
|
+
== INSTALL:
|
26
|
+
|
27
|
+
sudo gem install
|
28
|
+
|
29
|
+
== LICENSE:
|
30
|
+
|
31
|
+
(The MIT License)
|
32
|
+
|
33
|
+
Copyright (c) 2008 FIX
|
34
|
+
|
35
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
36
|
+
a copy of this software and associated documentation files (the
|
37
|
+
'Software'), to deal in the Software without restriction, including
|
38
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
39
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
40
|
+
permit persons to whom the Software is furnished to do so, subject to
|
41
|
+
the following conditions:
|
42
|
+
|
43
|
+
The above copyright notice and this permission notice shall be
|
44
|
+
included in all copies or substantial portions of the Software.
|
45
|
+
|
46
|
+
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
|
47
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
48
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
49
|
+
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
50
|
+
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
51
|
+
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
52
|
+
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/Rakefile
ADDED
@@ -0,0 +1,12 @@
|
|
1
|
+
# -*- ruby -*-
|
2
|
+
|
3
|
+
require 'rubygems'
|
4
|
+
require 'hoe'
|
5
|
+
require './lib/debian_package_downloader.rb'
|
6
|
+
|
7
|
+
Hoe.new('DebianPackageDownloader', DebianPackageDownloader::VERSION) do |p|
|
8
|
+
p.rubyforge_name = 'uwruby'
|
9
|
+
p.developer('Mathew Chasan', 'aftermathew@gmail.com')
|
10
|
+
end
|
11
|
+
|
12
|
+
# vim: syntax=Ruby
|
data/bin/dpkg_download
ADDED
@@ -0,0 +1,68 @@
|
|
1
|
+
#!/usr/bin/ruby -w
|
2
|
+
|
3
|
+
require 'pp'
|
4
|
+
|
5
|
+
class DebianPackageDownloader
|
6
|
+
VERSION = '0.6.0'
|
7
|
+
VALID_DEBIAN_ARCHITECTURES = %w[alpha amd64 arm armel hppa i386 ia64 mips
|
8
|
+
mipsel powerpc s390 sparc]
|
9
|
+
|
10
|
+
# The name of the base package that will be downloaded
|
11
|
+
attr_accessor :package, :architecture, :download_dir
|
12
|
+
|
13
|
+
|
14
|
+
def initialize packagename=nil, architecture=nil, dir=nil
|
15
|
+
if packagename then
|
16
|
+
self.package = packagename
|
17
|
+
else
|
18
|
+
@package = nil
|
19
|
+
end
|
20
|
+
|
21
|
+
@architecture = architecture
|
22
|
+
@download_dir = dir
|
23
|
+
@dependencies = []
|
24
|
+
@suggestions = []
|
25
|
+
@all_dependencies = []
|
26
|
+
@all_suggestions = []
|
27
|
+
end
|
28
|
+
|
29
|
+
# Returns true if packageName is a real debian package, and false otherwise
|
30
|
+
def self.validPackage? packageName
|
31
|
+
result = %x[apt-cache pkgnames]
|
32
|
+
result.split("\n").include?(packageName)
|
33
|
+
end
|
34
|
+
|
35
|
+
# Sets the package
|
36
|
+
def package=(packageName)
|
37
|
+
unless DebianPackageDownloader::validPackage? packageName
|
38
|
+
raise ArgumentError, "Package #{packageName} does not exist."
|
39
|
+
end
|
40
|
+
@package = packageName
|
41
|
+
end
|
42
|
+
|
43
|
+
# Equivelent to package=
|
44
|
+
def setPackageName packagename
|
45
|
+
self.package = packagename
|
46
|
+
end
|
47
|
+
|
48
|
+
def architecture= ( architecture )
|
49
|
+
arch = architecture.downcase
|
50
|
+
unless VALID_DEBIAN_ARCHITECTURES.include? arch
|
51
|
+
raise ArgumentError, "Invalid architecture"
|
52
|
+
end
|
53
|
+
@architecture = arch
|
54
|
+
end
|
55
|
+
|
56
|
+
def depends
|
57
|
+
unless @package
|
58
|
+
raise StandardError, "Package not set!"
|
59
|
+
end
|
60
|
+
|
61
|
+
deps = %x[apt-cache depends #{@package}]
|
62
|
+
pp deps
|
63
|
+
@dependencies = deps.map{ |x|
|
64
|
+
x.sub!("Depends:", '') ? x.strip! : nil
|
65
|
+
}
|
66
|
+
@dependencies.compact!
|
67
|
+
end
|
68
|
+
end
|
@@ -0,0 +1,54 @@
|
|
1
|
+
#!/usr/bin/env ruby -w
|
2
|
+
|
3
|
+
require 'test/unit'
|
4
|
+
require 'debian_package_downloader'
|
5
|
+
|
6
|
+
##
|
7
|
+
# Student Name: Mathew Chasan <aftermathew@gmail.com>
|
8
|
+
# Homework Week: 7
|
9
|
+
#
|
10
|
+
#
|
11
|
+
|
12
|
+
class PackageDownloaderTest < Test::Unit::TestCase
|
13
|
+
def setup
|
14
|
+
@downloader = DebianPackageDownloader.new
|
15
|
+
end
|
16
|
+
|
17
|
+
def test_invalid_package
|
18
|
+
assert_raise(ArgumentError){
|
19
|
+
@downloader.package = "FakePackageName"
|
20
|
+
}
|
21
|
+
end
|
22
|
+
|
23
|
+
def test_valid_package
|
24
|
+
assert(DebianPackageDownloader.validPackage?('ruby'))
|
25
|
+
end
|
26
|
+
|
27
|
+
def test_invalid_architecture
|
28
|
+
assert_raise(ArgumentError){
|
29
|
+
@downloader.architecture = "vax"
|
30
|
+
}
|
31
|
+
end
|
32
|
+
|
33
|
+
def test_valid_architecture
|
34
|
+
assert_nothing_raised{
|
35
|
+
@downloader.architecture = "arm"
|
36
|
+
}
|
37
|
+
end
|
38
|
+
|
39
|
+
def test_dependencies
|
40
|
+
@downloader.package = "ruby1.8"
|
41
|
+
assert_equal( %w[libc6 libruby1.8], @downloader.depends )
|
42
|
+
# assert_equal( %w[ruby1.8-examples, rdoc1.8, ri1.8], @downloader.suggests )
|
43
|
+
end
|
44
|
+
|
45
|
+
def test_recursive_dependencies
|
46
|
+
|
47
|
+
end
|
48
|
+
|
49
|
+
def test_download
|
50
|
+
end
|
51
|
+
|
52
|
+
def teardown
|
53
|
+
end
|
54
|
+
end
|
metadata
ADDED
@@ -0,0 +1,72 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: DebianPackageDownloader
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.6.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Mathew Chasan
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
|
12
|
+
date: 2008-12-17 00:00:00 -08:00
|
13
|
+
default_executable:
|
14
|
+
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
16
|
+
name: hoe
|
17
|
+
type: :development
|
18
|
+
version_requirement:
|
19
|
+
version_requirements: !ruby/object:Gem::Requirement
|
20
|
+
requirements:
|
21
|
+
- - ">="
|
22
|
+
- !ruby/object:Gem::Version
|
23
|
+
version: 1.8.2
|
24
|
+
version:
|
25
|
+
description: Debian Package Downloader is (going to be when completed) a useful tool for embedded developers working on embedded linux. When working on embedded linux it can be
|
26
|
+
email:
|
27
|
+
- aftermathew@gmail.com
|
28
|
+
executables:
|
29
|
+
- dpkg_download
|
30
|
+
extensions: []
|
31
|
+
|
32
|
+
extra_rdoc_files:
|
33
|
+
- History.txt
|
34
|
+
- Manifest.txt
|
35
|
+
- README.txt
|
36
|
+
files:
|
37
|
+
- History.txt
|
38
|
+
- Manifest.txt
|
39
|
+
- README.txt
|
40
|
+
- Rakefile
|
41
|
+
- bin/dpkg_download
|
42
|
+
- lib/debian_package_downloader.rb
|
43
|
+
- test/test_debian_package_downloader.rb
|
44
|
+
has_rdoc: true
|
45
|
+
homepage: http://rubyforge.org/projects/uwruby/
|
46
|
+
post_install_message:
|
47
|
+
rdoc_options:
|
48
|
+
- --main
|
49
|
+
- README.txt
|
50
|
+
require_paths:
|
51
|
+
- lib
|
52
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
53
|
+
requirements:
|
54
|
+
- - ">="
|
55
|
+
- !ruby/object:Gem::Version
|
56
|
+
version: "0"
|
57
|
+
version:
|
58
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
59
|
+
requirements:
|
60
|
+
- - ">="
|
61
|
+
- !ruby/object:Gem::Version
|
62
|
+
version: "0"
|
63
|
+
version:
|
64
|
+
requirements: []
|
65
|
+
|
66
|
+
rubyforge_project: uwruby
|
67
|
+
rubygems_version: 1.2.0
|
68
|
+
signing_key:
|
69
|
+
specification_version: 2
|
70
|
+
summary: Debian Package Downloader is (going to be when completed) a useful tool for embedded developers working on embedded linux
|
71
|
+
test_files:
|
72
|
+
- test/test_debian_package_downloader.rb
|