class Archlinux::PackageFiles
a list of packages archives
Attributes
files[RW]
Public Class Methods
from_dir(dir, config: Archlinux.config)
click to toggle source
# File lib/aur/repos.rb, line 332 def self.from_dir(dir, config: Archlinux.config) dir=Pathname.new(dir) list=dir.glob('*.pkg.*').map do |g| next if g.to_s.end_with?('~') or g.to_s.end_with?('.sig') f=dir+g next unless f.readable? f end.compact self.new(*list, config: config) end
new(*files, config: Archlinux.config)
click to toggle source
# File lib/aur/repos.rb, line 194 def initialize(*files, config: Archlinux.config) files=files.flatten #in case we are used with create @files=files.map {|file| Pathname.new(file)} @config=config end
rm_files(*files, dir: nil)
click to toggle source
# File lib/aur/repos.rb, line 282 def self.rm_files(*files, dir: nil) deleted=[] files.each do |file| path=Pathname.new(file) path=dir+path if path.relative? and dir if path.exist? path.rm deleted << path end sig=Pathname.new("#{path}.sig") if sig.exist? sig.rm deleted << sig end end SH.logger.verbose2 "Deleted: #{deleted}" deleted end
Public Instance Methods
bsdtar_infos()
click to toggle source
# File lib/aur/repos.rb, line 205 def bsdtar_infos list=[] @files.each do |file| info={repo: file} SH.run_simple("bsdtar -xOqf #{file.shellescape} .PKGINFO", chomp: :lines) do |error| SH.logger.info "Skipping #{file}: #{error}" next end.each do |l| next if l=~/^#/ key, value=l.split(/\s*=\s*/,2) key=key.to_sym case key when :builddate value=Time.at(value.to_i) when :size key=:install_size; value=value.to_i when :pkgver key=:version end Archlinux.add_to_hash(info, key, value) end # no need to add at the end, pacinfo always end with a new line list << info end list end
clean(dry_run: true) { |to_clean| ... }
click to toggle source
# File lib/aur/repos.rb, line 312 def clean(dry_run: true) to_clean=[] latest=packages.latest.values packages.each do |_name, pkg| to_clean << pkg unless latest.include?(pkg) end if block_given? to_clean = yield to_clean end unless dry_run to_clean.each do |f| p=f.path p.rm if p.exist? sig=Pathname.new(p.to_s+".sig") sig.rm if sig.exist? end end return to_clean.map {|pkg| pkg.path}, to_clean end
expac_infos(slice=200)
click to toggle source
# File lib/aur/repos.rb, line 232 def expac_infos(slice=200) #the command line should not be too long format={ filename: "%f", pkgname: "%n", pkgbase: "%e", version: "%v", url: "%u", description: "%d", packager: "%p", architecture: "%a", build_date: "%b", download_size: "%k", install_size: "%m", depends: "%D", conflicts: "%H", opt_depends: "%O", provides: "%P", replaces: "%T", # format << "%r\n" #repo } total=format.keys.count r=[]; delim=" , " split=lambda do |l| l.split(delim) end @files.each_slice(slice) do |files| SH.run_simple("expac --timefmt=%s #{format.values.join("\n").shellescape} -l #{delim.shellescape} -p #{files.shelljoin}", chomp: :lines).each_slice(total).with_index do |l,i| info={} format.keys.each_with_index do |k, kk| value=l[kk] value=split[value] if %i(depends conflicts opt_depends provides replaces).include?(k) value=nil if k==:pkgbase and value=="(null)" value=Time.at(value.to_i) if k==:build_date value=value.to_i if k==:download_size or k==:install_size info[k]=value if value end info[:repo]=files[i] r<<info end end r end
infos()
click to toggle source
# File lib/aur/repos.rb, line 200 def infos # expac_infos bsdtar_infos end
packages(refresh=false)
click to toggle source
# File lib/aur/repos.rb, line 273 def packages(refresh=false) @packages=nil if refresh @packages ||= @config.to_packages(self.infos) end
rm_pkgs(*pkgs)
click to toggle source
pass packages names to remove
# File lib/aur/repos.rb, line 302 def rm_pkgs(*pkgs) files=[] pkgs.each do |pkg_name| pkg=packages.fetch(pkg_name, nil) files << pkg.path if pkg end @packages=nil #we need to refresh the list. self.class.rm_files(*files) end
sign(sign_name: :package, **opts)
click to toggle source
# File lib/aur/repos.rb, line 278 def sign(sign_name: :package, **opts) @config&.sign(*@files, sign_name: sign_name, **opts) end