Version 1.3.1 - 7/Mar/2014

- Improved check-updates function (thanks to phenixia2003)
  - Improved debug-mode
This commit is contained in:
Matteo Rossini 2014-04-07 09:40:02 +02:00
parent 1e0bd6fd46
commit 2646d851fc
7 changed files with 174 additions and 33 deletions

View file

@ -1,3 +1,7 @@
Version 1.3.1 - 7/Mar/2014
- Improved check-updates function (thanks to phenixia2003)
- Improved debug-mode
Version 1.3.0 - 1/Jan/2014
- Added a debug-mode download verbosity
- On upgrade, the status bar show available packages from every repository

View file

@ -1,3 +1,7 @@
Version 1.3.1 - 7/Mar/2014
- Improved check-updates function (thanks to phenixia2003)
- Improved debug-mode
Version 1.3.0 - 1/Jan/2014
- Added a debug-mode download verbosity
- On upgrade, the status bar show available packages from every repository

View file

@ -381,6 +381,13 @@ Note that you can edit manually to modify or add informations.
At every slackpkg install/upgrade/remove invocation, a new log will be added.
At every slackpkg update invocation, a fast list rebuild will be done.
-----
CHECK-UPDATE IMPROVEMENT
the command "slackpkg check-updates" reports the repositories which have been changed since
the last update. For more details and some suggests how to use it in crontab see:
http://www.linuxquestions.org/questions/showthread.php?p=5146591
-----

View file

