aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2006-05-19 00:45:50 +0000
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2006-05-19 00:45:50 +0000
commit9fafaa438b524c3d281e2a76a6ec5f0c61c2169c (patch)
treeb0bc9bb9020840a09fc120ff4f0618878f9b788a
parentc2fa2e48ea6c1b88689853d0e2ac48a4af53d316 (diff)
downloadpaludis-9fafaa438b524c3d281e2a76a6ec5f0c61c2169c.tar.gz
paludis-9fafaa438b524c3d281e2a76a6ec5f0c61c2169c.tar.xz
Ship the news.eselect module as part of Paludis for now
-rw-r--r--Makefile.am2
-rw-r--r--configure.ac1
-rw-r--r--eselect/Makefile.am22
-rw-r--r--eselect/news.eselect225
4 files changed, 249 insertions, 1 deletions
diff --git a/Makefile.am b/Makefile.am
index 765f19e..201a396 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -3,7 +3,7 @@ MAINTAINERCLEANFILES = Makefile.in configure config/* aclocal.m4 \
config.h config.h.in INSTALL COPYING
AUTOMAKE_OPTIONS = dist-bzip2 no-dist-gzip std-options
EXTRA_DIST = autogen.bash
-SUBDIRS = misc test paludis ebuild src doc hooks
+SUBDIRS = misc test paludis ebuild src doc hooks eselect
doxygen :
$(MAKE) -C doc doxygen
diff --git a/configure.ac b/configure.ac
index 366b94f..d620529 100644
--- a/configure.ac
+++ b/configure.ac
@@ -358,6 +358,7 @@ AC_OUTPUT(
ebuild/Makefile
ebuild/digests/Makefile
ebuild/utils/Makefile
+ eselect/Makefile
hooks/Makefile
misc/Makefile
misc/svn-version-filter-data.bash
diff --git a/eselect/Makefile.am b/eselect/Makefile.am
new file mode 100644
index 0000000..f036668
--- /dev/null
+++ b/eselect/Makefile.am
@@ -0,0 +1,22 @@
+MAINTAINERCLEANFILES = Makefile.in Makefile.am
+CLEANFILES = *~ gmon.out *.gcov *.gcno *.gcda .keep
+SUBDIRS = .
+
+installeselectdir = $(datadir)/eselect/modules/
+
+installeselect_SCRIPTS = \
+ news.eselect
+
+TESTS_ENVIRONMENT = env \
+ PALUDIS_EBUILD_DIR="$(srcdir)/ebuild/" \
+ TEST_SCRIPT_DIR="$(srcdir)/" \
+ bash $(top_srcdir)/ebuild/run_test.bash
+
+TESTS =
+EXTRA_DIST = \
+ $(installeselect_SCRIPTS) \
+ $(TESTS)
+
+check_SCRIPTS = $(TESTS)
+check_PROGRAMS =
+
diff --git a/eselect/news.eselect b/eselect/news.eselect
new file mode 100644
index 0000000..5d57a2e
--- /dev/null
+++ b/eselect/news.eselect
@@ -0,0 +1,225 @@
+# Copyright 2006 Ciaran McCreesh
+# Distributed under the terms of the GNU General Public License v2
+# $Id: $
+
+DESCRIPTION="Read GLEP 42 news items"
+MAINTAINER="ciaran.mccreesh@blueyonder.co.uk"
+SVN_DATE='$Date: $'
+VERSION=$(svn_date_to_version "${SVN_DATE}" )
+
+paludis_command() {
+ echo ${PALUDIS_COMMAND:-paludis}
+}
+
+get_repositories() {
+ $(paludis_command ) --list-repositories | \
+ sed -n -e 's/^\* *//p'
+}
+
+get_unread() {
+ local repo repos
+ repos=( $(get_repositories ) )
+ for repo in ${repos[@]} ; do
+ [[ -f "${ROOT}/var/lib/paludis/news/news-${repo}.unread" ]] || continue
+ sed -e '/^#/d' -e "/./s,$,::${repo}," < \
+ ${ROOT}/var/lib/paludis/news/news-${repo}.unread
+ done
+}
+
+get_read() {
+ local repo repos
+ repos=( $(get_repositories ) )
+ for repo in ${repos[@]} ; do
+ [[ -f "${ROOT}/var/lib/paludis/news/news-${repo}.read" ]] || continue
+ sed -e '/^#/d' -e "/./s,$,::${repo}," < \
+ ${ROOT}/var/lib/paludis/news/news-${repo}.read
+ done
+}
+
+mark_read() {
+ local name=${1%::*} repo=${1##*::}
+
+ touch "${ROOT}"/var/lib/paludis/news/news-${repo}.read || \
+ die -q "Couldn't touch read file for ${1}"
+
+ if ! grep -q "^${name}\$" < "${ROOT}"/var/lib/paludis/news/news-${repo}.read ; then
+ echo "${name}" >> "${ROOT}"/var/lib/paludis/news/news-${repo}.read || \
+ die -q "Couldn't mark ${1} as read"
+ fi
+
+ sed -i -e "/^${name}\$/d" "${ROOT}"/var/lib/paludis/news/news-${repo}.unread || \
+ die -q "Couldn't remove ${1} from unread list"
+}
+
+mark_unread() {
+ local name=${1%::*} repo=${1##*::}
+
+ touch "${ROOT}"/var/lib/paludis/news/news-${repo}.unread || \
+ die -q "Couldn't touch unread file for ${1}"
+
+ if ! grep -q "^${name}\$" < "${ROOT}"/var/lib/paludis/news/news-${repo}.unread ; then
+ echo "${name}" >> "${ROOT}"/var/lib/paludis/news/news-${repo}.unread || \
+ die -q "Couldn't mark ${1} as unread"
+ fi
+
+ sed -i -e "/^${name}\$/d" "${ROOT}"/var/lib/paludis/news/news-${repo}.read || \
+ die -q "Couldn't remove ${1} from read list"
+}
+
+purge_read() {
+ local repo
+ for repo in $(get_repositories ) ; do
+ : > "${ROOT}"/var/lib/paludis/news/news-${repo}.read || \
+ die -q "Couldn't purge ${repo} read list"
+ done
+}
+
+get_dir_name() {
+ local name=${1%::*} repo=${1##*::}
+ $(paludis_command ) --list-repositories --repository ${repo} | \
+ sed -n -e "s~^ *newsdir: *\(.*\)~\1/${name}/~p"
+}
+
+get_headers() {
+ local dir=${1}
+ dir=${dir}/$(basename ${1%/} ).en.txt
+ sed -e '/^$/,$d' < ${dir}
+}
+
+get_body() {
+ local dir=${1}
+ dir=${dir}/$(basename ${1%/} ).en.txt
+ sed -e '1,/^$/d' < ${dir}
+}
+
+get_title() {
+ local f=$(get_dir_name ${1} )
+ if [[ -d ${f} ]] ; then
+ get_headers ${f} | sed -n -e 's/^Title:\s*//p'
+ else
+ echo "(no title available)"
+ fi
+}
+
+### list action ###
+
+describe_list() {
+ echo "List news items"
+}
+
+do_list() {
+ targets=( $(get_unread ) )
+ write_list_start "Unread news items:"
+ if [[ -n ${targets[@]} ]] ; then
+ local target
+ for target in ${targets[@]} ; do
+ write_kv_list_entry "${target%::*}" "$(get_title ${target} )"
+ done
+ else
+ write_kv_list_entry "(none found)" ""
+ fi
+
+ targets=( $(get_read ) )
+ write_list_start "Read news items:"
+ if [[ -n ${targets[@]} ]] ; then
+ local target
+ for target in ${targets[@]} ; do
+ write_kv_list_entry "${target%::*}" "$(get_title ${target} )"
+ done
+ else
+ write_kv_list_entry "(none found)" ""
+ fi
+}
+
+### read action ###
+
+describe_read() {
+ echo "Read a news item"
+}
+
+describe_read_parameters() {
+ echo "<target>"
+}
+
+describe_read_options() {
+ echo "target : News item ID (from 'list' action)"
+}
+
+do_read() {
+ [[ -z ${1} ]] && die -q "You didn't tell me what you want to read"
+
+ local i item= items
+ items=( $(get_unread ) )
+ for i in ${items[@]} ; do
+ [[ -n "${item}" ]] && break
+ [[ "${i%::*}" == "${1}" ]] || continue
+ item=${i}
+ done
+
+ items=( $(get_read ) )
+ for i in ${items[@]} ; do
+ [[ -n "${item}" ]] && break
+ [[ "${i%::*}" == "${1}" ]] || continue
+ item=${i}
+ done
+
+ [[ -z "${item}" ]] && die -q "Can't find news item '${1}'"
+
+ write_list_start "${item%::*}"
+ local f=$(get_dir_name ${item} ) line
+ get_headers ${f} | \
+ while read line ; do
+ local k=${line%%:*}
+ case ${k} in
+ Title|Author|Posted|Revision|Translator)
+ write_kv_list_entry "${k}" "${line#*:}"
+ ;;
+ esac
+ done
+ echo
+ get_body ${f}
+
+ mark_read "${item}"
+}
+
+### unread action ###
+
+describe_unread() {
+ echo "Unread a news item"
+}
+
+describe_unread_parameters() {
+ echo "<target>"
+}
+
+describe_unread_options() {
+ echo "target : News item ID (from 'list' action)"
+}
+
+do_unread() {
+ [[ -z ${1} ]] && die -q "You didn't tell me what you want to unread"
+
+ local i item= items
+ items=( $(get_read ) )
+ for i in ${items[@]} ; do
+ [[ -n "${item}" ]] && break
+ [[ "${i%::*}" == "${1}" ]] || continue
+ item=${i}
+ done
+
+ [[ -z "${item}" ]] && die -q "Can't find read news item '${1}'"
+
+ mark_unread "${item}"
+}
+
+### purge action ###
+
+describe_purge() {
+ echo "Purge read news items"
+}
+
+do_purge() {
+ purge_read
+}
+
+# vim: ts=4 sw=4 noet :