From cd5eeeeacd78544203c3e6e65dcaab25ec4a965b Mon Sep 17 00:00:00 2001 From: Marc Coquand Date: Tue, 7 May 2024 12:29:18 -0500 Subject: Add xsync script --- hooks/pre-up/void | 11 +++++++++++ local/bin/xsync | 24 ++++++++++++++++++++++++ 2 files changed, 35 insertions(+) create mode 100755 hooks/pre-up/void create mode 100755 local/bin/xsync diff --git a/hooks/pre-up/void b/hooks/pre-up/void new file mode 100755 index 0000000..72f1c42 --- /dev/null +++ b/hooks/pre-up/void @@ -0,0 +1,11 @@ +#!/bin/bash + +# We'll use xpkg from xtools to find installable packages +if ! [ -x "$(command -v xpkg)" ]; then + sudo xbps-install xtools +fi + +# Set up file sync +if [ ! -f ~/repository.list ]; then + xpkg -m > ~/repository.list +fi \ No newline at end of file diff --git a/local/bin/xsync b/local/bin/xsync new file mode 100755 index 0000000..576b733 --- /dev/null +++ b/local/bin/xsync @@ -0,0 +1,24 @@ +#!/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 + +set -e + +xpkg -m | sort > /tmp/xsync-installed +cat ~/repository.list | sort > /tmp/xsync-spec + +echo $INSTALLED + +comm /tmp/xsync-spec /tmp/xsync-installed -23 > /tmp/xsync-to-install +comm /tmp/xsync-spec /tmp/xsync-installed -13 > /tmp/xsync-to-remove + +[ -s /tmp/xsync-to-remove ] && sudo xbps-remove $(cat /tmp/xsync-to-remove) || echo "Nothing to remove" + +[ -s /tmp/xsync-to-install ] && sudo xbps-install $(cat /tmp/xsync-to-install) || echo "Nothing to install" + -- cgit v1.2.3