@ -10,10 +10,10 @@ config() {
# Otherwise, we leave the .new copy for the admin to consider...
}
remove() {
renam() {
FILE="$1"
if [ -r $FILE ]; then
rm $FILE
mv $FILE $FILE.tmp
fi
}
@ -38,10 +38,8 @@ copy_config_file
config etc/slackpkg/slackpkgplus.conf.new
config etc/slackpkg/greylist.new
config etc/slackpkg/notifymsg.conf.new
remove var/lib/slackpkg/ChangeLog.txt
remove var/lib/slackpkg/pkglist
( . usr/libexec/slackpkg/makeinstlog.sh >/dev/null )
renam var/lib/slackpkg/ChangeLog.txt
renam var/lib/slackpkg/pkglist
echo
echo

View file

@ -2,17 +2,20 @@
WORKDIR=/var/lib/slackpkg
. /etc/slackpkg/slackpkg.conf
if [ -e $WORKDIR/pkglist ];then
cp $WORKDIR/pkglist $WORKDIR/pkglist.tmp
fi
(
(
cd /var/log/removed_packages
( ls -l --full-time|tail +2|cut -c11-|sed -r -e 's/\.[0-9]{9}//' -e 's,-,/,' -e 's,-,/,'|awk '{print $8,$5,$6}'
grep -m1 'PACKAGE LOCATION:' *|sed -r 's/:PACKAGE LOCATION:.*(\.t.z)/ \1/'
grep -m1 'PACKAGE LOCATION:' * 2>/dev/null|sed -r 's/:PACKAGE LOCATION:.*(\.t.z)/ \1/'
)|sort|awk '{if(x=!x){printf("%s ", $2)}else{print $2,$3,$1}}' \
|sed -e 's/$/ removed/' -e 's/-upgraded-.*/ upgraded/'|awk '{print $2,$3,$4,$1,$5}'
cd /var/log/packages
( ls -l --full-time|tail +2|cut -c11-|sed -r -e 's/\.[0-9]{9}//' -e 's,-,/,' -e 's,-,/,'|awk '{print $8,$5,$6}'
grep -m1 'PACKAGE LOCATION:' *|sed -r 's/:PACKAGE LOCATION:.*(\.t.z)/ \1/'
grep -m1 'PACKAGE LOCATION:' * 2>/dev/null|sed -r 's/:PACKAGE LOCATION:.*(\.t.z)/ \1/'
)|sort|awk '{if(x=!x){printf("%s ", $2)}else{print $2,$3,$1}}' \
|sed -e 's/$/ installed/'|awk '{print $2,$3,$4,$1,$5}'
)| sed -r -e 's/^([^ ]+) ([^ ]+) (.*)-([^-]+)-([^-]+)-([^ ]+) (\.t.z) (.*)/\1 \2 \3 \3-\4-\5-\6 \7 \8/'|sort|awk '{
@ -24,24 +27,27 @@ WORKDIR=/var/lib/slackpkg
cat $WORKDIR/install.log 2>/dev/null|grep -v '\[\]'
)|sort -r|awk '{if(!a[$1$2$3$4]++)print}'|tac >$WORKDIR/install.log.new
)|sort -r|awk '{if(!a[$1$2$3$4]++)print}'|tac >$WORKDIR/install.log.tmp
if [ "$1" == "-t" ];then
if [ ! -e $WORKDIR/pkglist ];then
echo "pkglist does not exists; unable to try repository detect"
echo "An install log was created in $WORKDIR/install.log.new ; review it and rename in install.log"
else
cat $WORKDIR/install.log.new |while read a;do
if [ ! -e $WORKDIR/pkglist.tmp ];then
if [ -e $WORKDIR/pkglist ];then
cp $WORKDIR/pkglist $WORKDIR/pkglist.tmp
fi
fi
if [ ! -e $WORKDIR/pkglist.tmp ];then
echo "pkglist does not exists; unable to try repository detect"
mv $WORKDIR/install.log.tmp $WORKDIR/install.log.new
else
cat $WORKDIR/install.log.tmp |while read a;do
P=$(echo $a|awk '{print $4}')
R=$(grep -m1 \
"$(echo $P|awk -f /usr/libexec/slackpkg/pkglist.awk | awk '{print " "$1" .* "$3" "$4"$"}'| sed -r 's/ [0-9]+([^\$]*)\$/ [0-9]\\+\1 /')" \
/var/lib/slackpkg/pkglist|awk '{print $1}'|sed 's/SLACKPKGPLUS_//'
$WORKDIR/pkglist.tmp|awk '{print $1}'|sed 's/SLACKPKGPLUS_//'
)
echo "$a"|sed "s/\[\]/[$R]/"
done > $WORKDIR/install.log.tmp
echo "An install log was created in $WORKDIR/install.log.tmp ; review it and rename in install.log"
fi
else
mv $WORKDIR/install.log.new $WORKDIR/install.log
echo "An install log was created in $WORKDIR/install.log"
done > $WORKDIR/install.log.new
rm $WORKDIR/install.log.tmp
rm $WORKDIR/pkglist.tmp
fi
mv $WORKDIR/install.log.new $WORKDIR/install.log
echo "An install log was created in $WORKDIR/install.log"

View file

@ -7,10 +7,8 @@ Supported Repositories:
> ktown: http://taper.alienbase.nl/mirrors/alien-kde/{13.37,14.0,14.1,current}/latest/{x86,x86_64}/
> restricted: http://taper.alienbase.nl/mirrors/people/alien/restricted_sbrepos/{13.37,14.0,14.1,current}/{x86,x86_64}/
> slacky: http://repository.slacky.eu/slackware{,64}-{13.37,14.0,14.1}/
> zerouno: http://www.z01.eu/repo-slack/slackware64-current/
> mled: http://www.microlinux.fr/slackware/MLED-{14.0,14.1}-{32,64}bit/
> mles: http://www.microlinux.fr/slackware/MLES-{14.0,14.1}-{32,64}bit/
> mlws: http://www.microlinux.fr/slackware/MLWS-{14.0,14.1}-{32,64}bit/
> msb: http://slackware.org.uk/msb/{14.0,14.1}/1.6/{x86,x86_64}/
> slackers: http://www.slackers.it/repository/
> slacke17: http://ngc891.blogdns.net/pub/slacke17/slackware{,64,arm}-{14.0,14.1}/

View file

