Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Development #11

Merged
merged 14 commits into from
Feb 21, 2024
16 changes: 11 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
## Upd8All 🔄

Upd8All is a multi-purpose package updater tool that streamlines the process of keeping packages updated on Arch Linux. With support for Pacman, Yay, and Homebrew, Upd8All automatically handles superuser privileges when needed and notifies the user about important updates, such as the "gh" version in Homebrew. Simplify your life by keeping your system up to date with just one command.
Upd8All: Simplifying Package Updates for Arch Linux

Upd8All is a versatile and comprehensive package update tool meticulously crafted to cater to the needs of Arch Linux users. It provides a unified platform for managing package updates across various repositories, including both official Pacman repositories and the Arch User Repository (AUR),even Brew! empowering users to keep their systems up-to-date effortlessly.

<sub>* This is currently an experimental phase where the primary focus is on making the system functional and establishing a practical and logical pathway that aligns with both my vision and the project's goals. It might contain errors, bugs, etc. Many other non-core elements of the project are considered secondary.</sub>

Expand All @@ -19,11 +21,15 @@ Upd8All is a multi-purpose package updater tool that streamlines the process of

#### Features

- Supports Pacman, Yay, and Homebrew package managers.
- Automatically handles superuser privileges.
- Notifies about important updates, such as the "gh" version in Homebrew.
- Simplifies the process of keeping your system up to date with one command.
- Unified Package Management: Upd8All serves as a central hub for package management on Arch Linux systems. It seamlessly integrates with both Pacman and AUR repositories, allowing users to update all installed packages with ease. Whether updating essential system components or community-contributed packages, Upd8All offers a streamlined solution for maintaining software currency.

- Efficient Update Process: With Upd8All, updating packages on Arch Linux becomes a straightforward task. The tool automates the update process, enabling users to initiate updates with a single command. By handling privilege escalation and system updates intelligently, Upd8All ensures a smooth and hassle-free experience for users, minimizing manual intervention.

- Intuitive Command-Line Interface: Upd8All features an intuitive and user-friendly command-line interface designed to simplify package management tasks. Users can effortlessly check for available updates, perform package upgrades, and manage system software—all through simple and intuitive commands. Whether you're a seasoned Linux user or a newcomer, Upd8All makes package management accessible to everyone.

- Enhanced System Stability and Security: Keeping software up-to-date is crucial for maintaining system stability and security. Upd8All empowers users to stay ahead of potential vulnerabilities by providing timely updates for all installed packages. By ensuring that software components are patched and current, Upd8All contributes to a more secure and reliable computing environment for Arch Linux users.

- Community-Driven Development: Upd8All is a product of collaborative effort and community-driven development. Built by passionate Linux enthusiasts and developers, Upd8All embodies the spirit of open-source software, with contributions from users worldwide. The project is continuously evolving, with regular updates and improvements driven by user feedback and community engagement.

#### Installation
#### Via AUR using YAY
Expand Down
101 changes: 80 additions & 21 deletions src/upd8all_updater.py
Original file line number Diff line number Diff line change
@@ -1,41 +1,100 @@
import os
import sys
import threading
import getpass

def update_pacman():
# Function to print the welcome message
def print_welcome_message():
print("""
Welcome to the Upd8All Updater
=======================================
Description: Upd8All is a versatile and comprehensive package update tool meticulously
crafted to cater to the needs of Arch Linux users.
Creator: Felipe Alfonso Gonzalez - github.com/felipealfonsog - f.alfonso@res-ear.ch
License: BSD 3-Clause (Restrictive)
***************************************************************************
""")

# Function to update Pacman packages
def update_pacman(sudo_password):
print("Updating Pacman packages...")
command = "sudo pacman -Syu --noconfirm"
print("-------------------------------------")
command = f"echo {sudo_password} | sudo -S pacman -Syu --noconfirm"
os.system(command)

def update_yay():
# Function to update AUR packages with Yay
def update_yay(sudo_password):
print("Updating AUR packages with Yay...")
command = "yay -Syu --noconfirm"
print("-------------------------------------")
command = f"echo {sudo_password} | yay -Syu --noconfirm"
os.system(command)

# Function to update packages with Homebrew
def update_brew():
print("Updating packages with Homebrew...")
print("-------------------------------------")
command = "brew update && brew upgrade"
os.system(command)

def check_gh_update():
try:
command = "gh --version"
output = os.popen(command).read()
lines = output.splitlines()
for line in lines:
if "stable" in line and "gh" in line:
version = line.split()[1]
print(f"The updated gh version is: {version}")
except Exception as e:
print(f"Error checking gh update: {e}")
# Function to execute a command with or without sudo as needed
def execute_command_with_sudo(command, sudo_password):
if command.startswith("sudo"):
os.system(f'echo "{sudo_password}" | {command}')
else:
os.system(command)

# Function to check the version of a package in a specific package manager
def check_package_version(package, package_manager):
if package_manager == "pacman":
command = f"pacman -Qi {package} | grep Version"
elif package_manager == "yay":
command = f"yay -Si {package} | grep Version"
elif package_manager == "brew":
command = f"brew info {package} | grep -E 'stable '"
else:
print(f"Package manager {package_manager} not recognized.")
return

