RegisterRegister    Log inLog in    SearchSearch   

Post new topic   Reply to topic
Goto page 1, 2  Next 
View previous topic :: View next topic  
Author Message
ryguy222



PostPosted: Fri Aug 13, 2010 5:40 pm    Post subject: Windows -- Content server help, package does not build Reply with quote

I am having a heck of a time getting the content server to work on a Window Server, running Server 2003 x64
PHP 5.2.14

I run the build-update.bat file and the entire php document is shown in the cmd window, and then it closes. And I don't get any .txt files created.

I am testing all this with Team Fortress 2, which I have updated and put into C:\content\win32\orange-box\tf etc.

The rest of the content server files (the build-update files) are in C:\content

Here is my config file, with the password info removed. I'm hoping some of you notice something right off the bat.

Code:
<?php

// Authentication details needed to update revision information
// Include multiple lines if you need to notify more than one domain
// Example:   http://mammoth.au.gamecreate.com/admin/
//          http://mammoth.REGION.gamecreate.com/admin/
// login = mydomainlogin, password = mydomainpassword, region = au (us, nz, eu, af...)
$auth[] = array("login" => "*login removed*", "password" => "**********", "region" => "US");

// Content directory relative to build-update.
// Must include a trailing slash if set.
define('CONTENT_ROOT', '/win32');

// Whether backup of revision files (<name>.<revision>.txt) should be created
// when a new revision is made. This allows for easy rollback or revision information.
define('BACKUP_REVISION', false);

?>


Anything missing? Let me know, I'm a n00b when it comes to this stuff!

Ok next, the batch file I use.


Code:
@echo off
echo.
php.exe -q build-update.php %*tf2

I have also tried orange-box as well in place of "tf2"

Essentially what happens when I run the bat file is a lot of text runs through and then it closes.

If I get out the cmd cd over to C:\content, then run
php.exe build-update.php tf2 or orange-box etc. I get this very long code. Apologies for the length, and it looks like part was maybe cut off from the top, but that's all that I can manage to get out of the console.

Code:
        foreach($opersystems As $os) {
                $r = FindNextRevisionForOSAndPackage($os, $package);

                if ($r > $NewRevision)
                        $NewRevision = $r;
        }

        return $NewRevision;
}

function FindNextRevisionForOSAndPackage($OS, $package)
{
        $lines = @file(CONTENT_ROOT . $OS."/".$package.".txt");

        // No revision information - start at Revision 1
        if(sizeof($lines) <= 1)
                return 1;

        // Ignore first line (INSTALLER packagename instructioncount)
        array_shift($lines);

        $revision = 1;

        foreach ($lines As $line) {
                $line = trim($line);
                $bits = explode(" ", $line);
                $rev = $bits[sizeof($bits)-1];

                if ($rev > $revision)
                        $revision = $rev;
        }

        return $revision + 1;
}

function ParseInstallFile($OS, $package)
{
        global $Files;
        global $FilesIndex;
        global $Installer;
        global $PreviousOperations, $Operations;

        $Files = $FilesIndex = $PreviousOperations = $Operations = array();

        $contents = @file(CONTENT_ROOT . $OS."/".$package.".txt");
        if (!is_array($contents))
                return;

        array_splice($contents,0,1);

        $Files = $contents;
        for ($i=0,$j=sizeof($contents);$i<$j;$i++)
        {
                $line = $Files[$i];
                $parts = explode(" ", trim($line));

                if (!isset($parts[1]))
                        continue;

                MMparse_str($parts[1], $values);

                if ($OS == "win32")
                        $values["name"] = strtolower($values["name"]);

                if ($parts[0] == "EXECUTABLE")
                {
                        $PreviousOperations[trim($values["name"])] = true;
                } else {
                        if ($values["name"])
                                $FilesIndex[$values["name"]] = $i;
                }
        }
}


function GetDirectoryName($package)
{
        $contents = @file("packages.txt");
        if ($contents == '')
        {
                echo "Could not find package '$package' - did you add it to pack
ages.txt?\n";
                die;
        }

        foreach ($contents as $line)
        {
                $parts = explode(" ", trim($line), 2);
                if ($parts[0] == $package)
                        return $parts[1];
        }

        echo "Could not find package '$package' - did you add it to packages.txt
?\n";
        die;
}

function ParsePackagesList($OS, $package, $directory)
{
        global $IgnoreDirs, $IgnoreFiles, $OwnedDirs;
        $IgnoreDirs = array();
        $IgnoreFiles= array();
        $OwnedDirs = array();

        $contents = file("packages.txt");
        for ($i=0,$j=sizeof($contents);$i<$j;$i++)
        {
                $line = $contents[$i];

                @list ($name,$dir) = explode(" ", trim($line), 2);
                if ($dir != $directory)
                        continue;

                $isIgnoring = $name != $package;

                if ($isIgnoring)
                        AddToIgnoreFiles($OS,$name);

                // We've hit another package sharing our directory
                while ($i+1 < $j && $contents[$i+1][0] == '-')
                {
                        $i++;
                        $line = $contents[$i];
                        list ($dash,$path) = explode(" ", trim($line), 2);

                        if ($isIgnoring) {
                                $IgnoreDirs[] = ($OS == "win32" ? strtolower($pa
th) : $path);
                                echo "Ignoring $name Directory: $path\n";
                        } else {
                                $OwnedDirs[] = ($OS == "win32" ? strtolower($pat
h) : $path);
                        }
                }
        }
}

function AddToIgnoreFiles($OS,$package)
{
        global $IgnoreFiles;

        $contents = @file(CONTENT_ROOT . $OS."/".$package.".txt");
        if (!is_array($contents))
                return;

        foreach ($contents as $line)
        {
                $parts = explode(" ", $line);
                if ($parts[0] != "FILE" && $parts[0] != "MKDIR")
                        continue;

                MMparse_str($parts[1], $values);

                if ($OS == "win32")
                        $IgnoreFiles[strtolower($values["name"])] = 1;
                else
                        $IgnoreFiles[$values["name"]] = 1;

        }
}

function showParamHelp()
{
echo "GameCreate Build-Update Parameter Help
======================================
    /approve      - Approve the package revision on a successful version.
    /a

    /restart      - Restart affected servers for this update.
    /r

    /norestart    - Do not restart affected servers for this update.
    /n

    /md5          - Force an md5sum comparison of each file.
                    By default, md5sum comparisons are only performed when a fil
e on disk
                    has a different modified time or file size than what is spec
ified
                    in the previous revision.
                    This option ignores these checks, and will force an md5sum
                    comparison regardless of the file modified time or its size.


    /dry          - Perform a dry run. Changes are displayed but not committed.
    /d

    /confirm      - Automatically confirm the revision changes on success and no
tify GameCreate.
    /c              No confirmation of the build change log is needed at the end
 of the build.

    /version      - Show the GameCreate Package Builder version information.
    /v

    /help         - This help screen.
";
}

function parseParams(&$params)
{
        global $approve, $suspend, $forceMd5, $dryRun, $forceDeploy, $package;

        if (sizeof($params) < 2)
                return;

        for ($i = 1; $i < sizeof($params); $i++)
        {
                switch ($params[$i])
                {
                        case "/help": case "/?":
                                showParamHelp();
                                die;
                        case "/approve": case "/a":
                                $approve = true;
                                break;
                        case "/norestart": case "/n":
                                $suspend = false;
                                break;
                        case "/restart": case "/r":
                                $suspend = true;
                                break;
                        case "/dry": case "/d":
                                $dryRun = true;
                                break;
                        case "/confirm": case "/c":
                                $forceDeploy = true;
                                break;
                        case "/md5":
                                echo "Ignoring file time and size values; forcin
g md5sum comparison\n";
                                $forceMd5 = true;
                                break;
                        case "/version": case "/v":
                                showVersion();
                                die;
                        default:
                                $unknownParam = false;
                                if ($params[$i][0] == '/') {
                                        $unknownParam = true;
                                } else {
                                        if ($package == '') {
                                                // Assign package name
                                                $package = $params[$i];
                                        } else {
                                                echo "Package name already speci
fied as '$package'.\n";
                                                $unknownParam = true;
                                        }
                                }

                                if ($unknownParam) {
                                        echo "Unknown parameter: " . $params[$i]
 . "\n";
                                        echo "Type /help for a list of supported
 command arguments.\n";
                                        die;
                                }
                                break;
                }
        }

        if (!$approve || $suspend !== null)
                return;

        while (true)
        {
                echo "\nShould servers be suspended during this update? (Y/N): "
;
                $suspend = readConsole();

                if (convertToBoolean($suspend))
                        break;
        }
}

