#!/bin/bash if [ $# -eq 2 ]; then from="$1" to="$2" elif [ $# -ne 0 ]; then >&2 echo 'usage: report-installed-packages [from to]' exit 1 fi content=$( ( find '/var/lib/pacman/sync' -mindepth 1 -maxdepth 1 \ -name '*testing.db' \ -exec bsdtar -tf {} \; | \ sed -n ' /\/$/{ s|/$|| p } ' pacman -Q | \ tr ' ' '-' ) | \ sort | \ uniq -d ) content=$( cd '/var/cache/pacman/pkg' ls | \ sed 's|^\(.*\)-|\1 \0|' | \ sort -k1,1 | \ join -1 1 -2 1 -o 1.2 - <(echo "${content}") | \ xargs -r sha512sum ) if [ -z "${to}" ] || [ -z "${from}" ]; then echo "${content}" elif [ -n "${content}" ]; then gpg --list-keys --with-colons "${to}" \ | awk -F: '$1 == "fpr" {print $10}' \ | while read -r fpr; do curl -Ss 'https://archlinux32.org/keys.php?k='"${fpr}" done \ | gpg --import \ >/dev/null 2>&1 printf '%s\n' \ "From: ${from}" \ "To: ${to}" \ "Subject: $(uname -n) - report about installed i686 packages" \ "" \ "$( printf '%s\n' "${content}" | \ sed 's|^|stabilize: |' )" | \ sendmailadvanced -e -s fi