diff options
author | 2015-06-19 16:11:32 +0100 | |
---|---|---|
committer | 2015-06-19 16:11:32 +0100 | |
commit | eb79ff8a7cd8b3365d7d2001554965356004716d (patch) | |
tree | e8f56f3263f13c762b870fbf0d0c87ce74732a97 /web | |
parent | Strip the 8 byte header from docker's API response (diff) | |
download | ruby-tinderbox-eb79ff8a7cd8b3365d7d2001554965356004716d.tar.gz ruby-tinderbox-eb79ff8a7cd8b3365d7d2001554965356004716d.tar.bz2 ruby-tinderbox-eb79ff8a7cd8b3365d7d2001554965356004716d.zip |
#16 : Combine deps.py functionality with packages.py, which is already run from inside a container
Diffstat (limited to 'web')
-rw-r--r-- | web/lib/deps.py | 32 | ||||
-rw-r--r-- | web/lib/packages.py | 44 | ||||
-rw-r--r-- | web/lib/packages.rb | 13 |
3 files changed, 7 insertions, 82 deletions
diff --git a/web/lib/deps.py b/web/lib/deps.py deleted file mode 100644 index 8383463..0000000 --- a/web/lib/deps.py +++ /dev/null @@ -1,32 +0,0 @@ -import portage, sys - -def format_depend(dep_list): - for item in list(dep_list): - if "||" in item: dep_list.remove(item) - if "?" in item: dep_list.remove(item) - - index = 0 - for item in list(dep_list): - dep_list[index] = item.split('[')[0] - dep_list[index] = portage.dep.dep_getcpv(item) - index += 1 - - index = 0 - for item in list(dep_list): - if portage.getCPFromCPV(item): - dep_list[index] = portage.getCPFromCPV(item) - index += 1 - - return dep_list - -def join_depend(f_depend, f_rdepend, f_pdepend): - return ' '.join(sorted(list(set(f_depend + f_rdepend + f_pdepend)))) - -cpv = sys.argv[1] -depend, rdepend, pdepend = portage.portdb.aux_get(cpv, ['DEPEND', 'RDEPEND', 'PDEPEND']) -depend = portage.dep.flatten(portage.dep.paren_reduce(depend, 1)) -rdepend = portage.dep.flatten(portage.dep.paren_reduce(rdepend, 1)) -pdepend = portage.dep.flatten(portage.dep.paren_reduce(pdepend, 1)) -all_depend = join_depend(format_depend(depend), format_depend(rdepend), format_depend(pdepend)) - -print (all_depend) diff --git a/web/lib/packages.py b/web/lib/packages.py deleted file mode 100644 index 742750d..0000000 --- a/web/lib/packages.py +++ /dev/null @@ -1,44 +0,0 @@ -import portage, hashlib - -def format_output(cpv, slot, iuse, keyword): - category, pkgname, version, revision = portage.catpkgsplit(cpv) - sha1 = hashlib.sha1(open(porttree.dbapi.findname(cpv), 'rb').read()).hexdigest() - print (sha1 + ' ' + category + ' ' + pkgname + ' ' + version + ' ' + revision + ' ' + slot + ' ' + keyword, end=' ') - if 'ruby_targets_ruby19' in iuse: - print('ruby19', end=' ') - else: - print('nil', end=' ') - if 'ruby_targets_ruby20' in iuse: - print('ruby20', end=' ') - else: - print('nil', end=' ') - if 'ruby_targets_ruby21' in iuse: - print('ruby21', end=' ') - else: - print('nil', end=' ') - if 'ruby_targets_ruby22' in iuse: - print('ruby22', end=' ') - else: - print('nil', end=' ') - print() - -porttree = portage.db[portage.root]['porttree'] -for cp in porttree.dbapi.cp_all(): - slot_dict = {} - for cpv in porttree.dbapi.cp_list(cp): - slot, iuse = porttree.dbapi.aux_get(cpv, ['SLOT', 'IUSE']) - slot_dict.setdefault(slot, {})[cpv] = (iuse) - for slot, cpvd in slot_dict.items(): - if 'ruby_targets_' in iuse: - - cpvbs = (porttree.dep_bestmatch(cp)) - if cpvbs: - slot, iuse, keywords = porttree.dbapi.aux_get(cpvbs, ['SLOT', 'IUSE','KEYWORDS']) - if '~amd64' not in keywords and 'amd64' in keywords: - format_output(cpvbs, slot, iuse, 'amd64') - - cpvbu = portage.best(list(cpvd)) - if cpvbu: - slot, iuse, keywords = porttree.dbapi.aux_get(cpvbu, ['SLOT', 'IUSE', 'KEYWORDS']) - if '~amd64' in keywords: - format_output(cpvbu, slot, iuse, '~amd64') diff --git a/web/lib/packages.rb b/web/lib/packages.rb index 2586ca3..3e5a8bc 100644 --- a/web/lib/packages.rb +++ b/web/lib/packages.rb @@ -1,5 +1,5 @@ def update_packages(ci_image) - cmd = %W[python3 /ruby-tinderbox/packages.py | sort -u] + cmd = %W[/ruby-tinderbox/packages.py | sort -u] ci_container = Docker::Container.create( Cmd: cmd, Image: ci_image.id @@ -9,13 +9,14 @@ def update_packages(ci_image) packages_txt = ci_container.logs(stdout: true) ci_container.delete - packages_txt.lines.peach do |line| + packages_txt.lines.each do |line| line = line.bytes.drop(8).pack('c*') + next if line.empty? sha1, category, name, version, revision, slot, amd64_keyword, r19_target, r20_target, r21_target, r22_target = line.split(' ') identifier = category + '/' + name + '-' + version + (revision == 'r0' ? '' : "-#{revision}") gem_version = Gems.info(name)['version'] gem_version = 'nil' if gem_version.nil? - Package.find_or_create( + package = Package.find_or_create( sha1: sha1, category: category, name: name, @@ -30,12 +31,12 @@ def update_packages(ci_image) r22_target: r22_target, gem_version: gem_version ) + deps = line.split(' ').drop(11).join.gsub(';', ' ') + package.update(dependencies: deps) end Package.peach(8) do |package| - if packages_txt.include?(package[:sha1]) - package.update(dependencies: `python3 lib/deps.py #{package[:identifier]}`) - else + unless packages_txt.include?(package[:sha1]) package.build.map(&:delete) package.repoman.map(&:delete) package.delete |