Class: Slackware::Repo
- Inherits:
-
Object
- Object
- Slackware::Repo
- Defined in:
- lib/slackware/repo.rb
Overview
Stub
Constant Summary collapse
- RE_PACKAGE_NAME =
/^PACKAGE NAME:\s+(.*)\.t[gbx]z\s*/- RE_PACKAGE_LOCATION =
/^PACKAGE LOCATION:\s+(.*)$/- RE_COMPRESSED_SIZE =
/^PACKAGE SIZE \(compressed\):\s+(.*)$/- RE_UNCOMPRESSED_SIZE =
/^PACKAGE SIZE \(uncompressed\):\s+(.*)$/
Instance Attribute Summary collapse
-
#arch ⇒ Object
Returns the value of attribute arch.
-
#changelog ⇒ Object
Returns the value of attribute changelog.
-
#mirror ⇒ Object
Returns the value of attribute mirror.
-
#packages ⇒ Object
Returns the value of attribute packages.
-
#path ⇒ Object
Returns the value of attribute path.
-
#proto ⇒ Object
Returns the value of attribute proto.
-
#uri ⇒ Object
Returns the value of attribute uri.
-
#version ⇒ Object
Returns the value of attribute version.
Instance Method Summary collapse
- #fetch(file = nil) ⇒ Object
-
#get_changelog ⇒ Object
Pkg count that should be removed pkgs = Slackware::System.installed_packages sr = Slackware::Repo.new sr.version = “current” c = get_changelog (pkgs.map {|p| p.fullname } & c.map {|p| p.fullname }).count.
- #get_packages ⇒ Object
-
#initialize(repo = nil) ⇒ Repo
constructor
A new instance of Repo.
- #set_changelog ⇒ Object
- #set_packages ⇒ Object
- #url ⇒ Object
- #url=(thisurl) ⇒ Object
Constructor Details
#initialize(repo = nil) ⇒ Repo
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 |
# File 'lib/slackware/repo.rb', line 43 def initialize(repo = nil) @packages = nil if (repo.nil?) self.proto = "ftp://" self.mirror = "ftp.osuosl.org" self.path = "/pub/slackware/" self.version = begin v = Slackware::System.version if v =~ /(\d+)\.(\d+)\.\d+/ v = $1 + "." + $2 end v end self.arch = RbConfig::CONFIG["arch"] =~ /x86_64/ ? "64" : "" else ## TODO do some hot parsing of 'repo' self.uri = URI.parse(repo) end end |
Instance Attribute Details
#arch ⇒ Object
Returns the value of attribute arch.
41 42 43 |
# File 'lib/slackware/repo.rb', line 41 def arch @arch end |
#changelog ⇒ Object
Returns the value of attribute changelog.
41 42 43 |
# File 'lib/slackware/repo.rb', line 41 def changelog @changelog end |
#mirror ⇒ Object
Returns the value of attribute mirror.
41 42 43 |
# File 'lib/slackware/repo.rb', line 41 def mirror @mirror end |
#packages ⇒ Object
Returns the value of attribute packages.
41 42 43 |
# File 'lib/slackware/repo.rb', line 41 def packages @packages end |
#path ⇒ Object
Returns the value of attribute path.
41 42 43 |
# File 'lib/slackware/repo.rb', line 41 def path @path end |
#proto ⇒ Object
Returns the value of attribute proto.
41 42 43 |
# File 'lib/slackware/repo.rb', line 41 def proto @proto end |
#uri ⇒ Object
Returns the value of attribute uri.
41 42 43 |
# File 'lib/slackware/repo.rb', line 41 def uri @uri end |
#version ⇒ Object
Returns the value of attribute version.
41 42 43 |
# File 'lib/slackware/repo.rb', line 41 def version @version end |
Instance Method Details
#fetch(file = nil) ⇒ Object
75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 |
# File 'lib/slackware/repo.rb', line 75 def fetch(file = nil) #if file.nil? #url = URI.parse(self.proto + self.mirror + self.path) #else #url = URI.parse(self.proto + self.mirror + self.path + file) #end if self.proto =~ /ftp/ ftp = Net::FTP.open(self.mirror) ftp.login ftp.chdir(self.path + "slackware" + self.arch + "-" + self.version) if (file.nil?) data = ftp.list('*') else data = ftp.get(file, nil) end ftp.close return data elsif self.proto =~ /http/ # XXX this is not working yet req = Net::HTTP::Get.new(url.path) res = Net::HTTP.start(url.host, url.port) {|http| http.request(req) } return res elsif self.proto =~ /file/ if (file.nil?) return Dir.glob(self.path + "slackware" + self.arch + "-" + self.version + "/*") else return File.read(self.path + "slackware" + self.arch + "-" + self.version + "/" + file) end else return nil end end |
#get_changelog ⇒ Object
Pkg count that should be removed pkgs = Slackware::System.installed_packages sr = Slackware::Repo.new sr.version = “current” c = get_changelog (pkgs.map {|p| p.fullname } & c.map {|p| p.fullname }).count
114 115 116 117 118 119 120 121 122 |
# File 'lib/slackware/repo.rb', line 114 def get_changelog if (@changelog.nil?) changelog = {} changelog_data = fetch("ChangeLog.txt") return changelog else return @changelog end end |
#get_packages ⇒ Object
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 |
# File 'lib/slackware/repo.rb', line 129 def get_packages if (@packages.nil?) pkgs = [] fetch("PACKAGES.TXT").split(/\n\n/).each {|p_block| p_block = p_block.split(/\n/).reject {|cell| cell if cell == "" } if (p_block.shift =~ RE_PACKAGE_NAME) pkg = Slackware::Package.parse($1) p_block.shift =~ RE_PACKAGE_LOCATION pkg.package_location = $1 p_block.shift =~ RE_COMPRESSED_SIZE pkg.compressed_size = $1 p_block.shift =~ RE_UNCOMPRESSED_SIZE pkg.uncompressed_size = $1 # This is the empty PACKAGE DESCRIPTON: tag p_block.shift pkg.package_description = p_block.map {|cell| cell.sub(/^#{pkg.name}:\s*/, '') } pkgs << pkg end } return pkgs else return @packages end end |
#set_changelog ⇒ Object
124 125 126 127 |
# File 'lib/slackware/repo.rb', line 124 def set_changelog @changelog = get_changelog return nil end |
#set_packages ⇒ Object
162 163 164 165 |
# File 'lib/slackware/repo.rb', line 162 def set_packages @packages = get_packages return @packages.count end |
#url ⇒ Object
63 64 65 66 67 68 69 |
# File 'lib/slackware/repo.rb', line 63 def url "%s%s%sslackware%s-%s/" % [self.proto, self.mirror, self.path, self.arch, self.version] end |
#url=(thisurl) ⇒ Object
71 72 73 |
# File 'lib/slackware/repo.rb', line 71 def url=(thisurl) self.uri = URI.parse(thisurl) end |