From 126676c91b4dba2ce346fe33afd1e05d423ebba3 Mon Sep 17 00:00:00 2001 From: belliash Date: Tue, 17 Jan 2012 18:28:00 +0100 Subject: [PATCH] add update notifier --- config/modules/update-notification.conf | 9 +++++++ modules/update-notification.ezmod | 35 +++++++++++++++++++++++++ 2 files changed, 44 insertions(+) create mode 100644 config/modules/update-notification.conf create mode 100644 modules/update-notification.ezmod diff --git a/config/modules/update-notification.conf b/config/modules/update-notification.conf new file mode 100644 index 0000000..67dc405 --- /dev/null +++ b/config/modules/update-notification.conf @@ -0,0 +1,9 @@ +# This array specifies a list of packages that will be checked for updates. If any from +# listed below is older than the one found in mainline Portage tree, the notification +# will be sent. +MUSTCHECK=( "my-cat/package1" "my-cat2/package2" ) + +# Specifies an e-mail address, where all notifications about packages that needs update +# will be send to. If this variable is empty, none notification will be sent at all, even +# if the modules is enabled. +UPDATE_NOTIFY="" diff --git a/modules/update-notification.ezmod b/modules/update-notification.ezmod new file mode 100644 index 0000000..c91ede6 --- /dev/null +++ b/modules/update-notification.ezmod @@ -0,0 +1,35 @@ +# Copyright 2010-2012, Asio Software Technologies +# Distributed under the terms of the GNU General Public License v3 +EZMOD_DESCRIPTION="Sends a notification about packages that need an update" +EZMOD_COMPATIBILITY="ezsync" +EZMOD_AUTHOR="Rafal Kupiec" +EZMOD_VERSION="1.0" + +ezsync_postcommit() { + local BUILDVER MAINLINEVER NEEDSUPDATE NEWER PACKAGE + local SENDMESG=0 + if [ "${UPDATE_NOTIFY}" != "" ]; then + for PACKAGE in ${MUSTCHECK[*]}; do + makeCleanDirectory ${TRASHDIR}/ebuilds + makeDirectory ${TRASHDIR}/ebuilds/build + makeDirectory ${TRASHDIR}/ebuilds/mainline + run "cp -apf ${PORTAGESDIR}/${PORTAGE_BUILD[0]}/${PACKAGE}/*.ebuild ${TRASHDIR}/ebuilds/build/" || return 1 + run "cp -apf ${PORTAGESDIR}/${PORTAGE_MAINLINE[0]}/${PACKAGE}/*.ebuild ${TRASHDIR}/ebuilds/mainline/" || return 1 + find ${TRASHDIR}/ebuilds -type f -name \*-9999\*.ebuild -exec rm -rf {} \; + BUILDVER=$(find ${TRASHDIR}/ebuilds/build -type f | sed -u -e "s/.ebuild//g" -e "s/-r/_z/g" -e "s/_p/_z/g" -e "s/_zre/_pre/" -e "s/$/_z0/" | sed "/^$/d" | sort -Vr | head -1) + BUILDVER=${BUILDVER##*/} + MAINLINEVER=$(find ${TRASHDIR}/ebuilds/mainline -type f | sed -u -e "s/.ebuild//g" -e "s/-r/_z/g" -e "s/_p/_z/g" -e "s/_zre/_pre/" -e "s/$/_z0/" | sed "/^$/d" | sort -Vr | head -1) + MAINLINEVER=${MAINLINEVER##*/} + NEWER=$(echo -e "${BUILDVER}\n${MAINLINEVER}" | sed "/^$/d" | sort -Vr | head -1) + if [[ "${NEWER}" != "${BUILDVER}" ]]; then + SENDMSG=1 + NEEDSUPDATE=${NEEDSUPDATE+"$NEEDSUPDATE, "}"${PACKAGE}" + fi + done + rm -rf ${TRASHDIR}/ebuilds + if isEnabled ${SENDMSG}; then + echo "The following packages needs your attention, because they probably has been updated in mainline Portage tree: ${NEEDSUPDATE}" | mailx -s "Packages need an update!" ${UPDATE_NOTIFY} + fi + fi + return 0 +}