print(f"Checking version of {package} using {package_manager}...")
os.system(command)

# Function executed in a separate thread to show a warning message if no package name is entered within 1 minute
def timeout_warning():
print("Time's up. Program execution has ended.")
sys.exit(0)

def main():
if os.geteuid() == 0:
print("Error: Please do not run this script as root or using sudo.")
sys.exit(1)
update_pacman()
update_yay()
# Print welcome message
print_welcome_message()

# Request sudo password at the start of the program
sudo_password = getpass.getpass(prompt="Enter your sudo password: ")

# Update packages
update_pacman(sudo_password)
update_yay(sudo_password)
update_brew()
check_gh_update()

# Start timing thread
timer_thread = threading.Timer(60, timeout_warning)
timer_thread.start()

# Request package name and package manager to check its version
package = input("Enter the name of the package to check its version (e.g., gh), or 'q' to quit: ").strip().lower()

# Check if the user wants to quit
if package == 'q':
print("Exiting the program.")
timer_thread.cancel() # Cancel timer
sys.exit(0)

package_manager = input("Enter the package manager (pacman, yay, brew): ").strip().lower()

# Cancel timer if the user provides a package name
timer_thread.cancel()

# Check the version of the specified package
check_package_version(package, package_manager)

if __name__ == "__main__":
main()
101 changes: 80 additions & 21 deletions src/upd8all_updater_unstable.py
Original file line number Diff line number Diff line change
@@ -1,41 +1,100 @@
import os
import sys
import threading
import getpass

def update_pacman():
# Function to print the welcome message
def print_welcome_message():
print("""
Welcome to the Upd8All Updater
=======================================
Description: Upd8All is a versatile and comprehensive package update tool meticulously
crafted to cater to the needs of Arch Linux users.
Creator: Felipe Alfonso Gonzalez - github.com/felipealfonsog - f.alfonso@res-ear.ch
License: BSD 3-Clause (Restrictive)
***************************************************************************
""")

# Function to update Pacman packages
def update_pacman(sudo_password):
print("Updating Pacman packages...")
command = "sudo pacman -Syu --noconfirm"
print("-------------------------------------")
command = f"echo {sudo_password} | sudo -S pacman -Syu --noconfirm"
os.system(command)

def update_yay():
# Function to update AUR packages with Yay
def update_yay(sudo_password):
print("Updating AUR packages with Yay...")
command = "yay -Syu --noconfirm"
print("-------------------------------------")
command = f"echo {sudo_password} | yay -Syu --noconfirm"
os.system(command)

# Function to update packages with Homebrew
def update_brew():
print("Updating packages with Homebrew...")
print("-------------------------------------")
command = "brew update && brew upgrade"
os.system(command)

def check_gh_update():
try:
command = "gh --version"
output = os.popen(command).read()
lines = output.splitlines()
for line in lines:
if "stable" in line and "gh" in line:
version = line.split()[1]
print(f"The updated gh version is: {version}")
except Exception as e:
print(f"Error checking gh update: {e}")
# Function to execute a command with or without sudo as needed
def execute_command_with_sudo(command, sudo_password):
if command.startswith("sudo"):
os.system(f'echo "{sudo_password}" | {command}')
else:
os.system(command)

# Function to check the version of a package in a specific package manager
def check_package_version(package, package_manager):
if package_manager == "pacman":
command = f"pacman -Qi {package} | grep Version"
elif package_manager == "yay":
command = f"yay -Si {package} | grep Version"
elif package_manager == "brew":
command = f"brew info {package} | grep -E 'stable '"
else:
print(f"Package manager {package_manager} not recognized.")
return

print(f"Checking version of {package} using {package_manager}...")
os.system(command)

# Function executed in a separate thread to show a warning message if no package name is entered within 1 minute
def timeout_warning():
print("Time's up. Program execution has ended.")
sys.exit(0)

def main():
if os.geteuid() == 0:
print("Error: Please do not run this script as root or using sudo.")
sys.exit(1)
update_pacman()
update_yay()
# Print welcome message
print_welcome_message()

# Request sudo password at the start of the program
sudo_password = getpass.getpass(prompt="Enter your sudo password: ")

# Update packages
update_pacman(sudo_password)
update_yay(sudo_password)
update_brew()
check_gh_update()

# Start timing thread
timer_thread = threading.Timer(60, timeout_warning)
timer_thread.start()

# Request package name and package manager to check its version
package = input("Enter the name of the package to check its version (e.g., gh), or 'q' to quit: ").strip().lower()

# Check if the user wants to quit
if package == 'q':
print("Exiting the program.")
timer_thread.cancel() # Cancel timer
sys.exit(0)

package_manager = input("Enter the package manager (pacman, yay, brew): ").strip().lower()

# Cancel timer if the user provides a package name
timer_thread.cancel()

# Check the version of the specified package
check_package_version(package, package_manager)

if __name__ == "__main__":
main()