From ada6ea6330e27806ca98f606575f8388a7c0a9eb Mon Sep 17 00:00:00 2001 From: Felipe Date: Thu, 22 Feb 2024 00:21:37 -0300 Subject: [PATCH 01/18] Updates --- src/upd8all_updater.py | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/src/upd8all_updater.py b/src/upd8all_updater.py index f7f34a9..18d6341 100644 --- a/src/upd8all_updater.py +++ b/src/upd8all_updater.py @@ -45,8 +45,7 @@ def update_pacman(): command = "pacman -Syu --noconfirm" execute_command_with_sudo(command, sudo_password) -# Function to update AUR packages with Yay -def update_yay(): +def update_yay(sudo_password): print("\nUpdating AUR packages with Yay...") print("-------------------------------------") config_path = os.path.expanduser("~/.config/yay/") @@ -54,10 +53,8 @@ def update_yay(): config_file = os.path.join(config_path, "config.json") with open(config_file, "w") as f: json.dump({"misc": {"save": True}}, f) - command = "yay -Syu --noconfirm" - execute_command_with_sudo(command) - + execute_command_with_sudo(command, sudo_password) # Function to update packages with Homebrew def update_brew(): From 2aa016db65b446369322ebda7403723005f3654a Mon Sep 17 00:00:00 2001 From: Felipe Date: Thu, 22 Feb 2024 00:23:14 -0300 Subject: [PATCH 02/18] Updates --- src/upd8all_updater.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/upd8all_updater.py b/src/upd8all_updater.py index 18d6341..46296f6 100644 --- a/src/upd8all_updater.py +++ b/src/upd8all_updater.py @@ -45,6 +45,7 @@ def update_pacman(): command = "pacman -Syu --noconfirm" execute_command_with_sudo(command, sudo_password) +# Function to update AUR packages with Yay def update_yay(sudo_password): print("\nUpdating AUR packages with Yay...") print("-------------------------------------") @@ -56,6 +57,8 @@ def update_yay(sudo_password): command = "yay -Syu --noconfirm" execute_command_with_sudo(command, sudo_password) + + # Function to update packages with Homebrew def update_brew(): print("\nUpdating packages with Homebrew...") From feb14ba093efbf730efc11c8f32239cf65a18fa0 Mon Sep 17 00:00:00 2001 From: Felipe Date: Thu, 22 Feb 2024 00:24:26 -0300 Subject: [PATCH 03/18] Updates --- src/upd8all_updater.py | 1 - 1 file changed, 1 deletion(-) diff --git a/src/upd8all_updater.py b/src/upd8all_updater.py index 46296f6..f97645a 100644 --- a/src/upd8all_updater.py +++ b/src/upd8all_updater.py @@ -58,7 +58,6 @@ def update_yay(sudo_password): execute_command_with_sudo(command, sudo_password) - # Function to update packages with Homebrew def update_brew(): print("\nUpdating packages with Homebrew...") From c706191fc981f0e4353d8818e107abd0e4ddb77a Mon Sep 17 00:00:00 2001 From: Felipe Date: Thu, 22 Feb 2024 00:29:25 -0300 Subject: [PATCH 04/18] Updates --- src/upd8all_updater.py | 5 +++-- src/upd8all_updater_unstable.py | 10 +++++----- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/src/upd8all_updater.py b/src/upd8all_updater.py index f97645a..1378a6d 100644 --- a/src/upd8all_updater.py +++ b/src/upd8all_updater.py @@ -111,10 +111,11 @@ def main(): print() # Add a newline after entering the password # Update packages - update_pacman() + update_pacman(sudo_password) if has_yay: - update_yay() + update_yay(sudo_password) + else: print("You do not have Yay installed.") diff --git a/src/upd8all_updater_unstable.py b/src/upd8all_updater_unstable.py index f7f34a9..1378a6d 100644 --- a/src/upd8all_updater_unstable.py +++ b/src/upd8all_updater_unstable.py @@ -46,7 +46,7 @@ def update_pacman(): execute_command_with_sudo(command, sudo_password) # Function to update AUR packages with Yay -def update_yay(): +def update_yay(sudo_password): print("\nUpdating AUR packages with Yay...") print("-------------------------------------") config_path = os.path.expanduser("~/.config/yay/") @@ -54,9 +54,8 @@ def update_yay(): config_file = os.path.join(config_path, "config.json") with open(config_file, "w") as f: json.dump({"misc": {"save": True}}, f) - command = "yay -Syu --noconfirm" - execute_command_with_sudo(command) + execute_command_with_sudo(command, sudo_password) # Function to update packages with Homebrew @@ -112,10 +111,11 @@ def main(): print() # Add a newline after entering the password # Update packages - update_pacman() + update_pacman(sudo_password) if has_yay: - update_yay() + update_yay(sudo_password) + else: print("You do not have Yay installed.") From 577cdde9ccb6b1a7471b9032c1420222d499c053 Mon Sep 17 00:00:00 2001 From: Felipe Date: Thu, 22 Feb 2024 00:31:29 -0300 Subject: [PATCH 05/18] Updates --- src/upd8all_updater_unstable.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/upd8all_updater_unstable.py b/src/upd8all_updater_unstable.py index 1378a6d..44fb4ee 100644 --- a/src/upd8all_updater_unstable.py +++ b/src/upd8all_updater_unstable.py @@ -39,12 +39,13 @@ def execute_command_with_sudo(command, sudo_password): sys.exit(1) # Function to update Pacman packages -def update_pacman(): +def update_pacman(sudo_password): print("\nUpdating Pacman packages...") print("-------------------------------------") command = "pacman -Syu --noconfirm" execute_command_with_sudo(command, sudo_password) + # Function to update AUR packages with Yay def update_yay(sudo_password): print("\nUpdating AUR packages with Yay...") From 30bd43034d7e54d7b59d7e306f1fd1c05775db23 Mon Sep 17 00:00:00 2001 From: Felipe Date: Thu, 22 Feb 2024 00:34:37 -0300 Subject: [PATCH 06/18] Updates --- src/upd8all_updater_unstable.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/upd8all_updater_unstable.py b/src/upd8all_updater_unstable.py index 44fb4ee..bc16c03 100644 --- a/src/upd8all_updater_unstable.py +++ b/src/upd8all_updater_unstable.py @@ -54,7 +54,7 @@ def update_yay(sudo_password): os.makedirs(config_path, exist_ok=True) config_file = os.path.join(config_path, "config.json") with open(config_file, "w") as f: - json.dump({"misc": {"save": True}}, f) + json.dump({"misc": {"save": True}, "Sudo": False}, f) command = "yay -Syu --noconfirm" execute_command_with_sudo(command, sudo_password) From ada54bf1406e69ce7dcbaa3554b41601cca41444 Mon Sep 17 00:00:00 2001 From: Felipe Date: Thu, 22 Feb 2024 00:38:16 -0300 Subject: [PATCH 07/18] Updates --- src/upd8all_updater_unstable.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/upd8all_updater_unstable.py b/src/upd8all_updater_unstable.py index bc16c03..f1e1e52 100644 --- a/src/upd8all_updater_unstable.py +++ b/src/upd8all_updater_unstable.py @@ -54,11 +54,10 @@ def update_yay(sudo_password): os.makedirs(config_path, exist_ok=True) config_file = os.path.join(config_path, "config.json") with open(config_file, "w") as f: - json.dump({"misc": {"save": True}, "Sudo": False}, f) + json.dump({"misc": {"save": True}}, f) command = "yay -Syu --noconfirm" execute_command_with_sudo(command, sudo_password) - # Function to update packages with Homebrew def update_brew(): print("\nUpdating packages with Homebrew...") From 4e8c1d5c0990fd70193dc29ba8cc3c897096cc55 Mon Sep 17 00:00:00 2001 From: Felipe Date: Thu, 22 Feb 2024 00:39:41 -0300 Subject: [PATCH 08/18] Updates --- src/upd8all_updater_unstable.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/upd8all_updater_unstable.py b/src/upd8all_updater_unstable.py index f1e1e52..d8073ef 100644 --- a/src/upd8all_updater_unstable.py +++ b/src/upd8all_updater_unstable.py @@ -55,9 +55,14 @@ def update_yay(sudo_password): config_file = os.path.join(config_path, "config.json") with open(config_file, "w") as f: json.dump({"misc": {"save": True}}, f) + + # Set YAY_ROOT environment variable to avoid Yay warning + os.environ["YAY_ROOT"] = "/nonexistent" + command = "yay -Syu --noconfirm" execute_command_with_sudo(command, sudo_password) + # Function to update packages with Homebrew def update_brew(): print("\nUpdating packages with Homebrew...") From 6c5ad0053d40f6ff9b13f6fee4a42b588ea28bb6 Mon Sep 17 00:00:00 2001 From: Felipe Date: Thu, 22 Feb 2024 00:42:34 -0300 Subject: [PATCH 09/18] Updates --- src/upd8all_updater_unstable.py | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/src/upd8all_updater_unstable.py b/src/upd8all_updater_unstable.py index d8073ef..f7f34a9 100644 --- a/src/upd8all_updater_unstable.py +++ b/src/upd8all_updater_unstable.py @@ -39,15 +39,14 @@ def execute_command_with_sudo(command, sudo_password): sys.exit(1) # Function to update Pacman packages -def update_pacman(sudo_password): +def update_pacman(): print("\nUpdating Pacman packages...") print("-------------------------------------") command = "pacman -Syu --noconfirm" execute_command_with_sudo(command, sudo_password) - # Function to update AUR packages with Yay -def update_yay(sudo_password): +def update_yay(): print("\nUpdating AUR packages with Yay...") print("-------------------------------------") config_path = os.path.expanduser("~/.config/yay/") @@ -55,12 +54,9 @@ def update_yay(sudo_password): config_file = os.path.join(config_path, "config.json") with open(config_file, "w") as f: json.dump({"misc": {"save": True}}, f) - - # Set YAY_ROOT environment variable to avoid Yay warning - os.environ["YAY_ROOT"] = "/nonexistent" - + command = "yay -Syu --noconfirm" - execute_command_with_sudo(command, sudo_password) + execute_command_with_sudo(command) # Function to update packages with Homebrew @@ -116,11 +112,10 @@ def main(): print() # Add a newline after entering the password # Update packages - update_pacman(sudo_password) + update_pacman() if has_yay: - update_yay(sudo_password) - + update_yay() else: print("You do not have Yay installed.") From e0e8f05e1545d9786349609aa4389087aa43599e Mon Sep 17 00:00:00 2001 From: Felipe Date: Thu, 22 Feb 2024 00:44:27 -0300 Subject: [PATCH 10/18] Updates --- src/upd8all_updater_unstable.py | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/upd8all_updater_unstable.py b/src/upd8all_updater_unstable.py index f7f34a9..b31e0cd 100644 --- a/src/upd8all_updater_unstable.py +++ b/src/upd8all_updater_unstable.py @@ -54,10 +54,9 @@ def update_yay(): config_file = os.path.join(config_path, "config.json") with open(config_file, "w") as f: json.dump({"misc": {"save": True}}, f) - command = "yay -Syu --noconfirm" - execute_command_with_sudo(command) - + + execute_command_with_sudo(command, sudo_password) # Function to update packages with Homebrew def update_brew(): @@ -112,10 +111,10 @@ def main(): print() # Add a newline after entering the password # Update packages - update_pacman() + update_pacman(sudo_password) if has_yay: - update_yay() + update_yay(sudo_password) else: print("You do not have Yay installed.") From 68108c976aa03f30c6160d6ec21a060018c400fd Mon Sep 17 00:00:00 2001 From: Felipe Date: Thu, 22 Feb 2024 00:45:37 -0300 Subject: [PATCH 11/18] Updates --- src/upd8all_updater_unstable.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/upd8all_updater_unstable.py b/src/upd8all_updater_unstable.py index b31e0cd..d737b3f 100644 --- a/src/upd8all_updater_unstable.py +++ b/src/upd8all_updater_unstable.py @@ -39,14 +39,15 @@ def execute_command_with_sudo(command, sudo_password): sys.exit(1) # Function to update Pacman packages -def update_pacman(): +def update_pacman(sudo_password): print("\nUpdating Pacman packages...") print("-------------------------------------") command = "pacman -Syu --noconfirm" execute_command_with_sudo(command, sudo_password) + # Function to update AUR packages with Yay -def update_yay(): +def update_yay(sudo_password): print("\nUpdating AUR packages with Yay...") print("-------------------------------------") config_path = os.path.expanduser("~/.config/yay/") From 8211bb597833bd6ae1fbed3634eb53266acb7ccc Mon Sep 17 00:00:00 2001 From: Felipe Date: Thu, 22 Feb 2024 00:47:08 -0300 Subject: [PATCH 12/18] Updates --- src/upd8all_updater_unstable.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/upd8all_updater_unstable.py b/src/upd8all_updater_unstable.py index d737b3f..7aaa9f5 100644 --- a/src/upd8all_updater_unstable.py +++ b/src/upd8all_updater_unstable.py @@ -54,11 +54,11 @@ def update_yay(sudo_password): os.makedirs(config_path, exist_ok=True) config_file = os.path.join(config_path, "config.json") with open(config_file, "w") as f: - json.dump({"misc": {"save": True}}, f) + json.dump({"misc": {"save": True}, "Sudo": False}, f) command = "yay -Syu --noconfirm" - execute_command_with_sudo(command, sudo_password) + # Function to update packages with Homebrew def update_brew(): print("\nUpdating packages with Homebrew...") From 7973f67de672672ab06718c01cd98e066db131a1 Mon Sep 17 00:00:00 2001 From: Felipe Date: Thu, 22 Feb 2024 00:51:46 -0300 Subject: [PATCH 13/18] Updates --- src/upd8all_updater_unstable.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/upd8all_updater_unstable.py b/src/upd8all_updater_unstable.py index 7aaa9f5..eaa9180 100644 --- a/src/upd8all_updater_unstable.py +++ b/src/upd8all_updater_unstable.py @@ -54,11 +54,12 @@ def update_yay(sudo_password): os.makedirs(config_path, exist_ok=True) config_file = os.path.join(config_path, "config.json") with open(config_file, "w") as f: - json.dump({"misc": {"save": True}, "Sudo": False}, f) + json.dump({"misc": {"save": True}}, f) command = "yay -Syu --noconfirm" execute_command_with_sudo(command, sudo_password) + # Function to update packages with Homebrew def update_brew(): print("\nUpdating packages with Homebrew...") From f07ef5eb159696afdea24af02e1ab8717f109d69 Mon Sep 17 00:00:00 2001 From: Felipe Date: Thu, 22 Feb 2024 00:53:13 -0300 Subject: [PATCH 14/18] Updates --- src/upd8all_updater_unstable.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/upd8all_updater_unstable.py b/src/upd8all_updater_unstable.py index eaa9180..0373cdd 100644 --- a/src/upd8all_updater_unstable.py +++ b/src/upd8all_updater_unstable.py @@ -54,7 +54,7 @@ def update_yay(sudo_password): os.makedirs(config_path, exist_ok=True) config_file = os.path.join(config_path, "config.json") with open(config_file, "w") as f: - json.dump({"misc": {"save": True}}, f) + json.dump({"misc": {"save": True}, "Sudo": False}, f) command = "yay -Syu --noconfirm" execute_command_with_sudo(command, sudo_password) From b06995dab99c61638b37099c6d4806ef8931dd62 Mon Sep 17 00:00:00 2001 From: Felipe Date: Thu, 22 Feb 2024 00:57:13 -0300 Subject: [PATCH 15/18] Updates --- src/upd8all_updater.py | 10 +++++----- src/upd8all_updater_unstable.py | 6 ++++-- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/src/upd8all_updater.py b/src/upd8all_updater.py index 1378a6d..f7f34a9 100644 --- a/src/upd8all_updater.py +++ b/src/upd8all_updater.py @@ -46,7 +46,7 @@ def update_pacman(): execute_command_with_sudo(command, sudo_password) # Function to update AUR packages with Yay -def update_yay(sudo_password): +def update_yay(): print("\nUpdating AUR packages with Yay...") print("-------------------------------------") config_path = os.path.expanduser("~/.config/yay/") @@ -54,8 +54,9 @@ def update_yay(sudo_password): config_file = os.path.join(config_path, "config.json") with open(config_file, "w") as f: json.dump({"misc": {"save": True}}, f) + command = "yay -Syu --noconfirm" - execute_command_with_sudo(command, sudo_password) + execute_command_with_sudo(command) # Function to update packages with Homebrew @@ -111,11 +112,10 @@ def main(): print() # Add a newline after entering the password # Update packages - update_pacman(sudo_password) + update_pacman() if has_yay: - update_yay(sudo_password) - + update_yay() else: print("You do not have Yay installed.") diff --git a/src/upd8all_updater_unstable.py b/src/upd8all_updater_unstable.py index 0373cdd..2541c78 100644 --- a/src/upd8all_updater_unstable.py +++ b/src/upd8all_updater_unstable.py @@ -47,15 +47,17 @@ def update_pacman(sudo_password): # Function to update AUR packages with Yay -def update_yay(sudo_password): +def update_yay(): print("\nUpdating AUR packages with Yay...") print("-------------------------------------") config_path = os.path.expanduser("~/.config/yay/") os.makedirs(config_path, exist_ok=True) config_file = os.path.join(config_path, "config.json") with open(config_file, "w") as f: - json.dump({"misc": {"save": True}, "Sudo": False}, f) + json.dump({"misc": {"save": True}}, f) + command = "yay -Syu --noconfirm" + execute_command_with_sudo(command, sudo_password) From ef8c26567c9cf28f65c062e2c644bd19f8e4b68a Mon Sep 17 00:00:00 2001 From: Felipe Date: Thu, 22 Feb 2024 00:57:54 -0300 Subject: [PATCH 16/18] Updates --- src/upd8all_updater_unstable.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/upd8all_updater_unstable.py b/src/upd8all_updater_unstable.py index 2541c78..aebe99f 100644 --- a/src/upd8all_updater_unstable.py +++ b/src/upd8all_updater_unstable.py @@ -47,7 +47,7 @@ def update_pacman(sudo_password): # Function to update AUR packages with Yay -def update_yay(): +def update_yay(sudo_password): print("\nUpdating AUR packages with Yay...") print("-------------------------------------") config_path = os.path.expanduser("~/.config/yay/") From aa5c5bf8f3be122fd49a6481768b428bdc551a39 Mon Sep 17 00:00:00 2001 From: Felipe Date: Thu, 22 Feb 2024 01:01:48 -0300 Subject: [PATCH 17/18] Updates --- src/upd8all_updater_unstable.py | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/src/upd8all_updater_unstable.py b/src/upd8all_updater_unstable.py index aebe99f..5385366 100644 --- a/src/upd8all_updater_unstable.py +++ b/src/upd8all_updater_unstable.py @@ -57,8 +57,20 @@ def update_yay(sudo_password): json.dump({"misc": {"save": True}}, f) command = "yay -Syu --noconfirm" - - execute_command_with_sudo(command, sudo_password) + + # Verificar si se necesita sudo para el comando Yay + need_sudo = False + try: + subprocess.run(command.split(), stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, check=True) + except subprocess.CalledProcessError: + need_sudo = True + + if need_sudo: + # Ejecutar el comando Yay con sudo si es necesario + execute_command_with_sudo(command, sudo_password) + else: + # Ejecutar el comando Yay directamente sin sudo + os.system(command) From bed3bbbe4abc8779338b8855b1bebb87ddae3545 Mon Sep 17 00:00:00 2001 From: Felipe Date: Thu, 22 Feb 2024 01:03:17 -0300 Subject: [PATCH 18/18] Updates --- src/upd8all_updater.py | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-) diff --git a/src/upd8all_updater.py b/src/upd8all_updater.py index f7f34a9..5385366 100644 --- a/src/upd8all_updater.py +++ b/src/upd8all_updater.py @@ -39,14 +39,15 @@ def execute_command_with_sudo(command, sudo_password): sys.exit(1) # Function to update Pacman packages -def update_pacman(): +def update_pacman(sudo_password): print("\nUpdating Pacman packages...") print("-------------------------------------") command = "pacman -Syu --noconfirm" execute_command_with_sudo(command, sudo_password) + # Function to update AUR packages with Yay -def update_yay(): +def update_yay(sudo_password): print("\nUpdating AUR packages with Yay...") print("-------------------------------------") config_path = os.path.expanduser("~/.config/yay/") @@ -56,7 +57,21 @@ def update_yay(): json.dump({"misc": {"save": True}}, f) command = "yay -Syu --noconfirm" - execute_command_with_sudo(command) + + # Verificar si se necesita sudo para el comando Yay + need_sudo = False + try: + subprocess.run(command.split(), stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, check=True) + except subprocess.CalledProcessError: + need_sudo = True + + if need_sudo: + # Ejecutar el comando Yay con sudo si es necesario + execute_command_with_sudo(command, sudo_password) + else: + # Ejecutar el comando Yay directamente sin sudo + os.system(command) + # Function to update packages with Homebrew @@ -112,10 +127,10 @@ def main(): print() # Add a newline after entering the password # Update packages - update_pacman() + update_pacman(sudo_password) if has_yay: - update_yay() + update_yay(sudo_password) else: print("You do not have Yay installed.")