From 1062be24db0f85dbc12fcfb60a7ef8b492864f92 Mon Sep 17 00:00:00 2001 From: Jan Lindemann Date: Fri, 24 Jul 2026 12:41:58 +0200 Subject: [PATCH] App: Remove hardcoded local/src from App and defs.mk local/src is a janware-specific path, remove it from App and defs.mk. It's still in pkg.sh as a safety measure. Will have to go, too, but is kept in for now until further audit. Signed-off-by: Jan Lindemann --- make/defs.mk | 1 - make/test-jw-pkg.mk | 1 + src/python/jw/pkg/App.py | 9 +- .../integration/jw-pkg/help/test-expected.txt | 102 +++++++++--------- 4 files changed, 58 insertions(+), 55 deletions(-) diff --git a/make/defs.mk b/make/defs.mk index 5127b63b..8b416b55 100644 --- a/make/defs.mk +++ b/make/defs.mk @@ -282,7 +282,6 @@ ifeq ($(VCS),cvs) endif REV_SUBDIRS = $(call reverse $(SUBDIRS)) -FRESH_CVSDIR = $(HOME)/local/src/cvs.fresh PCKG_DEFS_DIR = $(JWBDIR)/make/defs.d HDRDIR_SCOPE_SUFFIX ?= $(PROJECT) diff --git a/make/test-jw-pkg.mk b/make/test-jw-pkg.mk index b13538a2..32f1d651 100644 --- a/make/test-jw-pkg.mk +++ b/make/test-jw-pkg.mk @@ -1,6 +1,7 @@ EXE ?= $(TOPDIR)/scripts/jw-pkg.py LOG_LEVEL ?= info +TEST_CMD_GLOBAL_OPTS ?= -t $(TOPDIR) ifneq ($(LOG_LEVEL),) TEST_OPTS_LOG_LEVEL := --log-level $(LOG_LEVEL) endif diff --git a/src/python/jw/pkg/App.py b/src/python/jw/pkg/App.py index 3dfee93c..f161253d 100644 --- a/src/python/jw/pkg/App.py +++ b/src/python/jw/pkg/App.py @@ -5,7 +5,6 @@ from __future__ import annotations import os -import pwd import re import sys @@ -115,6 +114,8 @@ class App(Base): return self.__pretty_topdir return self.__topdir for d in [self.__projs_root, self.___opt_root]: + if d is None: + continue ret = d + '/' + name if os.path.exists(ret): return ret @@ -353,7 +354,7 @@ class App(Base): # -- Members with default values self.__topdir_fmt = 'absolute' - self.__projs_root = pwd.getpwuid(os.getuid()).pw_dir + '/local/src/jw.dev/proj' + self.__projs_root: str | None = None self.___opt_root = '/opt' self.__pretty_projs_root = None @@ -485,7 +486,9 @@ class App(Base): return self.__top_name @property - def projs_root(self): + def projs_root(self) -> str: + if self.__projs_root is None: + raise Exception('Tried to get unknown projects root directory') return self.__projs_root @property diff --git a/test/integration/jw-pkg/help/test-expected.txt b/test/integration/jw-pkg/help/test-expected.txt index 66b44f81..ce70c996 100644 --- a/test/integration/jw-pkg/help/test-expected.txt +++ b/test/integration/jw-pkg/help/test-expected.txt @@ -1,4 +1,4 @@ -============= Running: jw-pkg.py --log-level info --help +============= Running: jw-pkg.py -t ../../../.. --log-level info --help usage: jw-pkg.py [--log-flags LOG_FLAGS] [--log-level LOG_LEVEL] [--log-file LOG_FILE] [--backtrace] [--write-profile WRITE_PROFILE] [-t TOPDIR] @@ -47,7 +47,7 @@ Available subcommands: POSIX utility interface projects Project metadata evaluation for building packages secrets Manage package secrets -============= Running: jw-pkg.py --log-level info packages --help +============= Running: jw-pkg.py -t ../../../.. --log-level info packages --help usage: jw-pkg.py packages [-h] ... System package manager wrapper @@ -65,7 +65,7 @@ Available subcommands of packages: reboot-required Check whether the machine needs rebooting refresh Refresh the distribution's notion of available packages select Select packages by filter -============= Running: jw-pkg.py --log-level info packages delete --help +============= Running: jw-pkg.py -t ../../../.. --log-level info packages delete --help usage: jw-pkg.py packages delete [-h] [names ...] Delete packages by name @@ -75,7 +75,7 @@ positional arguments: options: -h, --help show this help message and exit -============= Running: jw-pkg.py --log-level info packages dup --help +============= Running: jw-pkg.py -t ../../../.. --log-level info packages dup --help usage: jw-pkg.py packages dup [-h] [--download-only] Upgrade distribution @@ -84,7 +84,7 @@ options: -h, --help show this help message and exit --download-only Only download packages from the repos, don't install them, yet (default: False) -============= Running: jw-pkg.py --log-level info packages install --help +============= Running: jw-pkg.py -t ../../../.. --log-level info packages install --help usage: jw-pkg.py packages install [-h] [--only-update] [-F] [names ...] Install the distribution's notion of available packages @@ -97,7 +97,7 @@ options: --only-update Only update the listed packages, don't install them (default: False) -F, --fixed-strings Don't expand macros in (default: False) -============= Running: jw-pkg.py --log-level info packages ls --help +============= Running: jw-pkg.py -t ../../../.. --log-level info packages ls --help usage: jw-pkg.py packages ls [-h] [names ...] List package contents @@ -107,7 +107,7 @@ positional arguments: options: -h, --help show this help message and exit -============= Running: jw-pkg.py --log-level info packages meta --help +============= Running: jw-pkg.py -t ../../../.. --log-level info packages meta --help usage: jw-pkg.py packages meta [-h] [names ...] List package metadata @@ -117,21 +117,21 @@ positional arguments: options: -h, --help show this help message and exit -============= Running: jw-pkg.py --log-level info packages reboot-required --help +============= Running: jw-pkg.py -t ../../../.. --log-level info packages reboot-required --help usage: jw-pkg.py packages reboot-required [-h] Check whether the machine needs rebooting options: -h, --help show this help message and exit -============= Running: jw-pkg.py --log-level info packages refresh --help +============= Running: jw-pkg.py -t ../../../.. --log-level info packages refresh --help usage: jw-pkg.py packages refresh [-h] Refresh the distribution's notion of available packages options: -h, --help show this help message and exit -============= Running: jw-pkg.py --log-level info packages select --help +============= Running: jw-pkg.py -t ../../../.. --log-level info packages select --help usage: jw-pkg.py packages select [-h] filter Select packages by filter @@ -141,7 +141,7 @@ positional arguments: options: -h, --help show this help message and exit -============= Running: jw-pkg.py --log-level info platform --help +============= Running: jw-pkg.py -t ../../../.. --log-level info platform --help usage: jw-pkg.py platform [-h] ... Miscellaneous platform-related commands @@ -152,7 +152,7 @@ options: Available subcommands of platform: info Retrieve information about target platform -============= Running: jw-pkg.py --log-level info platform info --help +============= Running: jw-pkg.py -t ../../../.. --log-level info platform info --help usage: jw-pkg.py platform info [-h] [--format FORMAT] Retrieve information about target platform @@ -162,7 +162,7 @@ options: --format FORMAT Format string, expanding macros %{os}, %{id}, %{name}, %{codename}, %{gnu-triplet}, %{os-cascade}, %{os-release}, %{pkg-ext} (default: %{cascade}) -============= Running: jw-pkg.py --log-level info posix --help +============= Running: jw-pkg.py -t ../../../.. --log-level info posix --help usage: jw-pkg.py posix [-h] ... Perform various operations on a distro through its POSIX utility interface @@ -174,7 +174,7 @@ Available subcommands of posix: copy Copy files tar Handle tar archives -============= Running: jw-pkg.py --log-level info posix copy --help +============= Running: jw-pkg.py -t ../../../.. --log-level info posix copy --help usage: jw-pkg.py posix copy [-h] [-o OWNER] [-g GROUP] [-m MODE] [-F] src dst Copy files @@ -189,7 +189,7 @@ options: -g, --group GROUP Destination file group (default: None) -m, --mode MODE Destination file mode (default: None) -F, --fixed-strings Don't expand macros in and (default: False) -============= Running: jw-pkg.py --log-level info posix tar --help +============= Running: jw-pkg.py -t ../../../.. --log-level info posix tar --help usage: jw-pkg.py posix tar [-h] ... Handle tar archives @@ -200,7 +200,7 @@ options: Available subcommands of tar: x Extract a tar archive -============= Running: jw-pkg.py --log-level info posix tar x --help +============= Running: jw-pkg.py -t ../../../.. --log-level info posix tar x --help usage: jw-pkg.py posix tar x [-h] -f ARCHIVE_PATH dst Extract a tar archive @@ -212,7 +212,7 @@ options: -h, --help show this help message and exit -f, --archive-path ARCHIVE_PATH Archive path -============= Running: jw-pkg.py --log-level info projects --help +============= Running: jw-pkg.py -t ../../../.. --log-level info projects --help usage: jw-pkg.py projects [-h] ... Project metadata evaluation for building packages @@ -252,7 +252,7 @@ Available subcommands of projects: summary Print summary description of given modules test Test tmpl-dir Print directory containing templates of a given module -============= Running: jw-pkg.py --log-level info projects build --help +============= Running: jw-pkg.py -t ../../../.. --log-level info projects build --help usage: jw-pkg.py projects build [-h] [--exclude EXCLUDE] [-n] [-O] [-I] [--env-reinit] [--env-keep ENV_KEEP] target modules [modules ...] @@ -279,7 +279,7 @@ options: --env-keep ENV_KEEP Comma seperated list of environment variables to keep, "all" or "none", only meaningful if --env-reinit is specified (default: none) -============= Running: jw-pkg.py --log-level info projects canonicalize-remotes --help +============= Running: jw-pkg.py -t ../../../.. --log-level info projects canonicalize-remotes --help usage: jw-pkg.py projects canonicalize-remotes [-h] [-n] Streamline janware Git remotes @@ -287,7 +287,7 @@ Streamline janware Git remotes options: -h, --help show this help message and exit -n, --dry-run Only log what would be done (default: False) -============= Running: jw-pkg.py --log-level info projects cflags --help +============= Running: jw-pkg.py -t ../../../.. --log-level info projects cflags --help usage: jw-pkg.py projects cflags [-h] [module ...] cflags @@ -297,7 +297,7 @@ positional arguments: options: -h, --help show this help message and exit -============= Running: jw-pkg.py --log-level info projects check --help +============= Running: jw-pkg.py -t ../../../.. --log-level info projects check --help usage: jw-pkg.py projects check [-h] ... Run miscellaneous code and project checks @@ -308,7 +308,7 @@ options: Available subcommands of check: deps Check for circular dependencies between given modules -============= Running: jw-pkg.py --log-level info projects check deps --help +============= Running: jw-pkg.py -t ../../../.. --log-level info projects check deps --help usage: jw-pkg.py projects check deps [-h] [-f [FLAVOUR]] [module ...] Check for circular dependencies between given modules @@ -319,14 +319,14 @@ positional arguments: options: -h, --help show this help message and exit -f, --flavour [FLAVOUR] -============= Running: jw-pkg.py --log-level info projects commands --help +============= Running: jw-pkg.py -t ../../../.. --log-level info projects commands --help usage: jw-pkg.py projects commands [-h] List available commands options: -h, --help show this help message and exit -============= Running: jw-pkg.py --log-level info projects create-file --help +============= Running: jw-pkg.py -t ../../../.. --log-level info projects create-file --help usage: jw-pkg.py projects create-file [-h] [--format FORMAT] [--search-path SEARCH_PATH] [--template-name TEMPLATE_NAME] @@ -351,7 +351,7 @@ options: -f, --field KEY=VALUE Additional fields to insert into the output file (default: []) -============= Running: jw-pkg.py --log-level info projects create-pkg-config --help +============= Running: jw-pkg.py -t ../../../.. --log-level info projects create-pkg-config --help usage: jw-pkg.py projects create-pkg-config [-h] [-F PROJECT_DESCR_FILE] [-d DESCRIPTION] [-n NAME] [-s SUMMARY] [-p PREFIX] @@ -375,7 +375,7 @@ options: -r, --requires-run REQUIRES_RUN -R, --requires-build REQUIRES_BUILD -V, --variables [VARIABLES ...] -============= Running: jw-pkg.py --log-level info projects exepath --help +============= Running: jw-pkg.py -t ../../../.. --log-level info projects exepath --help usage: jw-pkg.py projects exepath [-h] [-d [DELIMITER]] [module ...] exepath @@ -387,7 +387,7 @@ options: -h, --help show this help message and exit -d, --delimiter [DELIMITER] Output words delimiter (default: :) -============= Running: jw-pkg.py --log-level info projects get-auth-info --help +============= Running: jw-pkg.py -t ../../../.. --log-level info projects get-auth-info --help usage: jw-pkg.py projects get-auth-info [-h] [--only-values] [--username] [--password] [--remote-owner-base] [--remote-base] @@ -402,7 +402,7 @@ options: --remote-owner-base Show remote base URL for owner jw-pkg was cloned from (default: False) --remote-base Show remote base URL (default: False) -============= Running: jw-pkg.py --log-level info projects getval --help +============= Running: jw-pkg.py -t ../../../.. --log-level info projects getval --help usage: jw-pkg.py projects getval [-h] [--project PROJECT] section key Get value from project config @@ -415,7 +415,7 @@ options: -h, --help show this help message and exit --project PROJECT Project name, default is name of project's topdir (default: None) -============= Running: jw-pkg.py --log-level info projects htdocs-dir --help +============= Running: jw-pkg.py -t ../../../.. --log-level info projects htdocs-dir --help usage: jw-pkg.py projects htdocs-dir [-h] [module ...] Print source directory containing document root of a given module @@ -425,7 +425,7 @@ positional arguments: options: -h, --help show this help message and exit -============= Running: jw-pkg.py --log-level info projects ldflags --help +============= Running: jw-pkg.py -t ../../../.. --log-level info projects ldflags --help usage: jw-pkg.py projects ldflags [-h] [--exclude EXCLUDE] [-s] [module ...] ldflags @@ -438,7 +438,7 @@ options: --exclude EXCLUDE Exclude Modules (default: []) -s, --add-self Include libflags of specified modules, too, not only their dependencies (default: False) -============= Running: jw-pkg.py --log-level info projects ldlibpath --help +============= Running: jw-pkg.py -t ../../../.. --log-level info projects ldlibpath --help usage: jw-pkg.py projects ldlibpath [-h] [-d [DELIMITER]] [module ...] ldlibpath @@ -450,7 +450,7 @@ options: -h, --help show this help message and exit -d, --delimiter [DELIMITER] Output words delimiter (default: :) -============= Running: jw-pkg.py --log-level info projects libname --help +============= Running: jw-pkg.py -t ../../../.. --log-level info projects libname --help usage: jw-pkg.py projects libname [-h] [module ...] libname @@ -460,7 +460,7 @@ positional arguments: options: -h, --help show this help message and exit -============= Running: jw-pkg.py --log-level info projects list-repos --help +============= Running: jw-pkg.py -t ../../../.. --log-level info projects list-repos --help usage: jw-pkg.py projects list-repos [-h] [--username USERNAME] [--askpass ASKPASS] [--from-owner FROM_OWNER] @@ -480,7 +480,7 @@ options: (default: None) --from-owner FROM_OWNER List from-owner's projects (default: janware) -============= Running: jw-pkg.py --log-level info projects modules --help +============= Running: jw-pkg.py -t ../../../.. --log-level info projects modules --help usage: jw-pkg.py projects modules [-h] [-F [FILTER]] Query existing janware packages @@ -490,7 +490,7 @@ options: -F, --filter [FILTER] Key-value pairs, seperated by commas, to be searched for in project.conf (default: None) -============= Running: jw-pkg.py --log-level info projects path --help +============= Running: jw-pkg.py -t ../../../.. --log-level info projects path --help usage: jw-pkg.py projects path [-h] [module ...] path @@ -500,7 +500,7 @@ positional arguments: options: -h, --help show this help message and exit -============= Running: jw-pkg.py --log-level info projects pkg-conflicts --help +============= Running: jw-pkg.py -t ../../../.. --log-level info projects pkg-conflicts --help usage: jw-pkg.py projects pkg-conflicts [-h] [-S [SUBSECTIONS]] [-d [DELIMITER]] [-p] [--dont-strip-revision] @@ -552,7 +552,7 @@ options: (default: False) --quote Put double quotes around each listed dependency (default: False) -============= Running: jw-pkg.py --log-level info projects pkg-provides --help +============= Running: jw-pkg.py -t ../../../.. --log-level info projects pkg-provides --help usage: jw-pkg.py projects pkg-provides [-h] [-S [SUBSECTIONS]] [-d [DELIMITER]] [-p] [--dont-strip-revision] @@ -603,7 +603,7 @@ options: (default: False) --quote Put double quotes around each listed dependency (default: False) -============= Running: jw-pkg.py --log-level info projects pkg-requires --help +============= Running: jw-pkg.py -t ../../../.. --log-level info projects pkg-requires --help usage: jw-pkg.py projects pkg-requires [-h] [-S [SUBSECTIONS]] [-d [DELIMITER]] [-p] [--dont-strip-revision] @@ -654,7 +654,7 @@ options: (default: False) --quote Put double quotes around each listed dependency (default: False) -============= Running: jw-pkg.py --log-level info projects proj-dir --help +============= Running: jw-pkg.py -t ../../../.. --log-level info projects proj-dir --help usage: jw-pkg.py projects proj-dir [-h] [module ...] Print directory of a given package @@ -664,7 +664,7 @@ positional arguments: options: -h, --help show this help message and exit -============= Running: jw-pkg.py --log-level info projects pythonpath --help +============= Running: jw-pkg.py -t ../../../.. --log-level info projects pythonpath --help usage: jw-pkg.py projects pythonpath [-h] [--subdir SUBDIR] [--delimiter DELIMITER] [--prefix PATH_COMPONENT_PREFIX] @@ -685,7 +685,7 @@ options: --prefix PATH_COMPONENT_PREFIX Prefix to prepend before every path component (default: None) -============= Running: jw-pkg.py --log-level info projects required-os-pkg --help +============= Running: jw-pkg.py -t ../../../.. --log-level info projects required-os-pkg --help usage: jw-pkg.py projects required-os-pkg [-h] [--skip-excluded] [--quote] flavours [modules ...] @@ -701,7 +701,7 @@ options: (default: False) --quote Put double quotes around each listed dependency (default: False) -============= Running: jw-pkg.py --log-level info projects summary --help +============= Running: jw-pkg.py -t ../../../.. --log-level info projects summary --help usage: jw-pkg.py projects summary [-h] [module ...] Print summary description of given modules @@ -711,7 +711,7 @@ positional arguments: options: -h, --help show this help message and exit -============= Running: jw-pkg.py --log-level info projects test --help +============= Running: jw-pkg.py -t ../../../.. --log-level info projects test --help usage: jw-pkg.py projects test [-h] blah Test @@ -721,7 +721,7 @@ positional arguments: options: -h, --help show this help message and exit -============= Running: jw-pkg.py --log-level info projects tmpl-dir --help +============= Running: jw-pkg.py -t ../../../.. --log-level info projects tmpl-dir --help usage: jw-pkg.py projects tmpl-dir [-h] [module ...] Print directory containing templates of a given module @@ -731,7 +731,7 @@ positional arguments: options: -h, --help show this help message and exit -============= Running: jw-pkg.py --log-level info secrets --help +============= Running: jw-pkg.py -t ../../../.. --log-level info secrets --help usage: jw-pkg.py secrets [-h] ... Manage package secrets @@ -750,7 +750,7 @@ Available subcommands of secrets: list-templates List package template files rm-compilation-output Remove package compilation output files -============= Running: jw-pkg.py --log-level info secrets compile-templates --help +============= Running: jw-pkg.py -t ../../../.. --log-level info secrets compile-templates --help usage: jw-pkg.py secrets compile-templates [-h] [--owner OWNER] [--group GROUP] [--mode MODE] [packages ...] @@ -765,7 +765,7 @@ options: --owner, -o OWNER Default output file owner (default: None) --group, -g GROUP Default output file group (default: None) --mode, -m MODE Default output file mode (default: None) -============= Running: jw-pkg.py --log-level info secrets install --help +============= Running: jw-pkg.py -t ../../../.. --log-level info secrets install --help usage: jw-pkg.py secrets install [-h] [--only-missing] src [packages ...] Install secrets from various sources as static secrets onto the target @@ -778,7 +778,7 @@ options: -h, --help show this help message and exit --only-missing Install only secrets not already on the target (default: False) -============= Running: jw-pkg.py --log-level info secrets list-compilation-output --help +============= Running: jw-pkg.py -t ../../../.. --log-level info secrets list-compilation-output --help usage: jw-pkg.py secrets list-compilation-output [-h] [--all] [packages ...] List package compilation output files @@ -790,7 +790,7 @@ options: -h, --help show this help message and exit --all Show all output targets, including non-existent files (default: False) -============= Running: jw-pkg.py --log-level info secrets list-secrets --help +============= Running: jw-pkg.py -t ../../../.. --log-level info secrets list-secrets --help usage: jw-pkg.py secrets list-secrets [-h] [--all] [packages ...] List package secret files @@ -802,7 +802,7 @@ options: -h, --help show this help message and exit --all Show all secret paths, including non-existent files (default: False) -============= Running: jw-pkg.py --log-level info secrets list-templates --help +============= Running: jw-pkg.py -t ../../../.. --log-level info secrets list-templates --help usage: jw-pkg.py secrets list-templates [-h] [packages ...] List package template files @@ -812,7 +812,7 @@ positional arguments: options: -h, --help show this help message and exit -============= Running: jw-pkg.py --log-level info secrets rm-compilation-output --help +============= Running: jw-pkg.py -t ../../../.. --log-level info secrets rm-compilation-output --help usage: jw-pkg.py secrets rm-compilation-output [-h] [packages ...] Remove package compilation output files