Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
E
eepm
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
etersoft
eepm
Commits
4efa0c62
Commit
4efa0c62
authored
May 10, 2023
by
Vitaly Lipatov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
epm repo status: implement for apt
parent
d6927148
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
85 additions
and
20 deletions
+85
-20
epm-check_updated_repo
bin/epm-check_updated_repo
+54
-19
epm-install
bin/epm-install
+1
-1
epm-kernel_update
bin/epm-kernel_update
+2
-0
epm-repo
bin/epm-repo
+4
-0
epm-reposave
bin/epm-reposave
+24
-0
No files found.
bin/epm-check_updated_repo
View file @
4efa0c62
#!/bin/sh
#
# Copyright (C) 2014, 2015 Etersoft
# Copyright (C) 2014, 2015 Vitaly Lipatov <lav@etersoft.ru>
# Copyright (C) 2014, 2015
, 2023
Etersoft
# Copyright (C) 2014, 2015
, 2023
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
...
...
@@ -17,13 +17,50 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
# initially copied from update-kernel
# print number of days and error status if number of days more than 0
__epm_check_apt_db_days
()
{
# apt-dpkg
local
pkg
=
"Packages"
[
"
$BASEDISTRNAME
"
=
"alt"
]
&&
pkg
=
"pkglist"
local
pkglists
pkglists
=
$(
find /var/lib/apt/lists
-name
"*_
$pkg
*"
-ctime
+1 2>/dev/null
)
[
-z
"
$pkglists
"
]
&&
return
local
i t
local
ts
=
0
# set ts to newest file ctime
# shellcheck disable=SC2044
for
i
in
$(
find /var/lib/apt/lists/
-name
"*_
$pkg
*"
2>/dev/null
)
;
do
t
=
$(
stat
-c
%Z
"
$i
"
)
[
"
$t
"
-gt
"
$ts
"
]
&&
ts
=
$t
done
if
[
"
$ts
"
-gt
0
]
;
then
# shellcheck disable=SC2017
local
now
=
$(
date
+%s
)
local
days
=
"
$((
(
now
-
ts
)
/
(
60
*
60
*
24
)
))
"
[
"
$days
"
=
"0"
]
&&
return
0
[
"
$days
"
=
"1"
]
&&
echo
"1 day old"
&&
return
1
echo
"
$days
days old"
else
# no any pkglist
echo
"stalled"
fi
return
1
}
# check if we need initial update
__is_repo_info_downloaded
()
{
case
$PMTYPE
in
apt-
*
)
#if [ -r /var/cache/apt ] ; then
# sudorun test -r /var/cache/apt/pkgcache.bin || return
#fi
# apt-dpkg
local
pkg
=
"Packages"
[
"
$BASEDISTRNAME
"
=
"alt"
]
&&
pkg
=
"pkglist"
local
pkglists
pkglists
=
$(
find /var/lib/apt/lists
-name
"*_
$pkg
*"
2>/dev/null
)
[
-n
"
$pkglists
"
]
||
return
1
;;
*
)
;;
...
...
@@ -35,14 +72,7 @@ __is_repo_info_uptodate()
{
case
$PMTYPE
in
apt-
*
)
# apt-deb do not update lock file date
#if $SUDO test -r /var/lib/apt/lists ; then
local
LOCKFILE
=
/var/lib/apt/lists
sudorun
test
-r
$LOCKFILE
||
return
# if repo older than 1 day, return false
# find print string if file is obsoleted
test
-z
"
$(
find
$LOCKFILE
-maxdepth
0
-mtime
+1
)
"
||
return
#fi
__epm_check_apt_db_days
>
/dev/null
;;
*
)
;;
...
...
@@ -52,14 +82,19 @@ __is_repo_info_uptodate()
update_repo_if_needed
()
{
# TODO: needs careful testing
local
days
days
=
"
$(
__epm_check_apt_db_days
)
"
&&
return
warning
"APT database is
$days
, please run 'epm update'!"
# TODO: enable __is_repo_info_downloaded
return
# check if we need skip update checking
if
[
"
$1
"
=
"soft"
]
&&
!
set_sudo nofail
;
then
# if sudo requires a password, skip autoupdate
info
"can't use sudo, so skip repo status checking"
return
1
fi
#
if [ "$1" = "soft" ] && ! set_sudo nofail ; then
#
# if sudo requires a password, skip autoupdate
#
info "can't use sudo, so skip repo status checking"
#
return 1
#
fi
cd
/
||
fatal
if
!
__is_repo_info_downloaded
||
!
__is_repo_info_uptodate
;
then
...
...
bin/epm-install
View file @
4efa0c62
...
...
@@ -475,7 +475,7 @@ epm_install()
return
0
fi
if
[
-
z
"
$fil
es
"
]
&&
[
-z
"
$direct
"
]
;
then
if
[
-
n
"
$nam
es
"
]
&&
[
-z
"
$direct
"
]
;
then
# it is useful for first time running
update_repo_if_needed
fi
...
...
bin/epm-kernel_update
View file @
4efa0c62
...
...
@@ -24,6 +24,8 @@ epm_kernel_update()
{
warmup_bases
update_repo_if_needed
info
"Updating system kernel to the latest version..."
case
$BASEDISTRNAME
in
...
...
bin/epm-repo
View file @
4efa0c62
...
...
@@ -88,6 +88,10 @@ epm_repo()
load_helper epm-reposave
epm_reporeset
"
$@
"
;;
status
)
load_helper epm-reposave
epm_repostatus
"
$@
"
;;
add
)
# HELPCMD: add package repo (etersoft, autoimports, archive 2017/12/31); run with param to get list
load_helper epm-addrepo
epm_addrepo
"
$@
"
...
...
bin/epm-reposave
View file @
4efa0c62
...
...
@@ -129,3 +129,27 @@ case $PMTYPE in
esac
}
epm_repostatus
()
{
case
$PMTYPE
in
apt-
*
)
load_helper epm-check_updated_repo
if
[
-n
"
$short
"
]
;
then
local
days
days
=
"
$(
__epm_check_apt_db_days
)
"
&&
return
0
echo
"
$days
"
return
1
else
local
days
days
=
"
$(
__epm_check_apt_db_days
)
"
&&
info
"APT database is actual."
&&
return
0
info
"APT database is
$days
."
return
1
fi
;;
*
)
fatal
"Have no suitable command for
$PMTYPE
"
;;
esac
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment