From 4f363544e2281803bdc0394074885789ab2a78d2 Mon Sep 17 00:00:00 2001 From: Michael Tremer Date: Sat, 23 Apr 2011 00:15:45 +0200 Subject: [PATCH] autobuilder: Switch back to download source package from the webserver. --- pakfire/server/slave.py | 36 +++++++++++++++++++++--------------- po/pakfire.pot | 12 ++++++------ 2 files changed, 27 insertions(+), 21 deletions(-) diff --git a/pakfire/server/slave.py b/pakfire/server/slave.py index cb86b4e7..32f103e5 100644 --- a/pakfire/server/slave.py +++ b/pakfire/server/slave.py @@ -3,6 +3,7 @@ import logging import os import socket +import tempfile import xmlrpclib import pakfire.api @@ -50,39 +51,44 @@ class Slave(MasterSlave): if not build: return + print build + build_id = build["id"] filename = build["name"] - data = build["data"].data + download = build["download"] hash1 = build["hash1"] - # XXX need to find a better temp dir. - tempfile = os.path.join("/var/tmp", filename) - resultdir = os.path.join("/var/tmp", build_id) + # Create a temporary file and a directory for the resulting files. + tmpdir = tempfile.mkdtemp() + tmpfile = os.path.join(tmpdir, filename) + + # Get a package grabber and add mirror download capabilities to it. + grabber = pakfire.downloader.PackageDownloader() try: + # Download the source. + grabber.urlgrab(download, filename=tmpfile) + # Check if the download checksum matches. - if pakfire.util.calc_hash1(data=data) == hash1: + if pakfire.util.calc_hash1(tmpfile) == hash1: print "Checksum matches: %s" % hash1 else: raise DownloadError, "Download was corrupted" - # Save the data to a temporary directory. - f = open(tempfile, "wb") - f.write(data) - f.close() - # Update the build status on the server. self.update_build_status(build_id, "running") # Run the build. - pakfire.api.build(tempfile, build_id=build_id, - resultdirs=[resultdir,]) + pakfire.api.build(tmpfile, build_id=build_id, + resultdirs=[tmpdir,]) self.update_build_status(build_id, "uploading") - for dir, subdirs, files in os.walk(resultdir): + for dir, subdirs, files in os.walk(tmpdir): for file in files: file = os.path.join(dir, file) + if file == tmpfile: + continue pkg = pakfire.packages.open(self.pakfire, None, file) @@ -101,5 +107,5 @@ class Slave(MasterSlave): self.update_build_status(build_id, "finished") finally: - #pakfire.util.rm(tempfile) - pass + # Cleanup the files we created. + pakfire.util.rm(tmpdir) diff --git a/po/pakfire.pot b/po/pakfire.pot index 176e4d3f..049ef31b 100644 --- a/po/pakfire.pot +++ b/po/pakfire.pot @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2011-04-13 21:57+0200\n" +"POT-Creation-Date: 2011-04-22 23:04+0200\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -143,7 +143,7 @@ msgstr "" msgid "Update the package indexes." msgstr "" -#: ../pakfire/cli.py:300 +#: ../pakfire/cli.py:300 ../pakfire/cli.py:461 msgid "Build one or more packages." msgstr "" @@ -203,19 +203,19 @@ msgstr "" msgid "Pakfire master command line interface." msgstr "" -#: ../pakfire/cli.py:459 +#: ../pakfire/cli.py:467 msgid "Update the sources." msgstr "" -#: ../pakfire/cli.py:469 +#: ../pakfire/cli.py:480 msgid "Pakfire slave command line interface." msgstr "" -#: ../pakfire/cli.py:493 +#: ../pakfire/cli.py:504 msgid "Request a build job from the server." msgstr "" -#: ../pakfire/cli.py:499 +#: ../pakfire/cli.py:510 msgid "Send a keepalive to the server." msgstr "" -- 2.39.2