mirror of
https://github.com/pfsense/pfsense.git
synced 2025-10-26 11:38:35 +00:00
Do not set PKG_AUTOUPDATE=false anymore and let pkg to update metadata when it's necessary. Some users reported to see issues in cases where update was necessary
This commit is contained in:
parent
274351c559
commit
6cf87aec74
@ -96,30 +96,7 @@ function pkg_remove_prefix(&$pkg_name) {
|
||||
function pkg_update($force = false) {
|
||||
global $g;
|
||||
|
||||
$now = strftime('%s');
|
||||
$last_update_file="{$g['varrun_path']}/{$g['product_name']}-upgrade-last-update";
|
||||
if (!$force) {
|
||||
if (file_exists($last_update_file)) {
|
||||
$last_update = rtrim(file_get_contents($last_update_file), "\n");
|
||||
if (!is_numericint($last_update)) {
|
||||
$last_update = 0;
|
||||
}
|
||||
}
|
||||
|
||||
if ($last_update > 0) {
|
||||
if ($now > $last_update && ($now - $last_update) <= (60 * 60)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$rc = pkg_call("update");
|
||||
|
||||
if ($rc) {
|
||||
file_put_contents($last_update_file, $now . "\n");
|
||||
}
|
||||
|
||||
return $rc;
|
||||
return pkg_call("update" . ($force ? " -f" : ""));
|
||||
}
|
||||
|
||||
/* return an array with necessary environment vars for pkg */
|
||||
@ -128,8 +105,7 @@ function pkg_env() {
|
||||
|
||||
$pkg_env_vars = array(
|
||||
"HTTP_USER_AGENT" => $user_agent,
|
||||
"ASSUME_ALWAYS_YES" => "true",
|
||||
"REPO_AUTOUPDATE" => "false"
|
||||
"ASSUME_ALWAYS_YES" => "true"
|
||||
);
|
||||
|
||||
if ($g['platform'] == "nanobsd" ||
|
||||
@ -409,21 +385,7 @@ function get_pkg_info($pkgs = 'all', $info = 'all') {
|
||||
$pkgs = $g['pkg_prefix'];
|
||||
}
|
||||
|
||||
/* Make sure repo metadata is up2date */
|
||||
update_status("\n" .
|
||||
gettext("Updating package repository metadada...") . "\n");
|
||||
|
||||
if (!pkg_update()) {
|
||||
$input_errors[] = gettext(
|
||||
"ERROR: An error occurred when updating packages repository. Aborting...")
|
||||
. "\n";
|
||||
update_status("\n" . gettext(
|
||||
"ERROR: An error occurred when updating packages repository. Aborting...")
|
||||
. "\n");
|
||||
return array();
|
||||
}
|
||||
|
||||
$rc = pkg_exec("search -U --raw-format json-compact " . $pkgs, $out, $err);
|
||||
$rc = pkg_exec("search --raw-format json-compact " . $pkgs, $out, $err);
|
||||
|
||||
if ($rc != 0) {
|
||||
update_status("\n" . gettext(
|
||||
@ -993,10 +955,6 @@ function package_reinstall_all() {
|
||||
sleep(1);
|
||||
}
|
||||
update_status("\n");
|
||||
} else {
|
||||
if (!pkg_update()) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
$pkg_info = get_pkg_info();
|
||||
|
||||
@ -244,25 +244,10 @@ pkg_update() {
|
||||
|
||||
local _force=""
|
||||
if [ "${1}" = "force" ]; then
|
||||
local _force=1
|
||||
_force=" -f"
|
||||
fi
|
||||
|
||||
if [ -z "${_force}" -a -f ${last_update_file} ]; then
|
||||
local _last_update=$(head -n 1 ${last_update_file})
|
||||
# Verify if content contains only numbers
|
||||
if echo "${_last_update}" | grep -E -q '^[0-9]+$'; then
|
||||
local _now=$(date +%s)
|
||||
# Only run update hourly, and if last update is in the future
|
||||
[ ${_now} -gt ${_last_update} -a $((${_now} - ${_last_update})) -le $((60 * 60)) ] \
|
||||
&& unset _run_update
|
||||
fi
|
||||
fi
|
||||
|
||||
[ -z "${_run_update}" ] \
|
||||
&& return 0
|
||||
|
||||
_exec "pkg ${pkg_chroot} update" "Updating repositories" mute
|
||||
date +%s > ${last_update_file}
|
||||
_exec "pkg ${pkg_chroot} update${_force}" "Updating repositories metadata"
|
||||
}
|
||||
|
||||
pkg_upgrade() {
|
||||
@ -609,8 +594,6 @@ pkg_install() {
|
||||
_exit 1
|
||||
fi
|
||||
|
||||
pkg_update
|
||||
|
||||
if is_pkg_installed ${_pkg_name}; then
|
||||
local _cversion=$(compare_pkg_version ${_pkg_name})
|
||||
|
||||
@ -672,16 +655,12 @@ do_reboot() {
|
||||
}
|
||||
|
||||
pid_file="/var/run/$(basename $0).pid"
|
||||
last_update_file="/var/run/$(basename $0)-last-update"
|
||||
logfile="/cf/conf/upgrade_log.txt"
|
||||
stdout='/dev/null'
|
||||
|
||||
# pkg should not ask for confirmations
|
||||
export ASSUME_ALWAYS_YES=true
|
||||
|
||||
# Disable automatic update
|
||||
export REPO_AUTOUPDATE=false
|
||||
|
||||
export product=$(/usr/local/bin/php -n /usr/local/sbin/read_global_var product_name pfSense)
|
||||
export pkg_prefix=$(/usr/local/bin/php -n /usr/local/sbin/read_global_var pkg_prefix pfSense-pkg-)
|
||||
export platform=$(cat /etc/platform)
|
||||
|
||||
Loading…
Reference in New Issue
Block a user