示例#1
0
function mkmetas($package, array &$metapaks, &$have_runtime_req = false)
{
    // filter platform reqs
    $platfilter = function ($v) {
        return preg_match("#^(hhvm\$|php(-64bit)?\$|ext-)#", $v);
    };
    // extract only platform requires, replaces and provides
    $preq = array_filter(isset($package["require"]) ? $package["require"] : [], $platfilter, ARRAY_FILTER_USE_KEY);
    $prep = array_filter(isset($package["replace"]) ? $package["replace"] : [], $platfilter, ARRAY_FILTER_USE_KEY);
    $ppro = array_filter(isset($package["provide"]) ? $package["provide"] : [], $platfilter, ARRAY_FILTER_USE_KEY);
    $pcon = array_filter(isset($package["conflict"]) ? $package["conflict"] : [], $platfilter, ARRAY_FILTER_USE_KEY);
    if (!$preq && !$prep && !$ppro && !$pcon) {
        return false;
    }
    $have_runtime_req |= hasreq($preq);
    $metapaks[] = ["type" => "metapackage", "name" => $package["name"], "version" => $package["version"], "require" => mkdep($preq), "replace" => mkdep($prep), "provide" => mkdep($ppro), "conflict" => mkdep($pcon)];
    return true;
}
    // if we do not do this, then a require for e.g. ext-curl or ext-mbstring in the main composer.json cannot be found by the installer plugin
    $root = ["name" => "{$COMPOSER}/{$COMPOSER_LOCK}", "version" => "dev-" . $lock["hash"], "require" => $lock["platform"]];
    if ($root["require"]) {
        $lock["packages"][] = $root;
        $require = [$root["name"] => $root["version"]];
    }
    foreach ($lock["packages"] as $package) {
        // extract only platform requires, replaces and provides
        $preq = array_filter(isset($package["require"]) ? $package["require"] : [], $platfilter, ARRAY_FILTER_USE_KEY);
        $prep = array_filter(isset($package["replace"]) ? $package["replace"] : [], $platfilter, ARRAY_FILTER_USE_KEY);
        $ppro = array_filter(isset($package["provide"]) ? $package["provide"] : [], $platfilter, ARRAY_FILTER_USE_KEY);
        $pcon = array_filter(isset($package["conflict"]) ? $package["conflict"] : [], $platfilter, ARRAY_FILTER_USE_KEY);
        if (!$preq && !$prep && !$ppro && !$pcon) {
            continue;
        }
        $have_runtime_req |= hasreq($preq);
        $metapaks[] = ["type" => "metapackage", "name" => $package["name"], "version" => $package["version"], "require" => mkdep($preq), "replace" => mkdep($prep), "provide" => mkdep($ppro), "conflict" => mkdep($pcon)];
        $require[$package["name"]] = $package["version"];
    }
    // add all meta-packages to one local package repo
    if ($metapaks) {
        $repositories[] = ["type" => "package", "package" => $metapaks];
    }
}
// if no PHP or HHVM is required anywhere, we need to add something
if (!$have_runtime_req) {
    file_put_contents("php://stderr", "NOTICE: No runtime required in {$COMPOSER_LOCK}; using PHP " . ($require["heroku-sys/php"] = "^5.5.17") . "\n");
} elseif (!isset($root["require"]["php"]) && !isset($root["require"]["hhvm"])) {
    file_put_contents("php://stderr", "NOTICE: No runtime required in {$COMPOSER}; requirements\nfrom dependencies in {$COMPOSER_LOCK} will be used for selection\n");
}
$require["heroku-sys/apache"] = "^2.4.10";