fix: remove aur packages from pacman packages #1
2 changed files with 222 additions and 23 deletions
163
.gitignore
vendored
Normal file
163
.gitignore
vendored
Normal file
|
@ -0,0 +1,163 @@
|
||||||
|
# custom
|
||||||
|
*.toml
|
||||||
|
|
||||||
|
# Byte-compiled / optimized / DLL files
|
||||||
|
__pycache__/
|
||||||
|
*.py[cod]
|
||||||
|
*$py.class
|
||||||
|
|
||||||
|
# C extensions
|
||||||
|
*.so
|
||||||
|
|
||||||
|
# Distribution / packaging
|
||||||
|
.Python
|
||||||
|
build/
|
||||||
|
develop-eggs/
|
||||||
|
dist/
|
||||||
|
downloads/
|
||||||
|
eggs/
|
||||||
|
.eggs/
|
||||||
|
lib/
|
||||||
|
lib64/
|
||||||
|
parts/
|
||||||
|
sdist/
|
||||||
|
var/
|
||||||
|
wheels/
|
||||||
|
share/python-wheels/
|
||||||
|
*.egg-info/
|
||||||
|
.installed.cfg
|
||||||
|
*.egg
|
||||||
|
MANIFEST
|
||||||
|
|
||||||
|
# PyInstaller
|
||||||
|
# Usually these files are written by a python script from a template
|
||||||
|
# before PyInstaller builds the exe, so as to inject date/other infos into it.
|
||||||
|
*.manifest
|
||||||
|
*.spec
|
||||||
|
|
||||||
|
# Installer logs
|
||||||
|
pip-log.txt
|
||||||
|
pip-delete-this-directory.txt
|
||||||
|
|
||||||
|
# Unit test / coverage reports
|
||||||
|
htmlcov/
|
||||||
|
.tox/
|
||||||
|
.nox/
|
||||||
|
.coverage
|
||||||
|
.coverage.*
|
||||||
|
.cache
|
||||||
|
nosetests.xml
|
||||||
|
coverage.xml
|
||||||
|
*.cover
|
||||||
|
*.py,cover
|
||||||
|
.hypothesis/
|
||||||
|
.pytest_cache/
|
||||||
|
cover/
|
||||||
|
|
||||||
|
# Translations
|
||||||
|
*.mo
|
||||||
|
*.pot
|
||||||
|
|
||||||
|
# Django stuff:
|
||||||
|
*.log
|
||||||
|
local_settings.py
|
||||||
|
db.sqlite3
|
||||||
|
db.sqlite3-journal
|
||||||
|
|
||||||
|
# Flask stuff:
|
||||||
|
instance/
|
||||||
|
.webassets-cache
|
||||||
|
|
||||||
|
# Scrapy stuff:
|
||||||
|
.scrapy
|
||||||
|
|
||||||
|
# Sphinx documentation
|
||||||
|
docs/_build/
|
||||||
|
|
||||||
|
# PyBuilder
|
||||||
|
.pybuilder/
|
||||||
|
target/
|
||||||
|
|
||||||
|
# Jupyter Notebook
|
||||||
|
.ipynb_checkpoints
|
||||||
|
|
||||||
|
# IPython
|
||||||
|
profile_default/
|
||||||
|
ipython_config.py
|
||||||
|
|
||||||
|
# pyenv
|
||||||
|
# For a library or package, you might want to ignore these files since the code is
|
||||||
|
# intended to run in multiple environments; otherwise, check them in:
|
||||||
|
# .python-version
|
||||||
|
|
||||||
|
# pipenv
|
||||||
|
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
|
||||||
|
# However, in case of collaboration, if having platform-specific dependencies or dependencies
|
||||||
|
# having no cross-platform support, pipenv may install dependencies that don't work, or not
|
||||||
|
# install all needed dependencies.
|
||||||
|
#Pipfile.lock
|
||||||
|
|
||||||
|
# poetry
|
||||||
|
# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
|
||||||
|
# This is especially recommended for binary packages to ensure reproducibility, and is more
|
||||||
|
# commonly ignored for libraries.
|
||||||
|
# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
|
||||||
|
#poetry.lock
|
||||||
|
|
||||||
|
# pdm
|
||||||
|
# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
|
||||||
|
#pdm.lock
|
||||||
|
# pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it
|
||||||
|
# in version control.
|
||||||
|
# https://pdm.fming.dev/#use-with-ide
|
||||||
|
.pdm.toml
|
||||||
|
|
||||||
|
# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
|
||||||
|
__pypackages__/
|
||||||
|
|
||||||
|
# Celery stuff
|
||||||
|
celerybeat-schedule
|
||||||
|
celerybeat.pid
|
||||||
|
|
||||||
|
# SageMath parsed files
|
||||||
|
*.sage.py
|
||||||
|
|
||||||
|
# Environments
|
||||||
|
.env
|
||||||
|
.venv
|
||||||
|
env/
|
||||||
|
venv/
|
||||||
|
ENV/
|
||||||
|
env.bak/
|
||||||
|
venv.bak/
|
||||||
|
|
||||||
|
# Spyder project settings
|
||||||
|
.spyderproject
|
||||||
|
.spyproject
|
||||||
|
|
||||||
|
# Rope project settings
|
||||||
|
.ropeproject
|
||||||
|
|
||||||
|
# mkdocs documentation
|
||||||
|
/site
|
||||||
|
|
||||||
|
# mypy
|
||||||
|
.mypy_cache/
|
||||||
|
.dmypy.json
|
||||||
|
dmypy.json
|
||||||
|
|
||||||
|
# Pyre type checker
|
||||||
|
.pyre/
|
||||||
|
|
||||||
|
# pytype static type analyzer
|
||||||
|
.pytype/
|
||||||
|
|
||||||
|
# Cython debug symbols
|
||||||
|
cython_debug/
|
||||||
|
|
||||||
|
# PyCharm
|
||||||
|
# JetBrains specific template is maintained in a separate JetBrains.gitignore that can
|
||||||
|
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
|
||||||
|
# and can be added to the global gitignore or merged into this file. For a more nuclear
|
||||||
|
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
|
||||||
|
#.idea/
|
82
profiler.py
82
profiler.py
|
@ -3,46 +3,56 @@ import subprocess
|
||||||
import os
|
import os
|
||||||
import argparse
|
import argparse
|
||||||
|
|
||||||
|
|
||||||
def run_subprocess(command, verbose=False):
|
def run_subprocess(command, verbose=False):
|
||||||
try:
|
try:
|
||||||
if verbose:
|
if verbose:
|
||||||
result = subprocess.run(command)
|
result = subprocess.run(command)
|
||||||
else:
|
else:
|
||||||
result = subprocess.run(command, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
result = subprocess.run(
|
||||||
|
command, stdout=subprocess.PIPE, stderr=subprocess.PIPE
|
||||||
|
)
|
||||||
if result.returncode != 0:
|
if result.returncode != 0:
|
||||||
print(f"Error running command: {' '.join(command)}")
|
print(f"Error running command: {' '.join(command)}")
|
||||||
return result
|
return result
|
||||||
except subprocess.CalledProcessError as e:
|
except subprocess.CalledProcessError as e:
|
||||||
print(f"Subprocess error: {e}")
|
print(f"Subprocess error: {e}")
|
||||||
|
|
||||||
|
|
||||||
def install_generic_packages(command, packages):
|
def install_generic_packages(command, packages):
|
||||||
for package in packages:
|
for package in packages:
|
||||||
print(f"Installing package: {package}")
|
print(f"Installing package: {package}")
|
||||||
run_subprocess(command + [package])
|
run_subprocess(command + [package])
|
||||||
|
|
||||||
|
|
||||||
def install_packages(packages):
|
def install_packages(packages):
|
||||||
install_generic_packages(["sudo", "pacman", "-S", "--noconfirm"], packages)
|
install_generic_packages(["sudo", "pacman", "-S", "--noconfirm"], packages)
|
||||||
|
|
||||||
|
|
||||||
def install_aur_packages(aur_packages):
|
def install_aur_packages(aur_packages):
|
||||||
install_generic_packages(["paru", "-S", "--noconfirm"], aur_packages)
|
install_generic_packages(["paru", "-S", "--noconfirm"], aur_packages)
|
||||||
|
|
||||||
|
|
||||||
def install_flatpak_packages(flatpak_packages):
|
def install_flatpak_packages(flatpak_packages):
|
||||||
install_generic_packages(["flatpak", "install", "-y"], flatpak_packages)
|
install_generic_packages(["flatpak", "install", "-y"], flatpak_packages)
|
||||||
|
|
||||||
|
|
||||||
def clone_config(config):
|
def clone_config(config):
|
||||||
for app, details in config.items():
|
for app, details in config.items():
|
||||||
if app == "nvim":
|
if app == "nvim":
|
||||||
url = details['url']
|
url = details["url"]
|
||||||
target_dir = os.path.expanduser("~/.config/nvim")
|
target_dir = os.path.expanduser("~/.config/nvim")
|
||||||
print(f"Cloning Neovim config from {url} to {target_dir}")
|
print(f"Cloning Neovim config from {url} to {target_dir}")
|
||||||
run_subprocess(["git", "clone", url, target_dir])
|
run_subprocess(["git", "clone", url, target_dir])
|
||||||
|
|
||||||
|
|
||||||
def enable_systemd_services(services):
|
def enable_systemd_services(services):
|
||||||
for service in services:
|
for service in services:
|
||||||
print(f"Enabling systemd service: {service}")
|
print(f"Enabling systemd service: {service}")
|
||||||
run_subprocess(["sudo", "systemctl", "enable", service])
|
run_subprocess(["sudo", "systemctl", "enable", service])
|
||||||
run_subprocess(["sudo", "systemctl", "start", service])
|
run_subprocess(["sudo", "systemctl", "start", service])
|
||||||
|
|
||||||
|
|
||||||
def check_toml(toml_file):
|
def check_toml(toml_file):
|
||||||
try:
|
try:
|
||||||
toml.load(toml_file)
|
toml.load(toml_file)
|
||||||
|
@ -50,13 +60,21 @@ def check_toml(toml_file):
|
||||||
except toml.TomlDecodeError as e:
|
except toml.TomlDecodeError as e:
|
||||||
print(f"Error in {toml_file}: {e}")
|
print(f"Error in {toml_file}: {e}")
|
||||||
|
|
||||||
|
|
||||||
def generate_system_toml(output_file):
|
def generate_system_toml(output_file):
|
||||||
# Get Pacman packages
|
# Get Pacman packages
|
||||||
pacman_packages = subprocess.check_output(["pacman", "-Qeq"], text=True).splitlines()
|
pacman_packages = subprocess.check_output(
|
||||||
|
["pacman", "-Qeq"], text=True
|
||||||
|
).splitlines()
|
||||||
# Get AUR packages (using paru or yay, assuming paru here)
|
# Get AUR packages (using paru or yay, assuming paru here)
|
||||||
aur_packages = subprocess.check_output(["paru", "-Qmq"], text=True).splitlines()
|
aur_packages = subprocess.check_output(["paru", "-Qmq"], text=True).splitlines()
|
||||||
# Get Flatpak packages
|
# Get Flatpak packages
|
||||||
flatpak_packages = subprocess.check_output(["flatpak", "list", "--app", "--columns=application"], text=True).splitlines()
|
flatpak_packages = subprocess.check_output(
|
||||||
|
["flatpak", "list", "--app", "--columns=application"], text=True
|
||||||
|
).splitlines()
|
||||||
|
|
||||||
|
# remove aur packages from pacman packages
|
||||||
|
pacman_packages = list(set(pacman_packages) - set(aur_packages))
|
||||||
|
|
||||||
# Create TOML structure
|
# Create TOML structure
|
||||||
config = {
|
config = {
|
||||||
|
@ -83,14 +101,15 @@ def generate_system_toml(output_file):
|
||||||
|
|
||||||
print(f"TOML file saved as {output_file}")
|
print(f"TOML file saved as {output_file}")
|
||||||
|
|
||||||
|
|
||||||
def generate_file_toml(input_file, output_file):
|
def generate_file_toml(input_file, output_file):
|
||||||
config = {
|
config = {
|
||||||
"packages": {"packages": []},
|
"packages": {"packages": []},
|
||||||
"aur": {"aur_packages": []},
|
"aur": {"aur_packages": []},
|
||||||
"flatpak": {"flatpak_packages": []}
|
"flatpak": {"flatpak_packages": []},
|
||||||
}
|
}
|
||||||
|
|
||||||
with open(input_file, 'r') as file:
|
with open(input_file, "r") as file:
|
||||||
for line in file:
|
for line in file:
|
||||||
line = line.strip()
|
line = line.strip()
|
||||||
if not line or ":" not in line:
|
if not line or ":" not in line:
|
||||||
|
@ -116,7 +135,7 @@ def generate_file_toml(input_file, output_file):
|
||||||
continue
|
continue
|
||||||
|
|
||||||
# Write the config to the output TOML file
|
# Write the config to the output TOML file
|
||||||
with open(output_file, 'w') as toml_file:
|
with open(output_file, "w") as toml_file:
|
||||||
toml.dump(config, toml_file)
|
toml.dump(config, toml_file)
|
||||||
|
|
||||||
print(f"TOML file generated at: {output_file}")
|
print(f"TOML file generated at: {output_file}")
|
||||||
|
@ -133,13 +152,29 @@ def generate_file_toml(input_file, output_file):
|
||||||
|
|
||||||
print(f"TOML file saved as {output_file}")
|
print(f"TOML file saved as {output_file}")
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
parser = argparse.ArgumentParser(description="Install packages and manage configurations from a TOML file.")
|
parser = argparse.ArgumentParser(
|
||||||
parser.add_argument('--load', type=str, help='Path to the TOML file to load and install packages.')
|
description="Install packages and manage configurations from a TOML file."
|
||||||
parser.add_argument('--check', type=str, help='Path to the TOML file to check for errors.')
|
)
|
||||||
parser.add_argument('--generate-system', type=str, help='Generate a TOML file with system installed packages.')
|
parser.add_argument(
|
||||||
parser.add_argument('--generate-file', type=str, nargs=2, metavar=('input', 'output'),
|
"--load", type=str, help="Path to the TOML file to load and install packages."
|
||||||
help='Generate a TOML file from a text file. Provide input and output file paths.')
|
)
|
||||||
|
parser.add_argument(
|
||||||
|
"--check", type=str, help="Path to the TOML file to check for errors."
|
||||||
|
)
|
||||||
|
parser.add_argument(
|
||||||
|
"--generate-system",
|
||||||
|
type=str,
|
||||||
|
help="Generate a TOML file with system installed packages.",
|
||||||
|
)
|
||||||
|
parser.add_argument(
|
||||||
|
"--generate-file",
|
||||||
|
type=str,
|
||||||
|
nargs=2,
|
||||||
|
metavar=("input", "output"),
|
||||||
|
help="Generate a TOML file from a text file. Provide input and output file paths.",
|
||||||
|
)
|
||||||
|
|
||||||
args = parser.parse_args()
|
args = parser.parse_args()
|
||||||
|
|
||||||
|
@ -152,24 +187,24 @@ def main():
|
||||||
return
|
return
|
||||||
|
|
||||||
# Install packages
|
# Install packages
|
||||||
if 'packages' in config:
|
if "packages" in config:
|
||||||
install_packages(config['packages']['packages'])
|
install_packages(config["packages"]["packages"])
|
||||||
|
|
||||||
# Install AUR packages
|
# Install AUR packages
|
||||||
if 'aur' in config:
|
if "aur" in config:
|
||||||
install_aur_packages(config['aur']['aur_packages'])
|
install_aur_packages(config["aur"]["aur_packages"])
|
||||||
|
|
||||||
# Install Flatpak packages
|
# Install Flatpak packages
|
||||||
if 'flatpak' in config:
|
if "flatpak" in config:
|
||||||
install_flatpak_packages(config['flatpak']['flatpak_packages'])
|
install_flatpak_packages(config["flatpak"]["flatpak_packages"])
|
||||||
|
|
||||||
# Clone configuration
|
# Clone configuration
|
||||||
if 'config' in config:
|
if "config" in config:
|
||||||
clone_config(config['config'])
|
clone_config(config["config"])
|
||||||
|
|
||||||
# Enable systemd services
|
# Enable systemd services
|
||||||
if 'systemd' in config:
|
if "systemd" in config:
|
||||||
enable_systemd_services(config['systemd']['systemd_services'])
|
enable_systemd_services(config["systemd"]["systemd_services"])
|
||||||
|
|
||||||
elif args.check:
|
elif args.check:
|
||||||
toml_file = args.check
|
toml_file = args.check
|
||||||
|
@ -186,5 +221,6 @@ def main():
|
||||||
else:
|
else:
|
||||||
print("Please provide a valid argument.")
|
print("Please provide a valid argument.")
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
main()
|
main()
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue