summaryrefslogtreecommitdiff
path: root/local/bin/xsync
blob: c6108ae041ae4afb707d56022099e510ed3d0fb3 (plain)
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
#!/bin/sh
# Binary for syncing xbps with a list
#
# HOWTO:
# Make sure to install xtools and that there is a
# repository.list, which should be initialized with xpkg -m > ~/repository.list
#
# Add whatever package you want to install, and run xsync to sync your
# list of packages with the new list

usr=$(whoami)
if [ $usr = "root" ]
  then echo "Xsync run as root; please do not run privileged"
  exit 1
fi

xpkg -m | sort > /tmp/xsync-installed
cat $HOME/repository.list | sort > /tmp/xsync-spec

comm /tmp/xsync-spec /tmp/xsync-installed -23 > /tmp/xsync-to-install
comm /tmp/xsync-spec /tmp/xsync-installed -13 > /tmp/xsync-to-remove

# You can add the -n flag to dry-run and see what will happen
[ -s /tmp/xsync-to-remove ] && sudo xbps-remove $(cat /tmp/xsync-to-remove) || echo "Nothing to remove"

# You can add the -n flag to dry-run and see what will happen
[ -s /tmp/xsync-to-install ] && sudo xbps-install -S $(cat /tmp/xsync-to-install) || echo "Nothing to install"