|
|
@@ -21,12 +21,12 @@ echo "\nsync mk6 packages - by DSR!\n\n";
|
|
|
|
|
|
$target = $argv[1];
|
|
|
$remoteSync = (isset($argv[2]) && filter_var($argv[2], FILTER_VALIDATE_BOOLEAN, FILTER_NULL_ON_FAILURE));
|
|
|
-
|
|
|
$buildDir = getcwd() . '/build';
|
|
|
$srcDir = getcwd() . '/src';
|
|
|
-$moduleData = json_decode(file_get_contents("{$buildDir}/modules.json"), true);
|
|
|
|
|
|
-if ($remoteSync) {
|
|
|
+
|
|
|
+// scripts
|
|
|
+function processRemoteSync($target, $buildDir) {
|
|
|
$moduleData = json_decode(file_get_contents("https://www.wifipineapple.com/{$target}/modules"), true);
|
|
|
|
|
|
echo "======== Packages (" . count($moduleData) . ") ========\n";
|
|
|
@@ -38,7 +38,11 @@ if ($remoteSync) {
|
|
|
file_put_contents("{$buildDir}/{$key}.tar.gz", $file);
|
|
|
}
|
|
|
}
|
|
|
-} else {
|
|
|
+
|
|
|
+ return $moduleData;
|
|
|
+}
|
|
|
+
|
|
|
+function updateSinglePackage($target, $srcDir, $buildDir) {
|
|
|
echo "======== Update Package: {$target} ========\n";
|
|
|
echo "Remember compress first!: tar czf {$target}.tar.gz {$target} && mv {$target}.tar.gz ../build\n";
|
|
|
echo "Doing this on Windows can actually BREAK scripts!\n\n";
|
|
|
@@ -67,6 +71,55 @@ if ($remoteSync) {
|
|
|
echo "module info:\n";
|
|
|
var_dump($module);
|
|
|
$moduleData[ $target ] = $module;
|
|
|
+
|
|
|
+ return $moduleData;
|
|
|
+}
|
|
|
+
|
|
|
+function processAllTargets($srcDir, $buildDir) {
|
|
|
+ $moduleData = [];
|
|
|
+ $files = scandir($buildDir);
|
|
|
+ foreach ($files as $fileName) {
|
|
|
+ if (in_array($fileName, ['.', '..', 'modules.json'])) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+
|
|
|
+ echo " [+] {$fileName}\n";
|
|
|
+ $target = str_replace('.tar.gz', '', $fileName);
|
|
|
+ $fileName = "{$buildDir}/{$fileName}";
|
|
|
+ $infoData = json_decode(file_get_contents("{$srcDir}/{$target}/module.info"));
|
|
|
+
|
|
|
+ $module = [
|
|
|
+ 'name' => $target,
|
|
|
+ 'title' => $infoData->title,
|
|
|
+ 'version' => $infoData->version,
|
|
|
+ 'description' => $infoData->description,
|
|
|
+ 'author' => $infoData->author,
|
|
|
+ 'size' => filesize($fileName),
|
|
|
+ 'checksum' => hash_file('sha256', $fileName),
|
|
|
+ 'num_downloads' => '0',
|
|
|
+ ];
|
|
|
+ if (isset($infoData->system)) {
|
|
|
+ $module['type'] = 'System';
|
|
|
+ } elseif (isset($infoData->cliOnly)) {
|
|
|
+ $module['type'] = 'CLI';
|
|
|
+ } else {
|
|
|
+ $module['type'] = 'GUI';
|
|
|
+ }
|
|
|
+
|
|
|
+ $moduleData[ $target ] = $module;
|
|
|
+ }
|
|
|
+
|
|
|
+ return $moduleData;
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+// implement...
|
|
|
+if ($target === 'all') {
|
|
|
+ $moduleData = processAllTargets($srcDir, $buildDir);
|
|
|
+} elseif ($remoteSync) {
|
|
|
+ $moduleData = processRemoteSync($target, $buildDir);
|
|
|
+} else {
|
|
|
+ $moduleData = updateSinglePackage($target, $srcDir, $buildDir);
|
|
|
}
|
|
|
|
|
|
asort($moduleData);
|