mirror of
https://github.com/kiviktnm/decman.git
synced 2026-09-19 20:18:28 +00:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
82a1fbdcb9 | ||
|
|
e153b8c400 | ||
|
|
bde9d9c70d | ||
|
|
53b227859c | ||
|
|
c091d18ee1 | ||
|
|
7dacad6be2 | ||
|
|
5fe7df23db |
@@ -148,7 +148,7 @@ decman.user_packages.append(
|
|||||||
pkgname="decman-git",
|
pkgname="decman-git",
|
||||||
# Note, this example may not be up to date
|
# Note, this example may not be up to date
|
||||||
provides=["decman"],
|
provides=["decman"],
|
||||||
version="0.3.0",
|
version="0.3.1",
|
||||||
dependencies=["python", "python-requests", "devtools", "pacman", "systemd", "git"],
|
dependencies=["python", "python-requests", "devtools", "pacman", "systemd", "git"],
|
||||||
make_dependencies=[
|
make_dependencies=[
|
||||||
"python-setuptools", "python-build", "python-installer", "python-wheel"
|
"python-setuptools", "python-build", "python-installer", "python-wheel"
|
||||||
@@ -163,6 +163,9 @@ Build packages are stored in a cache `/var/cache/decman`. By default decman keep
|
|||||||
|
|
||||||
### Systemd units
|
### Systemd units
|
||||||
|
|
||||||
|
> [!NOTE]
|
||||||
|
> Decman will only enable and disable systemd systemd. It will not start or stop them.
|
||||||
|
|
||||||
Decman can enable systemd services, system wide or for a specific user. Decman will enable all units defined in the source, and disable them when they are removed from the source. If a unit is not defined in the source, decman will not touch it.
|
Decman can enable systemd services, system wide or for a specific user. Decman will enable all units defined in the source, and disable them when they are removed from the source. If a unit is not defined in the source, decman will not touch it.
|
||||||
|
|
||||||
### Files
|
### Files
|
||||||
@@ -276,7 +279,7 @@ user_packages = [{
|
|||||||
pkgname="decman-git",
|
pkgname="decman-git",
|
||||||
# Note, this example may not be up to date
|
# Note, this example may not be up to date
|
||||||
provides=["decman"],
|
provides=["decman"],
|
||||||
version="0.3.0",
|
version="0.3.1",
|
||||||
dependencies=["python", "python-requests", "devtools", "pacman", "systemd", "git"],
|
dependencies=["python", "python-requests", "devtools", "pacman", "systemd", "git"],
|
||||||
make_dependencies=[
|
make_dependencies=[
|
||||||
"python-setuptools", "python-build", "python-installer", "python-wheel"
|
"python-setuptools", "python-build", "python-installer", "python-wheel"
|
||||||
|
|||||||
@@ -82,7 +82,7 @@ class MyModule(Module):
|
|||||||
return [
|
return [
|
||||||
UserPackage(
|
UserPackage(
|
||||||
pkgname="decman-git",
|
pkgname="decman-git",
|
||||||
version="0.3.0",
|
version="0.3.1",
|
||||||
provides=["decman"],
|
provides=["decman"],
|
||||||
dependencies=[
|
dependencies=[
|
||||||
"python",
|
"python",
|
||||||
|
|||||||
+4
-1
@@ -40,7 +40,7 @@ decman.config.makepkg_user = "kk"
|
|||||||
decman.user_packages.append(
|
decman.user_packages.append(
|
||||||
UserPackage(
|
UserPackage(
|
||||||
pkgname="decman-git",
|
pkgname="decman-git",
|
||||||
version="0.3.0",
|
version="0.3.1",
|
||||||
provides=["decman"],
|
provides=["decman"],
|
||||||
dependencies=[
|
dependencies=[
|
||||||
"python",
|
"python",
|
||||||
@@ -230,6 +230,9 @@ class MyCommands(decman.config.Commands):
|
|||||||
def git_get_commit_id(self) -> list[str]:
|
def git_get_commit_id(self) -> list[str]:
|
||||||
return ["git", "rev-parse", "HEAD"]
|
return ["git", "rev-parse", "HEAD"]
|
||||||
|
|
||||||
|
def git_log_commit_ids(self) -> list[str]:
|
||||||
|
return ["git", "log", "--format=format:%H"]
|
||||||
|
|
||||||
def review_file(self, file: str) -> list[str]:
|
def review_file(self, file: str) -> list[str]:
|
||||||
return ["less", file]
|
return ["less", file]
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
|
|||||||
|
|
||||||
[project]
|
[project]
|
||||||
name = "decman"
|
name = "decman"
|
||||||
version = "0.3.0"
|
version = "0.3.1"
|
||||||
description = "Declarative package & configuration manager for Arch Linux."
|
description = "Declarative package & configuration manager for Arch Linux."
|
||||||
license = {file = "LICENSE"}
|
license = {file = "LICENSE"}
|
||||||
authors = [
|
authors = [
|
||||||
|
|||||||
@@ -218,6 +218,9 @@ class Core:
|
|||||||
def _disable_units(self):
|
def _disable_units(self):
|
||||||
to_disable = self.source.units_to_disable(self.store)
|
to_disable = self.source.units_to_disable(self.store)
|
||||||
l.print_list("Disabling systemd units:", to_disable)
|
l.print_list("Disabling systemd units:", to_disable)
|
||||||
|
if to_disable:
|
||||||
|
l.print_info(
|
||||||
|
"Disabled systemd units won't be stopped automatically.")
|
||||||
if not self.only_print:
|
if not self.only_print:
|
||||||
self.systemctl.disable_units(to_disable)
|
self.systemctl.disable_units(to_disable)
|
||||||
|
|
||||||
@@ -286,6 +289,9 @@ class Core:
|
|||||||
def _enable_units(self):
|
def _enable_units(self):
|
||||||
to_enable = self.source.units_to_enable(self.store)
|
to_enable = self.source.units_to_enable(self.store)
|
||||||
l.print_list("Enabling systemd units:", to_enable)
|
l.print_list("Enabling systemd units:", to_enable)
|
||||||
|
if to_enable:
|
||||||
|
l.print_info(
|
||||||
|
"Enabled systemd units won't be started automatically.")
|
||||||
if not self.only_print:
|
if not self.only_print:
|
||||||
self.systemctl.enable_units(to_enable)
|
self.systemctl.enable_units(to_enable)
|
||||||
|
|
||||||
|
|||||||
@@ -136,6 +136,12 @@ class Commands:
|
|||||||
"""
|
"""
|
||||||
return ["git", "rev-parse", "HEAD"]
|
return ["git", "rev-parse", "HEAD"]
|
||||||
|
|
||||||
|
def git_log_commit_ids(self) -> list[str]:
|
||||||
|
"""
|
||||||
|
Running this command outputs commit hashes of the repository.
|
||||||
|
"""
|
||||||
|
return ["git", "log", "--format=format:%H"]
|
||||||
|
|
||||||
def review_file(self, file: str) -> list[str]:
|
def review_file(self, file: str) -> list[str]:
|
||||||
"""
|
"""
|
||||||
Running this command outputs a file for the user to see.
|
Running this command outputs a file for the user to see.
|
||||||
|
|||||||
@@ -680,11 +680,13 @@ class Source:
|
|||||||
return result
|
return result
|
||||||
|
|
||||||
def _all_user_units(self) -> dict[str, set[str]]:
|
def _all_user_units(self) -> dict[str, set[str]]:
|
||||||
result = {}
|
result = self.systemd_user_units
|
||||||
result.update(self.systemd_user_units)
|
for module in [m for m in self.modules if m.enabled]:
|
||||||
for module in self.modules:
|
module_user_units: dict[str, list[str]] = module.systemd_user_units()
|
||||||
if module.enabled:
|
for user in module_user_units.keys():
|
||||||
result.update(module.systemd_user_units())
|
if user not in result:
|
||||||
|
result[user] = set()
|
||||||
|
result[user].update(module_user_units[user])
|
||||||
return result
|
return result
|
||||||
|
|
||||||
|
|
||||||
@@ -922,11 +924,11 @@ class _OutputCapturingThread(threading.Thread):
|
|||||||
|
|
||||||
def run(self):
|
def run(self):
|
||||||
while not self.done and not self._stream.closed:
|
while not self.done and not self._stream.closed:
|
||||||
output = self._stream.read()
|
output = self._stream.read(1000)
|
||||||
if output:
|
if output:
|
||||||
output = output.decode()
|
output = output.decode()
|
||||||
self.output += output
|
self.output += output
|
||||||
print(output, end="")
|
print(output, end="", flush=True)
|
||||||
time.sleep(0.1)
|
time.sleep(0.1)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1078,7 +1078,14 @@ before and thus are found in the cache."
|
|||||||
default=True):
|
default=True):
|
||||||
latest_reviewed_commit = self._store.pkgbuild_latest_reviewed_commits.get(
|
latest_reviewed_commit = self._store.pkgbuild_latest_reviewed_commits.get(
|
||||||
pkgbase)
|
pkgbase)
|
||||||
if latest_reviewed_commit is None:
|
|
||||||
|
git_commit_ids = subprocess.run(
|
||||||
|
conf.commands.git_log_commit_ids(),
|
||||||
|
check=True,
|
||||||
|
stdout=subprocess.PIPE,
|
||||||
|
).stdout.decode().strip().split('\n')
|
||||||
|
|
||||||
|
if latest_reviewed_commit is None or latest_reviewed_commit not in git_commit_ids:
|
||||||
for file in os.scandir("."):
|
for file in os.scandir("."):
|
||||||
if file.is_file() and not file.name.startswith("."):
|
if file.is_file() and not file.name.startswith("."):
|
||||||
subprocess.run(conf.commands.review_file(
|
subprocess.run(conf.commands.review_file(
|
||||||
|
|||||||
@@ -264,3 +264,49 @@ class TestSource(unittest.TestCase):
|
|||||||
self.source.packages_to_remove(self.currently_installed_packages),
|
self.source.packages_to_remove(self.currently_installed_packages),
|
||||||
["p4", "A4", "M_A1", "M_A2"],
|
["p4", "A4", "M_A1", "M_A2"],
|
||||||
)
|
)
|
||||||
|
|
||||||
|
class TestModuleUserServices(unittest.TestCase):
|
||||||
|
|
||||||
|
class ModuleWithUserServiceOne(Module):
|
||||||
|
|
||||||
|
def __init__(self):
|
||||||
|
super().__init__("one", True, "0")
|
||||||
|
|
||||||
|
def systemd_user_units(self) -> dict[str, list[str]]:
|
||||||
|
return {
|
||||||
|
"user": ['foo.service']
|
||||||
|
}
|
||||||
|
|
||||||
|
class ModuleWithUserServiceTwo(Module):
|
||||||
|
|
||||||
|
def __init__(self):
|
||||||
|
super().__init__("two", True, "0")
|
||||||
|
|
||||||
|
def systemd_user_units(self) -> dict[str, list[str]]:
|
||||||
|
return {
|
||||||
|
"user": ['bar.service']
|
||||||
|
}
|
||||||
|
|
||||||
|
def setUp(self) -> None:
|
||||||
|
self.source = Source(
|
||||||
|
pacman_packages=set(),
|
||||||
|
aur_packages=set(),
|
||||||
|
user_packages=set(),
|
||||||
|
ignored_packages=set(),
|
||||||
|
systemd_units=set(),
|
||||||
|
systemd_user_units={},
|
||||||
|
files={},
|
||||||
|
directories={},
|
||||||
|
modules={
|
||||||
|
self.ModuleWithUserServiceOne(),
|
||||||
|
self.ModuleWithUserServiceTwo()
|
||||||
|
},
|
||||||
|
)
|
||||||
|
self.store = Store()
|
||||||
|
|
||||||
|
|
||||||
|
def test_user_units_to_enable(self):
|
||||||
|
self.assertDictEqual(
|
||||||
|
self.source.user_units_to_enable(self.store),
|
||||||
|
{"user": ["foo.service", "bar.service"]},
|
||||||
|
)
|
||||||
|
|||||||
Reference in New Issue
Block a user