2025-10-17 23:01:34 +02:00
|
|
|
.PHONY: install setup uninstall aur_builder_setup
|
2025-04-01 15:37:07 +02:00
|
|
|
|
|
|
|
|
setup: install
|
2025-10-17 22:38:17 +02:00
|
|
|
@python3 main.py install
|
2025-04-01 15:37:07 +02:00
|
|
|
|
2025-12-03 16:09:42 +01:00
|
|
|
test:
|
|
|
|
|
docker build -t package-manager-test .
|
|
|
|
|
docker run --rm --entrypoint python package-manager-test -m unittest discover -s tests -p "test_*.py"
|
|
|
|
|
|
2025-04-01 15:37:07 +02:00
|
|
|
install:
|
|
|
|
|
@echo "Making 'main.py' executable..."
|
|
|
|
|
@chmod +x main.py
|
2025-04-27 22:38:52 +02:00
|
|
|
@echo "Checking if global user virtual environment exists..."
|
2025-10-17 22:38:17 +02:00
|
|
|
@mkdir -p ~/.venvs
|
|
|
|
|
@if [ ! -d ~/.venvs/pkgmgr ]; then \
|
|
|
|
|
echo "Creating global venv at ~/.venvs/pkgmgr..."; \
|
|
|
|
|
python3 -m venv ~/.venvs/pkgmgr; \
|
|
|
|
|
fi
|
2025-04-27 22:38:52 +02:00
|
|
|
@echo "Installing required Python packages into ~/.venvs/pkgmgr..."
|
2025-10-17 22:38:17 +02:00
|
|
|
@~/.venvs/pkgmgr/bin/python -m ensurepip --upgrade
|
|
|
|
|
@~/.venvs/pkgmgr/bin/pip install --upgrade pip setuptools wheel
|
2025-04-27 22:38:52 +02:00
|
|
|
@~/.venvs/pkgmgr/bin/pip install -r requirements.txt
|
2025-08-08 09:38:18 +02:00
|
|
|
@echo "Ensuring ~/.bashrc and ~/.zshrc exist..."
|
|
|
|
|
@touch ~/.bashrc ~/.zshrc
|
2025-04-27 22:38:52 +02:00
|
|
|
@echo "Ensuring automatic activation of ~/.venvs/pkgmgr for this user..."
|
2025-08-08 09:38:18 +02:00
|
|
|
@for rc in ~/.bashrc ~/.zshrc; do \
|
|
|
|
|
rc_line='if [ -d "$${HOME}/.venvs/pkgmgr" ]; then . "$${HOME}/.venvs/pkgmgr/bin/activate"; echo "Global Python virtual environment '\''~/.venvs/pkgmgr'\'' activated."; fi'; \
|
|
|
|
|
grep -qxF "$${rc_line}" $$rc || echo "$${rc_line}" >> $$rc; \
|
|
|
|
|
done
|
2025-10-17 23:01:34 +02:00
|
|
|
@echo "Arch/Manjaro detection and optional AUR setup..."
|
|
|
|
|
@if command -v pacman >/dev/null 2>&1; then \
|
|
|
|
|
$(MAKE) aur_builder_setup; \
|
|
|
|
|
else \
|
|
|
|
|
echo "Not Arch-based (no pacman). Skipping aur_builder/yay setup."; \
|
|
|
|
|
fi
|
2025-08-08 09:38:18 +02:00
|
|
|
@echo "Installation complete. Please restart your shell (or 'exec bash' or 'exec zsh') for the changes to take effect."
|
2025-04-27 22:38:52 +02:00
|
|
|
|
2025-10-17 23:01:34 +02:00
|
|
|
# Only runs on Arch/Manjaro
|
|
|
|
|
aur_builder_setup:
|
|
|
|
|
@echo "Setting up aur_builder and yay (Arch/Manjaro)..."
|
|
|
|
|
@sudo pacman -Syu --noconfirm
|
|
|
|
|
@sudo pacman -S --needed --noconfirm base-devel git sudo
|
|
|
|
|
@# group & user
|
|
|
|
|
@if ! getent group aur_builder >/dev/null; then sudo groupadd -r aur_builder; fi
|
|
|
|
|
@if ! id -u aur_builder >/dev/null 2>&1; then sudo useradd -m -r -g aur_builder -s /bin/bash aur_builder; fi
|
|
|
|
|
@# sudoers rule for pacman
|
|
|
|
|
@echo '%aur_builder ALL=(ALL) NOPASSWD: /usr/bin/pacman' | sudo tee /etc/sudoers.d/aur_builder >/dev/null
|
|
|
|
|
@sudo chmod 0440 /etc/sudoers.d/aur_builder
|
|
|
|
|
@# yay install (if missing)
|
|
|
|
|
@if ! sudo -u aur_builder bash -lc 'command -v yay >/dev/null'; then \
|
|
|
|
|
sudo -u aur_builder bash -lc 'cd ~ && rm -rf yay && git clone https://aur.archlinux.org/yay.git && cd yay && makepkg -si --noconfirm'; \
|
|
|
|
|
else \
|
|
|
|
|
echo "yay already installed."; \
|
|
|
|
|
fi
|
|
|
|
|
@echo "aur_builder/yay setup complete."
|
|
|
|
|
|
2025-04-27 22:38:52 +02:00
|
|
|
uninstall:
|
|
|
|
|
@echo "Removing global user virtual environment if it exists..."
|
|
|
|
|
@rm -rf ~/.venvs/pkgmgr
|
2025-08-08 09:38:18 +02:00
|
|
|
@echo "Cleaning up ~/.bashrc and ~/.zshrc entries..."
|
|
|
|
|
@for rc in ~/.bashrc ~/.zshrc; do \
|
|
|
|
|
sed -i '/\.venvs\/pkgmgr\/bin\/activate"; echo "Global Python virtual environment '\''~\/\.venvs\/pkgmgr'\'' activated."; fi/d' $$rc; \
|
|
|
|
|
done
|
|
|
|
|
@echo "Uninstallation complete. Please restart your shell (or 'exec bash' or 'exec zsh') for the changes to fully apply."
|