]> git.ipfire.org Git - pakfire.git/commitdiff
autobuilder: Switch back to download source package from the webserver.
authorMichael Tremer <michael.tremer@ipfire.org>
Fri, 22 Apr 2011 22:15:45 +0000 (00:15 +0200)
committerMichael Tremer <michael.tremer@ipfire.org>
Fri, 22 Apr 2011 22:15:45 +0000 (00:15 +0200)
pakfire/server/slave.py
po/pakfire.pot

index cb86b4e794ad4ddb71cd615477062d3d0f2100e4..32f103e59f8e06699ff76002f59612f2999d3e56 100644 (file)
@@ -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)
index 176e4d3f08b222a1ae6fbb835aa9db29c79072f4..049ef31ba4df6b4e93e49103052a23178e129773 100644 (file)
@@ -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 <EMAIL@ADDRESS>\n"
 "Language-Team: LANGUAGE <LL@li.org>\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 ""