From 6cf87aec745eb5b2f488ed3a4ec24b11a806b613 Mon Sep 17 00:00:00 2001 From: Renato Botelho Date: Thu, 7 Jan 2016 19:14:44 -0200 Subject: 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 --- src/etc/inc/pkg-utils.inc | 48 +++-------------------------------------------- 1 file changed, 3 insertions(+), 45 deletions(-) (limited to 'src/etc') diff --git a/src/etc/inc/pkg-utils.inc b/src/etc/inc/pkg-utils.inc index e118896..55a0395 100644 --- a/src/etc/inc/pkg-utils.inc +++ b/src/etc/inc/pkg-utils.inc @@ -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(); -- cgit v1.1