getMessage(); exit(3); } } $config_path = __DIR__ . '/../data/config/pickle/' . $branch_name . '.ini'; $branch = new rm\PickleBranch($config_path); $branch_name = $branch->config->getName(); $builds = $branch->getBuildList('windows'); //var_dump($pickle); //var_dump($branch_name); //var_dump($builds); $was_errors = false; echo "Using <$pkg_path>" . PHP_EOL . PHP_EOL; $upload_status = array(); foreach ($builds as $build_name) { $build_error = 0; echo "Starting build $build_name" . PHP_EOL; //$build_config = $branch->config->getBuildFromName($build_name); try { $build = $branch->createBuildInstance($build_name); $ext = new rm\PickleExt($pkg_path, $build); } catch (Exception $e) { echo 'Error: ' . $e->getMessage() . PHP_EOL; /* send error mail*/ continue; } try { $ext->init(); } catch (Exception $e) { echo 'Error: ' . $e->getMessage() . PHP_EOL; /* send error mail*/ continue; } echo "Starting pickle build" . PHP_EOL; try { $cmd = $build->getPickleCmdToRun($ext); echo "Pickle command is " . PHP_EOL . " $cmd" . PHP_EOL; $ret = $build->build($ext); } catch (Exception $e) { echo 'Error: ' . $e->getMessage() . PHP_EOL; $ret = array("return_value" => 1, "log" => ""); /* send error mail*/ $build_error++; } if ($ret["return_value"]) { $build->clean(); $ext->cleanup(); $was_errors = true; echo "Build failed" . PHP_EOL; echo $ret["log"]; $build_error++; } /* XXX check zipballs path before saying this */ echo "Pickle build successful" . PHP_EOL; // add the deps license to the pickle archive ... or should pickle do that? /* upload logs and builds */ $fl_base = "php_" . $ext->getName() . "-" . $ext->getVersion() . "-" . $build->branch->config->getBranch() . "-" . ($build->thread_safe ? "ts" : "nts") . "-" . $build->compiler . "-" . $build->architecture; $logs_zip = realpath(TMP_DIR . DIRECTORY_SEPARATOR . "$fl_base-logs.zip"); $pkg_file = realpath(TMP_DIR . DIRECTORY_SEPARATOR . "$fl_base.zip"); $upload_success = true; if ($upload) { try { $root = $is_snap ? 'snaps' : 'releases'; $frag = $ext->getVendor() . "/" . $ext->getName(); $target = '/' . $root . '/' . $frag . '/' . $ext->getVersion(); $pkgs_to_upload = $build_error ? array() : array($pkg_file); if ($build_error) { echo "Uploading logs" . PHP_EOL; } else { echo "Uploading '$pkg_file' and logs" . PHP_EOL; } if ($build_error && !file_exists($logs_zip)) { throw new Exception("Logs wasn't packaged, nothing to upload"); } if (rm\upload_pickle_pkg_ftp_curl($pkgs_to_upload, array($logs_zip), $target)) { echo "Upload succeeded" . PHP_EOL; if (file_exists($logs_zip)) { unlink($logs_zip); } if (file_exists($pkg_file)) { unlink($pkg_file); } } else { throw new Exception("Upload failed"); } } catch (Exception $e) { echo 'Error . ' . $e->getMessage() . PHP_EOL; $upload_success = false; } } /* keep recording upload status for every package, the code at the end is going to evaluate it like in pecl. */ $upload_status[$build_name] = $upload_success; /* notify pickle */ echo PHP_EOL; } if ($is_last_run) { if (file_exists($job_path)) { unlink($job_path); } if (file_exists($pkg_path)) { unlink($pkg_path); } } exit(0);