cmds.distro.CmdInfo: Rename to cmds.platform.CmdInfo

Rename command "distro" to "pkg" together with "info", its last
remaining subcommand. "distro" is often used in the sense of "Linux
distribution", which would be too narrow for the targets jw-pkg could
theoretically support.

Signed-off-by: Jan Lindemann <jan@janware.com>
This commit is contained in:
Jan Lindemann 2026-04-24 12:16:20 +02:00
commit 514d66dac1
Signed by: Jan Lindemann
GPG key ID: 3750640C9E25DD61
10 changed files with 20 additions and 20 deletions

View file

@ -11,7 +11,7 @@ include $(JWBDIR)/make/dev-utils.mk
CACHED_FILES ?= $(VERSION_FILE) $(wildcard $(TOPDIR)/make/project.conf)
CACHED_VARS ?= PROJECT PREREQ VERSION HEX_VERSION FULL_NAME \
WHICH PYTHON ECHO TEST BROWSER SED RM PWD ID CUT TR \
AWK GETENT XARGS FIND PRINTF HOST_DISTRO_INFO OS_NAME_VERSION \
AWK GETENT XARGS FIND PRINTF PLATFORM_INFO OS_NAME_VERSION \
CAT BIN_INSTALL SUDO \
JW_PKG_LD_LIBRARY_PATH JW_PKG_EXE_PATH JW_PKG_PYTHON_PATH

View file

@ -71,17 +71,17 @@ endif
# -- arch, vendor, os, libc
ifeq ($(HOST_DISTRO_INFO),)
HOST_DISTRO_INFO := $(shell $(JW_PKG_PY) distro info --format '%{gnu-triplet} %{cascade}')
ifeq ($(PLATFORM_INFO),)
PLATFORM_INFO := $(shell $(JW_PKG_PY) platform info --format '%{gnu-triplet} %{cascade}')
endif
HOST_TUPLE ?= $(word 1,$(HOST_DISTRO_INFO))
HOST_TUPLE ?= $(word 1,$(PLATFORM_INFO))
HOST_TUPLE_WORDS := $(subst -, ,$(HOST_TUPLE))
HOST_ARCH := $(word 1,$(HOST_TUPLE_WORDS))
HOST_VENDOR := $(word 2,$(HOST_TUPLE_WORDS))
HOST_OS := $(word 3,$(HOST_TUPLE_WORDS))
HOST_ABI := $(word 4,$(HOST_TUPLE_WORDS))
HOST_TRIPLET := $(HOST_ARCH)-$(HOST_OS)-$(HOST_ABI)
HOST_OS_CASCADE := $(wordlist 2,$(words $(HOST_DISTRO_INFO)),$(HOST_DISTRO_INFO))
HOST_OS_CASCADE := $(wordlist 2,$(words $(PLATFORM_INFO)),$(PLATFORM_INFO))
PKG_FORMAT ?= $(patsubst pkg-%,%,$(filter pkg-%,$(HOST_OS_CASCADE)))
ifndef TARGET
@ -176,7 +176,7 @@ else
endif
ifeq ($(OS_NAME_VERSION),)
OS_NAME_VERSION := $(shell $(JW_PKG_PY) distro info --format '%{id}-%{codename}')
OS_NAME_VERSION := $(shell $(JW_PKG_PY) platform info --format '%{id}-%{codename}')
endif
ifeq ($(OS_NAME),)

View file