function checkAuth($auth)
{
        if (sizeof($auth) == 0)
                die("You need to define at least one set of domain login informa
tion to be used in the build-update.config file.");

        $args = array('login', 'password', 'region');
        foreach ($auth As $domain)
        {
                foreach ($args As $arg)
                        if (!isset($domain[$arg]) || $domain[$arg] == '')
                                die("One or more arguments are undefined for a d
omain in build-update.config");
        }
}

function showVersion()
{
        echo "GameCreate Package Builder v1.0.2\n";
}

?>


I wouldn't be surprised if I'm not setting parameters correctly, but idk.

I see all sorts of errors for missing packages and what not, the package.txt is in C:\content like all the other files. So I'm not sure what is going on. any help would be greatly appreciated!
Back to top
View user's profile Send private message
adbot



PostPosted: Thu Mar 31, 2011 3:57 am 

Kybber



PostPosted: Mon Aug 16, 2010 6:41 pm    Post subject: Reply with quote

I use Linux for our content server, so I may not be of much use here. But I'll see what I can do.

You seem to be having two problems, which may or may not be related:
1. Your script doesn't run properly
2. Your script doesn't detect your packages.

To tackle 1 first: I am not familiar with running php in Windows. The fact that the code is dumped to your console makes me think that perhaps you script doesn't actually run. Or is it dumped because it detects an error? You should make sure it actually runs.

About 2: Your config-file should not include /win32, but should be the path to the directory which contains win32 (and also where your packages.txt shoudl reside). You should try to include the full path, like so:
Code:
define('CONTENT_ROOT', 'c:\gamecreatecontent\');

(Not sure it this is 100% correct syntax for Windows with backslashes and such. You may have to escape \ by typing \\ or use forward-slashes /)

Also, your packages.txt may be out of date and not include the new CSS-game, which is called cssob. Edit packages.txt and place the following two lines in the segment for orange-box, for instance right afther the tf2 entry:
Code:
cssob orange-box
- /orangebox/cstrike

This will ensure that build-update.php recognizes the package when you run 'build-update.php cssob'
Back to top
View user's profile Send private message
ryguy222



PostPosted: Tue Aug 17, 2010 1:16 pm    Post subject: Reply with quote

Ok so I changed the directories up, C:\content\ and it still dumped the script into their.

I do have PHP installed correctly, and still no good >_<

Better than nobody answering thanks! Smile
Back to top
View user's profile Send private message
Kybber



PostPosted: Tue Aug 17, 2010 4:18 pm    Post subject: Reply with quote

Are you able to view the topmost part of the text in your console when the script is dumped? If you can't scroll far enough, simply right-click the title-bar of your console, properties->layout and set Screen Buffer Size Height to a couple of thousand. You may find a helpful error message when you thereafter execute the command and scroll to the top.

Also: I just noticed that the batch-file you are using is incorrect. There should be a space between %* and tf2. Or preferably there should be no tf2 at all.

If it doesn't already exist, create a file called build-update.bat, and paste in the following:
Code:
@echo off
echo.
php.exe -q build-update.php %*

(This assumes that php.exe is in your path, which you can verify by just typing 'php.exe -version' in a console. If it spits out some version information, you're good. It not, you'll need to provide the full path to php.exe on the last line).

This script can be used to (or at least should be able to be used to) update all your packages with any argument, not just tf2:
Code:
build-update.bat tf2
build-update.bat /a /r cssob
etc.
Back to top
View user's profile Send private message
ryguy222



PostPosted: Mon Aug 23, 2010 2:55 pm    Post subject: Reply with quote

Well I tried using the bat file, that you suggested and it still spits out the code, and then closes instantly.

So I ran the same code, without the echo part, in command prompt manually. I was able to get the top most portion.

Code:
Microsoft Windows [Version 5.2.3790]
(C) Copyright 1985-2003 Microsoft Corp.

C:\Documents and Settings\Administrator>cd C:\content

C:\Content>C:\content\php.exe -q build-update.php %* tf
<?
require "build-update.config";
set_time_limit(0);

checkAuth($auth);

$approve = false;
$suspend = null;
$forceMd5 = false;
$dryRun = false;
$forceDeploy = false;
$Changes = 0;
$ChangeLog = array();
$Installer = array();

$params = array();
for ($i = 0; $i < $_SERVER['argc']; $i++)
        $params[] = strtolower($_SERVER['argv'][$i]);

parseParams($params);

if (!$package)
{
        echo "Usage: " . $_SERVER["argv"][0] ." <package-name> [parameters]\n\n"
;
        echo "Package name may appear before, between, or after any parameters.\
n\n";
        echo "Type /help for more information.\n\n";
        die;
}

$starttime = time();
RunBuild($package);
$endtime = time();

echo "\n\n============================================\n";

if ($dryRun) {
        showChangeLog();
        echo "No revision was written. This was a dry run.\n";
} else {
        if ($Changes == 0)
        {
                echo "NOTE: Not writing a new revision.\n";
                echo "No changes were made since the last revision!\n";
        } else {
                showChangeLog();
                if (!$forceDeploy) {
                        while (true)
                        {
                                echo "\nDo you want to continue with this revisi
on? (Y/N): ";
                                $forceDeploy = readConsole();

                                if (convertToBoolean($forceDeploy))
                                        break;
                        }
                }

                if ($forceDeploy) {
                        echo "Writing revisions...\n";
                        WriteInstallFiles($package);

                        SendNewRevision($package);

                        if ($approve)
                                ApproveRevision($package);
                } else {
                        echo "Revision cancelled.\n";
                }
        }
}

echo "============================================\n\n";

ShowTimeTaken($endtime - $starttime);

function showTimeTaken($diff)
{
        global $package, $Changes, $dryRun, $forceDeploy;

        $secs = $diff % 60;
        $mins = ($diff - $secs) / 60;
        if ($secs < 10)
                $secs = '0' . $secs;

        if (!$dryRun && $forceDeploy)
                echo "\nFinished updating package: $package [$Changes instructio
n revisions]\n";

        echo "Time taken: $mins:$secs minutes\n";
}

function convertToBoolean(&$string)
{
        $test = strtolower(substr($string, 0, 1));

        if (in_array($test, array ('y', 'n')))
        {
                $string = ($test == 'y' ? true : false);
                return true;
        } else {
                return false;
        }
}

function readConsole ($length = 5)
{
   if (!isset ($GLOBALS['StdinPointer']))
     $GLOBALS['StdinPointer'] = fopen ("php://stdin","r");

   $line = fgets ($GLOBALS['StdinPointer'], $length);
   return trim ($line);
}

// parse_str seems contrary in regards to magic quotes
function MMparse_str($s, &$result)
{
        $result = array();
        $parts = explode("&", $s);
        foreach ($parts as $part)
        {
                list ($k,$v) = explode("=", $part, 2);
                $result[urldecode($k)] = urldecode($v);
        }
}

function addChangeLog($message, $type, $OS)
{
        global $ChangeLog;

        if (!isset($ChangeLog[$OS][$type]))
                $ChangeLog[$OS][$type] = array();

        $ChangeLog[$OS][$type][] = $message;

        echo "$message\n";
}

function getOperSystems()
{
        return array('linux', 'win32');
}

function showChangeLog()
{
        global $ChangeLog, $Changes;

        $types = array('add' => '+', 'update' => '*', 'delete' => '-', 'op' => '
o');
        $opersystems = getOperSystems();

        echo "Revision Change Log:\n";
        echo "--------------------\n\n";

        if ($Changes == 0) {
                echo "No changes were made in this revision.\n";
                return;
        }

        foreach($opersystems As $os) {
                echo "Revision changes for $os:\n";

                $log = '';

                foreach($types as $type => $char) {
                        if (!isset($ChangeLog[$os][$type]))
                                continue;

                        $log .= " " . ucfirst($type) . " Operations (" . sizeof(
$ChangeLog[$os][$type]) . "):\n";

                        foreach($ChangeLog[$os][$type] As $change)
                                $log .= "  $char $change\n";
                }

                if ($log == '')
                        echo " None\n";
                else
                        echo $log;

                echo "\n";
        }
}

function ApproveRevision($package)
{
        global $Revision, $auth, $suspend;

        echo "Approving Revision...\n";

        $ignoreWarnings = false;
        $updateParentPackages = true;
        $retry = false;

        foreach ($auth As $domain)
        {
                do {
                        $client = getSoapClient($domain);
                        if (!$client)
                                continue;

                        $params = array();
                        $params['domainLogin'] = $domain['login'];
                        $params['domainPassword'] = $domain['password'];
                        $params['packageUniqueName'] = $package;
                        $params['suspend'] = $suspend;
                        $params['ignoreWarnings'] = $ignoreWarnings;
                        $params['updateParentPackages'] = $updateParentPackages;


                        $response = $client->__soapCall('ApprovePackageRevision'
, array('parameters' => $params));
                        $result = $response->ApprovePackageRevisionResult;
                        $retry = false;

                        echo $domain['login'] . ": [" . $result->PackageApproval
ResponseCode . "] " . $result->Description . "\n";

                        if (!$result->Success) {
                                switch($result->PackageApprovalErrorCode) {
                                        case "None":
                                                break;

                                        case "UnapprovedParentPackages":
                                                $updateParentPackages = false;
                                                while (true) {
                                                        echo "\nShould the paren
t packages for " . $package . " be approved (and " . ($suspend ? "have servers s
uspended" : "not suspend servers") . ")? (Y/N): ";
                                                        $updateParentPackages =
readConsole();

                                                        if (convertToBoolean($up
dateParentPackages))
                                                                break;
                                                }
                                                $ignoreWarnings = true;
                                                $retry = true;

                                                break;
                                        default:
                                                echo "Unknown response error cod
e: " . $result->PackageApprovalErrorCode . "\n";
                                                break;
                                }
                        }
                } while ($retry);

                $ignoreWarnings = false;
        }
}

function SendNewRevision($package)
{
        global $Revision, $auth;

        echo "Notifying GameCreate of new revision...\n";

        foreach ($auth As $domain)
        {
                $client = getSoapClient($domain);
                if (!$client)
                        continue;

                $params = array();
                $params['domainLogin'] = $domain['login'];
                $params['domainPassword'] = $domain['password'];
                $params['packageUniqueName'] = $package;
                $params['revision'] = $Revision;

                $response = $client->__soapCall('NotifyPackageRevision', array('
parameters' => $params));
                $result = $response->NotifyPackageRevisionResult;

                if (!$result) {
                        echo "Warning: An error occurred in notifying GameCreate
 about the new package revision for domain login " . $domain['login'] . "\nIs yo
ur domain login information correct and does the domain package exist?\n";
                }
        }
}

function getSoapClient($domain)
{
        static $client = array();
        $id = $domain['region'];

        if (!isset($client[$id])) {
                $urlPrefix = (substr($id, 0, 7) == 'http://') ? $id : 'http://'
. $id . '.gamecreate.com';
                $clientUrl = $urlPrefix . '/admin/Remote.asmx?wsdl';
                $client = null;

                try {
                        $client[$id] = @new SoapClient($clientUrl);
                } catch (SoapFault $ex) {
                        $client[$id] = null;
                        echo "Warning: Failed to retrieve a valid SOAP Client fo
r $clientUrl\n";
                        echo "Reason: " . $ex->getMessage() . "\n";
                }
        }

        return $client[$id];
}

function RunBuild($package)
{
        global $Revision;

        $Revision = FindNextGlobalRevisionForPackage($package);
        $opersystems = getOperSystems();

        foreach($opersystems As $os)
                BuildUpdate($os,$package);
}

function BuildUpdate($OS,$package)
{
        global $Revision, $Files, $FilesIndex, $FileExists, $IgnoreFiles, $Ignor
eDirs, $PreviousOperations, $Operations, $OperationsIndex;

        // Empty out our files information
        $Files = $FilesIndex = $FileExists = $IgnoreFiles = $IgnoreDirs = $Previ
ousOperations = $Operations = $OperationsIndex = array();

        echo "
============================================
Building new installation script for $OS
============================================
\n";

        $directory = GetDirectoryName($package);
        ParsePackagesList($OS,$package, $directory);
        ParseInstallFile($OS,$package);
        CheckForUpdates(CONTENT_ROOT . "$OS/$directory","", $OS);
        CheckForDeletes($OS);
        CheckForOperations($OS, $package);
        PrepareInstallFile($directory, CONTENT_ROOT . "$OS/$package");
}

function PrepareInstallFile($package, $path)
{
        global $Files, $Revision, $Installer;
        echo "Preparing " . (defined('CONTENT_ROOT') ? substr($path, strlen(CONT
ENT_ROOT)) : 0) . " revision $Revision\n";
        $data = "INSTALLER $package ".sizeof($Files)."\n";
        $data .= join("", $Files);

        $Installer[$path] = $data;
}


function WriteInstallFiles($package)
{
        global $Files, $Revision, $Installer;

        $backup = defined('BACKUP_REVISION') && BACKUP_REVISION;

        foreach (array_keys($Installer) As $path)
        {
                echo "Writing " . (defined('CONTENT_ROOT') ? substr($path, strle
n(CONTENT_ROOT)) : 0) . " revision $Revision\n";

                if ($backup)
                        $file = $path.".".$Revision.".txt";
                else
                        $file = $path.".txt";

                $fp = @fopen($file, "w");

                if ($fp === false)
                        die("An error occurred attempting to open $file for writ
e");

                fputs($fp, $Installer[$path]);
                fclose($fp);

                if ($backup)
                        copy ($path.".".$Revision.".txt",$path.".txt");
        }
}

function CheckForDeletes($OS)
{
        global $Files, $FilesIndex, $FileExists, $Revision, $Changes;
        foreach ($FilesIndex as $name => $index)
        {
                if ($OS == "win32")
                        $nameCompare = strtolower($name);
                else
                        $nameCompare = $name;

                if (isset($FileExists[$nameCompare]))
                        continue;

                $parts = explode(" ", $Files[$FilesIndex[$nameCompare]]);

                if ($parts[0] == "DELETE" || $parts[0] == "RMDIR")
                        continue;

                $op = "DELETE";
                if ($parts[0] == "MKDIR")
                        $op = "RMDIR";

                addChangeLog("Deleting $name", 'delete', $OS);
                $Changes++;

                $Files[$index]="";
                $newIndex = sizeof($Files);
                $Files[$newIndex] = "$op name=".urlencode($name)." $Revision\n";

                $FilesIndex[$name] = $newIndex;
        }
}

function IgnoreFile($file, $isDirectory)
{
        global $IgnoreFiles, $IgnoreDirs, $OwnedDirs;

        // If this directory is along the path of one of our package's explicitl
y owned
        // directories, then do not ignore this directory as there is content in
side it we need to check
        if ($isDirectory) {
                foreach($OwnedDirs As $dir) {
                        $dir = substr($dir, 1, strlen($file));
                        if ($dir == $file)
                                return false;
                }
        }

        if (isset($IgnoreFiles[$file]))
                return true;

        foreach ($IgnoreDirs as $dir)
        {
                $dir = substr($dir, 1);
                if ($file == $dir)
                        return true;
        }

        return false;
}

function CheckForOperations($OS, $package)
{
        global $PreviousOperations, $Operations, $OperationsIndex, $Files;
        global $Revision;
        global $Changes;

        //Get current file operations
        $contents = @file(CONTENT_ROOT . $OS."/".$package.".op.txt");
        if (is_array($contents))
        {
                //Operations are case insensitive in windows
                foreach ($contents As $line)
                {
                        $line = trim($line);

                        if ($line == "")
                                continue;

                        if ($OS == "win32")
                                $line = strtolower($line);

                        $Operations[] = $line;

                        if (!isset($PreviousOperations[$line]))
                        {

                                //New operation
                                addChangeLog("Adding new EXECUTABLE operation fo
r $line", 'op', $OS);
                                $Files[] = "EXECUTABLE name=".urlencode($line)."
 $Revision\n";
                                $Changes++;
                        }
                }
        }

        foreach ($PreviousOperations As $key => $dummy)
        {
                if (array_search($key, $Operations) !== false)
                        continue;

                $index = -1;
                foreach ($Files as $fileValue)
                {
                        $index++;
                        $parts = explode(" ", $fileValue);

                        if ($parts[0] != "EXECUTABLE")
                                continue;

                        MMparse_str($parts[1], $values);

                        if ($OS == "win32")
                                $values["name"] = strtolower($values["name"]);

                        if ($key == $values["name"])
                        {
                                addChangeLog("Removing operation on file: " . $v
alues["name"], 'op', $OS);
                                $Changes++;
                                $Files[$index] = '';
                        }
                }


        }
}

function CheckForUpdates($realDir, $logicalDir, $OS)
{
        global $Files, $FilesIndex, $FileExists, $Changes, $forceMd5;
        global $Revision;

        $handle = @opendir($realDir);
        if (!$handle)
                return;

        while (($file = readdir($handle)) !== FALSE)
        {
                if ($file == "." || $file == "..") continue;

                $logicalFile = $logicalDir.$file;

                if ($OS == "linux")
                {
                        //Case sensitivity matters in linux files, FILE is diffe
rent from file.
                        $compareFile = $logicalFile;
                } else {
                        //Ignore case changes when building updates for other (w
in32) OSs - FILE is the same as file
                        $compareFile = strtolower($logicalFile);
                }

                $realFile = $realDir."/".$file;
                $isDirectory = is_dir($realFile);

                // Ignore file owned by other packages
                if (IgnoreFile($compareFile, $isDirectory))
                {
                        echo "Ignoring " . ($isDirectory ? "directory" : "file")
 . " $logicalFile\n";
                        continue;
                }

                // Handle directory
                if (is_dir($realFile))
                {
                        $FileExists[$compareFile] = true;
                        if (!isset($FilesIndex[$compareFile]))
                        {
                                $index = sizeof($Files);
                                $Files[$index] = "MKDIR name=".urlencode($logica
lFile)." $Revision\n";
                                $FilesIndex[$compareFile] = $index;
                                $Changes++;
                                addChangeLog("Adding new directory $logicalFile"
, 'add', $OS);
                        }

                        echo "Checking $logicalDir$file/ for updates\n";
                        CheckForUpdates($realDir."/".$file, "$logicalDir$file/",
 $OS);
                        continue;
                }


                // Mark file as still existing
                $FileExists[$compareFile] = true;

                $time = filemtime($realFile);
                $size = filesize($realFile);

                // New file?
                if (!isset($FilesIndex[$compareFile]))
                {
                        $md5 = md5_file($realFile);
                        $index = sizeof($Files);
                        $Files[$index] = "FILE name=".urlencode($logicalFile)."&
md5sum=$md5&time=$time&size=$size $Revision\n";
                        $FilesIndex[$compareFile] = $index;
                        addChangeLog("Adding new file $logicalFile", 'add', $OS)
;
                        $Changes++;
                }
                else
                {

                        $index = $FilesIndex[$compareFile];

                        // Check if this file's size or time differs. If so, do
the more intensive md5sum check
                        if (!$forceMd5 && isset($Files[$index]) && GetTimeFromLi
ne($Files[$index]) == $time && GetSizeFromLine($Files[$index]) == $size)
                        {
                                //echo "Ignoring unmodified file $logicalFile (N
o time or size change)\n";
                                continue;
                        }

                        $md5 = md5_file($realFile);
                        $oldmd5 = GetMd5FromLine($Files[$index]);

                        if ($oldmd5 == $md5)
                        {
                                // md5 does not differ, however the file time/si
ze was different.
                                // Update our FILE line with these new values so
 we dont check the md5 again next run

                                $Files[$index] = "FILE name=".urlencode($logical
File)."&md5sum=$md5&time=$time&size=$size " . GetRevisionFromLine($Files[$index]
) . "\n";
                                echo "Ignoring unmodified file $logicalFile (No
md5sum change)\n";

                        }
                        else
                        {
                                $Files[$index] = "";
                                $index = sizeof($Files);
                                $Files[$index] = "FILE name=".urlencode($logical
File)."&md5sum=$md5&time=$time&size=$size $Revision\n";
                                $FilesIndex[$compareFile] = $index;
                                $Changes++;
                                addChangeLog("Updating file $logicalFile", 'upda
te', $OS);
                        }
                }
        }
}

function GetMd5FromLine($line)
{
        $parts = explode(" ", trim($line));
        MMparse_str($parts[1], $values);
        return @$values["md5sum"];
}

function GetRevisionFromLine($line)
{
        $parts = explode(" ", trim($line));
        return @$parts[2];
}

function GetTimeFromLine($line)
{
        $parts = explode(" ", trim($line));
        MMparse_str($parts[1], $values);
        return @$values["time"];
}

function GetSizeFromLine($line)
{
        $parts = explode(" ", trim($line));
        MMparse_str($parts[1], $values);
        return @$values["size"];
}

function FindNextGlobalRevisionForPackage($package)
{
        $opersystems = getOperSystems();

        $NewRevision = 1;

        foreach($opersystems As $os) {
                $r = FindNextRevisionForOSAndPackage($os, $package);

                if ($r > $NewRevision)
                        $NewRevision = $r;
        }

        return $NewRevision;
}

function FindNextRevisionForOSAndPackage($OS, $package)
{
        $lines = @file(CONTENT_ROOT . $OS."/".$package.".txt");

        // No revision information - start at Revision 1
        if(sizeof($lines) <= 1)
                return 1;

        // Ignore first line (INSTALLER packagename instructioncount)
        array_shift($lines);

        $revision = 1;

        foreach ($lines As $line) {
                $line = trim($line);
                $bits = explode(" ", $line);
                $rev = $bits[sizeof($bits)-1];

                if ($rev > $revision)
                        $revision = $rev;
        }

        return $revision + 1;
}

function ParseInstallFile($OS, $package)
{
        global $Files;
        global $FilesIndex;
        global $Installer;
        global $PreviousOperations, $Operations;

        $Files = $FilesIndex = $PreviousOperations = $Operations = array();

        $contents = @file(CONTENT_ROOT . $OS."/".$package.".txt");
        if (!is_array($contents))
                return;

        array_splice($contents,0,1);

        $Files = $contents;
        for ($i=0,$j=sizeof($contents);$i<$j;$i++)
        {
                $line = $Files[$i];
                $parts = explode(" ", trim($line));

                if (!isset($parts[1]))
                        continue;

                MMparse_str($parts[1], $values);

                if ($OS == "win32")
                        $values["name"] = strtolower($values["name"]);

                if ($parts[0] == "EXECUTABLE")
                {
                        $PreviousOperations[trim($values["name"])] = true;
                } else {
                        if ($values["name"])
                                $FilesIndex[$values["name"]] = $i;
                }
        }
}


function GetDirectoryName($package)
{
        $contents = @file("packages.txt");
        if ($contents == '')
        {
                echo "Could not find package '$package' - did you add it to pack
ages.txt?\n";
                die;
        }

        foreach ($contents as $line)
        {
                $parts = explode(" ", trim($line), 2);
                if ($parts[0] == $package)
                        return $parts[1];
        }

        echo "Could not find package '$package' - did you add it to packages.txt
?\n";
        die;
}

function ParsePackagesList($OS, $package, $directory)
{
        global $IgnoreDirs, $IgnoreFiles, $OwnedDirs;
        $IgnoreDirs = array();
        $IgnoreFiles= array();
        $OwnedDirs = array();

        $contents = file("packages.txt");
        for ($i=0,$j=sizeof($contents);$i<$j;$i++)
        {
                $line = $contents[$i];

                @list ($name,$dir) = explode(" ", trim($line), 2);
                if ($dir != $directory)
                        continue;

                $isIgnoring = $name != $package;

                if ($isIgnoring)
                        AddToIgnoreFiles($OS,$name);

                // We've hit another package sharing our directory
                while ($i+1 < $j && $contents[$i+1][0] == '-')
                {
                        $i++;
                        $line = $contents[$i];
                        list ($dash,$path) = explode(" ", trim($line), 2);

                        if ($isIgnoring) {
                                $IgnoreDirs[] = ($OS == "win32" ? strtolower($pa
th) : $path);
                                echo "Ignoring $name Directory: $path\n";
                        } else {
                                $OwnedDirs[] = ($OS == "win32" ? strtolower($pat
h) : $path);
                        }
                }
        }
}

function AddToIgnoreFiles($OS,$package)
{
        global $IgnoreFiles;

        $contents = @file(CONTENT_ROOT . $OS."/".$package.".txt");
        if (!is_array($contents))
                return;

        foreach ($contents as $line)
        {
                $parts = explode(" ", $line);
                if ($parts[0] != "FILE" && $parts[0] != "MKDIR")
                        continue;

                MMparse_str($parts[1], $values);

                if ($OS == "win32")
                        $IgnoreFiles[strtolower($values["name"])] = 1;
                else
                        $IgnoreFiles[$values["name"]] = 1;

        }
}

function showParamHelp()
{
echo "GameCreate Build-Update Parameter Help
======================================
    /approve      - Approve the package revision on a successful version.
    /a

    /restart      - Restart affected servers for this update.
    /r

    /norestart    - Do not restart affected servers for this update.
    /n

    /md5          - Force an md5sum comparison of each file.
                    By default, md5sum comparisons are only performed when a fil
e on disk
                    has a different modified time or file size than what is spec
ified
                    in the previous revision.
                    This option ignores these checks, and will force an md5sum
                    comparison regardless of the file modified time or its size.


    /dry          - Perform a dry run. Changes are displayed but not committed.
    /d

    /confirm      - Automatically confirm the revision changes on success and no
tify GameCreate.
    /c              No confirmation of the build change log is needed at the end
 of the build.

    /version      - Show the GameCreate Package Builder version information.
    /v

    /help         - This help screen.
";
}

function parseParams(&$params)
{
        global $approve, $suspend, $forceMd5, $dryRun, $forceDeploy, $package;

        if (sizeof($params) < 2)
                return;

        for ($i = 1; $i < sizeof($params); $i++)
        {
                switch ($params[$i])
                {
                        case "/help": case "/?":
                                showParamHelp();
                                die;
                        case "/approve": case "/a":
                                $approve = true;
                                break;
                        case "/norestart": case "/n":
                                $suspend = false;
                                break;
                        case "/restart": case "/r":
                                $suspend = true;
                                break;
                        case "/dry": case "/d":
                                $dryRun = true;
                                break;
                        case "/confirm": case "/c":
                                $forceDeploy = true;
                                break;
                        case "/md5":
                                echo "Ignoring file time and size values; forcin
g md5sum comparison\n";
                                $forceMd5 = true;
                                break;
                        case "/version": case "/v":
                                showVersion();
                                die;
                        default:
                                $unknownParam = false;
                                if ($params[$i][0] == '/') {
                                        $unknownParam = true;
                                } else {
                                        if ($package == '') {
                                                // Assign package name
                                                $package = $params[$i];
                                        } else {
                                                echo "Package name already speci
fied as '$package'.\n";
                                                $unknownParam = true;
                                        }
                                }

                                if ($unknownParam) {
                                        echo "Unknown parameter: " . $params[$i]
 . "\n";
                                        echo "Type /help for a list of supported
 command arguments.\n";
                                        die;
                                }
                                break;
                }
        }

        if (!$approve || $suspend !== null)
                return;

        while (true)
        {
                echo "\nShould servers be suspended during this update? (Y/N): "
;
                $suspend = readConsole();

                if (convertToBoolean($suspend))
                        break;
        }
}

function checkAuth($auth)
{
        if (sizeof($auth) == 0)
                die("You need to define at least one set of domain login informa
tion to be used in the build-update.config file.");

        $args = array('login', 'password', 'region');
        foreach ($auth As $domain)
        {
                foreach ($args As $arg)
                        if (!isset($domain[$arg]) || $domain[$arg] == '')
                                die("One or more arguments are undefined for a d
omain in build-update.config");
        }
}

function showVersion()
{
        echo "GameCreate Package Builder v1.0.2\n";
}

?>

C:\Content>


Thanks for the help kybber, I hope you see something funky
Back to top
View user's profile Send private message
Kybber



PostPosted: Mon Aug 23, 2010 6:04 pm    Post subject: Reply with quote

Well, for some reason the PHP interpreter doesn't seem to interpret the code, but just dumps it to screen.

ryguy222 wrote:
Code:
C:\Content>C:\content\php.exe -q build-update.php %* tf


I don't know what it actually does to Windows PHP, but %* shouldn't be there. Try this:

Code:
C:\content\php.exe -q build-update.php tf

or even this:
Code:
C:\content\php.exe build-update.php tf
Back to top
View user's profile Send private message
ryguy222



PostPosted: Tue Aug 24, 2010 1:19 pm    Post subject: Reply with quote

Tried those, and still same thing <_<

I re-installed php, tried putting it in the Program files folder, then tried moving it. Tried the latest version 5.3.3 i think, as well as 5.2.4

I think a lot of the problems have to do with the fact that this is an x64 machine. Usually when I have problems it's cuz of the 64 bit part Sad

And there isn't an x64 bit version of php. I tried running the command in a 32 bit cmd window, and same thing.

When I un-installed php, I tried running the bat file to see what happens. And it just dumped it into the window again, which happens when PHP is installed. Meaning it can't get to php, or can't run it.

I'm not sure what the deal is, but I believe it could be a compatibility issue with PHP and x64, or a newer version of php not compatibile with this update system.


What version of php do you use?
Back to top
View user's profile Send private message
Kybber



PostPosted: Tue Aug 24, 2010 4:42 pm    Post subject: Reply with quote

ryguy222 wrote:
When I un-installed php, I tried running the bat file to see what happens. And it just dumped it into the window again, which happens when PHP is installed. Meaning it can't get to php, or can't run it.

Now this is interesting, and very stupid behaviour from Windows. I am assuming you don't have the php command added to your path? You can't type "C:\content\php.exe" and expect php.exe to run if it doesn't exist in that directory. You need to either provide the full path to php.exe, e.g. "C:\Program Files(x86)\php/php.exe" or add it to your path: My Computer->Properies->Advanced->Environment Variables->System variables->Path->Edit

You should be able to verify that php.exe is actually being called by using the --version argument (e.g. "C:\Program Files(x86)\php/php.exe --version" or, if added to your path: "php.exe --version"

ryguy222 wrote:
What version of php do you use?

I only have php on Linux-hosts. The version I use happens to be 5.2.9, but that shouldn't make any difference for you.
Back to top
View user's profile Send private message
ryguy222



PostPosted: Wed Aug 25, 2010 5:34 am    Post subject: Reply with quote

I first had it installed in the program files directory, then I tried to install it in the content folder, to see if that would do anything. Then I installed the latest 5.3.3 in the program files folder, and still the same issue.

I have been using the full path. I haven't put in an environment variable yet, as that would require a restart. I'll probably restart it later this evening, when the box isn't in use.
Although I'm not sure if that will fix this issue.
Back to top
View user's profile Send private message
Kybber



PostPosted: Wed Aug 25, 2010 6:05 am    Post subject: Reply with quote

... and "php.exe --version", with or without paths, yields nothing?

Edit: I just downloaded "PHP 5.2.14 zip package [10,281Kb] - 22 July 2010" from http://www.php.net/downloads.php and extracted it to my Downloads-folder. Open a cmd, cd to the directory, and it seems to work nicely:
Code:
C:\Users\Einar\Downloads\php-5.2.14-Win32>php.exe --version
PHP 5.2.14 (cli) (built: Jul 21 2010 18:43:55)
Copyright (c) 1997-2010 The PHP Group
Zend Engine v2.2.0, Copyright (c) 1998-2010 Zend Technologies

Not tried with the GC content files, though.

Update: I downloaded the GC content files and extracted to my Downloads dir. Renamed build-update.config-default to build-update.config and got this:
Code:
C:\Users\Einar\Downloads\ContentServerSupport>..\php-5.2.14-Win32\php.exe build-update.php
Usage: build-update.php <package-name> [parameters]

Package name may appear before, between, or after any parameters.

Type /help for more information.


So all seems to be working nicely here, and I can't really say what goes on your end. Perhaps you could try to clone what I did above and go from there? Download the php zip package and the GC content-server files, extract them to you Downloads dir and run the commands I ran and see what happens.

This is in Windows 7 64bit, by the way.
Back to top
View user's profile Send private message
ryguy222



PostPosted: Wed Aug 25, 2010 2:48 pm    Post subject: Reply with quote

I also have windows 7 x64 so I gave this a try, and I'm getting the same thing, so that means I must have something mis-configured

Here is my current config

Code:
<?php

// Authentication details needed to update revision information
// Include multiple lines if you need to notify more than one domain
// Example:   http://mammoth.au.gamecreate.com/admin/
//          
http://mammoth.us.gamecreate.com/admin/
// login = mydomainlogin, password = mydomainpassword, region = au (us, nz, eu, af...)
$auth[] = array("login" => "evlgaming", "password" => "*******", "region" => "us");

// Content directory relative to build-update.
// Must include a trailing slash if set.
define('CONTENT_ROOT', '');

// Whether backup of revision files (<name>.<revision>.txt) should be created
// when a new revision is made. This allows for easy rollback or revision information.
define('BACKUP_REVISION', false);

?>


I am using the domain login, and the domain pass, same that the remote program uses correct?

Would you mind posting your config maybe? Just so I can see where everything goes, or how it's all setup.
Back to top
View user's profile Send private message
Kybber



PostPosted: Wed Aug 25, 2010 8:16 pm    Post subject: Reply with quote

There is at least one error and one potential problem:
1. See that uncommented line that reads "http://mammoth..."? Remove it.
2. define your content root with a complete path
Back to top
View user's profile Send private message
ryguy222



PostPosted: Thu Aug 26, 2010 11:06 am    Post subject: Reply with quote

The root content would be?
C:\content\
or
C:\content\win32?

I have the TF2 installation located at

C:\content\win32\orange-box\orangebox\tf

I have both a zip file, and the unzipped directory in that spot.

Changing the un-commented section didn't fix it either ><
Back to top
View user's profile Send private message
Kybber



PostPosted: Thu Aug 26, 2010 6:10 pm    Post subject: Reply with quote

Your content path is "C:\content\" or possibly "C:/content/"

Can you re-post your current config?

Here's one of my configs:
Code:
<?php

// Authentication details needed to update revision information
// Include multiple lines if you need to notify more than one domain
// Example:     http://mammoth.au.gamecreate.com/admin/
//                      http://mammoth.REGION.gamecreate.com/admin/
// login = mydomainlogin, password = mydomainpassword, region = au (us, nz, eu, af...)
$auth[] = array("login" => "mydomain", "password" => "mypassword", "region" => "eu");

// Content directory relative to build-update.
// Must include a trailing slash if set.
define('CONTENT_ROOT', '/mnt/nfs/files1/gccontent/cn/');

// Whether backup of revision files (<name>.<revision>.txt) should be created
// when a new revision is made. This allows for easy rollback or revision information.
define('BACKUP_REVISION', true);

?>


But please note that running the script from a default installation of the GC content server files (just renamed the default config) yielded proper-looking results for me. You should try to do that. It even that doesn't work, then I don't know what to tell you. As said, it works for me in Win 7 x64 with the procedure I outlined above.
Back to top
View user's profile Send private message
ryguy222



PostPosted: Sun Aug 29, 2010 9:07 am    Post subject: Reply with quote

Hmm, well I've tried many different things, and still this doesn't work. I re-installed php, I've tried a few different versions of php as well.

I also re-downloaded the content files to see if my files were possibly corrupted.

Php.exe --version always works fine, but if I try to run the script it just can't identify it.

Same thing happens on my desktop, it makes no sense >_<
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic All times are GMT + 10 Hours
Goto page 1, 2  Next
Page 1 of 2

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Forum powered by phpBB © 2001, 2005 phpBB Group
GameCreate Service Terms | Privacy Policy | © Copyright Mammoth Media 2001-2007
GameCreate™ is a trademark of Mammoth Media Pty Ltd. GameCreate® is a registered trademark in Australia.