aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2007-07-09 20:47:36 +0000
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2007-07-09 20:47:36 +0000
commit6367ccea5397b980a93535cb993fa2b31cd2615a (patch)
tree19fbebd3aed152dcbe7e9d18b5c2aabd36182a52
parent1ca05a0e7a21cce9646ba0df61d88f195f87e55f (diff)
downloadpaludis-6367ccea5397b980a93535cb993fa2b31cd2615a.tar.gz
paludis-6367ccea5397b980a93535cb993fa2b31cd2615a.tar.xz
Don't ship news.eselect as part of Paludis. Use 'eselect news count' rather than manually implementing news counting. Fixes: Gentoo\#179064
-rw-r--r--eselect/Makefile.am1
-rw-r--r--eselect/news.eselect262
-rwxr-xr-xhooks/news.hook13
3 files changed, 2 insertions, 274 deletions
diff --git a/eselect/Makefile.am b/eselect/Makefile.am
index a27edce..1baef52 100644
--- a/eselect/Makefile.am
+++ b/eselect/Makefile.am
@@ -5,7 +5,6 @@ SUBDIRS = .
installeselectdir = $(datadir)/eselect/modules/
installeselect_SCRIPTS = \
- news.eselect \
repo.eselect
TESTS_ENVIRONMENT = env \
diff --git a/eselect/news.eselect b/eselect/news.eselect
deleted file mode 100644
index edf17bd..0000000
--- a/eselect/news.eselect
+++ /dev/null
@@ -1,262 +0,0 @@
-# Copyright 2006 Ciaran McCreesh
-# Distributed under the terms of the GNU General Public License v2
-# $Id: $
-
-DESCRIPTION="Read GLEP 42 news items"
-MAINTAINER="ciaranm@ciaranm.org"
-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_lang() {
- if [[ -n "${LC_MESSAGES}" ]] ; then
- echo ${LC_MESSAGES:0:2}
- elif [[ -n "${LANG}" ]] ; then
- echo ${LANG:0:2}
- else
- echo en
- fi
-}
-
-get_headers() {
- local dir=${1}
- dir=${1}/$(basename ${1%/} ).$(get_lang).txt
- [[ -f ${dir} ]] || dir=${1}/$(basename ${1%/} ).en.txt
- sed -e '/^$/,$d' < ${dir}
-}
-
-get_body() {
- local dir=${1}
- dir=${1}/$(basename ${1%/} ).$(get_lang).txt
- [[ -f ${dir} ]] || dir=${1}/$(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), or the special" \
- "item 'new', to list all new news items, or 'all', to" \
- "show all items"
-}
-
-do_read() {
- [[ -z ${1} ]] && die -q "You didn't tell me what you want to read"
-
- local i item= items
- items=( $(get_unread ) )
-
- if [[ "${1}" == "new" ]] ; then
- for i in "${items[@]}" ; do
- do_read "${i%::*}"
- done
- return
- elif [[ "${1}" == "all" ]] ; then
- items=( "${items[@]}" $(get_read) )
- for i in "${items[@]}" ; do
- do_read "${i%::*}"
- done
- return
- fi
-
- 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), or the special" \
- "item 'all', to mark all items as unread"
-}
-
-do_unread() {
- [[ -z ${1} ]] && die -q "You didn't tell me what you want to unread"
-
- local i item= items
- items=( $(get_read ) )
-
- if [[ "${1}" == "all" ]] ; then
- for i in "${items[@]}" ; do
- do_unread "${i%::*}"
- done
- return
- fi
-
- 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 :
diff --git a/hooks/news.hook b/hooks/news.hook
index 9b7d569..ea5726c 100755
--- a/hooks/news.hook
+++ b/hooks/news.hook
@@ -19,20 +19,11 @@
check_for_news()
{
export PATH="$(${PALUDIS_EBUILD_DIR}/utils/canonicalise ${PALUDIS_EBUILD_DIR}/utils/ ):${PATH}"
+ export ROOT="${ROOT}"
source ${PALUDIS_EBUILD_DIR}/echo_functions.bash
-
- mkdir -p ${ROOT}/var/lib/paludis/news/
+ count="$(eselect news count )"
done_echo=
-
- count=0
- for f in "${ROOT}/var/lib/paludis/news/"news-*.unread ; do
- [[ -f "${f}" ]] || continue
- if grep --silent . "${f}" ; then
- count=$(( count + $(grep --count . < "${f}" ) ))
- fi
- done
-
if [[ ${count} -gt 0 ]] ; then
[[ -z "${done_echo}" ]] && echo ; done_echo=yes
ewarn "You have ${count} unread news items (use 'eselect news' to read)"