update/makefile
2024-09-08 16:36:19 +02:00

33 lines
1.1 KiB
Makefile

IGREEN := \033[0;92m
NO_COLOR := \033[0m
help:
@echo "Usage: make [OPTION]"
@echo "Available options are:"
@echo "help"
@echo "compile"
@echo "install This will also compile"
@echo "uninstall"
compile:
@echo -e "$(IGREEN)==> Compiling backup$(NO_COLOR)"
go build .
install: compile
@echo -e "$(IGREEN)==> Copying the hooks into /etc/pacman.d/hooks$(NO_COLOR)"
[[ -d /etc/pacman.d/hooks ]] || sudo mkdir /etc/pacman.d/hooks
sudo cp pre_backup.hook post_backup.hook /etc/pacman.d/hooks
@echo -e "$(IGREEN)==> Copying backup into /usr/local/bin$(NO_COLOR)"
sudo install -Dm755 backup /usr/local/bin/backup
@echo -e "$(IGREEN)==> Copying the config into /etc$(NO_COLOR)"
[[ -f /etc/update.toml ]] || sudo cp update.toml /etc
@echo -e "$(IGREEN)==> Finished.$(NO_COLOR)"
uninstall:
@echo -e "$(IGREEN)==> Removing the hooks from /etc/pacman.d/hooks$(NO_COLOR)"
sudo rm /etc/pacman.d/hooks/pre_backup.hook /etc/pacman.d/hooks/post_backup.hook
@echo -e "$(IGREEN)==> Removing backup into /usr/local/bin$(NO_COLOR)"
sudo rm /usr/local/bin/backup
@echo -e "$(IGREEN)==> /etc/update.toml will remain$(NO_COLOR)"
@echo -e "$(IGREEN)==> Finished.$(NO_COLOR)"