class Archlinux::Repo

this hold a repo name

Attributes

config[RW]
repo[RW]

Public Class Methods

foreign_list() click to toggle source
# File lib/aur/repos.rb, line 124
def self.foreign_list
        %x(pacman -Qqm).split
end
foreign_packages() click to toggle source
# File lib/aur/repos.rb, line 128
def self.foreign_packages
        packages(*foreign_list)
end
info(*packages) click to toggle source
# File lib/aur/repos.rb, line 109
def self.info(*packages)
        if SH.find_executable("pacinfo")
                pacinfo(*packages)
        else
                pacman_info(*packages)
        end
end
new(name, config: Archlinux.config) click to toggle source
# File lib/aur/repos.rb, line 11
def initialize(name, config: Archlinux.config)
        @repo=name
        @config=config
end
pacinfo(*pkgs) click to toggle source
# File lib/aur/repos.rb, line 86
def self.pacinfo(*pkgs) #this refers to the local db info
        list=[]; info={}
        res=SH.run_simple("pacinfo #{pkgs.shelljoin}", chomp: :lines)
        res.each do |l|
                key, value=l.split(/\s*:\s*/,2)
                if key.nil? #next package
                        list << info; info={}
                        next
                end
                key=key.downcase.gsub(' ', '_').to_sym
                case key
                when :install_script
                        value=false if value=="No"
                        value=true if value=="Yes"
                when :install_date, :build_date
                        value=Time.parse(value)
                end
                Archlinux.add_to_hash(info, key, value)
        end
        # no need to add at the end, pacinfo always end with a new line
        list
end
packages(*packages) click to toggle source

Exemple: Archlinux::Repo.packages(* %x/pacman -Qqm/.split) Warning: this does not use config, so this is just for a convenience helper. Use RepoPkgs for install/config stuff

# File lib/aur/repos.rb, line 120
def self.packages(*packages)
        PackageList.new(info(*packages))
end
pacman_info(*pkgs, local: false) click to toggle source
# File lib/aur/repos.rb, line 45
def self.pacman_info(*pkgs, local: false) #local=true refers to the local db info. Note that pacman does not understand local/pkg but pacinfo does
        list=[]
        to_list=lambda do |s|
                return [] if s=="None"
                s.split
        end
        # Note: core/pacman only works for -Sddp or -Si, not for -Qi
        # Indeed local/pacman works for pacinfo, but not for pacman (needs
        # the -Q options)
        res=SH.run_simple({'COLUMNS' => '1000'}, "pacman -#{local ? 'Q': 'S'}i #{pkgs.shelljoin}", chomp: :lines)
        key=nil; info={}
        res.each do |l|
                if key==:optional_deps and (m=l.match(/^\s+(\w*):\s+(.*)$/))
                        #here we cannot split(':') because we need to check for the leading space
                        info[key][m[1]]=m[2]
                else
                        key, value=l.split(/\s*:\s*/,2)
                        if key.nil? #new package
                                list << info; key=nil; info={}
                                next
                        end
                        key=key.strip.downcase.gsub(' ', '_').to_sym
                        case key
                        when :optional_deps
                                dep, reason=value.split(/\s*:\s*/,2)
                                value={dep => reason}
                        when :groups, :provides, :depends_on, :required_by, :optional_for, :conflicts_with, :replaces
                                value=to_list.call(value)
                        when :install_script
                                value=false if value=="No"
                                value=true if value=="Yes"
                        when :install_date, :build_date
                                value=Time.parse(value)
                        end
                        info[key]=value
                end
        end
        # no need to add the last info, pacman -Q/Si always end with a new line
        list
end

Public Instance Methods

list(mode: :pacsift) click to toggle source
# File lib/aur/repos.rb, line 16
def list(mode: :pacsift)
        command= case mode
        when :pacman, :name
                if @repo=="local"
                        "pacman -Qq"
                else
                        "pacman -Slq #{@repo.shellescape}" #returns pkg
                end
        when :repo_name
                #like pacsift, but using pacman
                list(mode: :name).map {|i| @repo+"/"+i}
        when :pacsift
                #this mode is prefered, so that if the same pkg is in different
                #repo, than pacman_info returns the correct info
                #pacsift understand the 'local' repo
                "pacsift --exact --repo=#{@repo.shellescape} <&-" #returns repo/pkg
        when :paclist, :name_version
                #cannot show the local repo; we could use `expac -Q '%n %v' but we
                #don't use this mode anyway
                "paclist #{@repo.shellescape}" #returns 'pkg version'
        end
        SH.run_simple(command, chomp: :lines) {return nil}
end
packages(refresh=false) click to toggle source
# File lib/aur/repos.rb, line 40
def packages(refresh=false)
        @packages=nil if refresh
        @packages ||= @config.to_packages(self.class.info(*list))
end