Sha256: 9a2bfb9c39c2ae72e9fd4b02c3dd52cccf087f9cc64f1788e4a9778ac5cad3a1
Contents?: true
Size: 1.79 KB
Versions: 5
Compression:
Stored size: 1.79 KB
Contents
require 'tmpdir' require 'set' require_relative 'helper' require_relative 'rpm' require_relative 'pkgs' require_relative 'elf' require_relative 'constants' 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(Constants::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
5 entries across 5 versions & 1 rubygems
Version | Path |
---|---|
dply-0.3.8 | lib/dply/deplist.rb |
dply-0.3.7 | lib/dply/deplist.rb |
dply-0.3.6 | lib/dply/deplist.rb |
dply-0.3.5 | lib/dply/deplist.rb |
dply-0.3.4 | lib/dply/deplist.rb |