forked from sayan01/scripts
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpkgsync
More file actions
executable file
·34 lines (28 loc) · 904 Bytes
/
Copy pathpkgsync
File metadata and controls
executable file
·34 lines (28 loc) · 904 Bytes
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
#!/bin/bash
if test -z "$PACKLIST" ;then echo 'PACKLIST not defined' ; exit 1; fi
cd "$( dirname "$PACKLIST" )" || exit
# make temporary files to store current system state and backup pkglist
pkghere=$(mktemp pkgsyncXXXXXXX)
pkglist=$(mktemp pkgsyncXXXXXXX)
pkglist > "$pkghere"
cat "$(basename "$PACKLIST")" > "$pkglist"
# install any missing packages in this systems
inslist="$(diff "$pkghere" "$pkglist" | grep "^>" | cut -d' ' -f2 | tr '\n' ' ')"
if test -n "$inslist" ; then
echo "Installing packages: $inslist"
yay -S --needed $inslist
else
echo "Nothing to install"
fi
# then remove extra packages present:
pkglist > "$pkghere"
dellist="$(diff "$pkghere" "$pkglist" | grep "^<" | cut -d' ' -f2 | tr '\n' ' ')"
if test -n "$dellist" ; then
echo "Removing packages: $dellist"
yay -Rns $dellist
else
echo "Nothing to remove"
fi
# remove temporary files
rm "$pkglist"
rm "$pkghere"