class Archlinux::MakepkgList

Attributes

cache[RW]
config[RW]
l[RW]

Public Class Methods

from_dir(dir=nil, config: Archlinux.config) click to toggle source
# File lib/aur/makepkg.rb, line 333
def self.from_dir(dir=nil, config: Archlinux.config)
        l=[]
        dir=config.cachedir if dir.nil?
        dir.children.each do |child|
                if child.directory? and (child+"PKGBUILD").file?
                        l << child
                end
        end
        self.new(l, config: config)
end
new(l=[], config: Archlinux.config, cache: config.cachedir) click to toggle source
# File lib/aur/makepkg.rb, line 344
def initialize(l=[], config: Archlinux.config, cache: config.cachedir)
        @config=config
        @cache=Pathname.new(cache) if cache #how relative filenames are resolved; pass nil to use current dir
        @l={}
        merge(l)
end

Public Instance Methods

build(*args, chroot: @config.dig(:chroot, :active), install: false, **opts) click to toggle source
# File lib/aur/makepkg.rb, line 419
def build(*args, chroot: @config.dig(:chroot, :active), install: false, **opts)
        mkarchroot if chroot
        @config.pre_install(*args, makepkg_list: self, install: install, **opts)
        built=@l.values.map do |l|
                l.build(*args, chroot: chroot, **opts)
        end
        l_success=built.flat_map { |pkgs| pkgs || []}
        @config.post_install(l_success, makepkg_list: self, install: install, **opts)
        built
end
get(*_args, view: true, pkgver: false, **opts) click to toggle source
# File lib/aur/makepkg.rb, line 374
def get(*_args, view: true, pkgver: false, **opts)
        Dir.mktmpdir("aur_view") do |d|
                @l.values.each do |l|
                        l.get(*_args, logdir: d, view: false, pkgver: false, **opts) #l.get does not take arguments, we put them here for arg/opt ruby confusion
                end
                if view
                        r=@config.view(d)
                        if r
                                @l.values.each do |l|
                                        l.get_pkg.done_view if l.get_pkg.respond_to?(:done_view)
                                end
                        end
                else
                        r=true
                end
                if r and pkgver
                        @l.values.map do |l| #all?
                                l.get_source if l.pkgver?
                        end
                end
                return r
        end
end
install(*args, view: true, **opts) click to toggle source
# File lib/aur/makepkg.rb, line 438
def install(*args, view: true, **opts)
        r=get(view: view)
        pre_build(*args, **opts)
        build(*args, **opts) if r
        post_build(*args, **opts)
end
list() click to toggle source
# File lib/aur/makepkg.rb, line 415
def list
        @l.values.flat_map { |l| l.list }
end
make(*args) click to toggle source
# File lib/aur/makepkg.rb, line 398
def make(*args)
        @l.values.each do |l|
                l.make(*args)
        end
end
makechroot(*args) click to toggle source
# File lib/aur/makepkg.rb, line 404
def makechroot(*args)
        @l.values.each do |l|
                l.makechroot(*args)
        end
end
merge(l) click to toggle source
# File lib/aur/makepkg.rb, line 351
def merge(l)
        l.each do |m|
                unless m.is_a?(Makepkg)
                        m=Pathname.new(m)
                        m = @cache+m if m.relative? and @cache
                        m=Makepkg.new(m, config: @config)
                end
                @l[m.name]=m
        end
end
mkarchroot() click to toggle source
# File lib/aur/makepkg.rb, line 410
def mkarchroot
        args=@config.dig(:chroot, :packages) || ["base-devel"]
        @config.chroot_devtools.mkarchroot(*args)
end
packages(refresh=false, get: false) click to toggle source
# File lib/aur/makepkg.rb, line 362
def packages(refresh=false, get: false)
        @packages = nil if refresh
        if get
                get_options={}
                get_options=get if get.is_a?(Hash)
                self.get(**get_options)
        end
        @packages ||= @l.values.reduce(@config.to_packages) do |list, makepkg|
                list.merge(makepkg.packages(get: false))
        end
end
post_build(*args, **opts) click to toggle source
# File lib/aur/makepkg.rb, line 434
def post_build(*args, **opts)
end
pre_build(*args, **opts) click to toggle source

Note that in build @config.{pre,post}_install is called

# File lib/aur/makepkg.rb, line 431
def pre_build(*args, **opts)
end