Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
d2b991a28c |
|||
|
2aaed09356 |
|||
|
7cec4007da |
|||
|
65e55a1119 |
|||
|
8b31d7a091 |
|||
|
dd67dbf544 |
|||
|
b47163582d |
|||
|
56d2b445e7 |
|||
|
f717fe2174 |
|||
|
fc79545c30 |
|||
|
2416257cba |
|||
|
48ec9fdb95 |
|||
|
ea751d3949 |
|||
|
dc9ef58c8b |
|||
|
9bf5e07da0 |
|||
|
372356a8df |
|||
|
5ac36ec271 |
|||
|
31e0d1f3a4 |
|||
|
135018b5b6 |
|||
|
ec00ab9b17 |
|||
|
6fe9eeb546 |
|||
|
6a51b9e9a0 |
|||
|
c4769cf79f |
|||
|
d9628937c8 |
|||
|
0c287908ce |
|||
|
8dee1ed41e |
|||
|
623254fcab |
|||
|
a24769a840 |
|||
|
bb1353cfb3 |
|||
|
a968352d16 |
|||
|
1be510e9af |
|||
|
8752440bc0 |
|||
|
1fa738553e |
39 changed files with 717 additions and 248 deletions
4
HASH
4
HASH
|
|
@ -1,4 +1,4 @@
|
||||||
suse-tumbleweed/x86_64: 61628efd05405aa6e6498468b3df7538
|
suse-tumbleweed/x86_64: 0f11ee4501fcdbb1e99e1b03c1ec2eaa
|
||||||
suse-tumbleweed/i586: 86ea923ca3861900dd03d4b1da44f8b6
|
suse-tumbleweed/i586: 86ea923ca3861900dd03d4b1da44f8b6
|
||||||
debian-10/amd64: 47167eb2d7fe2d845a1b12e0702a6e9b
|
debian-10/amd64: 47167eb2d7fe2d845a1b12e0702a6e9b
|
||||||
suse-42.3/x86_64: bd0e29fda82e38c89d2ed6f11797ce3a
|
suse-42.3/x86_64: bd0e29fda82e38c89d2ed6f11797ce3a
|
||||||
|
|
@ -7,4 +7,4 @@ debian-8/amd64: b16e55fee0967a75aa67a4d859f0455d
|
||||||
ubuntu-18.04/amd64: 190b5c45953399fd93354db0621d6f5f
|
ubuntu-18.04/amd64: 190b5c45953399fd93354db0621d6f5f
|
||||||
debian-10/armhf: 5d92c234d483deaf44c80cad168a8d5d
|
debian-10/armhf: 5d92c234d483deaf44c80cad168a8d5d
|
||||||
debian-2025.4/amd64: 977965179baa6fd24d0975a05d583eb6
|
debian-2025.4/amd64: 977965179baa6fd24d0975a05d583eb6
|
||||||
kali-rolling/amd64: 61628efd05405aa6e6498468b3df7538
|
kali-rolling/amd64: 9520b93fa4bdb6af3e75a78dd605b5a8
|
||||||
|
|
|
||||||
10
RELEASES
10
RELEASES
|
|
@ -1,10 +0,0 @@
|
||||||
suse-tumbleweed/x86_64: 1.0.0-289
|
|
||||||
suse-tumbleweed/i586: 1.0.0-44
|
|
||||||
debian-10/amd64: 1.0.0-47
|
|
||||||
suse-42.3/x86_64: 1.0.0-48
|
|
||||||
centos-7/x86_64: 1.0.0-84
|
|
||||||
debian-8/amd64: 1.0.0-84
|
|
||||||
ubuntu-18.04/amd64: 1.0.0-99
|
|
||||||
debian-10/armhf: 1.0.0-102
|
|
||||||
debian-2025.4/amd64: 1.0.0-172
|
|
||||||
kali-rolling/amd64: 1.0.0-289
|
|
||||||
2
VERSION
2
VERSION
|
|
@ -1 +1 @@
|
||||||
1.0.0-289-dev
|
1.0.0-294-dev
|
||||||
|
|
|
||||||
|
|
@ -37,6 +37,7 @@ build = realpath
|
||||||
[pkg.requires.suse]
|
[pkg.requires.suse]
|
||||||
run = python3
|
run = python3
|
||||||
release = rpmbuild, python3-base
|
release = rpmbuild, python3-base
|
||||||
|
lint = python3-ruff, python3-pyright
|
||||||
|
|
||||||
[pkg.requires.debian]
|
[pkg.requires.debian]
|
||||||
run = python3
|
run = python3
|
||||||
|
|
|
||||||
|
|
@ -353,7 +353,7 @@ git-get-mini: $(SSH_WRAPPER_SH)
|
||||||
PGIT_SH_PROJECTS="$(patsubst %/.git,%,$(wildcard $(addsuffix /.git,$(shell make -s build-order))))" $(PGIT_SH_GET_DEFAULT)
|
PGIT_SH_PROJECTS="$(patsubst %/.git,%,$(wildcard $(addsuffix /.git,$(shell make -s build-order))))" $(PGIT_SH_GET_DEFAULT)
|
||||||
|
|
||||||
git-pull-all: $(SSH_WRAPPER_SH)
|
git-pull-all: $(SSH_WRAPPER_SH)
|
||||||
$(PGIT_SH) pull $(PGIT_SH_OPTS_NETWORK) --all
|
$(PGIT_SH) pull $(PGIT_SH_OPTS_NETWORK) --all --tags
|
||||||
|
|
||||||
git-get-maintainer: $(SSH_WRAPPER_SH)
|
git-get-maintainer: $(SSH_WRAPPER_SH)
|
||||||
PGIT_SH_PROJECTS="$(PROJECTS_WITH_PROJECT_CONF)" $(PGIT_SH) exec make $@
|
PGIT_SH_PROJECTS="$(PROJECTS_WITH_PROJECT_CONF)" $(PGIT_SH) exec make $@
|
||||||
|
|
|
||||||
|
|
@ -119,7 +119,7 @@ love:
|
||||||
@echo "Not war?"
|
@echo "Not war?"
|
||||||
|
|
||||||
cvsupdate update:
|
cvsupdate update:
|
||||||
if [ -d "CVS" ]; then cvs update -dP || exit 1; else git pull && git submodule update --init --recursive || exit 1; fi
|
if [ -d "CVS" ]; then cvs update -dP || exit 1; else git pull --tags && git submodule update --init --recursive || exit 1; fi
|
||||||
|
|
||||||
cvsdiff diff:
|
cvsdiff diff:
|
||||||
if [ -d "CVS" ]; then cvs diff -u || exit 1; else git --no-pager diff --relative --no-prefix . || exit 1; fi
|
if [ -d "CVS" ]; then cvs diff -u || exit 1; else git --no-pager diff --relative --no-prefix . || exit 1; fi
|
||||||
|
|
|
||||||
|
|
@ -280,7 +280,7 @@ git-get-maintainer:
|
||||||
|
|
||||||
git-get-pub:
|
git-get-pub:
|
||||||
set -e; if git remote | grep -q "^pub$$"; then \
|
set -e; if git remote | grep -q "^pub$$"; then \
|
||||||
git fetch --prune --recurse-submodules=on-demand pub master ;\
|
git fetch --prune --tags --recurse-submodules=on-demand pub master ;\
|
||||||
git submodule foreach --recursive 'git fetch --tags -f pub' ;\
|
git submodule foreach --recursive 'git fetch --tags -f pub' ;\
|
||||||
git rebase --autostash pub/master ;\
|
git rebase --autostash pub/master ;\
|
||||||
git merge --ff-only pub/master ;\
|
git merge --ff-only pub/master ;\
|
||||||
|
|
@ -303,7 +303,7 @@ pkg-install-release-deps:
|
||||||
$(PKG_MANAGER) install $(shell $(proj_query_cmd) required-os-pkg --quote "build,run,release" $(PROJECT))
|
$(PKG_MANAGER) install $(shell $(proj_query_cmd) required-os-pkg --quote "build,run,release" $(PROJECT))
|
||||||
|
|
||||||
pkg-install-testbuild-deps:
|
pkg-install-testbuild-deps:
|
||||||
$(PKG_MANAGER) install $(shell $(proj_query_cmd) pkg-requires --quote --hide-self --syntax names-only --delimiter " " "build,run,devel,release" $(PROJECT))
|
$(PKG_MANAGER) install $(shell $(proj_query_cmd) pkg-requires --quote --hide-self --syntax names-only --delimiter " " "lint,build,run,devel,release" $(PROJECT))
|
||||||
|
|
||||||
recache-vars:
|
recache-vars:
|
||||||
rm -f $(TOPDIR)/make clean-cache cache
|
rm -f $(TOPDIR)/make clean-cache cache
|
||||||
|
|
|
||||||
|
|
@ -263,7 +263,7 @@ cmd_get()
|
||||||
run_git -C $project_dir remote add $remote_name $pull_url
|
run_git -C $project_dir remote add $remote_name $pull_url
|
||||||
[ "$from_user" = "$remote_user" ] || run_git -C $project_dir remote set-url --push $remote_name no_push
|
[ "$from_user" = "$remote_user" ] || run_git -C $project_dir remote set-url --push $remote_name no_push
|
||||||
}
|
}
|
||||||
run_git -C $project_dir fetch --prune --recurse-submodules=on-demand $remote_name $from_ref
|
run_git -C $project_dir fetch --prune --tags --recurse-submodules=on-demand $remote_name $from_ref
|
||||||
run_git -C $project_dir submodule foreach --recursive 'git fetch --tags -f origin'
|
run_git -C $project_dir submodule foreach --recursive 'git fetch --tags -f origin'
|
||||||
if [ "$to_ref" ]; then
|
if [ "$to_ref" ]; then
|
||||||
run_git -C $project_dir rebase --autostash $remote_name/$from_ref $to_ref
|
run_git -C $project_dir rebase --autostash $remote_name/$from_ref $to_ref
|
||||||
|
|
|
||||||
|
|
@ -85,6 +85,13 @@ write_map()
|
||||||
cmd_version -p `platform` $1 write $2
|
cmd_version -p `platform` $1 write $2
|
||||||
}
|
}
|
||||||
|
|
||||||
|
release_tags()
|
||||||
|
{
|
||||||
|
# a release of a version on a platform is tagged
|
||||||
|
# v<version>@<platform>
|
||||||
|
git tag -l "v*@`platform`"
|
||||||
|
}
|
||||||
|
|
||||||
find_path()
|
find_path()
|
||||||
{
|
{
|
||||||
local p
|
local p
|
||||||
|
|
@ -123,7 +130,7 @@ check_scm()
|
||||||
{
|
{
|
||||||
if [ -d .git ]; then
|
if [ -d .git ]; then
|
||||||
log + checking git
|
log + checking git
|
||||||
git pull --no-edit || fatal "git pull failed, giving up"
|
git pull --no-edit --tags || fatal "git pull failed, giving up"
|
||||||
git submodule update --init --recursive || fatal "git submodule update failed, giving up"
|
git submodule update --init --recursive || fatal "git submodule update failed, giving up"
|
||||||
git status --porcelain | grep -v '^??' | grep -q . && {
|
git status --porcelain | grep -v '^??' | grep -q . && {
|
||||||
git status
|
git status
|
||||||
|
|
@ -177,12 +184,6 @@ increase_build_no()
|
||||||
check_next_version()
|
check_next_version()
|
||||||
{
|
{
|
||||||
local v=`read_map $TOPDIR/VERSION | sed 's/-dev//'`
|
local v=`read_map $TOPDIR/VERSION | sed 's/-dev//'`
|
||||||
local n=`read_map -n $TOPDIR/RELEASES | sed 's/-dev//'`
|
|
||||||
if [ "$n" != "$v" ]; then
|
|
||||||
echo "+ $PKG_PROJECT version is already at $v, no need to increase for release" >&2
|
|
||||||
echo $v
|
|
||||||
return
|
|
||||||
fi
|
|
||||||
local h=`calculate_hash`
|
local h=`calculate_hash`
|
||||||
[ -n "$h" ] || fatal "failed to calculate source hash"
|
[ -n "$h" ] || fatal "failed to calculate source hash"
|
||||||
if [ ! -f $TOPDIR/HASH ]; then
|
if [ ! -f $TOPDIR/HASH ]; then
|
||||||
|
|
@ -190,12 +191,19 @@ check_next_version()
|
||||||
echo $v
|
echo $v
|
||||||
return
|
return
|
||||||
fi
|
fi
|
||||||
if ! read_map $TOPDIR/HASH | grep -q $h; then
|
if ! grep -q $h $TOPDIR/HASH; then
|
||||||
echo "+ $PKG_PROJECT has no matching HASH value, needs release" >&2
|
echo "+ $PKG_PROJECT has no matching HASH value, needs release" >&2
|
||||||
increase_build_no $v
|
increase_build_no $v
|
||||||
return
|
return
|
||||||
fi
|
fi
|
||||||
echo "+ $PKG_PROJECT has unchanged source" >&2
|
echo "+ $PKG_PROJECT has unchanged source" >&2
|
||||||
|
if ! release_tags | grep -qF "v$v@"; then
|
||||||
|
# the release commit allocated $v and recorded the source hash; a missing tag means
|
||||||
|
# this platform has not released it yet, so release $v as is
|
||||||
|
echo "+ $PKG_PROJECT has no release tag for $v on `platform`, needs release" >&2
|
||||||
|
echo $v
|
||||||
|
return
|
||||||
|
fi
|
||||||
if [ "$reinstall_check_failed" = 1 ]; then
|
if [ "$reinstall_check_failed" = 1 ]; then
|
||||||
echo "version $v is uninstallable, needs release" >&2
|
echo "version $v is uninstallable, needs release" >&2
|
||||||
increase_build_no $v
|
increase_build_no $v
|
||||||
|
|
@ -274,8 +282,8 @@ check_release_is_current()
|
||||||
done
|
done
|
||||||
shift
|
shift
|
||||||
|
|
||||||
if ! read_map -n $TOPDIR/RELEASES | grep -Fq $next; then
|
if ! release_tags | grep -qF "v$next@"; then
|
||||||
echo "next version $next is not in RELEASES, needs release" >&2
|
echo "next version $next is not released on `platform`, needs release" >&2
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
@ -293,7 +301,7 @@ check_release_is_current()
|
||||||
|
|
||||||
check_update_version()
|
check_update_version()
|
||||||
{
|
{
|
||||||
local comment="Start version"
|
local comment="Release"
|
||||||
set -- `getopt 'c:' "$@"`
|
set -- `getopt 'c:' "$@"`
|
||||||
while [ "$1" != -- ] ; do
|
while [ "$1" != -- ] ; do
|
||||||
case "$1" in
|
case "$1" in
|
||||||
|
|
@ -311,8 +319,19 @@ check_update_version()
|
||||||
local next=`check_next_version`
|
local next=`check_next_version`
|
||||||
[ "$next" ] || fatal "Failed to get next version."
|
[ "$next" ] || fatal "Failed to get next version."
|
||||||
if [ "$next" != "$v" ]; then
|
if [ "$next" != "$v" ]; then
|
||||||
|
local h=`calculate_hash`
|
||||||
|
[ -n "$h" ] || fatal "failed to calculate source hash"
|
||||||
|
local files="VERSION $TOPDIR/HASH"
|
||||||
|
# the release tags replace the RELEASES file; the
|
||||||
|
# release commit drops it from the tree
|
||||||
|
if [ "$SCM" = git ] && [ -f $TOPDIR/RELEASES ] && \
|
||||||
|
git rm -qf $TOPDIR/RELEASES 2>/dev/null; then
|
||||||
|
files="$files $TOPDIR/RELEASES"
|
||||||
|
fi
|
||||||
echo "$next-dev" > VERSION
|
echo "$next-dev" > VERSION
|
||||||
scm_commit -m "$comment: $next" VERSION
|
write_map $TOPDIR/HASH $h
|
||||||
|
$SCM add $TOPDIR/HASH || true
|
||||||
|
scm_commit -m "$comment $next" $files
|
||||||
return 0
|
return 0
|
||||||
fi
|
fi
|
||||||
return 1
|
return 1
|
||||||
|
|
@ -373,6 +392,7 @@ cmd_version()
|
||||||
|
|
||||||
case $cmd in
|
case $cmd in
|
||||||
read)
|
read)
|
||||||
|
[ -f "$file" ] || return 0
|
||||||
local p=`echo $platform | sed 's%/%\\\/%g'`
|
local p=`echo $platform | sed 's%/%\\\/%g'`
|
||||||
local v=`sed "/$p:/ !d; s/$p: *//" $file`
|
local v=`sed "/$p:/ !d; s/$p: *//" $file`
|
||||||
[ "$v" ] && {
|
[ "$v" ] && {
|
||||||
|
|
@ -609,8 +629,6 @@ upload_pkg()
|
||||||
set -e
|
set -e
|
||||||
local p
|
local p
|
||||||
local v=`read_map $TOPDIR/VERSION | sed 's/-dev//'`
|
local v=`read_map $TOPDIR/VERSION | sed 's/-dev//'`
|
||||||
local h=`calculate_hash`
|
|
||||||
[ -n "$h" ] || fatal "failed to calculate source hash"
|
|
||||||
case $PKG_FORMAT in
|
case $PKG_FORMAT in
|
||||||
rpm)
|
rpm)
|
||||||
server=pkg.janware.com
|
server=pkg.janware.com
|
||||||
|
|
@ -657,17 +675,12 @@ upload_pkg()
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
write_map $TOPDIR/RELEASES $v
|
|
||||||
$SCM add $TOPDIR/RELEASES || true
|
|
||||||
write_map $TOPDIR/HASH $h
|
|
||||||
$SCM add $TOPDIR/HASH || true
|
|
||||||
echo "+ scheduling rebuild"
|
echo "+ scheduling rebuild"
|
||||||
$SSH -l root $server /opt/packager-server/bin/packager-server schedule-rebuild
|
$SSH -l root $server /opt/packager-server/bin/packager-server schedule-rebuild
|
||||||
scm_commit -m "Release $v@`platform`" $TOPDIR/RELEASES $TOPDIR/HASH
|
local tag="v$v@`platform`"
|
||||||
if [ "$SCM" = git ]; then
|
git tag -m "Release $v@`platform`" "$tag" || fatal "Failed to tag the release as $tag"
|
||||||
# Don't use extra options, they might contain -l
|
# Don't use extra options, they might contain -l
|
||||||
JW_PKG_SSH_EXTRA_OPTS="" git push || fatal "Failed to push changes to RELEASES and HASH"
|
JW_PKG_SSH_EXTRA_OPTS="" git push origin HEAD "$tag" || fatal "Failed to push the release commit and tag $tag"
|
||||||
fi
|
|
||||||
}
|
}
|
||||||
|
|
||||||
install_exe_wrapper()
|
install_exe_wrapper()
|
||||||
|
|
@ -1297,7 +1310,7 @@ build)
|
||||||
cmd_build "$@"
|
cmd_build "$@"
|
||||||
;;
|
;;
|
||||||
release-reinstall)
|
release-reinstall)
|
||||||
check_update_version -c "Start version"
|
check_update_version
|
||||||
cmd_build "$@"
|
cmd_build "$@"
|
||||||
cmd_upload
|
cmd_upload
|
||||||
;;
|
;;
|
||||||
|
|
|
||||||
|
|
@ -116,6 +116,7 @@ for vcs in $vcss; do
|
||||||
for p in $local_git_proj; do
|
for p in $local_git_proj; do
|
||||||
[ -L $p ] && continue
|
[ -L $p ] && continue
|
||||||
[ -d $p ] || continue
|
[ -d $p ] || continue
|
||||||
|
git -C $p remote | grep -q . || { log "leaving \"$p\" alone, it has no remote"; continue; }
|
||||||
echo $remote_git_proj | grep -q "\(^\| \)$p\($\| \)" && continue
|
echo $remote_git_proj | grep -q "\(^\| \)$p\($\| \)" && continue
|
||||||
check_scm $p
|
check_scm $p
|
||||||
echo done checking scm
|
echo done checking scm
|
||||||
|
|
|
||||||
|
|
@ -21,4 +21,4 @@ class CmdLs(NamedPkgsCmd): # export
|
||||||
@override
|
@override
|
||||||
async def _run(self, args: Namespace) -> None:
|
async def _run(self, args: Namespace) -> None:
|
||||||
for name in args.names:
|
for name in args.names:
|
||||||
print('\n'.join(await self.distro.pkg_files(name)))
|
print('\n'.join(await self.distro.pkg_paths(name)))
|
||||||
|
|
|
||||||
|
|
@ -71,7 +71,7 @@ class BaseCmdPkgRelations(Cmd):
|
||||||
)
|
)
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
'flavours',
|
'flavours',
|
||||||
help = 'Dependency flavours (run, build, devel, release), '
|
help = 'Dependency flavours (lint, run, build, devel, release), '
|
||||||
'separated by comma or whitespace'
|
'separated by comma or whitespace'
|
||||||
)
|
)
|
||||||
parser.add_argument('modules', nargs = '*', help = 'Modules')
|
parser.add_argument('modules', nargs = '*', help = 'Modules')
|
||||||
|
|
|
||||||
|
|
@ -33,11 +33,12 @@ class DistroContext(FilesContext):
|
||||||
self.__distro = distro
|
self.__distro = distro
|
||||||
|
|
||||||
async def match_files(self, pkg_names: Collection[str], pattern: str) -> list[str]:
|
async def match_files(self, pkg_names: Collection[str], pattern: str) -> list[str]:
|
||||||
|
# -- One query for the whole name list: the distro backends
|
||||||
|
# accept a list and issue a single file-listing command
|
||||||
ret: list[str] = []
|
ret: list[str] = []
|
||||||
for pkg_name in pkg_names:
|
for path in await self.__distro.pkg_paths(list(pkg_names)):
|
||||||
for path in await self.__distro.pkg_files(pkg_name):
|
if re.match(pattern, path):
|
||||||
if re.match(pattern, path):
|
ret.append(path)
|
||||||
ret.append(path)
|
|
||||||
return ret
|
return ret
|
||||||
|
|
||||||
async def list_template_files(self, pkg_names: Collection[str]) -> list[str]:
|
async def list_template_files(self, pkg_names: Collection[str]) -> list[str]:
|
||||||
|
|
@ -89,20 +90,25 @@ class DistroContext(FilesContext):
|
||||||
ret: list[str] = []
|
ret: list[str] = []
|
||||||
failed: list[str] = []
|
failed: list[str] = []
|
||||||
missing = 0
|
missing = 0
|
||||||
targets = await self.list_compilation_targets(pkg_names)
|
# -- Keep the exec context and the store open across the whole
|
||||||
for target in targets:
|
# compile, so the run() calls in the per-target operations
|
||||||
try:
|
# bump the reference counter instead of opening and closing
|
||||||
ok = await self.compile_template_file(target, default_attrs)
|
# the connection for every remote command.
|
||||||
except Exception as e:
|
async with self.ctx, self.store:
|
||||||
if not keep_going:
|
targets = await self.list_compilation_targets(pkg_names)
|
||||||
raise
|
for target in targets:
|
||||||
log(ERR, f'{target}: {e}')
|
try:
|
||||||
failed.append(target)
|
ok = await self.compile_template_file(target, default_attrs)
|
||||||
continue
|
except Exception as e:
|
||||||
if ok:
|
if not keep_going:
|
||||||
ret.append(target)
|
raise
|
||||||
else:
|
log(ERR, f'{target}: {e}')
|
||||||
missing += 1
|
failed.append(target)
|
||||||
|
continue
|
||||||
|
if ok:
|
||||||
|
ret.append(target)
|
||||||
|
else:
|
||||||
|
missing += 1
|
||||||
if missing > 0:
|
if missing > 0:
|
||||||
from ....lib.util import pretty_cmd
|
from ....lib.util import pretty_cmd
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -10,6 +10,8 @@ from typing import TYPE_CHECKING, Any
|
||||||
|
|
||||||
from .base import InputMode
|
from .base import InputMode
|
||||||
from .log import ERR, INFO, WARNING, log
|
from .log import ERR, INFO, WARNING, log
|
||||||
|
from .PathFilter import Verdict
|
||||||
|
from .pf.Pkg import PackageFilter
|
||||||
|
|
||||||
if TYPE_CHECKING:
|
if TYPE_CHECKING:
|
||||||
from collections.abc import Collection
|
from collections.abc import Collection
|
||||||
|
|
@ -20,7 +22,6 @@ if TYPE_CHECKING:
|
||||||
from .FlaggedFile import FlaggedFile
|
from .FlaggedFile import FlaggedFile
|
||||||
from .Package import Package
|
from .Package import Package
|
||||||
from .PathFilter import PathFilter
|
from .PathFilter import PathFilter
|
||||||
from .pf.Pkg import PackageFilter
|
|
||||||
|
|
||||||
class Distro(abc.ABC):
|
class Distro(abc.ABC):
|
||||||
|
|
||||||
|
|
@ -504,13 +505,13 @@ class Distro(abc.ABC):
|
||||||
return
|
return
|
||||||
return await self._delete(names)
|
return await self._delete(names)
|
||||||
|
|
||||||
# -- pkg_files
|
# -- pkg_paths
|
||||||
|
|
||||||
@abc.abstractmethod
|
@abc.abstractmethod
|
||||||
async def _pkg_files(self, names: list[str] | None) -> Iterable[str]:
|
async def _pkg_paths(self, names: list[str] | None) -> Iterable[str]:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
async def pkg_files(self, names: str | list[str] | None = None) -> Iterable[str]:
|
async def pkg_paths(self, names: str | list[str] | None = None) -> Iterable[str]:
|
||||||
# -- The file paths of the packages selected by the
|
# -- The file paths of the packages selected by the
|
||||||
# argument: None, the default selection, filtered to the
|
# argument: None, the default selection, filtered to the
|
||||||
# app's packages when a filter is set, all installed
|
# app's packages when a filter is set, all installed
|
||||||
|
|
@ -519,9 +520,49 @@ class Distro(abc.ABC):
|
||||||
# compatibility with the single-package call
|
# compatibility with the single-package call
|
||||||
if isinstance(names, str):
|
if isinstance(names, str):
|
||||||
names = [names]
|
names = [names]
|
||||||
if names is None and self.default_path_filter is not None:
|
elif names is None and self.default_path_filter is not None:
|
||||||
names = [p.name for p in await self.select()]
|
names = [p.name for p in await self.select()]
|
||||||
return await self._pkg_files(names)
|
return await self._pkg_paths(names)
|
||||||
|
|
||||||
|
# -- paths
|
||||||
|
|
||||||
|
async def _paths(
|
||||||
|
self,
|
||||||
|
filter: PathFilter | None = None,
|
||||||
|
pkg_names: Collection[str] = [],
|
||||||
|
) -> Iterable[str]:
|
||||||
|
if filter and pkg_names and not isinstance(filter, PackageFilter):
|
||||||
|
raise Exception(
|
||||||
|
f'Tried to select files from {self} with non-package-filter {filter} '
|
||||||
|
f'and package list {", ".join(pkg_names)}'
|
||||||
|
)
|
||||||
|
if not filter:
|
||||||
|
filter = self.__default_path_filter
|
||||||
|
# -- pkg_names follows the select() convention: an empty
|
||||||
|
# list selects every package, which is listed in one
|
||||||
|
# whole-system query instead of by name
|
||||||
|
if isinstance(filter, PackageFilter):
|
||||||
|
pkg_names = [p.name for p in await self._select(pkg_names, filter)]
|
||||||
|
ret: list[str] = [
|
||||||
|
path for path in await self.pkg_paths(names = list(pkg_names))
|
||||||
|
]
|
||||||
|
elif pkg_names:
|
||||||
|
pkg_names = [p.name for p in await self._select_by_name(pkg_names)]
|
||||||
|
ret = [path for path in await self.pkg_paths(names = list(pkg_names))]
|
||||||
|
else:
|
||||||
|
# -- _pkg_paths() directly: pkg_paths() would re-resolve
|
||||||
|
# the default filter, which _paths() already did
|
||||||
|
ret = [path for path in await self._pkg_paths(None)]
|
||||||
|
if filter and not isinstance(filter, PackageFilter):
|
||||||
|
ret = [path for path in ret if await filter.run(path) == Verdict.ALLOW]
|
||||||
|
return ret
|
||||||
|
|
||||||
|
async def paths(
|
||||||
|
self,
|
||||||
|
filter: PathFilter | None = None,
|
||||||
|
pkg_names: Collection[str] = [],
|
||||||
|
) -> Iterable[str]:
|
||||||
|
return await self._paths(filter, pkg_names)
|
||||||
|
|
||||||
# -- verify
|
# -- verify
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -124,29 +124,31 @@ class FileContext(abc.ABC):
|
||||||
def chroot(self) -> bool:
|
def chroot(self) -> bool:
|
||||||
return self.__chroot
|
return self.__chroot
|
||||||
|
|
||||||
|
def _create_path_filter(
|
||||||
|
self, candidate: str | PathFilter | Literal[False] | None
|
||||||
|
) -> PathFilter | Literal[False]:
|
||||||
|
if candidate is None or candidate is False:
|
||||||
|
return False
|
||||||
|
if isinstance(candidate, PathFilter):
|
||||||
|
return candidate
|
||||||
|
return PathFilter.create(spec = candidate, file_context = self)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def path_filter(self) -> PathFilter | None:
|
def path_filter(self) -> PathFilter | None:
|
||||||
|
|
||||||
def __create_path_filter(
|
|
||||||
candidate: str | None | PathFilter | Literal[False]
|
|
||||||
) -> PathFilter | Literal[False]:
|
|
||||||
if candidate is None or candidate is False:
|
|
||||||
return False
|
|
||||||
if isinstance(candidate, PathFilter):
|
|
||||||
return candidate
|
|
||||||
return PathFilter.create(spec = candidate, file_context = self)
|
|
||||||
|
|
||||||
if self.__path_filter is None:
|
if self.__path_filter is None:
|
||||||
query = self.__uri.query_dict if self.__uri.query_dict else {}
|
query = self.__uri.query_dict if self.__uri.query_dict else {}
|
||||||
candidate: str | PathFilter | Literal[False] | None = \
|
candidate: str | PathFilter | Literal[False] | None = \
|
||||||
query.get('path-filter')
|
query.get('path-filter')
|
||||||
if candidate is None:
|
if candidate is None:
|
||||||
candidate = self.__default_path_filter
|
candidate = self.__default_path_filter
|
||||||
self.__path_filter = __create_path_filter(candidate)
|
self.__path_filter = self._create_path_filter(candidate)
|
||||||
return self.__path_filter or None
|
return self.__path_filter or None
|
||||||
|
|
||||||
@path_filter.setter
|
@path_filter.setter
|
||||||
def path_filter(self, value: str | PathFilter | None | Literal[False]) -> None:
|
def path_filter(self, value: str | PathFilter | None | Literal[False]) -> None:
|
||||||
|
self._set_path_filter(value)
|
||||||
|
|
||||||
|
def _set_path_filter(self, value: str | PathFilter | None | Literal[False]) -> None:
|
||||||
self.__path_filter = None
|
self.__path_filter = None
|
||||||
self.__default_path_filter = value
|
self.__default_path_filter = value
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -54,7 +54,9 @@ class PathFilter(abc.ABC):
|
||||||
f'Unsupported filter spec "{spec}": expected a "name:spec" '
|
f'Unsupported filter spec "{spec}": expected a "name:spec" '
|
||||||
'form, where the name picks the filter class'
|
'form, where the name picks the filter class'
|
||||||
)
|
)
|
||||||
class_name = name.capitalize()
|
from .util import kebab_to_pascal
|
||||||
|
|
||||||
|
class_name = kebab_to_pascal(name)
|
||||||
module_name = 'jw.pkg.lib.pf.' + class_name
|
module_name = 'jw.pkg.lib.pf.' + class_name
|
||||||
filter_classes: LoadTypes[PathFilter] = LoadTypes(
|
filter_classes: LoadTypes[PathFilter] = LoadTypes(
|
||||||
[module_name],
|
[module_name],
|
||||||
|
|
|
||||||
|
|
@ -67,7 +67,7 @@ class Distro(Base):
|
||||||
)
|
)
|
||||||
|
|
||||||
@override
|
@override
|
||||||
async def _pkg_files(self, names: list[str] | None) -> Iterable[str]:
|
async def _pkg_paths(self, names: list[str] | None) -> Iterable[str]:
|
||||||
raise NotImplementedError(
|
raise NotImplementedError(
|
||||||
'distro pkg ls yet implemented for Arch-like distributions'
|
'distro pkg ls yet implemented for Arch-like distributions'
|
||||||
)
|
)
|
||||||
|
|
|
||||||
|
|
@ -156,7 +156,7 @@ class Distro(Base):
|
||||||
await self.dpkg(['-P', *names], sudo = True)
|
await self.dpkg(['-P', *names], sudo = True)
|
||||||
|
|
||||||
@override
|
@override
|
||||||
async def _pkg_files(self, names: list[str] | None) -> Iterable[str]:
|
async def _pkg_paths(self, names: list[str] | None) -> Iterable[str]:
|
||||||
return await list_files(names, ec = self.ctx)
|
return await list_files(names, ec = self.ctx)
|
||||||
|
|
||||||
@override
|
@override
|
||||||
|
|
|
||||||
|
|
@ -88,7 +88,7 @@ class Distro(Base):
|
||||||
await self.rpm(['-e', *names], sudo = True)
|
await self.rpm(['-e', *names], sudo = True)
|
||||||
|
|
||||||
@override
|
@override
|
||||||
async def _pkg_files(self, names: list[str] | None) -> Iterable[str]:
|
async def _pkg_paths(self, names: list[str] | None) -> Iterable[str]:
|
||||||
return await list_files(names, ec = self.ctx)
|
return await list_files(names, ec = self.ctx)
|
||||||
|
|
||||||
@override
|
@override
|
||||||
|
|
|
||||||
|
|
@ -107,7 +107,7 @@ class Distro(Base):
|
||||||
await self.rpm(['-e', *names], sudo = True)
|
await self.rpm(['-e', *names], sudo = True)
|
||||||
|
|
||||||
@override
|
@override
|
||||||
async def _pkg_files(self, names: list[str] | None) -> Iterable[str]:
|
async def _pkg_paths(self, names: list[str] | None) -> Iterable[str]:
|
||||||
return await list_files(names, ec = self.ctx)
|
return await list_files(names, ec = self.ctx)
|
||||||
|
|
||||||
@override
|
@override
|
||||||
|
|
|
||||||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue