2014-03-11 18:12:58 +01:00
|
|
|
#!/bin/bash
|
|
|
|
|
2014-03-13 11:17:01 +01:00
|
|
|
if [ ! -d /tmp/yunohost ];
|
2014-03-11 18:12:58 +01:00
|
|
|
then
|
2014-03-13 11:17:01 +01:00
|
|
|
mkdir /tmp/yunohost
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ -f /tmp/yunohost/changelog ];
|
|
|
|
then
|
|
|
|
rm /tmp/yunohost/changelog
|
2014-03-11 18:12:58 +01:00
|
|
|
fi
|
|
|
|
|
|
|
|
apt-get update -y > /dev/null 2>&1
|
|
|
|
if [[ $? != 0 ]];
|
|
|
|
then
|
|
|
|
exit 2
|
|
|
|
else
|
2014-03-13 11:17:01 +01:00
|
|
|
echo OK > /tmp/yunohost/update_status
|
2014-03-11 18:12:58 +01:00
|
|
|
fi
|
|
|
|
|
|
|
|
# Set $DIRCACHE
|
|
|
|
eval `/usr/bin/apt-config shell DIRCACHE Dir::Cache`
|
|
|
|
|
|
|
|
|
|
|
|
# get the list of packages which are pending an upgrade
|
|
|
|
PKGNAMES=`/usr/bin/apt-get -q -y --ignore-hold --allow-unauthenticated -s dist-upgrade | \
|
|
|
|
/bin/grep ^Inst | /usr/bin/cut -d\ -f2 | /usr/bin/sort`
|
|
|
|
|
|
|
|
if [[ $PKGNAMES = "" ]];
|
|
|
|
then
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ -n "$PKGNAMES" ] ; then
|
|
|
|
|
|
|
|
# do the upgrade downloads
|
|
|
|
/usr/bin/apt-get --ignore-hold -qq -d --allow-unauthenticated --force-yes dist-upgrade > /dev/null
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
|
|
PKGPATH="/${DIRCACHE}archives/"
|
|
|
|
for PKG in $PKGNAMES ; do
|
|
|
|
VER=`LC_ALL=C /usr/bin/apt-cache policy $PKG |\
|
|
|
|
/bin/grep Candidate: | /usr/bin/cut -f 4 -d \ `
|
|
|
|
OLDVER=`LC_ALL=C /usr/bin/apt-cache policy $PKG |\
|
|
|
|
/bin/grep Installed: | /usr/bin/cut -f 4 -d \ `
|
|
|
|
VERFILE=`echo "$VER" | /bin/sed -e "s/:/%3a/g"`
|
|
|
|
if ls ${PKGPATH}${PKG}_${VERFILE}_*.deb >& /dev/null ; then
|
|
|
|
DEBS="$DEBS ${PKGPATH}${PKG}_${VERFILE}_*.deb"
|
|
|
|
fi
|
|
|
|
echo -e "$PKG $OLDVER -> $VER"
|
|
|
|
done
|
|
|
|
|
|
|
|
MISSING_DEBS=`apt-get -y --ignore-hold --allow-unauthenticated --print-uris dist-upgrade \
|
|
|
|
| grep "file:" \
|
|
|
|
| sed "s/'file:\(.*\)' .*/\1/g"`
|
|
|
|
|
|
|
|
DEBS=`echo $MISSING_DEBS $DEBS | /usr/bin/sort`
|
|
|
|
|
|
|
|
if [[ $DEBS = "" ]];
|
|
|
|
then
|
|
|
|
exit 3
|
|
|
|
else
|
|
|
|
if [ -x /usr/bin/apt-listchanges ] ; then
|
2014-03-13 11:17:01 +01:00
|
|
|
/usr/bin/apt-listchanges --which=both -f text $DEBS > /tmp/yunohost/changelog 2>/dev/null
|
2014-03-11 18:12:58 +01:00
|
|
|
fi
|
|
|
|
fi
|