Compare commits

..
39 changed files with 248 additions and 717 deletions

4
HASH
View file

@ -1,4 +1,4 @@
suse-tumbleweed/x86_64: 0f11ee4501fcdbb1e99e1b03c1ec2eaa
suse-tumbleweed/x86_64: 61628efd05405aa6e6498468b3df7538
suse-tumbleweed/i586: 86ea923ca3861900dd03d4b1da44f8b6
debian-10/amd64: 47167eb2d7fe2d845a1b12e0702a6e9b
suse-42.3/x86_64: bd0e29fda82e38c89d2ed6f11797ce3a
@ -7,4 +7,4 @@ debian-8/amd64: b16e55fee0967a75aa67a4d859f0455d
ubuntu-18.04/amd64: 190b5c45953399fd93354db0621d6f5f
debian-10/armhf: 5d92c234d483deaf44c80cad168a8d5d
debian-2025.4/amd64: 977965179baa6fd24d0975a05d583eb6
kali-rolling/amd64: 9520b93fa4bdb6af3e75a78dd605b5a8
kali-rolling/amd64: 61628efd05405aa6e6498468b3df7538

10
RELEASES Normal file
View file

@ -0,0 +1,10 @@
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

View file

@ -1 +1 @@
1.0.0-294-dev
1.0.0-289-dev

View file

@ -37,7 +37,6 @@ build = realpath
[pkg.requires.suse]
run = python3
release = rpmbuild, python3-base
lint = python3-ruff, python3-pyright
[pkg.requires.debian]
run = python3

View file

@ -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)
git-pull-all: $(SSH_WRAPPER_SH)
$(PGIT_SH) pull $(PGIT_SH_OPTS_NETWORK) --all --tags
$(PGIT_SH) pull $(PGIT_SH_OPTS_NETWORK) --all
git-get-maintainer: $(SSH_WRAPPER_SH)
PGIT_SH_PROJECTS="$(PROJECTS_WITH_PROJECT_CONF)" $(PGIT_SH) exec make $@

View file

@ -119,7 +119,7 @@ love:
@echo "Not war?"
cvsupdate update:
if [ -d "CVS" ]; then cvs update -dP || exit 1; else git pull --tags && git submodule update --init --recursive || exit 1; fi
if [ -d "CVS" ]; then cvs update -dP || exit 1; else git pull && git submodule update --init --recursive || exit 1; fi
cvsdiff diff:
if [ -d "CVS" ]; then cvs diff -u || exit 1; else git --no-pager diff --relative --no-prefix . || exit 1; fi

View file

@ -280,7 +280,7 @@ git-get-maintainer:
git-get-pub:
set -e; if git remote | grep -q "^pub$$"; then \
git fetch --prune --tags --recurse-submodules=on-demand pub master ;\
git fetch --prune --recurse-submodules=on-demand pub master ;\
git submodule foreach --recursive 'git fetch --tags -f pub' ;\
git rebase --autostash 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-install-testbuild-deps:
$(PKG_MANAGER) install $(shell $(proj_query_cmd) pkg-requires --quote --hide-self --syntax names-only --delimiter " " "lint,build,run,devel,release" $(PROJECT))
$(PKG_MANAGER) install $(shell $(proj_query_cmd) pkg-requires --quote --hide-self --syntax names-only --delimiter " " "build,run,devel,release" $(PROJECT))
recache-vars:
rm -f $(TOPDIR)/make clean-cache cache

View file

@ -263,7 +263,7 @@ cmd_get()
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
}
run_git -C $project_dir fetch --prune --tags --recurse-submodules=on-demand $remote_name $from_ref
run_git -C $project_dir fetch --prune --recurse-submodules=on-demand $remote_name $from_ref
run_git -C $project_dir submodule foreach --recursive 'git fetch --tags -f origin'
if [ "$to_ref" ]; then
run_git -C $project_dir rebase --autostash $remote_name/$from_ref $to_ref

View file

