Commit 7bef5c47 authored by Vitaly Lipatov's avatar Vitaly Lipatov

epm-check_updated_repo: add support for LISTS from apt-config (see ALT bug 46987)

parent 3057e5e2
...@@ -17,18 +17,30 @@ ...@@ -17,18 +17,30 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>. # along with this program. If not, see <http://www.gnu.org/licenses/>.
# #
__epm_apt_set_lists_pkg()
{
# apt-dpkg
pkg="Packages"
LISTS='/var/lib/apt/lists'
if [ "$BASEDISTRNAME" = "alt" ] ; then
pkg="pkglist"
# see update-kernel: Use Dir::State::lists for apt update freshness check (ALT bug 46987)
eval "$(apt-config shell LISTS Dir::State::lists/f)"
fi
}
# initially copied from update-kernel # initially copied from update-kernel
# print number of days and error status if number of days more than 0 # print number of days and error status if number of days more than 0
__epm_check_apt_db_days() __epm_check_apt_db_days()
{ {
# apt-dpkg local pkg
local pkg="Packages"
[ "$BASEDISTRNAME" = "alt" ] && pkg="pkglist"
local pkglists local pkglists
pkglists=$(find /var/lib/apt/lists -name "*_$pkg*" -ctime +1 2>/dev/null) __epm_apt_set_lists_pkg
pkglists=$(find $LISTS -name "*_$pkg*" -ctime +1 2>/dev/null)
if [ -z "$pkglists" ] ; then if [ -z "$pkglists" ] ; then
# note: duplicate __is_repo_info_downloaded # note: duplicate __is_repo_info_downloaded
pkglists=$(find /var/lib/apt/lists -name "*_$pkg*" 2>/dev/null) pkglists=$(find $LISTS -name "*_$pkg*" 2>/dev/null)
[ -n "$pkglists" ] && return [ -n "$pkglists" ] && return
echo "never downloaded" echo "never downloaded"
return 1 return 1
...@@ -38,7 +50,7 @@ __epm_check_apt_db_days() ...@@ -38,7 +50,7 @@ __epm_check_apt_db_days()
local ts=0 local ts=0
# set ts to newest file ctime # set ts to newest file ctime
# shellcheck disable=SC2044 # shellcheck disable=SC2044
for i in $(find /var/lib/apt/lists/ -name "*_$pkg*" 2>/dev/null); do for i in $(find $LISTS -name "*_$pkg*" 2>/dev/null); do
t=$(stat -c%Z "$i") t=$(stat -c%Z "$i")
[ "$t" -gt "$ts" ] && ts=$t [ "$t" -gt "$ts" ] && ts=$t
done done
...@@ -59,11 +71,10 @@ __epm_check_apt_db_days() ...@@ -59,11 +71,10 @@ __epm_check_apt_db_days()
__epm_touch_apt_pkg() __epm_touch_apt_pkg()
{ {
# apt-dpkg local pkg
local pkg="Packages" __epm_apt_set_lists_pkg
[ "$BASEDISTRNAME" = "alt" ] && pkg="pkglist"
# ordinal package file have date of latest upstream change, not latest update, so update fake file # ordinal package file have date of latest upstream change, not latest update, so update fake file
sudorun touch "/var/lib/apt/lists/eepm-fake_$pkg" sudorun touch "$LISTS/eepm-fake_$pkg"
} }
__epm_touch_pkg() __epm_touch_pkg()
...@@ -80,11 +91,10 @@ __is_repo_info_downloaded() ...@@ -80,11 +91,10 @@ __is_repo_info_downloaded()
{ {
case $PMTYPE in case $PMTYPE in
apt-*) apt-*)
# apt-dpkg local pkg
local pkg="Packages" __epm_apt_set_lists_pkg
[ "$BASEDISTRNAME" = "alt" ] && pkg="pkglist"
local pkglists local pkglists
pkglists=$(find /var/lib/apt/lists -name "*_$pkg*" 2>/dev/null) pkglists=$(find $LIST -name "*_$pkg*" 2>/dev/null)
[ -n "$pkglists" ] || return 1 [ -n "$pkglists" ] || return 1
;; ;;
*) *)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment