-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathpkgdump
More file actions
executable file
·45 lines (39 loc) · 1.51 KB
/
pkgdump
File metadata and controls
executable file
·45 lines (39 loc) · 1.51 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#!/usr/bin/env bash
# Written by: crossroads1112
#
# Purpose: This script dumps a list of your installed packages and packages built from the AUR and pushes those files to a git repository.
# NOTE: This script requires that you have a git repo already setup. I would recommend putting this script in /etc/cron.weekly
# Then install cronie from the official repos and enable it with systemd (systemctl enable cronie && systemctl start cronie) and that's all folks
#
#
#
########################################
dotfilesdir=~/.dotfiles # change this to your dotfiles directory
force=0
change=0
while getopts "f" OPT; do
case "${OPT}" in
f) force=1 ;;
*) echo "Unrecognized argument";;
esac
done
if [[ ! -d $dotfilesdir/.git ]];then
echo "You must set up a git repo first. I'd recommend taking a look at this quide http://blog.smalleycreative.com/tutorials/using-git-and-github-to-manage-your-dotfiles/"
exit 1
fi
pacman -Qqne > $dotfilesdir/pacman_pkgs #Dump package list from official repos
pacman -Qqme > $dotfilesdir/aur_pkgs #Dump package list not from oficial repos
cd $dotfilesdir
for i in pacman_pkgs aur_pkgs; do
if [[ -n $(git diff $i) ]]; then #Only run git add if there is a difference between local and remote files
git add $i
change=1
else
echo -e "\e[0;32mNo change in ${i}. Ignoring\e[0m"
fi
done
change=$((force || change))
if (( change )); then #If there was a difference, commit and push
git commit -vm "Pkgdump script"
git push origin master
fi