Написал простой скрипт на баше. Скрипт кривой и костыльный, но работает.
Зависимости: bash, grep, sed, awk, curl, KDE4
От кед фактически используется только kdialog для вывода уведомления. Для гномеров в репах дебиана есть своя утилита. Буду рад если кому-нибудь пригодится
Можно поставить на крон:
0 * * * * export DISPLAY=:0; <path>deb-check-updates.sh > /dev/null
Собственно сам скрипт:
#!/bin/bash
get_remote_mtime () {
remote_date=`curl --silent --head "$1" | grep -i "Last-Modified:" | sed 's/^Last-Modified\://i'`
remote_mtime=`date -d "$remote_date" "+%s"`
return 0
}
check_entry () {
if [ "$1" == "deb-src" ]; then
deb_type="source"
else
deb_type="binary"
fi
# trim last /
mirror=${2%\/}
release="$3"
# replace / with _
release_local=${release//\//_}
echo "deb_type=$deb_type"
echo "mirror=$mirror"
echo "release_local=$release_local"
# check each component (main, contrib etc.)
shift 3
until [ -z "$1" ]; do
component="$1"
echo "component=$component"
shift
host=`echo "$mirror" | awk -F "/" '{print $3}'`
path=`echo "$mirror" | sed 's/^[a-z]*:\/\/[^\/]*//i'`
path="$path/"
echo "path=$path"
path_local=${path//\//_}
echo "host=$host"
echo "path_local=$path_local"
# local path to index file
packages_local="/var/lib/apt/lists/${host}${path_local}dists_${release_local}_${component}_"
if [ "$deb_type" == "binary" ]; then
packages_local="${packages_local}${deb_type}-${arch}_Packages"
else
packages_local="${packages_local}${deb_type}_Sources"
fi
echo "packages_local=$packages_local"
# remote index file path
packages_remote="${mirror}/dists/${release}/${component}/"
if [ "$deb_type" == "binary" ]; then
packages_remote="${packages_remote}${deb_type}-${arch}/Packages"
else
packages_remote="${packages_remote}source/Sources"
fi
echo "packages_remote=$packages_remote"
# compare local and remote Packages.diff mtime
if [ -e "$packages_local.IndexDiff" ]; then
local_mtime=`date -r "${packages_local}.IndexDiff" "+%s"`
echo "local_mtime=$local_mtime"
get_remote_mtime "${packages_remote}.IndexDiff"
echo "remote_mtime=$remote_mtime"
if [ -n "$remote_mtime" ]; then
# if remote files is newer than local
if [ "$remote_mtime" -gt "$local_mtime" ]; then
echo "updates on $mirror $release $component $deb_type"
updated_sources=( "${updated_sources[@]}" "$host $release $component $deb_type")
continue
fi
fi
fi
# compare Packages.gz file
if [ -e "$packages_local" ]; then
local_mtime=`date -r "${packages_local}" "+%s"`
echo "local_mtime=$local_mtime"
get_remote_mtime "${packages_remote}.gz"
echo "remote_mtime=$remote_mtime"
if [ -n "$remote_mtime" ]; then
# if remote files is newer than local
if [ "$remote_mtime" -gt "$local_mtime" ]; then
echo "updates on $mirror $release $component $deb_type"
updated_sources=( "${updated_sources[@]}" "$host $release $component $deb_type")
fi
fi
fi
done
}
# get architecture
arch=`dpkg-architecture -qDEB_HOST_ARCH`
echo "arch = $arch"
declare -a updated_sources
# read sources.list
while read line; do
# skip empty lines
if [ -z "$line" ]; then
continue
fi
# ignore commented lines
if [ -n "`expr match "$line" '\(^[\ ]*\#\)'`" ]; then
continue
fi
echo "$line"
check_entry $line
echo ""
done < /etc/apt/sources.list
echo ""
# show notification
if [ "${#updated_sources[@]}" -gt "0" ]; then
msg="Updates available on<ul>"
for i in "${updated_sources[@]}"; do
msg="${msg}<li>${i}</li>"
done
msg="${msg}</ul>"
echo "$msg"
kdialog --title 'Update checker' --passivepopup "$msg" 2000
else
echo "no updates"
fi