396 |
396 |
*/
|
397 |
397 |
if (!$installed_pkgs_only || !$remote_repo_usage_disabled) {
|
398 |
398 |
$did_search = true;
|
|
399 |
/* Update the repository access credentials. */
|
|
400 |
mwexec("/usr/local/sbin/{$g['product_name']}-repo-setup");
|
399 |
401 |
$search_rc = pkg_exec("search {$repo_param} " .
|
400 |
402 |
"{$extra_param}-R --raw-format json-compact " .
|
401 |
403 |
$pkgs, $search_out, $search_err);
|
... | ... | |
1152 |
1154 |
if ($current_repo_path != $default_repo['path']) {
|
1153 |
1155 |
config_set_path('system/pkg_repo_conf_path', $default_repo['path']);
|
1154 |
1156 |
write_config( "Configured default pkg repo after restore");
|
1155 |
|
pkg_switch_repo($default_repo['path']);
|
|
1157 |
pkg_switch_repo($default_repo['path'], $default_repo['name']);
|
1156 |
1158 |
}
|
1157 |
1159 |
|
1158 |
1160 |
/* wait for internet connection */
|
... | ... | |
1393 |
1395 |
function pkg_list_repos() {
|
1394 |
1396 |
global $g;
|
1395 |
1397 |
|
1396 |
|
$path = "/usr/local/share/{$g['product_name']}/pkg/repos";
|
1397 |
|
|
1398 |
|
$default_descr = @file_get_contents($path .
|
1399 |
|
"/{$g['product_name']}-repo.descr");
|
1400 |
|
|
1401 |
|
$default = array(
|
1402 |
|
'name' => 'Default',
|
1403 |
|
'path' => $path . "/{$g['product_name']}-repo.conf",
|
1404 |
|
'descr' => $default_descr
|
1405 |
|
);
|
1406 |
|
|
1407 |
|
$result = array($default);
|
1408 |
|
|
1409 |
|
$conf_files = glob("{$path}/{$g['product_name']}-repo-*.conf");
|
1410 |
|
foreach ($conf_files as $conf_file) {
|
1411 |
|
$descr_file = preg_replace('/.conf$/', '.descr', $conf_file);
|
|
1398 |
$repo_base = "{$g['pkg_repos_path']}/{$g['product_name']}-repo";
|
|
1399 |
$result = array();
|
|
1400 |
$name_files = glob("{$repo_base}-*.name");
|
|
1401 |
foreach ($name_files as $name_file) {
|
|
1402 |
$repo_name = file_get_contents($name_file);
|
|
1403 |
if ($repo_name == false || strlen($repo_name) <= 1) {
|
|
1404 |
continue;
|
|
1405 |
}
|
|
1406 |
$repo_name_base = "{$repo_base}-{$repo_name}";
|
|
1407 |
$descr_file = "{$repo_name_base}.descr";
|
1412 |
1408 |
if (file_exists($descr_file)) {
|
1413 |
|
$descr_content = file($descr_file);
|
1414 |
|
$descr = chop($descr_content[0]);
|
|
1409 |
$descr = file_get_contents($descr_file);
|
|
1410 |
if ($descr == false) {
|
|
1411 |
$descr = 'Unknown';
|
|
1412 |
}
|
1415 |
1413 |
} else {
|
1416 |
1414 |
$descr = 'Unknown';
|
1417 |
1415 |
}
|
1418 |
|
if (!preg_match('/-repo-(.*).conf/', $conf_file, $matches)) {
|
1419 |
|
continue;
|
1420 |
|
}
|
1421 |
1416 |
$entry = array(
|
1422 |
|
'name' => ucfirst(strtolower($matches[1])),
|
1423 |
|
'path' => $conf_file,
|
|
1417 |
'name' => $repo_name,
|
|
1418 |
'path' => "{$repo_name_base}.conf",
|
1424 |
1419 |
'descr' => $descr
|
1425 |
1420 |
);
|
1426 |
|
if (file_exists($conf_file . ".default")) {
|
|
1421 |
if (file_exists("{$repo_name_base}.default")) {
|
1427 |
1422 |
$entry['default'] = true;
|
1428 |
1423 |
}
|
1429 |
1424 |
$result[] = $entry;
|
... | ... | |
1475 |
1470 |
return $default;
|
1476 |
1471 |
}
|
1477 |
1472 |
|
1478 |
|
/* Setup pkg.conf according current repo */
|
1479 |
|
function pkg_conf_setup($repo_path) {
|
1480 |
|
global $g;
|
1481 |
|
|
1482 |
|
$pkg_conf_path = "/usr/local/etc/pkg.conf";
|
1483 |
|
$conf = "/usr/local/etc/pkg/repos/{$g['product_name']}.conf";
|
1484 |
|
if (!file_exists($conf)) {
|
1485 |
|
return;
|
1486 |
|
}
|
1487 |
|
|
1488 |
|
$real_conf = readlink($conf);
|
1489 |
|
|
1490 |
|
if (!$real_conf) {
|
1491 |
|
return;
|
1492 |
|
}
|
1493 |
|
|
1494 |
|
$abi_file = str_replace('.conf', '.abi', $real_conf);
|
1495 |
|
$altabi_file = str_replace('.conf', '.altabi', $real_conf);
|
1496 |
|
|
1497 |
|
$pkg_conf = array();
|
1498 |
|
if (file_exists($abi_file) && file_exists($altabi_file)) {
|
1499 |
|
$abi = file_get_contents($abi_file);
|
1500 |
|
$altabi = file_get_contents($altabi_file);
|
1501 |
|
|
1502 |
|
$pkg_conf = array(
|
1503 |
|
"ABI={$abi}\n",
|
1504 |
|
"ALTABI={$altabi}\n"
|
1505 |
|
);
|
1506 |
|
}
|
1507 |
|
|
1508 |
|
$auth_ca = "/etc/ssl/netgate-ca.pem";
|
1509 |
|
$auth_cert = "/etc/ssl/pfSense-repo-custom.cert";
|
1510 |
|
$auth_key = "/etc/ssl/pfSense-repo-custom.key";
|
1511 |
|
if (strpos($repo_path, "{$g['product_name']}-repo-custom") &&
|
1512 |
|
file_exists($auth_ca) && file_exists($auth_cert) &&
|
1513 |
|
file_exists($auth_key)) {
|
1514 |
|
$pkg_conf[] = "PKG_ENV {\n";
|
1515 |
|
$pkg_conf[] = "\tSSL_CA_CERT_FILE=$auth_ca\n";
|
1516 |
|
$pkg_conf[] = "\tSSL_CLIENT_CERT_FILE=$auth_cert\n";
|
1517 |
|
$pkg_conf[] = "\tSSL_CLIENT_KEY_FILE=$auth_key\n";
|
1518 |
|
$pkg_conf[] = "}\n";
|
1519 |
|
}
|
1520 |
|
|
1521 |
|
file_put_contents($pkg_conf_path, $pkg_conf);
|
1522 |
|
}
|
1523 |
|
|
1524 |
1473 |
/* Switch between stable and devel repos */
|
1525 |
|
function pkg_switch_repo($path) {
|
1526 |
|
global $g;
|
|
1474 |
function pkg_switch_repo($repo_path, $repo_name) {
|
|
1475 |
global $g, $config;
|
1527 |
1476 |
|
1528 |
1477 |
safe_mkdir("/usr/local/etc/pkg/repos");
|
1529 |
1478 |
@unlink("/usr/local/etc/pkg/repos/{$g['product_name']}.conf");
|
1530 |
|
@symlink($path, "/usr/local/etc/pkg/repos/{$g['product_name']}.conf");
|
|
1479 |
$repo = "{$repo_path}/{$g['product_name']}-repo-{$repo_name}.conf";
|
|
1480 |
@symlink($repo, "/usr/local/etc/pkg/repos/{$g['product_name']}.conf");
|
1531 |
1481 |
|
1532 |
|
pkg_conf_setup($path);
|
|
1482 |
/* Do not fetch new settings, only setup the repo pkg.conf. */
|
|
1483 |
mwexec("/usr/local/sbin/{$g['product_name']}-repo-setup -U");
|
1533 |
1484 |
|
1534 |
1485 |
/* Update pfSense_version cache */
|
1535 |
1486 |
mwexec_bg("/etc/rc.update_pkg_metadata now");
|
1536 |
1487 |
return;
|
1537 |
1488 |
}
|
1538 |
1489 |
|
|
1490 |
/*
|
|
1491 |
* Update the repository settings.
|
|
1492 |
*/
|
|
1493 |
function update_repos() {
|
|
1494 |
|
|
1495 |
/* Load the old custom repo settings. */
|
|
1496 |
update_custom_repos();
|
|
1497 |
|
|
1498 |
$rc = -1;
|
|
1499 |
$out = NULL;
|
|
1500 |
$product_name = g_get('product_name');
|
|
1501 |
|
|
1502 |
$res = exec("/usr/local/sbin/{$product_name}-repoc", $out, $rc);
|
|
1503 |
if ($res === false || $out === NULL) {
|
|
1504 |
return (array( "error" => 1,
|
|
1505 |
"messages" => array("We could not connect to Netgate servers. Please try again later.")));
|
|
1506 |
}
|
|
1507 |
$rtrn = array( "error" => $rc, "messages" => array() );
|
|
1508 |
if (isset($out) && is_array($out) &&
|
|
1509 |
count($out) > 1 && $out[0] === "Messages:") {
|
|
1510 |
for ($i = 1; $i < count($out); $i++) {
|
|
1511 |
$rtrn['messages'][] = $out[$i];
|
|
1512 |
}
|
|
1513 |
}
|
|
1514 |
|
|
1515 |
return ($rtrn);
|
|
1516 |
}
|
|
1517 |
|
1539 |
1518 |
$FQDN = "https://ews.netgate.com/pfupdate";
|
1540 |
1519 |
$refreshinterval = (24 * 3600); // 24 hours
|
1541 |
1520 |
$idfile = "/var/db/uniqueid";
|
... | ... | |
1549 |
1528 |
* migration to another update repository should the existing one become
|
1550 |
1529 |
* unavailable
|
1551 |
1530 |
*/
|
1552 |
|
function update_repos() {
|
|
1531 |
function update_custom_repos() {
|
1553 |
1532 |
global $g, $cafile, $cafilesrc, $idfile, $FQDN;
|
1554 |
1533 |
|
1555 |
1534 |
if (!file_exists($idfile) || !function_exists('curl_version')) {
|
Add the dynamic repos support.
Load the repository settings dynamically from Netgate, allowing for more
flexibility and direct support to update for the Plus repositories.
(cherry picked from commit 654dc4ac4544b16c76d56cf90ece112c13149d5b)