#!/bin/sh # # Copyright (C) 2014, 2015 Etersoft # Copyright (C) 2014, 2015 Vitaly Lipatov <lav@etersoft.ru> # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. # __is_repo_info_downloaded() { case $PMTYPE in apt-*) if [ -r /var/cache/apt ] ; then $SUDO test -r /var/cache/apt/pkgcache.bin || return fi ;; *) ;; esac return 0 } __is_repo_info_uptodate() { case $PMTYPE in apt-rpm) # apt-deb do not update lock file date if $SUDO test -r /var/lib/apt/lists ; then local LOCKFILE=/var/lib/apt/lists/lock $SUDO test -r $LOCKFILE || return # if repo older than 1 day, return false # find print string if file is obsoleted test -z "$($SUDO find $LOCKFILE -mtime +1)" || return fi ;; *) ;; esac return 0 } update_repo_if_needed() { # check if we need skip update checking if [ "$1" = "soft" ] && [ -n "$SUDO" ] ; then # if sudo requires a password, skip autoupdate sudo -n true 2>/dev/null || { info "sudo requires a password, skip repo status checking" ; return 0 ; } fi cd / if ! __is_repo_info_downloaded || ! __is_repo_info_uptodate ; then load_helper epm-update pkg_filenames= epm_update fi cd - >/dev/null }