@bell, Danke für den Tip
---
Wenn man die Git Methode benutzt um sehr schnell den Portage Tree zu aktualisieren, bekommt man aber keine News mehr. Oder habe ich eine Möglichkeit nicht gesehen? Jetzt habe ich mir erstmal diese Methode ausgedact: /etc/cron.daily/gentoonews
Code: Select all
#!/bin/bash
temp="${TMPDIR:=/tmp}/www.gentoo.org/support/news-items"
pdir="/usr/share/portage/metadata"
debug=0
[ ${debug} -gt 2 ] \
&&set -x
[ -d "${pdir}" ] \
||pdir="$(portageq get_repo_path / gentoo)/metadata"
[ ! -d "${pdir}" ] \
&&echo "ERROR gentoo repository" \
&&exit
[ ${debug} -lt 2 ] \
&&quiet="-q" \
||quiet=""
mkdir -p $temp \
&&cd ${TMPDIR} \
&&wget ${quiet} --no-parent --no-clobber --continue \
--recursive https://www.gentoo.org/support/news-items/index.html
pdir="${pdir}/news"
cd ${temp}
for i in 20*.html; do
[ ! -f $i ] \
&&echo "WARN not exists $i" \
&&continue
cat "${temp}/$i" \
|sed -n -e'/^Title: /,/<.pre>/b show' \
-e'b' \
-e':show' \
-e'/<.pre>/Q' \
-e"s/'./\'/g" \
-e's/</</g' \
-e's/>/>/g' \
-e's/"/\"/g'\
-e's/&/\&/g' \
-e'p' >"${temp}/${i%%.html}.en.txt"
rm "${temp}/$i"
done
for j in *.en.txt ; do
[ ! -f $j ] \
&&echo "ERROR not exists $j" \
&&continue
a="${j%%.en.txt}"
if /usr/bin/diff -w -B "$j" "${pdir}/$a/$j"; then
rm "${temp}/$j"
[ ${debug} -gt 0 ] \
&&echo "OK -- ${pdir}/$a/$j"
else
[ ! -d "${pdir}/$a" ] \
&&mkdir -p "${pdir}/$a"
[ ! -d "${pdir}/$a" ] \
&&echo "ERROR mkdir ${pdir}/$a" \
&&continue
[ -f "${pdir}/$a/$j" ] \
&&[ ${debug} -gt 1 ] \
&&cp "${temp}/$j" "${temp}/$j.sic" \
&&echo "WARN diff ${temp}/$j.sic"
[ -f "${pdir}/$a/$j" ] \
&&rm "${pdir}/$a/$j"
cp "$j" "${pdir}/$a/$j" \
&&rm "${temp}/$j" \
||echo "ERROR cp $j"
grep -q "$a" /var/lib/gentoo/news/news-gentoo.{read,skip,unread} \
||echo "$a" >>/var/lib/gentoo/news/news-gentoo.unread
fi
done 

