Skip to content

Commit

Permalink
Merge pull request #25 from felipealfonsog/development
Browse files Browse the repository at this point in the history
Development
  • Loading branch information
felipealfonsog committed Feb 22, 2024
2 parents a075d70 + bed3bbb commit 8d709b3
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 10 deletions.
25 changes: 20 additions & 5 deletions src/upd8all_updater.py
Original file line number Diff line number Diff line change
Expand Up @@ -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/")
Expand All @@ -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
Expand Down Expand Up @@ -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.")

Expand Down
25 changes: 20 additions & 5 deletions src/upd8all_updater_unstable.py
Original file line number Diff line number Diff line change
Expand Up @@ -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/")
Expand All @@ -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
Expand Down Expand Up @@ -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.")

Expand Down

0 comments on commit 8d709b3

Please sign in to comment.