Changeset 1916
- Timestamp:
- 4/16/2010 6:52:25 AM (3 years ago)
- Location:
- trunk/website/scripts
- Files:
-
- 2 edited
-
Build.php (modified) (3 diffs)
-
BuildPublish.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/website/scripts/Build.php
r1915 r1916 59 59 60 60 /** 61 * Gets the Builds which are still active for the given branch. 61 * Gets the Builds which are still active for the given branch. The result is ordered by 62 * decreasing age. 62 63 * 63 64 * @param string $branch The name of the Build branch. … … 68 69 $statement = $pdo->prepare('SELECT builds.DownloadID FROM builds 69 70 INNER JOIN downloads ON builds.DownloadID=downloads.DownloadID 70 WHERE downloads.Superseded=0 AND builds.Branch=?'); 71 WHERE downloads.Superseded=0 AND builds.Branch=? 72 ORDER BY builds.DownloadID'); 71 73 $statement->bindParam(1, $branch); 72 74 $statement->execute(); … … 90 92 * to the public web server before allowing the build to be downloaded. 91 93 * 92 * @param string $branch The name of the Build branch. 93 * @param <type> $revision The revision of the Build. 94 * @param mixed $branch The name of the Build branch or a BuildBranch object containing the 95 * branch. 96 * @param int $revision The revision of the Build. 97 * @param int $filesize The size of the file, in bytes. 98 * @param string $link The link to the download. 94 99 */ 95 public static function CreateBuild($branch, $revision )100 public static function CreateBuild($branch, $revision, $filesize, $link) 96 101 { 97 102 $pdo = new Database(); 103 $pdo->beginTransaction(); 104 105 //Define the download properties. 106 $statement = $pdo->prepare('INSERT INTO downloads ( 107 Name, Released, `Type`, Version, PublisherID, Architecture, Filesize, Link 108 ) 109 VALUES 110 ( 111 CONCAT(\'Eraser \', :Version), NOW(), \'build\', :Version, 1, 112 \'any\', :Filesize, :Link 113 )'); 114 115 if (is_string($branch)) 116 { 117 $branches = BuildBranch::Get(); 118 $branchName = $branch; 119 $branch = $branches[$branchName]; 120 if (!$branch) 121 throw new Exception('The provided branch ' . $branchName . ' does not exist.'); 122 } 123 else if (!is_a($branch, 'BuildBranch')) 124 throw new Exception('The provided branch is invalid.'); 125 126 $statement->bindParam('Version', sprintf('%s.%s', $branch->Version, $revision)); 127 $statement->bindParam('Filesize', $filesize); 128 $statement->bindParam('Link', $link); 129 $statement->execute(); 130 131 //Define the build properties. 132 $statement = $pdo->prepare('INSERT INTO builds ( 133 DownloadID, Branch, Revision 134 ) VALUES ( 135 LAST_INSERT_ID(), ?, ? 136 )'); 137 $statement->bindParam(1, $branch->ID); 138 $statement->bindParam(2, $revision); 139 $statement->execute(); 140 141 //Commit to the database. 142 $pdo->commit(); 98 143 } 99 144 } -
trunk/website/scripts/BuildPublish.php
r1915 r1916 11 11 12 12 require_once('Credentials.php'); 13 require_once('Database.php'); 13 14 require_once('Build.php'); 14 15 … … 66 67 die('The branch ' . $argv[1] . ' does not exist.'); 67 68 69 define('SHELL_WEB_ROOT', 'sftp://web.sourceforge.net/home/groups/e/er/eraser/htdocs'); 70 define('HTTP_WEB_ROOT', 'http://eraser.sourceforge.net'); 71 68 72 $branch = $branches[$argv[1]]; 69 73 $pathInfo = pathinfo($argv[3]); 70 74 $fileName = sprintf('Eraser %s.%d.%s', $branch->Version, $argv[2], $pathInfo['extension']); 71 $uploadURL = sprintf('sftp://web.sourceforge.net/home/groups/e/er/eraser/htdocs/builds/%s/%s', 72 $branch->ID, $fileName); 73 Upload($uploadURL, $file, $sftp_username, $sftp_password); 74 Delete($uploadURL, $sftp_username, $sftp_password); 75 $installerPath = sprintf('/builds/%s/%s', $branch->ID, $fileName); 76 77 //Then upload the installer to the URL. 78 Upload(SHELL_WEB_ROOT . $installerPath, $file, $sftp_username, $sftp_password); 79 80 //Insert the build to the database. 81 printf('Inserting build into database... '); 82 Build::CreateBuild($branch->ID, intval($argv[2]), filesize($argv[3]), HTTP_WEB_ROOT . $installerPath); 83 printf("Inserted.\n"); 84 85 //Remove old builds 86 printf('Removing old builds from database... '); 87 88 $pdo = new Database(); 89 $pdo->beginTransaction(); 90 $statement = $pdo->prepare('UPDATE downloads SET Superseded=1 WHERE DownloadID=?'); 91 92 $builds = Build::GetActive($branch->ID); 93 for ($i = 0, $j = count($builds) - 3; $i < $j; ++$i) 94 { 95 $statement->bindParam(1, $builds[$i]->ID); 96 $statement->execute(); 97 } 98 $pdo->commit(); 75 99 } 76 100 catch (Exception $e)
Note: See TracChangeset
for help on using the changeset viewer.
