Browse Source

add update notifier

master
belliash 7 years ago
parent
commit
126676c91b
2 changed files with 44 additions and 0 deletions
  1. 9
    0
      config/modules/update-notification.conf
  2. 35
    0
      modules/update-notification.ezmod

+ 9
- 0
config/modules/update-notification.conf View File

@@ -0,0 +1,9 @@
1
+# This array specifies a list of packages that will be checked for updates. If any from
2
+# listed below is older than the one found in mainline Portage tree, the notification
3
+# will be sent.
4
+MUSTCHECK=( "my-cat/package1" "my-cat2/package2" )
5
+
6
+# Specifies an e-mail address, where all notifications about packages that needs update
7
+# will be send to. If this variable is empty, none notification will be sent at all, even
8
+# if the modules is enabled.
9
+UPDATE_NOTIFY=""

+ 35
- 0
modules/update-notification.ezmod View File

@@ -0,0 +1,35 @@
1
+# Copyright 2010-2012, Asio Software Technologies
2
+# Distributed under the terms of the GNU General Public License v3
3
+EZMOD_DESCRIPTION="Sends a notification about packages that need an update"
4
+EZMOD_COMPATIBILITY="ezsync"
5
+EZMOD_AUTHOR="Rafal Kupiec"
6
+EZMOD_VERSION="1.0"
7
+
8
+ezsync_postcommit() {
9
+	local BUILDVER MAINLINEVER NEEDSUPDATE NEWER PACKAGE
10
+	local SENDMESG=0
11
+	if [ "${UPDATE_NOTIFY}" != "" ]; then
12
+		for PACKAGE in ${MUSTCHECK[*]}; do
13
+			makeCleanDirectory ${TRASHDIR}/ebuilds
14
+			makeDirectory ${TRASHDIR}/ebuilds/build
15
+			makeDirectory ${TRASHDIR}/ebuilds/mainline
16
+			run "cp -apf ${PORTAGESDIR}/${PORTAGE_BUILD[0]}/${PACKAGE}/*.ebuild ${TRASHDIR}/ebuilds/build/" || return 1
17
+			run "cp -apf ${PORTAGESDIR}/${PORTAGE_MAINLINE[0]}/${PACKAGE}/*.ebuild ${TRASHDIR}/ebuilds/mainline/" || return 1
18
+			find ${TRASHDIR}/ebuilds -type f -name \*-9999\*.ebuild -exec rm -rf {} \;
19
+			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)
20
+			BUILDVER=${BUILDVER##*/}
21
+			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)
22
+			MAINLINEVER=${MAINLINEVER##*/}
23
+			NEWER=$(echo -e "${BUILDVER}\n${MAINLINEVER}" | sed "/^$/d" | sort -Vr | head -1)
24
+			if [[ "${NEWER}" != "${BUILDVER}" ]]; then
25
+				SENDMSG=1
26
+				NEEDSUPDATE=${NEEDSUPDATE+"$NEEDSUPDATE, "}"${PACKAGE}"
27
+			fi
28
+		done
29
+		rm -rf ${TRASHDIR}/ebuilds
30
+		if isEnabled ${SENDMSG}; then
31
+			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}
32
+		fi
33
+	fi
34
+	return 0
35
+}

Loading…
Cancel
Save