Restyling code only!

This commit is contained in:
Matteo Rossini 2013-05-05 16:16:02 +02:00
parent 9a10a4d531
commit 2deb2b4445

View file

@ -8,68 +8,9 @@ fi
if [ "$SLACKPKGPLUS" = "on" ];then
REPOPLUS=$(echo "${REPOPLUS[*]} ${PKGS_PRIORITY[*]} ${!MIRRORPLUS[*]}"|sed 's/ /\n/g'|sed 's/:.*//'|awk '{if(!a[$1]++)print $1}')
PRIORITY=( ${PRIORITY[*]} SLACKPKGPLUS_$(echo $REPOPLUS|sed 's/ / SLACKPKGPLUS_/g') )
# Test repositories
for pp in ${REPOPLUS[*]};do
echo "${MIRRORPLUS[$pp]}"|grep -q -e ^http:// -e ^https:// -e ^ftp:// -e ^file://
if [ $? -ne 0 ];then
echo "Repository '$pp' not configured." >> $TMPDIR/error.log
echo "Add:" >> $TMPDIR/error.log
echo "MIRRORPLUS['$pp']=http://repoaddres/..." >> $TMPDIR/error.log
echo "See documentation in /usr/doc/slackpkg+-* for details" >> $TMPDIR/error.log
cleanup
fi
done
if [ /etc/slackpkgplus.conf -nt /var/lib/slackpkg/pkglist -a "$CMD" != "update" ];then
echo
echo "NOTICE: remember to re-run 'slackpkg update' after modifing slackpkgplus.conf"
echo
sleep 5
fi
# -- merge priorities from PKGS_PRIORITY with PRIORITY, as needed ...
if [ ! -z "$PKGS_PRIORITY" -a "$CMD" != "update" ] ; then
PREFIX=""
for pp in ${PKGS_PRIORITY[*]} ; do
repository=$(echo "$pp" | cut -f1 -d":")
package=$(echo "$pp" | cut -f2- -d":")
if [ ! -z "$repository" ] && [ ! -z "$package" ] ; then
if [ -z "$PREFIX" ] ; then
PREFIX=( SLACKPKGPLUS_${repository}:$package )
else
PREFIX=( ${PREFIX[*]} SLACKPKGPLUS_${repository}:$package )
fi
fi
done
[ ! -z "$PREFIX" ] && PRIORITY=( ${PREFIX[*]} ${PRIORITY[*]} )
fi
function checkgpg() {
gpg --verify ${1}.asc ${1} 2>/dev/null && echo "1" || echo "0"
if [ "$(basename $1)" == "CHECKSUMS.md5" ];then
X86_64=$(ls /var/log/packages/aaa_base*x86_64*|head -1 2>/dev/null)
for PREPO in $REPOPLUS;do
if [ ! -z "$X86_64" ];then
egrep -e ^[a-f0-9]{32} ${TMPDIR}/CHECKSUMS.md5-$PREPO|egrep -- "-(x86_64|noarch)-" |sed -r "s# \./# ./SLACKPKGPLUS_$PREPO/#" >> ${TMPDIR}/CHECKSUMS.md5
else
egrep -e ^[a-f0-9]{32} ${TMPDIR}/CHECKSUMS.md5-$PREPO|egrep -v -- "-(x86_64|arm)-" |sed -r "s# \./# ./SLACKPKGPLUS_$PREPO/#" >> ${TMPDIR}/CHECKSUMS.md5
fi
done
fi
}
if [ -z "$DOWNLOADER" ];then
DOWNLOADER="wget --passive-ftp -O"
fi
# Override the slackpkg getfile().
# The new getfile() download all file needed from all defined repositories
# then merge all in a format slackpkg-compatible
function getfile(){
local URLFILE
URLFILE=$1
@ -183,13 +124,23 @@ if [ "$SLACKPKGPLUS" = "on" ];then
rm $2-tmp
done
fi
}
# Global variable required by givepriority()
#
PRIORITYIDX=1
# override slackpkg checkgpg()
# new checkgpg() is used to check gpg and to merge the CHECKSUMS.md5 files
function checkgpg() {
gpg --verify ${1}.asc ${1} 2>/dev/null && echo "1" || echo "0"
if [ "$(basename $1)" == "CHECKSUMS.md5" ];then
X86_64=$(ls /var/log/packages/aaa_base*x86_64*|head -1 2>/dev/null)
for PREPO in $REPOPLUS;do
if [ ! -z "$X86_64" ];then
egrep -e ^[a-f0-9]{32} ${TMPDIR}/CHECKSUMS.md5-$PREPO|egrep -- "-(x86_64|noarch)-" |sed -r "s# \./# ./SLACKPKGPLUS_$PREPO/#" >> ${TMPDIR}/CHECKSUMS.md5
else
egrep -e ^[a-f0-9]{32} ${TMPDIR}/CHECKSUMS.md5-$PREPO|egrep -v -- "-(x86_64|arm)-" |sed -r "s# \./# ./SLACKPKGPLUS_$PREPO/#" >> ${TMPDIR}/CHECKSUMS.md5
fi
done
fi
}
# Found packages in repository.
# This function selects the package from the higher priority
@ -201,7 +152,6 @@ if [ "$SLACKPKGPLUS" = "on" ];then
#
# repository_name:pattern
#
#
function givepriority {
local DIR
local ARGUMENT=$1
@ -256,43 +206,6 @@ if [ "$SLACKPKGPLUS" = "on" ];then
done
}
if [ "$CMD" == "install" ] || [ "$CMD" == "upgrade" ] ; then
NEWINPUTLIST=""
for pref in $INPUTLIST ; do
if echo "$pref" | grep -q "[a-zA-Z0-9]\+[:][a-zA-Z0-9]\+" ; then
repository=$(echo "$pref" | cut -f1 -d":")
package=$(echo "$pref" | cut -f2- -d":")
PRIORITY=( SLACKPKGPLUS_${repository}:$package ${PRIORITY[*]} )
else
package=$pref
fi
NEWINPUTLIST="$NEWINPUTLIST $package"
done
INPUTLIST=$NEWINPUTLIST
fi
if [ "$CMD" == "install-new" ] ; then
ls -1 /var/log/packages/*compat32 2>/dev/null | rev | cut -f1 -d/ | cut -f4- -d- | rev | sort > $TMPDIR/installed-compat32-packages.lst
grep "[[:digit:]]\+compat32[ ]" $WORKDIR/pkglist | cut -f2 -d" " | sort -u > $TMPDIR/available-compat32-packages.lst
NEWCOMPAT32PKGS=$(comm -3 $TMPDIR/installed-compat32-packages.lst $TMPDIR/available-compat32-packages.lst)
if [ ! -z "$NEWCOMPAT32PKGS" ] ; then
LIST=""
for pkg in $NEWCOMPAT32PKGS ; do
LIST="$LIST $(grep " ${pkg} " $WORKDIR/pkglist | cut -f6,8 -d" " --output-delimiter=".")"
done
fi
fi
function searchPackages() {
local i
@ -406,8 +319,7 @@ function searchlistEX() {
# First is the package already installed?
# Amazing what a little sleep will do
# exclusion is so much nicer :)
INSTPKG=$(ls -1 /var/log/packages | \
grep -e "^${BASENAME}-[^-]\+-\(${ARCH}\|fw\|noarch\)-[^-]\+")
INSTPKG=$(ls -1 /var/log/packages | grep -e "^${BASENAME}-[^-]\+-\(${ARCH}\|fw\|noarch\)-[^-]\+")
# INSTPKG is local version
if [ ! "${INSTPKG}" = "" ]; then
@ -426,6 +338,96 @@ function searchlistEX() {
done
}
REPOPLUS=$(echo "${REPOPLUS[*]} ${PKGS_PRIORITY[*]} ${!MIRRORPLUS[*]}"|sed 's/ /\n/g'|sed 's/:.*//'|awk '{if(!a[$1]++)print $1}')
PRIORITY=( ${PRIORITY[*]} SLACKPKGPLUS_$(echo $REPOPLUS|sed 's/ / SLACKPKGPLUS_/g') )
# Test repositories
for pp in ${REPOPLUS[*]};do
echo "${MIRRORPLUS[$pp]}"|grep -q -e ^http:// -e ^https:// -e ^ftp:// -e ^file://
if [ $? -ne 0 ];then
echo "Repository '$pp' not configured." >> $TMPDIR/error.log
echo "Add:" >> $TMPDIR/error.log
echo "MIRRORPLUS['$pp']=http://repoaddres/..." >> $TMPDIR/error.log
echo "See documentation in /usr/doc/slackpkg+-* for details" >> $TMPDIR/error.log
cleanup
fi
done
if [ /etc/slackpkgplus.conf -nt /var/lib/slackpkg/pkglist -a "$CMD" != "update" ];then
echo
echo "NOTICE: remember to re-run 'slackpkg update' after modifing slackpkgplus.conf"
echo
sleep 5
fi
# -- merge priorities from PKGS_PRIORITY with PRIORITY, as needed ...
if [ ! -z "$PKGS_PRIORITY" -a "$CMD" != "update" ] ; then
PREFIX=""
for pp in ${PKGS_PRIORITY[*]} ; do
repository=$(echo "$pp" | cut -f1 -d":")
package=$(echo "$pp" | cut -f2- -d":")
if [ ! -z "$repository" ] && [ ! -z "$package" ] ; then
if [ -z "$PREFIX" ] ; then
PREFIX=( SLACKPKGPLUS_${repository}:$package )
else
PREFIX=( ${PREFIX[*]} SLACKPKGPLUS_${repository}:$package )
fi
fi
done
[ ! -z "$PREFIX" ] && PRIORITY=( ${PREFIX[*]} ${PRIORITY[*]} )
fi
if [ -z "$DOWNLOADER" ];then
DOWNLOADER="wget --passive-ftp -O"
fi
# Global variable required by givepriority()
#
PRIORITYIDX=1
if [ "$CMD" == "install" ] || [ "$CMD" == "upgrade" ] ; then
NEWINPUTLIST=""
for pref in $INPUTLIST ; do
if echo "$pref" | grep -q "[a-zA-Z0-9]\+[:][a-zA-Z0-9]\+" ; then
repository=$(echo "$pref" | cut -f1 -d":")
package=$(echo "$pref" | cut -f2- -d":")
PRIORITY=( SLACKPKGPLUS_${repository}:$package ${PRIORITY[*]} )
else
package=$pref
fi
NEWINPUTLIST="$NEWINPUTLIST $package"
done
INPUTLIST=$NEWINPUTLIST
fi
if [ "$CMD" == "install-new" ] ; then
ls -1 /var/log/packages/*compat32 2>/dev/null | rev | cut -f1 -d/ | cut -f4- -d- | rev | sort > $TMPDIR/installed-compat32-packages.lst
grep "[[:digit:]]\+compat32[ ]" $WORKDIR/pkglist | cut -f2 -d" " | sort -u > $TMPDIR/available-compat32-packages.lst
NEWCOMPAT32PKGS=$(comm -3 $TMPDIR/installed-compat32-packages.lst $TMPDIR/available-compat32-packages.lst)
if [ ! -z "$NEWCOMPAT32PKGS" ] ; then
LIST=""
for pkg in $NEWCOMPAT32PKGS ; do
LIST="$LIST $(grep " ${pkg} " $WORKDIR/pkglist | cut -f6,8 -d" " --output-delimiter=".")"
done
fi
fi
if [ "$CMD" == "search" ] || [ "$CMD" == "file-search" ] ; then
PATTERN=$(echo $ARG | sed -e 's/\+/\\\+/g' -e 's/\./\\\./g' -e 's/ /\|/g')
searchPackages $PATTERN