From aa59472d13157e4155a7c0f2a1c044bfbcf5a0c4 Mon Sep 17 00:00:00 2001 From: Peter Wilmott Date: Tue, 5 May 2015 20:21:03 +0100 Subject: Calculate the sha1 sum earlier in the database population process to prevent duplicates --- web/lib/packages.py | 5 +++-- web/lib/packages.rb | 6 ++---- 2 files changed, 5 insertions(+), 6 deletions(-) (limited to 'web') diff --git a/web/lib/packages.py b/web/lib/packages.py index a18fb3b..742750d 100644 --- a/web/lib/packages.py +++ b/web/lib/packages.py @@ -1,8 +1,9 @@ -import portage +import portage, hashlib def format_output(cpv, slot, iuse, keyword): category, pkgname, version, revision = portage.catpkgsplit(cpv) - print (category + ' ' + pkgname + ' ' + version + ' ' + revision + ' ' + slot + ' ' + keyword, end=' ') + 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: diff --git a/web/lib/packages.rb b/web/lib/packages.rb index a741a9e..fc9044d 100644 --- a/web/lib/packages.rb +++ b/web/lib/packages.rb @@ -1,12 +1,10 @@ def update_packages packages_txt = `python3 lib/packages.py | sort -u` packages_txt.lines.peach do |line| - category, name, version, revision, slot, amd64_keyword, r19_target, r20_target, r21_target, r22_target = line.split(' ') + 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? - ebuild = "/usr/portage/#{category}/#{name}/#{identifier.split('/')[1]}.ebuild" - sha1 = Digest::SHA1.hexdigest(File.read(ebuild)) Package.find_or_create( sha1: sha1, category: category, @@ -25,7 +23,7 @@ def update_packages end Package.peach(8) do |package| - if packages_txt.include?("#{package[:category]} #{package[:name]} #{package[:version]} #{package[:revision]} #{package[:slot]} #{package[:amd64_keyword]} #{package[:r19_target]} #{package[:r20_target]} #{package[:r21_target]} #{package[:r22_target]}") + if packages_txt.include?(package[:sha1]) package.update(dependencies: `python3 lib/deps.py #{package[:identifier]}`) else package.build.map(&:delete) -- cgit v1.2.3-65-gdbad