@ -66,7 +66,7 @@ JW_PKG_PY = python3 $(JWB_SCRIPT_DIR)/jw-pkg.py --prefix $(sh
SSH_WRAPPER_SH := $(CWD)/ssh-wrapper.sh
EXCLUDES_FILE ?= exclude.txt
EXCLUDES_FILES := $(wildcard $(patsubst %,exclude-%.txt,$(shell $(JW_PKG_PY) distro info --format '%{cascade}')) $(EXCLUDES_FILE))
EXCLUDES_FILES := $(wildcard $(patsubst %,exclude-%.txt,$(shell $(JW_PKG_PY) platform info --format '%{cascade}')) $(EXCLUDES_FILE))
ifneq ($(EXCLUDES_FILES),)
EXCLUDE_FROM_BUILD += $(shell sed 's/\#.*//g' $(EXCLUDES_FILES))
@ -194,7 +194,7 @@ echo-install-deps:
echo-release-deps:
$(Q)$(JW_PKG_PY_PROJECTS) required-os-pkg --quote --skip-excluded "build,run,release" $(TARGET_PROJECTS)
echo-os:
$(Q)$(JW_PKG_PY) distro info
$(Q)$(JW_PKG_PY) platform info
echo-projects:
@echo $(PROJECTS)

View file

@ -41,7 +41,7 @@ subpackage_description()
os_cascade()
{
/usr/bin/python3 $JWB_SCRIPT_DIR/jw-pkg.py distro info --format '%{cascade}'
/usr/bin/python3 $JWB_SCRIPT_DIR/jw-pkg.py platform info --format '%{cascade}'
}
# -- here we go

View file

@ -34,14 +34,14 @@ fatal()
quit 1
}
distro_info()
platform_info()
{
/usr/bin/python3 $JWB_SCRIPT_DIR/jw-pkg.py distro info --format "$1"
/usr/bin/python3 $JWB_SCRIPT_DIR/jw-pkg.py platform info --format "$1"
}
get_os()
{
[ "$__get_os" ] || __get_os=`distro_info '%{id}-%{codename}'`
[ "$__get_os" ] || __get_os=`platform_info '%{id}-%{codename}'`
echo $__get_os
}
@ -616,7 +616,7 @@ upload_pkg()
;;
debian|deb)
local -r server=apt.janware.com
local -r distro_subdir=$(distro_info '%{id}/%{codename}')
local -r distro_subdir=$(platform_info '%{id}/%{codename}')
local conf=`mktemp "/tmp/$myname"_XXXXXX`
cat <<-EOT > $conf
[DEFAULT]
@ -1096,7 +1096,7 @@ cmd_milk_install_log()
echo "== processing stage $stage: cfg_section pkg.$p.$stage" >&2
local os content=""
for os in '' `distro_info '%{cascade}'`; do
for os in '' `platform_info '%{cascade}'`; do
local sec=pkg.$p.$stage head=""
if [ "$os" ]; then
sec="$sec.$os"

View file

@ -0,0 +1,15 @@
# -*- coding: utf-8 -*-
from argparse import ArgumentParser
from ..App import App
from .Cmd import Cmd as CmdBase
class CmdPlatform(CmdBase): # export
def __init__(self, parent: App) -> None:
super().__init__(parent, 'platform', help="Miscellaneous platform-related comamnds")
self._add_subcommands()
def add_arguments(self, p: ArgumentParser) -> None:
super().add_arguments(p)

View file

@ -0,0 +1,16 @@
# -*- coding: utf-8 -*-
from __future__ import annotations
from typing import TYPE_CHECKING
if TYPE_CHECKING:
from ...lib.Distro import Distro
from ..CmdPlatform import CmdPlatform
from ..Cmd import Cmd as Base
class Cmd(Base): # export
def __init__(self, parent: CmdPlatform, name: str, help: str) -> None:
super().__init__(parent, name, help)

View file

@ -0,0 +1,21 @@
# -*- coding: utf-8 -*-
from argparse import Namespace, ArgumentParser
from ...lib.log import *
from ...lib.Distro import Distro
from ..Cmd import Cmd
from ..CmdPlatform import CmdPlatform
class CmdInfo(Cmd): # export
def __init__(self, parent: CmdPlatform) -> None:
super().__init__(parent, 'info', help='Retrieve information about target platform')
def add_arguments(self, parser: ArgumentParser) -> None:
super().add_arguments(parser)
parser.add_argument('--format', default='%{cascade}',
help=f'Format string, expanding macros {", ".join(Distro.macros())}')
async def _run(self, args: Namespace) -> None:
print(self.app.distro.expand_macros(args.format))

View file

@ -0,0 +1,5 @@
TOPDIR = ../../../../../..
PY_UPDATE_INIT_PY = false
include $(TOPDIR)/make/proj.mk
include $(JWBDIR)/make/py-mod.mk

View file

@ -0,0 +1,11 @@
import importlib, pkgutil
__all__ = []
for finder, module_name, ispkg in pkgutil.iter_modules(__path__):
if not module_name.startswith("Cmd"):
continue
module = importlib.import_module(f".{module_name}", __name__)
cls = getattr(module, module_name)
globals()[module_name] = cls
__all__.append(module_name)