bootstrap: Switch package list to tsv
Package list is now a single tab separated list. That should make several automations in the future much simpler. The table is built as follows: `Name Description Source Target` with one line per package. Source denotes official repositories or AUR, and target is kept for future potential of creating different deployments per target automatically (e.g. different package list for desktop and server, and so on). There is an updater script `bootstrap/update_package_list.sh` which will automatically populate the table, removing uninstalled packages, adding new ones and (making its best attempt to be) keeping the selected targets as they are. The git commit hook comparing installed and committed packages has also been rewritten to use the new table and be a little simpler overall. Fixes #2.
This commit is contained in:
parent
0a9271ffe8
commit
280fab6ad3
6 changed files with 374 additions and 356 deletions
|
|
@ -1,59 +1,27 @@
|
|||
#!/usr/bin/env sh
|
||||
#!/usr/bin/env bash
|
||||
|
||||
COMMIT_MSG_FILE="$1"
|
||||
COMMIT_SOURCE="$2"
|
||||
|
||||
BOOTSTRAPDIR="bootstrap"
|
||||
pkgfileloc="$(git rev-parse --show-toplevel)/$BOOTSTRAPDIR/packages.txt"
|
||||
pkgignoreloc="$(git rev-parse --show-toplevel)/$BOOTSTRAPDIR/packages_ignore.txt"
|
||||
listgen="paru"
|
||||
pkg_committed="$(cat $(git rev-parse --show-toplevel)/$BOOTSTRAPDIR/packages.tsv | tail +2 | cut -f1 | sort)"
|
||||
pkg_onsystem=$(pacman -Qqett | grep -v "$(pacman -Qqg base-devel)" | sort)
|
||||
|
||||
err() {
|
||||
printf "\x1b[33mCAUTION:\x1b[0m %s\n" "$*"
|
||||
exit 1
|
||||
}
|
||||
|
||||
if [ ! -f "$pkgfileloc" ]; then
|
||||
err "File not found - $pkgfileloc, can not determine package differences!"
|
||||
fi
|
||||
|
||||
if ! type "$listgen" >/dev/null 2>&1; then
|
||||
err "List generator not installed on machine, can not reliably determine package differences!"
|
||||
fi
|
||||
|
||||
# get commited packages, remove empty lines
|
||||
# and lines beginning with # to allow comments
|
||||
pkgcommited=$(mktemp)
|
||||
sed -e '/^[#$]/d' <"$pkgfileloc" | sort >"$pkgcommited"
|
||||
|
||||
# get packages on this machine
|
||||
# q removes extraneous info
|
||||
# e only lists explicitly installed
|
||||
# tt removes those that are depended on, but NOT those optionally depended on
|
||||
pkgcurrent=$("$listgen" -Qqett | sort)
|
||||
# remove those listed in package_ignore.txt
|
||||
if [ -f "$pkgignoreloc" ]; then
|
||||
pkgcurrent=$(echo "$pkgcurrent" | comm -23 - "$pkgignoreloc")
|
||||
fi
|
||||
|
||||
# compare the lists, list differences
|
||||
result=$(echo "$pkgcurrent" | comm -3 - "$pkgcommited")
|
||||
|
||||
# get files only in repo (field1), and only on machine (field2)
|
||||
added=$(echo "$result" | cut -f1 | sed -e '/^$/d')
|
||||
removed=$(echo "$result" | cut -s -f2)
|
||||
# get files only in repo, and only on machine
|
||||
only_committed=$(comm -23 <(echo "$pkg_committed") <(echo "$pkg_onsystem"))
|
||||
only_onsystem=$(comm -13 <(echo "$pkg_committed") <(echo "$pkg_onsystem"))
|
||||
|
||||
# if we have no changes, do nothing
|
||||
if [ -n "$added" ] || [ -n "$removed" ]; then
|
||||
text=$(printf "\-- PACKAGE DIFFERENCES TO COMMITED LIST FOUND --\nPackages NOT YET in repo:\n%s\n\nPackages ONLY in repo:%s\n" "$added" "$removed" | sed 's/^/# /gm')
|
||||
if [ -n "$only_onsystem" ] || [ -n "$only_committed" ]; then
|
||||
text=$(printf "\-- PACKAGE CHANGES --\nPackages on machine but not committed:\n%s\n\nPackages committed but not on machine:\n%s\n" "$only_onsystem" "$only_committed" | sed 's/^/# /gm')
|
||||
else
|
||||
exit 0
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# prepend package changes to message
|
||||
case $COMMIT_SOURCE in
|
||||
"" | message, | template,)
|
||||
msg=$(echo "$text" | cat - "$COMMIT_MSG_FILE")
|
||||
printf "%s" "$msg" >"$COMMIT_MSG_FILE"
|
||||
;;
|
||||
msg=$(echo "$text" | cat - "$COMMIT_MSG_FILE")
|
||||
printf "%s" "$msg" >"$COMMIT_MSG_FILE"
|
||||
;;
|
||||
esac
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue