feat: improved pkgbuild, config concepts
This commit is contained in:
@@ -7,7 +7,7 @@ pkgdesc='A nixos-like declarative config and package manager for Arch Linux'
|
|||||||
arch=('any')
|
arch=('any')
|
||||||
url="https://github.com/janishutz/archmgr"
|
url="https://github.com/janishutz/archmgr"
|
||||||
license=('GPL3')
|
license=('GPL3')
|
||||||
depends=('python', 'python-pyaml')
|
depends=('python' 'python-pyaml' 'python-colorama' 'python-pystache')
|
||||||
makedepends=('git')
|
makedepends=('git')
|
||||||
provides=('archmgr')
|
provides=('archmgr')
|
||||||
conflicts=('archmgr')
|
conflicts=('archmgr')
|
||||||
|
|||||||
+3
-1
@@ -1,7 +1,9 @@
|
|||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python3
|
||||||
# PYTHON_ARGCOMPLETE_OK
|
# PYTHON_ARGCOMPLETE_OK
|
||||||
|
|
||||||
# TODO: Re-export the config stuff
|
from archmgr.config import create_config
|
||||||
|
|
||||||
|
__all__ = ["create_config"]
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
from app import run as _run
|
from app import run as _run
|
||||||
|
|||||||
@@ -0,0 +1,17 @@
|
|||||||
|
from archmgr.config.pkgs import ArchMgrPkgs
|
||||||
|
|
||||||
|
|
||||||
|
class ArchMgrConfig:
|
||||||
|
pkgs: ArchMgrPkgs
|
||||||
|
|
||||||
|
def __init__(self) -> None:
|
||||||
|
self.pkgs = ArchMgrPkgs()
|
||||||
|
|
||||||
|
|
||||||
|
def create_config():
|
||||||
|
"""Create a new ArchMgrConfig, or get the existing config, if one exists
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
[TODO:return]
|
||||||
|
"""
|
||||||
|
return ArchMgrConfig()
|
||||||
@@ -0,0 +1,2 @@
|
|||||||
|
class ArchMgrPkgs:
|
||||||
|
pass
|
||||||
|
|||||||
@@ -0,0 +1,3 @@
|
|||||||
|
class ArchMgrAURPackages:
|
||||||
|
def __init__(self) -> None:
|
||||||
|
pass
|
||||||
@@ -0,0 +1,40 @@
|
|||||||
|
import subprocess as sp
|
||||||
|
from typing import List
|
||||||
|
|
||||||
|
from util.input import password
|
||||||
|
|
||||||
|
|
||||||
|
def uninstall_package_list(pkgs: List[str]) -> bool:
|
||||||
|
"""Uninstall all packages in the list
|
||||||
|
|
||||||
|
Args:
|
||||||
|
pkgs: A list of packages to uninstall
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
True if successful, False otherwise
|
||||||
|
"""
|
||||||
|
# TODO: Add guard to protect against uninstalling archmgr and confirm uninstalling crucial pkgs
|
||||||
|
# pkgs.index("archmgr")
|
||||||
|
# TODO: Consider if we want to print out stdout and stderr on err
|
||||||
|
return run_pkg_manager_cmd(["-Rs", *pkgs], True).returncode == 0
|
||||||
|
|
||||||
|
|
||||||
|
def install_package_list(pkgs: List[str]) -> bool:
|
||||||
|
"""Install all packages in the list
|
||||||
|
|
||||||
|
Args:
|
||||||
|
pkgs: A list of packages to install
|
||||||
|
"""
|
||||||
|
return run_pkg_manager_cmd(["-S", *pkgs], True).returncode == 0
|
||||||
|
|
||||||
|
|
||||||
|
def run_pkg_manager_cmd(
|
||||||
|
args: List[str], use_sudo: bool = False
|
||||||
|
) -> sp.CompletedProcess[str]:
|
||||||
|
if use_sudo:
|
||||||
|
pw = password()
|
||||||
|
return sp.run(
|
||||||
|
["yay", "--noconfirm", *args], capture_output=True, text=True, input=pw
|
||||||
|
)
|
||||||
|
else:
|
||||||
|
return sp.run(["yay", "--noconfirm", *args], capture_output=True, text=True)
|
||||||
@@ -0,0 +1,13 @@
|
|||||||
|
class AURPackage:
|
||||||
|
def __init__(self, name: str) -> None:
|
||||||
|
self._name = name
|
||||||
|
self._deps: list[str] = []
|
||||||
|
|
||||||
|
def add_aur_dep(self, name: str) -> None:
|
||||||
|
self._deps.append(name)
|
||||||
|
|
||||||
|
def get_pkg_name(self) -> str:
|
||||||
|
return self._name
|
||||||
|
|
||||||
|
def get_deps(self) -> list[str]:
|
||||||
|
return self._deps
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
class ArchMgrRepoPkgs:
|
||||||
|
def __init__(self) -> None:
|
||||||
|
pass
|
||||||
@@ -0,0 +1,10 @@
|
|||||||
|
[project]
|
||||||
|
name = "archmgr"
|
||||||
|
version = "0.1.0"
|
||||||
|
dependencies = [
|
||||||
|
"pyaml"
|
||||||
|
]
|
||||||
|
|
||||||
|
[build-system]
|
||||||
|
requires = ["setuptools >= 77.0.3"]
|
||||||
|
build-backend = "setuptools.build_meta"
|
||||||
@@ -3,8 +3,6 @@ from typing import List
|
|||||||
|
|
||||||
from util.input import password
|
from util.input import password
|
||||||
|
|
||||||
pkg_manager = ["yay", "--noconfirm"]
|
|
||||||
|
|
||||||
|
|
||||||
def list_explicitly_installed() -> List[str]:
|
def list_explicitly_installed() -> List[str]:
|
||||||
"""List all packages explicitly installed
|
"""List all packages explicitly installed
|
||||||
@@ -59,6 +57,11 @@ def run_pkg_manager_cmd(
|
|||||||
) -> sp.CompletedProcess[str]:
|
) -> sp.CompletedProcess[str]:
|
||||||
if use_sudo:
|
if use_sudo:
|
||||||
pw = password()
|
pw = password()
|
||||||
return sp.run([*pkg_manager, *args], capture_output=True, text=True, input=pw)
|
return sp.run(
|
||||||
|
["sudo", "-S", "pacman", "--noconfirm", *args],
|
||||||
|
capture_output=True,
|
||||||
|
text=True,
|
||||||
|
input=pw,
|
||||||
|
)
|
||||||
else:
|
else:
|
||||||
return sp.run([*pkg_manager, *args], capture_output=True, text=True)
|
return sp.run(["pacman", "--noconfirm", *args], capture_output=True, text=True)
|
||||||
|
|||||||
@@ -3,5 +3,28 @@
|
|||||||
In python, using functions and args for them
|
In python, using functions and args for them
|
||||||
|
|
||||||
|
|
||||||
|
### Packages config
|
||||||
|
#### Repos
|
||||||
|
- Just use pacman with the list
|
||||||
|
|
||||||
|
#### AUR
|
||||||
|
Users can choose to either use yay (less secure, but easier, using `archmgr.pkgs.aur.add_aur_helper_package`, does not do any checks on the PKGBUILDs) or
|
||||||
|
**Explicit management:**
|
||||||
|
- User provides package (by creating `archmgr.pkgs.aur.AURPackage` class) and adding its AUR deps. Other deps are resolved automatically
|
||||||
|
- Send the package class to the manager using `archmgr.pkgs.aur.add_aur_package`
|
||||||
|
- In the future will provide a function that will do the dep resolution automatically.
|
||||||
|
- For each and its deps, it will analyze the PKGBUILD for common malware issues. Also add option to display all PKGBUILDs before building
|
||||||
|
|
||||||
|
### Commands
|
||||||
|
- Run the command on the specified hook
|
||||||
|
|
||||||
|
### Templates
|
||||||
|
- Use pystache to replace elements
|
||||||
|
|
||||||
|
### Themes
|
||||||
|
- Use python-colorthief to extract palette
|
||||||
|
- Add those as named elements to the templates list
|
||||||
|
|
||||||
|
|
||||||
## Init
|
## Init
|
||||||
- Copy
|
- Copy
|
||||||
|
|||||||
Reference in New Issue
Block a user