From f8db15adc49c13fb6cf89cabb1ce5f3a4c255d15 Mon Sep 17 00:00:00 2001 From: Vitor Lopes Date: Sun, 21 Jun 2020 17:24:29 +0100 Subject: [PATCH 1/8] add pamac support --- src/modules/packages/main.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/modules/packages/main.py b/src/modules/packages/main.py index 3e29d72e1..6d81f9fe4 100644 --- a/src/modules/packages/main.py +++ b/src/modules/packages/main.py @@ -309,6 +309,24 @@ class PMPacman(PackageManager): def update_system(self): check_target_env_call(["pacman", "-Su", "--noconfirm"]) + + +class PMPamac(PackageManager): + backend = "pamac" + + def install(self, pkgs, from_local=False): + pamac_flags = "install" + + check_target_env_call([backend, pamac_flags + pkgs) + + def remove(self, pkgs): + check_target_env_call([backend, "remove"] + pkgs) + + def update_db(self): + check_target_env_call([backend, "update"]) + + def update_system(self): + check_target_env_call([backend, "upgrade"]) class PMPortage(PackageManager): From 75bba349bed99b1b65cad8079c4c22afd185060f Mon Sep 17 00:00:00 2001 From: Vitor Lopes Date: Sun, 21 Jun 2020 18:03:21 +0100 Subject: [PATCH 2/8] Update main.py --- src/modules/packages/main.py | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/src/modules/packages/main.py b/src/modules/packages/main.py index 6d81f9fe4..633cb3a0f 100644 --- a/src/modules/packages/main.py +++ b/src/modules/packages/main.py @@ -313,20 +313,31 @@ class PMPacman(PackageManager): class PMPamac(PackageManager): backend = "pamac" + + def check_db_lock(self, lock="/var/lib/pacman/db.lck"): + # In case some error or crash, the database will be locked, + # resulting in remaining packages not being installed. + import os + if os.path.exists(lock): + check_target_env_call(["rm", lock) def install(self, pkgs, from_local=False): + self.check_db_lock() pamac_flags = "install" - check_target_env_call([backend, pamac_flags + pkgs) + check_target_env_call([backend, pamac_flags, "--no-confirm"] + pkgs) def remove(self, pkgs): - check_target_env_call([backend, "remove"] + pkgs) + self.check_db_lock() + check_target_env_call([backend, "remove", "--no-confirm"] + pkgs) def update_db(self): - check_target_env_call([backend, "update"]) + self.check_db_lock() + check_target_env_call([backend, "update", "--no-confirm"]) def update_system(self): - check_target_env_call([backend, "upgrade"]) + self.check_db_lock() + check_target_env_call([backend, "upgrade", "--no-confirm"]) class PMPortage(PackageManager): From 5bb49e252d1f15555befa7aba6724744e5488cce Mon Sep 17 00:00:00 2001 From: Vitor Lopes Date: Sun, 21 Jun 2020 18:28:17 +0100 Subject: [PATCH 3/8] Update main.py --- src/modules/packages/main.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/modules/packages/main.py b/src/modules/packages/main.py index 633cb3a0f..1f4cef986 100644 --- a/src/modules/packages/main.py +++ b/src/modules/packages/main.py @@ -319,7 +319,7 @@ class PMPamac(PackageManager): # resulting in remaining packages not being installed. import os if os.path.exists(lock): - check_target_env_call(["rm", lock) + check_target_env_call(["rm", lock]) def install(self, pkgs, from_local=False): self.check_db_lock() From ddfd12019772929f8641645cd8368079263b30c8 Mon Sep 17 00:00:00 2001 From: Vitor Lopes Date: Sun, 21 Jun 2020 23:43:31 +0100 Subject: [PATCH 4/8] add missing self --- src/modules/packages/main.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/modules/packages/main.py b/src/modules/packages/main.py index 1f4cef986..f2fd135a4 100644 --- a/src/modules/packages/main.py +++ b/src/modules/packages/main.py @@ -325,19 +325,19 @@ class PMPamac(PackageManager): self.check_db_lock() pamac_flags = "install" - check_target_env_call([backend, pamac_flags, "--no-confirm"] + pkgs) + check_target_env_call([self.backend, pamac_flags, "--no-confirm"] + pkgs) def remove(self, pkgs): self.check_db_lock() - check_target_env_call([backend, "remove", "--no-confirm"] + pkgs) + check_target_env_call([self.backend, "remove", "--no-confirm"] + pkgs) def update_db(self): self.check_db_lock() - check_target_env_call([backend, "update", "--no-confirm"]) + check_target_env_call([self.backend, "update", "--no-confirm"]) def update_system(self): self.check_db_lock() - check_target_env_call([backend, "upgrade", "--no-confirm"]) + check_target_env_call([self.backend, "upgrade", "--no-confirm"]) class PMPortage(PackageManager): From 976150bc1e86ce0f033771bbd52e945910aaa4a9 Mon Sep 17 00:00:00 2001 From: Vitor Lopes Date: Mon, 22 Jun 2020 00:12:02 +0100 Subject: [PATCH 5/8] simplify install code --- src/modules/packages/main.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/modules/packages/main.py b/src/modules/packages/main.py index f2fd135a4..b2000ab14 100644 --- a/src/modules/packages/main.py +++ b/src/modules/packages/main.py @@ -322,10 +322,8 @@ class PMPamac(PackageManager): check_target_env_call(["rm", lock]) def install(self, pkgs, from_local=False): - self.check_db_lock() - pamac_flags = "install" - - check_target_env_call([self.backend, pamac_flags, "--no-confirm"] + pkgs) + self.check_db_lock() + check_target_env_call([self.backend, "install", "--no-confirm"] + pkgs) def remove(self, pkgs): self.check_db_lock() From d78cbfc6446a5934abf9017b3f9929a739700afb Mon Sep 17 00:00:00 2001 From: Vitor Lopes Date: Sun, 5 Jul 2020 08:18:38 +0100 Subject: [PATCH 6/8] update example configurations and schema --- src/modules/packages/packages.conf | 1 + src/modules/packages/packages.schema.yaml | 1 + 2 files changed, 2 insertions(+) diff --git a/src/modules/packages/packages.conf b/src/modules/packages/packages.conf index bcf313972..738117ea4 100644 --- a/src/modules/packages/packages.conf +++ b/src/modules/packages/packages.conf @@ -11,6 +11,7 @@ # - urpmi - Mandriva package manager # - yum - Yum RPM frontend # - zypp - Zypp RPM frontend +# - pamac - Manjaro package manager # # Not actually a package manager, but suitable for testing: # - dummy - Dummy manager, only logs diff --git a/src/modules/packages/packages.schema.yaml b/src/modules/packages/packages.schema.yaml index 40f82bb35..cdb2fefdf 100644 --- a/src/modules/packages/packages.schema.yaml +++ b/src/modules/packages/packages.schema.yaml @@ -17,6 +17,7 @@ properties: - urpmi - yum - zypp + - pamac - dummy update_db: { type: boolean, default: true } From e29462bc05c08a18d37dd4addcf0be189eef0103 Mon Sep 17 00:00:00 2001 From: Vitor Lopes Date: Sun, 5 Jul 2020 08:35:52 +0100 Subject: [PATCH 7/8] [pamac] rework db_lock --- src/modules/packages/main.py | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/src/modules/packages/main.py b/src/modules/packages/main.py index b2000ab14..b1a94697e 100644 --- a/src/modules/packages/main.py +++ b/src/modules/packages/main.py @@ -309,32 +309,30 @@ class PMPacman(PackageManager): def update_system(self): check_target_env_call(["pacman", "-Su", "--noconfirm"]) - - + + class PMPamac(PackageManager): backend = "pamac" - - def check_db_lock(self, lock="/var/lib/pacman/db.lck"): + + def del_db_lock(self, lock="/var/lib/pacman/db.lck"): # In case some error or crash, the database will be locked, # resulting in remaining packages not being installed. - import os - if os.path.exists(lock): - check_target_env_call(["rm", lock]) + check_target_env_call(["rm", "-f", lock]) def install(self, pkgs, from_local=False): - self.check_db_lock() + self.del_db_lock() check_target_env_call([self.backend, "install", "--no-confirm"] + pkgs) def remove(self, pkgs): - self.check_db_lock() + self.del_db_lock() check_target_env_call([self.backend, "remove", "--no-confirm"] + pkgs) def update_db(self): - self.check_db_lock() + self.del_db_lock() check_target_env_call([self.backend, "update", "--no-confirm"]) def update_system(self): - self.check_db_lock() + self.del_db_lock() check_target_env_call([self.backend, "upgrade", "--no-confirm"]) From c16866fb885f98d047f208b916e14833733e293d Mon Sep 17 00:00:00 2001 From: Vitor Lopes Date: Sun, 5 Jul 2020 08:37:28 +0100 Subject: [PATCH 8/8] pep8 302 --- src/modules/packages/main.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/modules/packages/main.py b/src/modules/packages/main.py index b1a94697e..4f746dccc 100644 --- a/src/modules/packages/main.py +++ b/src/modules/packages/main.py @@ -178,6 +178,7 @@ class PMPackageKit(PackageManager): def update_system(self): check_target_env_call(["pkcon", "-py", "update"]) + class PMZypp(PackageManager): backend = "zypp" @@ -198,6 +199,7 @@ class PMZypp(PackageManager): # Doesn't need to update the system explicitly pass + class PMYum(PackageManager): backend = "yum" @@ -215,6 +217,7 @@ class PMYum(PackageManager): def update_system(self): check_target_env_call(["yum", "-y", "upgrade"]) + class PMDnf(PackageManager): backend = "dnf" @@ -274,6 +277,7 @@ class PMApt(PackageManager): # Doesn't need to update the system explicitly pass + class PMXbps(PackageManager): backend = "xbps" @@ -289,6 +293,7 @@ class PMXbps(PackageManager): def update_system(self): check_target_env_call(["xbps", "-Suy"]) + class PMPacman(PackageManager): backend = "pacman"