Sha256: 4a9e4a6ec5918b65759f91aa08287b732fe95ac779fbd843d71355233143bf73
Contents?: true
Size: 1.75 KB
Versions: 4
Compression:
Stored size: 1.75 KB
Contents
require 'tmpdir' require 'set' require_relative 'helper' require_relative 'rpm' require_relative 'pkgs' require_relative 'elf' module Dply class Deplist include Helper BASE_PACKAGES = Set["glibc", "libgcc", "libstdc++", "openssl", "ruby-alt", "jemalloc"] def initialize(tar_path) @tar_path = Pathname.new(tar_path).realpath end def verify! error "#{@tar_path} not readable" if not File.readable? @tar_path tmp_dir do logger.info "(in #{Dir.pwd})" cmd "tar xf #{@tar_path}" pkgs_list = Pkgs.new("pkgs.yml").runtime @libs_files_map = libs_files_map libs = @libs_files_map.keys if logger.debug? require 'pp' pp @libs_files_map end deps = Rpm.libs_pkgs_map libs verify_deps(deps, pkgs_list) end end private def verify_deps(deps, pkgs_list) deps.each do |lib, pkgs| next if pkgs.find { |pkg| BASE_PACKAGES.include? pkg } if not pkgs.any? { |pkg| pkgs_list.include? pkg } logger.error "missing from pkgs.yml : any of #{pkgs} (lib: #{lib}, files: #{@libs_files_map[lib]})" @error = true end end error "packages dependencies not satisfied" if @error puts "all dependencies satisfied".green end def tmp_dir(&block) dir = File.exist?("tmp") ? "tmp" : "/tmp" Dir.mktmpdir(nil, dir) do |d| Dir.chdir(d) { yield } end end def libs_files_map libs = {} Dir["./**/*"].each do |f| next if not Elf.elf? f dynamic_libs(f).each do |l| libs[l] ||= [] libs[l] << f end end return libs end def dynamic_libs(file) Elf.new(file).external_libs end end end
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
dply-0.3.3 | lib/dply/deplist.rb |
dply-0.3.2 | lib/dply/deplist.rb |
dply-0.3.1 | lib/dply/deplist.rb |
dply-0.3.0 | lib/dply/deplist.rb |