@ -1,7 +1,6 @@
# Thanks to AlienBob and phenixia2003 (on LQ) for contributing
# A special thanks to all packagers that make slackpkg+ useful
declare -A MIRRORPLUS
declare -A NOTIFYMSG
@ -34,21 +33,70 @@ fi
if [ "$SLACKPKGPLUS" = "on" ];then
SPKGPLUS_VERSION="1.2.0"
SPKGPLUS_VERSION="1.3.1"
VERSION="$VERSION / slackpkg+ $SPKGPLUS_VERSION"
if [ ! -e "$WORKDIR" ];then
mkdir -p "$WORKDIR"
fi
if [ "$CMD" == "update" ];then
if [ "$VERBOSE" == "2" ];then
echo "Updating $WORKDIR/install.log"
touch $TMPDIR/info.log
if [ $VERBOSE -gt 1 ];then
/usr/libexec/slackpkg/makeinstlog.sh -t >> $TMPDIR/info.log &
else
/usr/libexec/slackpkg/makeinstlog.sh >/dev/null &
fi
/usr/libexec/slackpkg/makeinstlog.sh >/dev/null
PIDINSTLOG=$!
fi
function cleanup(){
[ "$SPINNING" = "off" ] || tput cnorm
if [ "$CMD" == "update" ];then
if [ $VERBOSE -gt 2 ];then
echo "Updating $WORKDIR/install.log..."
else
echo "Updating install.log"
fi
echo
fi
if [ "$DELALL" = "on" ] && [ "$NAMEPKG" != "" ]; then
rm $CACHEPATH/$NAMEPKG &>/dev/null
fi
wait
if [ $VERBOSE -gt 2 ];then
echo "The temp directory $TMPDIR will NOT be removed!" >>$TMPDIR/info.log
echo
fi
if [ -s $TMPDIR/error.log -o -s $TMPDIR/info.log ];then
echo -e "\n\n=============================================================================="
fi
if [ -e $TMPDIR/error.log ]; then
echo " WARNING! One or more errors occurred while slackpkg was running"
echo "------------------------------------------------------------------------------"
cat $TMPDIR/error.log
if [ -s $TMPDIR/info.log ];then
echo "------------------------------------------------------------------------------"
fi
fi
if [ -s $TMPDIR/info.log ]; then
echo " INFO! Debug informations"
echo "------------------------------------------------------------------------------"
cat $TMPDIR/info.log
echo "=============================================================================="
fi
echo
rm -f /var/lock/slackpkg.$$
if [ $VERBOSE -lt 3 ];then
rm -rf $TMPDIR
fi
exit
}
# Override the slackpkg getfile().
# The new getfile() download all file needed from all defined repositories
# then merge all in a format slackpkg-compatible
@ -195,7 +243,9 @@ if [ "$SLACKPKGPLUS" = "on" ];then
sleep 5
echo -e "$PREPO: Invalid repository (fails to download CHECKSUMS.md5)" >> $TMPDIR/error.log
fi
echo $PREPO $(md5sum ${TMPDIR}/CHECKSUMS.md5-$PREPO|awk '{print $1}') >>$2
echo "SLACKPKGPLUS_$PREPO[MD5]" $(md5sum ${TMPDIR}/CHECKSUMS.md5-$PREPO|awk '{print $1}') >>$2
done
fi
if [ $(basename $1) = "GPG-KEY" ];then
@ -242,7 +292,7 @@ if [ "$SLACKPKGPLUS" = "on" ];then
echo 1
fi
if [ "$(basename $1)" == "CHECKSUMS.md5" ];then
X86_64=$(ls /var/log/packages/aaa_base*x86_64*|head -1 2>/dev/null)
X86_64=$(ls /var/log/packages/aaa_base*x86_64* 2>/dev/null|head -1)
for PREPO in $REPOPLUS;do
if [ ! -z "$X86_64" ];then
if [ "$ALLOW32BIT" == "on" ];then
@ -749,7 +799,7 @@ if [ "$SLACKPKGPLUS" = "on" ];then
md5sum $DSTFILE >> $TMPDIR/error.log 2>&1
echo >> $TMPDIR/error.log
else
echo "$SRCURL --> OK" >> $TMPDIR/error.log
echo "$SRCURL --> OK" >> $TMPDIR/info.log
fi
return $WGETERR
@ -968,5 +1018,79 @@ if [ "$SLACKPKGPLUS" = "on" ];then
cleanup
fi
if [ "$CMD" == "check-updates" ] ; then
[ ! -e ~/.slackpkg ] && mkdir ~/.slackpkg
echo -n "" > ~/.slackpkg/updated-repos.txt
UPDATES=false
if ! checkchangelog 1>/dev/null 2>/dev/null; then
# -- Note:
# checkchangelog() download the ChangeLog.txt and stores it
# in ${TMPDIR}
# extract the slackpkgplus repositories md5 from the ChangeLog.txt
# files (in ${WORKDIR} and ${TMPDIR} to identify updates in Slackware
# repository.
#
grep -v "^SLACKPKGPLUS_.*\[MD5\] " ${WORKDIR}/ChangeLog.txt > ${TMPDIR}/ChangeLog.old
grep -v "^SLACKPKGPLUS_.*\[MD5\] " ${TMPDIR}/ChangeLog.txt > ${TMPDIR}/ChangeLog.new
if [ "$(md5sum ${TMPDIR}/ChangeLog.old | cut -f1 -d' ')" != "$(md5sum ${TMPDIR}/ChangeLog.new | cut -f1 -d' ')" ] ; then
echo "slackware" > ${TMPDIR}/updated-repos.txt
fi
# -- get the list of the repositories configured before this call to check-updates
#
grep "^SLACKPKGPLUS_.*\[MD5\] " ${WORKDIR}/ChangeLog.txt | sed 's/^SLACKPKGPLUS_//; s/\[MD5\]//' | cut -f1 -d" "> ${TMPDIR}/selected.3pr
# create pseudo changelogs for the selected 3rd party repositories
#
grep "^SLACKPKGPLUS_.*\[MD5\] " ${WORKDIR}/ChangeLog.txt | sort > "${TMPDIR}/3rp-ChangeLog.old"
grep "^SLACKPKGPLUS_.*\[MD5\] " ${TMPDIR}/ChangeLog.txt | sort > "${TMPDIR}/3rp-ChangeLog.new"
# from the pseudo changelogs, find the updated 3rd party repositories and add them
# to the updates report file
#
comm -1 -3 "${TMPDIR}/3rp-ChangeLog.old" \
"${TMPDIR}/3rp-ChangeLog.new" \
| sed -e "s/^SLACKPKGPLUS_//" -e "s/\[MD5\]//" \
| cut -f1 -d" " | grep -f ${TMPDIR}/selected.3pr >> "${TMPDIR}/updated-repos.txt"
# when TMPDIR/updated-repos.txt is not empty , it contains the
# names of the updated repositories.
#
# NOTE:
# at this point, updated-repos.txt can be empty when user
# has added a repository in REPOPLUS and run "slackpkg check-updates"
# instead (or prior to) "slackpkg update"
[ -s "${TMPDIR}/updated-repos.txt" ] && UPDATES=true
fi
if $UPDATES ; then
echo "News on ChangeLog.txt"
printf "\n [ %-24s ] [ %-20s ]\n" "Repository" "Status"
for REPO in slackware $REPOPLUS; do
if grep -q "^${REPO}$" ${TMPDIR}/updated-repos.txt ; then
printf " %-24s %-20s \n" "$REPO" "AVAILABLE UPDATES"
else
printf " %-24s %-20s \n" "$REPO" " Up to date "
fi
done
# save ${TMPDIR}/updates-repos.txt in ~/.slackpkg/updated-repos.txt
#
cat ${TMPDIR}/updated-repos.txt > ~/.slackpkg/updated-repos.txt
else
echo "No news is good news"
fi
cleanup
fi
fi