-
-
Notifications
You must be signed in to change notification settings - Fork 57
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ea63c42
commit 3558c22
Showing
3 changed files
with
129 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,6 @@ | ||
/locales/*.mo | ||
/nbproject | ||
/vendor | ||
/*.tar | ||
/*.tar.gz | ||
/*.zip |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<?php | ||
|
||
function log_and_exec($cmd) { | ||
echo "Running: $cmd\n"; | ||
return shell_exec($cmd); | ||
} | ||
|
||
$dir = dirname(dirname(__FILE__)); | ||
|
||
$files = glob("$dir/locales/*.po"); | ||
|
||
// Build .mo | ||
foreach ($files as $file) { | ||
$lang = basename($file, ".po"); | ||
|
||
log_and_exec("msgfmt $dir/locales/$lang.po -o $dir/locales/$lang.mo"); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,109 @@ | ||
<?php | ||
|
||
function log_and_exec($cmd) { | ||
echo "CMD: $cmd\n"; | ||
return shell_exec($cmd); | ||
} | ||
|
||
function remove_recursive($dir) { | ||
if (is_dir($dir)) { | ||
$objects = scandir($dir); | ||
foreach ($objects as $object) { | ||
if ($object != "." && $object != "..") { | ||
remove_recursive($dir . "/" . $object); | ||
} | ||
} | ||
rmdir($dir); | ||
} else if ($dir != "." && $dir != ".." && file_exists($dir)) { | ||
unlink($dir); | ||
} | ||
} | ||
|
||
if (!function_exists('glob_recursive')) { | ||
|
||
// Does not support flag GLOB_BRACE | ||
function glob_recursive($pattern, $flags = 0) { | ||
$files = glob($pattern, $flags); | ||
foreach (glob(dirname($pattern) . '/*', GLOB_ONLYDIR | GLOB_NOSORT) as $dir) { | ||
$files = array_merge($files, glob_recursive($dir . '/' . basename($pattern), $flags)); | ||
} | ||
return $files; | ||
} | ||
|
||
} | ||
|
||
$dir = dirname(dirname(__FILE__)); | ||
|
||
$tmp_dir = "/tmp/singlesignon"; | ||
|
||
echo "Delete old release\n"; | ||
remove_recursive("$dir/singlesignon.zip"); | ||
remove_recursive("$dir/singlesignon.tar"); | ||
remove_recursive("$dir/singlesignon.tar.gz"); | ||
|
||
chdir($dir); | ||
|
||
if (file_exists($tmp_dir)) { | ||
echo "Delete existing temp directory\n"; | ||
remove_recursive($tmp_dir); | ||
} | ||
|
||
echo "Copy to /tmp directory\n"; | ||
log_and_exec("git checkout-index -a -f --prefix=/tmp/singlesignon/"); | ||
|
||
chdir($tmp_dir); | ||
|
||
echo "Retrieve PHP vendor\n"; | ||
log_and_exec("composer install --no-dev --optimize-autoloader --prefer-dist"); | ||
|
||
echo "Compile locale files\n"; | ||
log_and_exec("php tools/build-locales-mo.php"); | ||
|
||
echo "Remove unused files\n"; | ||
$to_remove = [ | ||
'tools', | ||
'composer.json', | ||
'composer.lock', | ||
]; | ||
|
||
$to_remove = array_merge($to_remove, glob(".*")); | ||
|
||
$to_remove = array_filter($to_remove, function ($t) { | ||
return $t && !in_array($t, [".", ".."]); | ||
}); | ||
|
||
$to_remove = array_values($to_remove); | ||
|
||
foreach ($to_remove as $r) { | ||
remove_recursive($r); | ||
} | ||
|
||
echo "Zip files\n"; | ||
$zip = new ZipArchive(); | ||
$tar = new PharData("$dir/singlesignon.tar"); | ||
|
||
|
||
if (!$zip->open("$dir/singlesignon.zip", ZipArchive::CREATE)) { | ||
echo "Failed to create singlesignon.zip\n"; | ||
} | ||
|
||
$current_dir = getcwd() . DIRECTORY_SEPARATOR; | ||
|
||
$files = glob_recursive("*"); | ||
|
||
foreach ($files as $f) { | ||
$f = realpath($f); | ||
|
||
if (!is_file($f)) { | ||
continue; | ||
} | ||
|
||
// Relativer file only | ||
$f = str_replace($current_dir, '', $f); | ||
|
||
$zip->addFile($f); | ||
$tar->addFile($f); | ||
} | ||
|
||
$zip->close(); | ||
$tar->compress(Phar::GZ); |