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 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: 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] [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

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) 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 --tags $(PGIT_SH) pull $(PGIT_SH_OPTS_NETWORK) --all
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 $@

View file

@ -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 --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: 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

View file

@ -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 --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 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 " " "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: recache-vars:
rm -f $(TOPDIR)/make clean-cache cache 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 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 --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' 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

View file

@ -85,13 +85,6 @@ 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
@ -130,7 +123,7 @@ check_scm()
{ {
if [ -d .git ]; then if [ -d .git ]; then
log + checking git 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 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
@ -184,6 +177,12 @@ 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
@ -191,19 +190,12 @@ check_next_version()
echo $v echo $v
return return
fi 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 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
@ -282,8 +274,8 @@ check_release_is_current()
done done
shift shift
if ! release_tags | grep -qF "v$next@"; then if ! read_map -n $TOPDIR/RELEASES | grep -Fq $next; then
echo "next version $next is not released on `platform`, needs release" >&2 echo "next version $next is not in RELEASES, needs release" >&2
return 1 return 1
fi fi
@ -301,7 +293,7 @@ check_release_is_current()
check_update_version() check_update_version()
{ {
local comment="Release" local comment="Start version"
set -- `getopt 'c:' "$@"` set -- `getopt 'c:' "$@"`
while [ "$1" != -- ] ; do while [ "$1" != -- ] ; do
case "$1" in case "$1" in
@ -319,19 +311,8 @@ 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
write_map $TOPDIR/HASH $h scm_commit -m "$comment: $next" VERSION
$SCM add $TOPDIR/HASH || true
scm_commit -m "$comment $next" $files
return 0 return 0
fi fi
return 1 return 1
@ -392,7 +373,6 @@ 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" ] && {
@ -629,6 +609,8 @@ 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
@ -675,12 +657,17 @@ 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
local tag="v$v@`platform`" scm_commit -m "Release $v@`platform`" $TOPDIR/RELEASES $TOPDIR/HASH
git tag -m "Release $v@`platform`" "$tag" || fatal "Failed to tag the release as $tag" if [ "$SCM" = git ]; then
# 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 origin HEAD "$tag" || fatal "Failed to push the release commit and tag $tag" JW_PKG_SSH_EXTRA_OPTS="" git push || fatal "Failed to push changes to RELEASES and HASH"
fi
} }
install_exe_wrapper() install_exe_wrapper()
@ -1310,7 +1297,7 @@ build)
cmd_build "$@" cmd_build "$@"
;; ;;
release-reinstall) release-reinstall)
check_update_version check_update_version -c "Start version"
cmd_build "$@" cmd_build "$@"
cmd_upload cmd_upload
;; ;;

View file

@ -116,7 +116,6 @@ 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

View file

@ -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_paths(name))) print('\n'.join(await self.distro.pkg_files(name)))

View file

@ -71,7 +71,7 @@ class BaseCmdPkgRelations(Cmd):
) )
parser.add_argument( parser.add_argument(
'flavours', 'flavours',
help = 'Dependency flavours (lint, run, build, devel, release), ' help = 'Dependency flavours (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')

View file

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

View file

@ -10,8 +10,6 @@ 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
@ -22,6 +20,7 @@ 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):
@ -505,13 +504,13 @@ class Distro(abc.ABC):
return return
return await self._delete(names) return await self._delete(names)
# -- pkg_paths # -- pkg_files
@abc.abstractmethod @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 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 # -- 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
@ -520,49 +519,9 @@ 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]
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()] names = [p.name for p in await self.select()]
return await self._pkg_paths(names) return await self._pkg_files(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

View file

@ -124,31 +124,29 @@ 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 = self._create_path_filter(candidate) self.__path_filter = __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

View file

@ -54,9 +54,7 @@ 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'
) )
from .util import kebab_to_pascal class_name = name.capitalize()
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],

View file

@ -67,7 +67,7 @@ class Distro(Base):
) )
@override @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( raise NotImplementedError(
'distro pkg ls yet implemented for Arch-like distributions' '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) await self.dpkg(['-P', *names], sudo = True)
@override @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) return await list_files(names, ec = self.ctx)
@override @override

View file

@ -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_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) return await list_files(names, ec = self.ctx)
@override @override

View file

@ -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_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) 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