diff options
-rw-r--r-- | .SRCINFO | 14 | ||||
-rw-r--r-- | PKGBUILD | 59 | ||||
-rw-r--r-- | fangfrisch-has-news.sh | 81 | ||||
-rw-r--r-- | fangfrisch.conf | 8 |
4 files changed, 130 insertions, 32 deletions
@@ -1,7 +1,7 @@ pkgbase = python-fangfrisch pkgdesc = Freshclam like utility that allows downloading unofficial virus definition files - pkgver = 1.8.1 - pkgrel = 2 + pkgver = 1.9.0 + pkgrel = 1 url = https://rseichter.github.io/fangfrisch/ install = fangfrisch.install arch = any @@ -16,15 +16,19 @@ pkgbase = python-fangfrisch provides = clamav-unofficial-sigs conflicts = clamav-unofficial-sigs backup = etc/fangfrisch/fangfrisch.conf - source = python-fangfrisch-1.8.1.tar.gz::https://github.com/rseichter/fangfrisch/archive/1.8.1.tar.gz + source = python-fangfrisch-1.9.0.tar.gz::https://github.com/rseichter/fangfrisch/archive/1.9.0.tar.gz + source = python-fangfrisch-1.9.0.tar.gz::https://files.pythonhosted.org/packages/f8/0e/9bc54127d0c3320dd10fc06db498761aaa345457e7b55fa99ce98fb9a091/fangfrisch-1.9.0.dev3.tar.gz source = fangfrisch.conf source = fangfrisch.service source = fangfrisch.timer source = fangfrisch.tmpfiles - sha512sums = a2e6552b35f29044f22fabe1ffb007da910f8a3e3a95031c3e321cec3d2c7ce4f8af7fb81aa91582c4ba37c8be9216c1a9dc2035b2e2c1e40907a6edc8ad99e0 - sha512sums = 3ad6d187e7a549f14e7fb72fcd105fda37dd85512186380caf5f71b3614fa424cc6fdad83ba8da365ff0e61e1fbfeb6bbd78e51e46a5ef86c263f90d6598fe39 + source = fangfrisch-has-news.sh + sha512sums = 08cc36f20884fedb553de905b8faafce99fcef80e3bce7c0b264691b1a8d83b91a582c095b684f6f7a6af77fd4ed0405fa771a74bbeee3f1b255ff74a161d37e + sha512sums = 08cc36f20884fedb553de905b8faafce99fcef80e3bce7c0b264691b1a8d83b91a582c095b684f6f7a6af77fd4ed0405fa771a74bbeee3f1b255ff74a161d37e + sha512sums = d36db5093a4a0187a7bbc8e6cbb4f5a029e369fbf3b129da0ebe6b5be5851b2b58df4e6986f303b3c6d37b921740e1d9707eabafa28dac01a028a61a420ce05a sha512sums = 266df243ac0a23efc2797583b9c1e09855aa43b9decabd78bc1ca8a5158c5a71ceee9f77ededc374bd17be094595acd84bea729fc7459cc71337d1029911591f sha512sums = 22462dbb76e9b1df0717efff6c94a49b1db33c150380abc0d66bccc72215eab89ab871ba6e359db817543130ae45844665fc106cae8990dbf92f8a27851d15da sha512sums = f421c4f2618422957cd203bf8f50bae1e5656d6208774244092987c07427ca86bf587884510c9180a0cb554200fdc996b0fad382671c913e6729b215b6f8e651 + sha512sums = a38ceae123732602eb1206572052a7f548a8950a608e8c07c1e7ae61123eaabbd33caa8c3b548020a8f57d842ef230b2a90aab81edb2d5db74068ca925a73413 pkgname = python-fangfrisch @@ -1,8 +1,8 @@ # Maintainer: Amish <contact at via dot aur> pkgname=python-fangfrisch _name=${pkgname#python-} -pkgver=1.8.1 -pkgrel=2 +pkgver=1.9.0 +pkgrel=1 pkgdesc="Freshclam like utility that allows downloading unofficial virus definition files" arch=('any') license=('GPL') @@ -12,41 +12,46 @@ provides=('clamav-unofficial-sigs') depends=('clamav' 'python-requests' 'python-sqlalchemy>=1.4.0') makedepends=(python-setuptools python-build python-installer python-wheel) source=("${pkgname}-${pkgver}.tar.gz::https://github.com/rseichter/fangfrisch/archive/${pkgver}.tar.gz" - "${_name}.conf" - "${_name}.service" - "${_name}.timer" - "${_name}.tmpfiles") -sha512sums=('a2e6552b35f29044f22fabe1ffb007da910f8a3e3a95031c3e321cec3d2c7ce4f8af7fb81aa91582c4ba37c8be9216c1a9dc2035b2e2c1e40907a6edc8ad99e0' - '3ad6d187e7a549f14e7fb72fcd105fda37dd85512186380caf5f71b3614fa424cc6fdad83ba8da365ff0e61e1fbfeb6bbd78e51e46a5ef86c263f90d6598fe39' + "${pkgname}-${pkgver}.tar.gz::https://files.pythonhosted.org/packages/f8/0e/9bc54127d0c3320dd10fc06db498761aaa345457e7b55fa99ce98fb9a091/fangfrisch-1.9.0.dev3.tar.gz" + "${_name}.conf" + "${_name}.service" + "${_name}.timer" + "${_name}.tmpfiles" + "fangfrisch-has-news.sh") +sha512sums=('08cc36f20884fedb553de905b8faafce99fcef80e3bce7c0b264691b1a8d83b91a582c095b684f6f7a6af77fd4ed0405fa771a74bbeee3f1b255ff74a161d37e' + '08cc36f20884fedb553de905b8faafce99fcef80e3bce7c0b264691b1a8d83b91a582c095b684f6f7a6af77fd4ed0405fa771a74bbeee3f1b255ff74a161d37e' + 'd36db5093a4a0187a7bbc8e6cbb4f5a029e369fbf3b129da0ebe6b5be5851b2b58df4e6986f303b3c6d37b921740e1d9707eabafa28dac01a028a61a420ce05a' '266df243ac0a23efc2797583b9c1e09855aa43b9decabd78bc1ca8a5158c5a71ceee9f77ededc374bd17be094595acd84bea729fc7459cc71337d1029911591f' '22462dbb76e9b1df0717efff6c94a49b1db33c150380abc0d66bccc72215eab89ab871ba6e359db817543130ae45844665fc106cae8990dbf92f8a27851d15da' - 'f421c4f2618422957cd203bf8f50bae1e5656d6208774244092987c07427ca86bf587884510c9180a0cb554200fdc996b0fad382671c913e6729b215b6f8e651') + 'f421c4f2618422957cd203bf8f50bae1e5656d6208774244092987c07427ca86bf587884510c9180a0cb554200fdc996b0fad382671c913e6729b215b6f8e651' + 'a38ceae123732602eb1206572052a7f548a8950a608e8c07c1e7ae61123eaabbd33caa8c3b548020a8f57d842ef230b2a90aab81edb2d5db74068ca925a73413') backup=('etc/fangfrisch/fangfrisch.conf') install=fangfrisch.install build() { - cd "$_name-$pkgver" || exit 1 - python -m build --wheel --no-isolation + cd "$_name-$pkgver" || exit 1 + python -m build --wheel --no-isolation } check() { - local tmp - pushd >/dev/null "$_name-$pkgver" || exit 1 - tmp="$(pwd -P)/unittest.tmp" - rm >/dev/null -fr "${tmp}" - mkdir "${tmp}" || exit 1 - # shellcheck disable=SC2064 - trap "rm -fr ${tmp}" EXIT - sed -i -e "s,/tmp/fangfrisch/unittest,${tmp},g" tests/* - sqlite3 "${tmp}"/db.sqlite < tests/tests.sql - python -m unittest discover -v tests/ - popd >/dev/null || exit 1 + local tmp + pushd >/dev/null "$_name-$pkgver" || exit 1 + tmp="$(pwd -P)/unittest.tmp" + rm >/dev/null -fr "${tmp}" + mkdir "${tmp}" || exit 1 + # shellcheck disable=SC2064 + trap "rm -fr ${tmp}" EXIT + sed -i -e "s,/tmp/fangfrisch/unittest,${tmp},g" tests/* + sqlite3 "${tmp}"/db.sqlite <tests/tests.sql + python -m unittest discover -v tests/ + popd >/dev/null || exit 1 } package() { - cd "$_name-$pkgver" || exit 1 - python -m installer --destdir="$pkgdir" dist/*.whl - install -Dm644 -t "${pkgdir}/etc/fangfrisch" "${srcdir}/${_name}.conf" - install -Dm644 -t "${pkgdir}/usr/lib/systemd/system" "${srcdir}/${_name}".{service,timer} - install -Dm644 "${srcdir}/${_name}.tmpfiles" "${pkgdir}/usr/lib/tmpfiles.d/${_name}.conf" + cd "$_name-$pkgver" || exit 1 + python -m installer --destdir="$pkgdir" dist/*.whl + install -Dm0644 "${srcdir}/${_name}.tmpfiles" "${pkgdir}/usr/lib/tmpfiles.d/${_name}.conf" + install -Dm0644 -t "${pkgdir}/usr/lib/systemd/system" "${srcdir}/${_name}".{service,timer} + install -Dm0644 -t "${pkgdir}/etc/fangfrisch" "${srcdir}/${_name}.conf" + install -Dm0750 -g clamav -t "${pkgdir}/etc/fangfrisch" "${srcdir}/fangfrisch-has-news.sh" } diff --git a/fangfrisch-has-news.sh b/fangfrisch-has-news.sh new file mode 100644 index 000000000000..81ab7c7da59e --- /dev/null +++ b/fangfrisch-has-news.sh @@ -0,0 +1,81 @@ +#!/usr/bin/env bash +# vim: ts=4 sw=4 noet ft=sh +# +# Example script to process Fangfrisch News. + +declare -r MAILFROM="noreply" +declare -r MAILTO="alice@example.com" +declare -r SUBJECT="Fangfrisch News are available" + +# Pick one of the following three options and uncomment its 'declare' statements. + +# Option 1: Mutt +#declare -r MAILAPP="mutt" +#declare -r MAILAPP_OPT=( "-s" "$SUBJECT" "$MAILTO" ) + +# Option 2: sendmail +#declare -r MAILAPP="sendmail" +#declare -r MAILAPP_OPT=( "-t" ) +#export PATH="$PATH:/usr/sbin" + +# Option 3: swaks +#declare -r MAILAPP="swaks" +#declare -r MAILAPP_OPT=( "-d" "-" "-f" "$MAILFROM" "-t" "$MAILTO" ) + +### No changes required below this line ### + +set -euo pipefail + +die() { + echo >&2 "$@" + exit 1 +} + +usage() { + die "Usage: $(basename "$0") {directory}" +} + +gen_header() { + cat <<EOT +From: Fangfrisch News <$MAILFROM> +To: $MAILTO +Subject: $SUBJECT + +EOT +# Mail header must end with an empty line! +} + +declare -a NEWSITEMS=() + +report_news() { + local dir=$1 ni + [ -d "$dir" ] || die "$dir is not a directory" + while IFS= read -r -d '' ni; do + if [ ${#NEWSITEMS[*]} -eq 0 ] && [ "$MAILAPP" != mutt ]; then + # Mutt does not need the header, others do. + gen_header + fi + NEWSITEMS+=( "$ni" ) + echo -e "\n### $(basename "$ni"):\n" + cat "$ni" + done < <(find "$dir" -maxdepth 1 -type f -name "fangfrisch*.txt" -print0) +} + +main() { + local t + [ -n "$MAILAPP" ] || die "MAILAPP is undefined, exiting." + if tty -s; then + # Running in a terminal session + t=$(mktemp) + # shellcheck disable=SC2064 + trap "rm $t" EXIT + report_news "$@" | tee "$t" || exit 1 + [ ! -s "$t" ] || "$MAILAPP" "${MAILAPP_OPT[@]}" >/dev/null <"$t" + else + report_news "$@" 2>&1 | "$MAILAPP" "${MAILAPP_OPT[@]}" >/dev/null + [ ${#NEWSITEMS[*]} -eq 0 ] || rm -v "${NEWSITEMS[@]}" + fi +} + +[ $# -ge 1 ] || usage +main "$@" diff --git a/fangfrisch.conf b/fangfrisch.conf index 54e8f5d9087e..2260e75ba533 100644 --- a/fangfrisch.conf +++ b/fangfrisch.conf @@ -19,6 +19,14 @@ db_url = sqlite:////var/lib/fangfrisch/db.sqlite local_directory = /var/lib/clamav on_update_exec = clamdscan --reload +[fangfrischnews] +enabled = yes +# The following script *must* be modified to suit +# your needs before it can be used. However, using +# the script is completely optional. +# +#script = /etc/fangfrisch/fangfrisch-has-news.sh + [sanesecurity] enabled = yes |