diff --git a/TODO.md b/TODO.md index 8f1b651..805226f 100644 --- a/TODO.md +++ b/TODO.md @@ -117,7 +117,7 @@ Live ISO без графіки з консольним інсталятором: - [x] Значки Wi-Fi і Bluetooth у треї лишались блідими: панельні значки Papirus (`#dfdfdf`) зроблені для темних панелей, а CSS їх не перефарбовує. Світла тема тепер на `Papirus-Light` (`#444`): `xsettings.xml`, `index.theme`, екран входу; `das-theme` 0.3.0, `das-settings` 0.6.0, 0.9.5; перевірити на ISO. - [x] `das-panel-icon help` (`-h`, `--help`) показує підказку, а не ставить значок «?»; невідомі `-ключі` відхиляються. - [x] На десктопний образ додано `publisher` (`publish`) і `deployer` (`deploy`): копії проєктів з `~/Dev/Projects/Python`, конфіг у `~/.config/<назва>/` (створюється з прикладу при першому запуску), історія в `~/.local/state/<назва>/`; перевірити на ISO. -- [ ] Перенести в оригінальні `publisher` і `deployer` зміну шляхів конфігу та `history.log` (зараз вони лише в копіях пакетів), щоб копії не розходились. +- [x] Зміну шляхів конфігу та `history.log` перенесено в оригінальні `publisher` і `deployer` (`config.default_path()`, `pipeline._history_path()`): у checkout усе як було, у пакеті — `~/.config` і `~/.local/state`. Копії пакетів відрізняються від оригіналів лише значеннями за замовчуванням (localhost, user). - [ ] Прибрати значки томів live-носія («Том 6,6 ГБ») з робочого столу live-сесії. - [ ] Тема GRUB у встановленій системі (зараз стандартний чорний екран). - [ ] Перевірити меню Whisker вручну. diff --git a/srcpkgs/deployer/files/python/deployer/cli.py b/srcpkgs/deployer/files/python/deployer/cli.py index 7c0ae0b..f31f449 100644 --- a/srcpkgs/deployer/files/python/deployer/cli.py +++ b/srcpkgs/deployer/files/python/deployer/cli.py @@ -148,7 +148,7 @@ def main(argv=None) -> int: args = p.parse_args(argv) color(sys.stdout.isatty() and not args.no_color) - cfg_path = Path(args.config) if args.config else Path(__file__).resolve().parent.parent / "deploy.toml" + cfg_path = Path(args.config) if args.config else config.default_path() try: cfg = config.load(cfg_path) except (OSError, config.ConfigError) as e: diff --git a/srcpkgs/deployer/files/python/deployer/config.py b/srcpkgs/deployer/files/python/deployer/config.py index 6b75754..b58d16e 100644 --- a/srcpkgs/deployer/files/python/deployer/config.py +++ b/srcpkgs/deployer/files/python/deployer/config.py @@ -211,3 +211,11 @@ def append_apps(path: Path, apps: list[App], drafts: list[App] = ()) -> None: block = "".join(f"# {line}\n" for line in app_to_toml(a).splitlines()) text = text.rstrip("\n") + "\n\n# TODO: check src / build / dest, then uncomment\n" + block path.write_text(text) + + +def default_path() -> Path: + """deploy.toml next to the sources (a checkout), else ~/.config/deployer/deploy.toml (an installed package).""" + local = Path(__file__).resolve().parent.parent / "deploy.toml" + if local.exists(): + return local + return Path(os.environ.get("XDG_CONFIG_HOME") or Path.home() / ".config") / "deployer" / "deploy.toml" diff --git a/srcpkgs/deployer/files/python/deployer/pipeline.py b/srcpkgs/deployer/files/python/deployer/pipeline.py index 9386c5a..d681e58 100644 --- a/srcpkgs/deployer/files/python/deployer/pipeline.py +++ b/srcpkgs/deployer/files/python/deployer/pipeline.py @@ -13,8 +13,17 @@ from . import kinds, remote, snapshots from .config import App, Config from .kinds import Options, Plan -# Das OS package: /usr/lib is read-only, so the history goes to the user's state dir -HISTORY = Path(os.environ.get("XDG_STATE_HOME") or Path.home() / ".local/state") / "deployer" / "history.log" + + +def _history_path() -> Path: + """history.log next to the sources (a checkout), else ~/.local/state/deployer/ (an installed package).""" + local = Path(__file__).resolve().parent.parent + if os.access(local, os.W_OK): + return local / "history.log" + return Path(os.environ.get("XDG_STATE_HOME") or Path.home() / ".local/state") / "deployer" / "history.log" + + +HISTORY = _history_path() class DeployError(RuntimeError): diff --git a/srcpkgs/publisher/files/python/publisher/cli.py b/srcpkgs/publisher/files/python/publisher/cli.py index f1d8def..f105d54 100644 --- a/srcpkgs/publisher/files/python/publisher/cli.py +++ b/srcpkgs/publisher/files/python/publisher/cli.py @@ -150,7 +150,7 @@ def main(argv=None) -> int: args = p.parse_args(argv) global COLOR COLOR = sys.stdout.isatty() and not args.no_color - cfg_path = Path(args.config) if args.config else Path(__file__).resolve().parent.parent / "publish.toml" + cfg_path = Path(args.config) if args.config else config.default_path() try: cfg = config.load(cfg_path) except (OSError, config.ConfigError) as e: diff --git a/srcpkgs/publisher/files/python/publisher/config.py b/srcpkgs/publisher/files/python/publisher/config.py index 13ad926..8ebb791 100644 --- a/srcpkgs/publisher/files/python/publisher/config.py +++ b/srcpkgs/publisher/files/python/publisher/config.py @@ -185,3 +185,11 @@ def append_apps(path: Path, apps: list[App]) -> None: validate_app(a) text = text.rstrip("\n") + "\n\n" + app_to_toml(a) path.write_text(text) + + +def default_path() -> Path: + """publish.toml next to the sources (a checkout), else ~/.config/publisher/publish.toml (an installed package).""" + local = Path(__file__).resolve().parent.parent / "publish.toml" + if local.exists(): + return local + return Path(os.environ.get("XDG_CONFIG_HOME") or Path.home() / ".config") / "publisher" / "publish.toml" diff --git a/srcpkgs/publisher/files/python/publisher/pipeline.py b/srcpkgs/publisher/files/python/publisher/pipeline.py index 9a14afc..e9238a3 100644 --- a/srcpkgs/publisher/files/python/publisher/pipeline.py +++ b/srcpkgs/publisher/files/python/publisher/pipeline.py @@ -13,8 +13,17 @@ from . import packages, remote from .config import App, Config from .packages import Kind, Local, Published, version_key -# Das OS package: /usr/lib is read-only, so the history goes to the user's state dir -HISTORY = Path(os.environ.get("XDG_STATE_HOME") or Path.home() / ".local/state") / "publisher" / "history.log" + + +def _history_path() -> Path: + """history.log next to the sources (a checkout), else ~/.local/state/publisher/ (an installed package).""" + local = Path(__file__).resolve().parent.parent + if os.access(local, os.W_OK): + return local / "history.log" + return Path(os.environ.get("XDG_STATE_HOME") or Path.home() / ".local/state") / "publisher" / "history.log" + + +HISTORY = _history_path() # Plan item actions; the first five change the server NEW, REPLACE, META, NOTES, DELETE, SAME, SKIP = "new", "replace", "meta", "notes", "delete", "same", "skip"