diff options
author | 2015-06-19 16:11:32 +0100 | |
---|---|---|
committer | 2015-06-19 16:11:32 +0100 | |
commit | eb79ff8a7cd8b3365d7d2001554965356004716d (patch) | |
tree | e8f56f3263f13c762b870fbf0d0c87ce74732a97 | |
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
-rw-r--r-- | Dockerfile | 2 | ||||
-rwxr-xr-x[-rw-r--r--] | bin/packages.py (renamed from web/lib/packages.py) | 33 | ||||
-rw-r--r-- | web/lib/deps.py | 32 | ||||
-rw-r--r-- | web/lib/packages.rb | 13 |
4 files changed, 40 insertions, 40 deletions
@@ -4,7 +4,5 @@ ADD cache/stage3-amd64.tar.bz2 / RUN mkdir /ruby-tinderbox ADD bin/* /ruby-tinderbox/ -ADD web/lib/packages.py /ruby-tinderbox/ -ADD web/lib/deps.py /ruby-tinderbox/ RUN /ruby-tinderbox/provision.sh diff --git a/web/lib/packages.py b/bin/packages.py index 742750d..ed07e68 100644..100755 --- a/web/lib/packages.py +++ b/bin/packages.py @@ -1,5 +1,36 @@ +#!/usr/bin/env python3 + import portage, hashlib +def format_deps(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_deps(f_depend, f_rdepend, f_pdepend): + return ';'.join(sorted(list(set(f_depend + f_rdepend + f_pdepend)))) + +def get_deps(cpv): + 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)) + return join_deps(format_deps(depend), format_deps(rdepend), format_deps(pdepend)) + 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() @@ -20,8 +51,10 @@ def format_output(cpv, slot, iuse, keyword): print('ruby22', end=' ') else: print('nil', end=' ') + print(get_deps(cpv), end=' ') print() + porttree = portage.db[portage.root]['porttree'] for cp in porttree.dbapi.cp_all(): slot_dict = {} 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.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 |