Ignore:
Timestamp:
11/26/2011 2:01:07 AM (3 years ago)
Author:
lowjoel
Message:

Factor the utility functions used by the Build slaves to a separate BuildUtil? file which is referenced by both the build server and build client scripts.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/website/scripts/BuildServer.php

    r2385 r2386  
    11<?php 
    2  
    32//HTTP Digest authentication code, modified from http://php.net/manual/en/features.http-auth.php 
    43define('HTTP_DIGEST_REALM', 'Build Server'); 
     
    5655    http_digest_challenge(); 
    5756 
     57require('Build.php'); 
     58require('BuildUtil.php'); 
     59require('Credentials.php'); 
     60require('Database.php'); 
    5861 
     62try 
     63{ 
     64    //Check that we have all the necessary information 
     65    $branches = BuildBranch::Get(); 
     66    if (!array_key_exists($_GET['branch'], $branches)) 
     67        throw new Exception('The branch ' . $_GET['branch'] . ' does not exist.'); 
     68    if (!is_numeric($_GET['revision']) || !is_numeric($_GET['filesize']) || empty($_GET['url'])) 
     69        throw new Exception('Invalid build information provided.'); 
     70 
     71    //Get the branch the notification is for 
     72    define('HTTP_WEB_ROOT', 'http://eraser.sourceforge.net'); 
     73    $branch = $branches[$_GET['branch']]; 
     74 
     75    //Insert the build to the database. 
     76    printf('Inserting build into database... '); 
     77    Build::CreateBuild($branch->ID, intval($_GET['revision']), intval($_GET['filesize']), $_GET['url']); 
     78    printf("Inserted.\n"); 
     79 
     80    //Remove old builds 
     81    printf('Removing old builds from database...' . "\n"); 
     82 
     83    $pdo = new Database(); 
     84    $statement = $pdo->prepare('UPDATE downloads SET Superseded=1 WHERE DownloadID=?'); 
     85 
     86    $builds = Build::GetActive($branch->ID); 
     87    for ($i = 0, $j = count($builds) - 3; $i < $j; ++$i) 
     88    { 
     89        printf("\n\t" . 'Removing build %s' . "\n\t\t", $builds[$i]->Name); 
     90 
     91        //Delete the copy on the SourceForge web server. 
     92        Delete(SHELL_WEB_ROOT . parse_url($builds[$i]->Link, PHP_URL_PATH), $sftp_username, 
     93            $sftp_password); 
     94 
     95        //Remove from the database 
     96        $statement->execute(array($builds[$i]->ID)); 
     97    } 
     98} 
     99catch (Exception $e) 
     100{ 
     101    echo $e->getMessage(); 
     102    exit(1); 
     103} 
    59104?> 
Note: See TracChangeset for help on using the changeset viewer.