File:  [mozdev] / AMOLocaliser / res / Attic / cbx.php
Revision 1.1: download - view: text, annotated - select for diffs - revision graph
Sat Aug 23 22:09:56 2008 UTC (10 years, 6 months ago) by ej
Branches: MAIN
CVS tags: HEAD
*** empty log message ***

<?php
include_once('version.php');

function get_include_contents($filename) {
    global $extdetails;
	if (is_file($filename)) {
        ob_start();
        include $filename;
        $contents = ob_get_contents();
        ob_end_clean();
        return $contents;
    }
    return false;
}

function parse_properties_file($file) {
	$out=array();
	$lines=file($file,FILE_SKIP_EMPTY_LINES | FILE_IGNORE_NEW_LINES);
	foreach($lines as $line) $out[substr($line,0,strpos($line,"="))]=trim(substr($line,strpos($line,"=")+1));
	return $out;
}

function make_chrome_manifest($header,$filename) {
	global $extdetails;
	$f=fopen($filename,'w');
	fwrite($f,$header);
	$oldwd=getcwd();
	chdir($extdetails['builddir'].'\\'.$extdetails['locales']);
	foreach(glob('*') as $dir) {
		fwrite($f,str_replace('\\','/',"locale {$extdetails['name']} $dir {$extdetails['locales']}/{$dir}/{$extdetails['localesub']}\r\n"));
		$extdetails['amoproperties'][$dir]=parse_properties_file("{$dir}\\{$extdetails['localesub']}amo.properties");
	}
	chdir($oldwd);
	fclose($f);
}

foreach(glob('*.xpi') as $filename) {
		unlink($filename);
}

echo system("rmdir {$extdetails['builddir']} /s/q");
echo system('md '.$extdetails['builddir']);
echo system("xcopy chrome {$extdetails['builddir']}\\chrome\\ /E /EXCLUDE:{$extdetails['excludedfiles']}");
if (!$extdetails['inclocales']) {
	echo system("xcopy {$extdetails['locales']} {$extdetails['builddir']}\\{$extdetails['locales']}\\ /E ");
}
else foreach($extdetails['inclocales'] as $loc) {
	echo system("xcopy {$extdetails['locales']}\\$loc {$extdetails['builddir']}\\{$extdetails['locales']}\\$loc\\ /E ");
}
echo system("xcopy defaults {$extdetails['builddir']}\\defaults\\ /E");

if ($extdetails['manifestheader']!="") make_chrome_manifest(file_get_contents($extdetails['manifestheader']),'chrome.manifest');
copy('chrome.manifest',$extdetails['builddir'].'\chrome.manifest');

file_put_contents('install.rdf',get_include_contents('res\install.rdf.php'));
copy('install.rdf',"{$extdetails['builddir']}\\install.rdf");

foreach($extdetails['postprocessfiles'] as $file) {
	file_put_contents("{$extdetails['builddir']}\\{$file}",get_include_contents($file));
}

chdir($extdetails['builddir']);
echo system("..\\..\\7za.exe a -tzip ..\\{$extdetails['xpi']} * -r -mx=9");
chdir('..');
echo system("rmdir {$extdetails['builddir']} /s/q");

if ($extdetails['archive']!="") copy($extdetails['xpi'],
		"{$extdetails['archive']}\\{$extdetails['name']}{$extdetails['version']} [".filemtime($extdetails['xpi'])."].xpi");

file_put_contents('updatefragment.txt',get_include_contents('res\updatefragment.phpd'));
?>

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>