@ -85,13 +85,6 @@ write_map()
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()
{
local p
@ -130,7 +123,7 @@ check_scm()
{
if [ -d .git ]; then
log + checking git
git pull --no-edit --tags || fatal "git pull failed, giving up"
git pull --no-edit || fatal "git pull failed, giving up"
git submodule update --init --recursive || fatal "git submodule update failed, giving up"
git status --porcelain | grep -v '^??' | grep -q . && {
git status
@ -184,6 +177,12 @@ increase_build_no()
check_next_version()
{
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`
[ -n "$h" ] || fatal "failed to calculate source hash"
if [ ! -f $TOPDIR/HASH ]; then
@ -191,19 +190,12 @@ check_next_version()
echo $v
return
fi
if ! grep -q $h $TOPDIR/HASH; then
if ! read_map $TOPDIR/HASH | grep -q $h; then
echo "+ $PKG_PROJECT has no matching HASH value, needs release" >&2
increase_build_no $v
return
fi
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
echo "version $v is uninstallable, needs release" >&2
increase_build_no $v
@ -282,8 +274,8 @@ check_release_is_current()
done
shift
if ! release_tags | grep -qF "v$next@"; then
echo "next version $next is not released on `platform`, needs release" >&2
if ! read_map -n $TOPDIR/RELEASES | grep -Fq $next; then
echo "next version $next is not in RELEASES, needs release" >&2
return 1
fi
@ -301,7 +293,7 @@ check_release_is_current()
check_update_version()
{
local comment="Release"
local comment="Start version"
set -- `getopt 'c:' "$@"`
while [ "$1" != -- ] ; do
case "$1" in
@ -319,19 +311,8 @@ check_update_version()
local next=`check_next_version`
[ "$next" ] || fatal "Failed to get next version."
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
write_map $TOPDIR/HASH $h
$SCM add $TOPDIR/HASH || true
scm_commit -m "$comment $next" $files
scm_commit -m "$comment: $next" VERSION
return 0
fi
return 1
@ -392,7 +373,6 @@ cmd_version()
case $cmd in
read)
[ -f "$file" ] || return 0
local p=`echo $platform | sed 's%/%\\\/%g'`
local v=`sed "/$p:/ !d; s/$p: *//" $file`
[ "$v" ] && {
@ -629,6 +609,8 @@ upload_pkg()
set -e
local p
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
rpm)
server=pkg.janware.com
@ -675,12 +657,17 @@ upload_pkg()
;;
esac
write_map $TOPDIR/RELEASES $v
$SCM add $TOPDIR/RELEASES || true
write_map $TOPDIR/HASH $h
$SCM add $TOPDIR/HASH || true
echo "+ scheduling rebuild"
$SSH -l root $server /opt/packager-server/bin/packager-server schedule-rebuild
local tag="v$v@`platform`"
git tag -m "Release $v@`platform`" "$tag" || fatal "Failed to tag the release as $tag"
# Don't use extra options, they might contain -l
JW_PKG_SSH_EXTRA_OPTS="" git push origin HEAD "$tag" || fatal "Failed to push the release commit and tag $tag"
scm_commit -m "Release $v@`platform`" $TOPDIR/RELEASES $TOPDIR/HASH
if [ "$SCM" = git ]; then
# 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"
fi
}
install_exe_wrapper()
@ -1310,7 +1297,7 @@ build)
cmd_build "$@"
;;
release-reinstall)
check_update_version
check_update_version -c "Start version"
cmd_build "$@"
cmd_upload
;;

View file

@ -116,7 +116,6 @@ for vcs in $vcss; do
for p in $local_git_proj; do
[ -L $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
check_scm $p
echo done checking scm

View file

@ -21,4 +21,4 @@ class CmdLs(NamedPkgsCmd): # export
@override
async def _run(self, args: Namespace) -> None:
for name in args.names:
print('\n'.join(await self.distro.pkg_paths(name)))
print('\n'.join(await self.distro.pkg_files(name)))

View file

@ -71,7 +71,7 @@ class BaseCmdPkgRelations(Cmd):
)
parser.add_argument(
'flavours',
help = 'Dependency flavours (lint, run, build, devel, release), '
help = 'Dependency flavours (run, build, devel, release), '
'separated by comma or whitespace'
)
parser.add_argument('modules', nargs = '*', help = 'Modules')

View file

@ -33,12 +33,11 @@ class DistroContext(FilesContext):
self.__distro = distro
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] = []
for path in await self.__distro.pkg_paths(list(pkg_names)):
if re.match(pattern, path):
ret.append(path)
for pkg_name in pkg_names:
for path in await self.__distro.pkg_files(pkg_name):
if re.match(pattern, path):
ret.append(path)
return ret
async def list_template_files(self, pkg_names: Collection[str]) -> list[str]:
@ -90,25 +89,20 @@ class DistroContext(FilesContext):
ret: list[str] = []
failed: list[str] = []
missing = 0
# -- Keep the exec context and the store open across the whole
# compile, so the run() calls in the per-target operations
# bump the reference counter instead of opening and closing
# the connection for every remote command.
async with self.ctx, self.store:
targets = await self.list_compilation_targets(pkg_names)
for target in targets:
try:
ok = await self.compile_template_file(target, default_attrs)
except Exception as e:
if not keep_going:
raise
log(ERR, f'{target}: {e}')
failed.append(target)
continue
if ok:
ret.append(target)
else:
missing += 1
targets = await self.list_compilation_targets(pkg_names)
for target in targets:
try:
ok = await self.compile_template_file(target, default_attrs)
except Exception as e:
if not keep_going:
raise
log(ERR, f'{target}: {e}')
failed.append(target)
continue
if ok:
ret.append(target)
else:
missing += 1
if missing > 0:
from ....lib.util import pretty_cmd

View file

@ -10,8 +10,6 @@ from typing import TYPE_CHECKING, Any
from .base import InputMode
from .log import ERR, INFO, WARNING, log
from .PathFilter import Verdict
from .pf.Pkg import PackageFilter
if TYPE_CHECKING:
from collections.abc import Collection
@ -22,6 +20,7 @@ if TYPE_CHECKING:
from .FlaggedFile import FlaggedFile
from .Package import Package
from .PathFilter import PathFilter
from .pf.Pkg import PackageFilter
class Distro(abc.ABC):
@ -505,13 +504,13 @@ class Distro(abc.ABC):
return
return await self._delete(names)
# -- pkg_paths
# -- pkg_files
@abc.abstractmethod
async def _pkg_paths(self, names: list[str] | None) -> Iterable[str]:
async def _pkg_files(self, names: list[str] | None) -> Iterable[str]:
pass
async def pkg_paths(self, names: str | list[str] | None = None) -> Iterable[str]:
async def pkg_files(self, names: str | list[str] | None = None) -> Iterable[str]:
# -- The file paths of the packages selected by the
# argument: None, the default selection, filtered to the
# app's packages when a filter is set, all installed
@ -520,49 +519,9 @@ class Distro(abc.ABC):
# compatibility with the single-package call
if isinstance(names, str):
names = [names]
elif names is None and self.default_path_filter is not None:
if names is None and self.default_path_filter is not None:
names = [p.name for p in await self.select()]
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)
return await self._pkg_files(names)
# -- verify

View file

@ -124,31 +124,29 @@ class FileContext(abc.ABC):
def chroot(self) -> bool:
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
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:
query = self.__uri.query_dict if self.__uri.query_dict else {}
candidate: str | PathFilter | Literal[False] | None = \
query.get('path-filter')
if candidate is None:
candidate = self.__default_path_filter
self.__path_filter = self._create_path_filter(candidate)
self.__path_filter = __create_path_filter(candidate)
return self.__path_filter or None
@path_filter.setter
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.__default_path_filter = value

View file

@ -54,9 +54,7 @@ class PathFilter(abc.ABC):
f'Unsupported filter spec "{spec}": expected a "name:spec" '
'form, where the name picks the filter class'
)
from .util import kebab_to_pascal
class_name = kebab_to_pascal(name)
class_name = name.capitalize()
module_name = 'jw.pkg.lib.pf.' + class_name
filter_classes: LoadTypes[PathFilter] = LoadTypes(
[module_name],

View file

@ -67,7 +67,7 @@ class Distro(Base):
)
@override
async def _pkg_paths(self, names: list[str] | None) -> Iterable[str]:
async def _pkg_files(self, names: list[str] | None) -> Iterable[str]:
raise NotImplementedError(
'distro pkg ls yet implemented for Arch-like distributions'
)

View file

@ -156,7 +156,7 @@ class Distro(Base):
await self.dpkg(['-P', *names], sudo = True)
@override
async def _pkg_paths(self, names: list[str] | None) -> Iterable[str]:
async def _pkg_files(self, names: list[str] | None) -> Iterable[str]:
return await list_files(names, ec = self.ctx)
@override

View file

@ -88,7 +88,7 @@ class Distro(Base):
await self.rpm(['-e', *names], sudo = True)
@override
async def _pkg_paths(self, names: list[str] | None) -> Iterable[str]:
async def _pkg_files(self, names: list[str] | None) -> Iterable[str]:
return await list_files(names, ec = self.ctx)
@override

View file

@ -107,7 +107,7 @@ class Distro(Base):
await self.rpm(['-e', *names], sudo = True)
@override
async def _pkg_paths(self, names: list[str] | None) -> Iterable[str]:
async def _pkg_files(self, names: list[str] | None) -> Iterable[str]:
return await list_files(names, ec = self.ctx)
@override

Some files were not shown because too many files have changed in this diff Show more