mirror of
https://github.com/zuno/slackpkgplus
synced 2024-12-27 09:58:34 +01:00
Code reordering. No significant code modify:
Add vim modeline settings (but vim has nomodeline set by default, so it is just informational) Removed tab (use spaces instead) Reindent code Add/Modify comments moved zdialogplus.sh into slackpkgplus.sh reordering functions (and separing from main): function internal_blacklist() function applyblacklist() function cleanup() function handle_event() function remove_pkg() function upgrade_pkg() function install_pkg() function wgetdebug() function cached_downloader() function getfile() function checkgpg() function checkmd5() function givepriority() function searchPackages() function searchlistEX() function showlist() // dialog=on (ex-zdialogplus.sh) function showlist() // dialog=off
This commit is contained in:
parent
eab93929d0
commit
1dccd06d0a
3 changed files with 766 additions and 693 deletions
|
@ -57,7 +57,6 @@ mkdir -p usr/doc/slackpkg+-$VERSION/
|
|||
mkdir -p install/
|
||||
|
||||
cp $CWD/slackpkgplus.sh usr/libexec/slackpkg/functions.d/
|
||||
cp $CWD/zdialogplus.sh usr/libexec/slackpkg/functions.d/
|
||||
cp $CWD/makeinstlog.sh usr/libexec/slackpkg/makeinstlog.sh
|
||||
cp $CWD/README usr/doc/slackpkg+-$VERSION/
|
||||
cp $CWD/ChangeLog.txt usr/doc/slackpkg+-$VERSION/
|
||||
|
@ -73,7 +72,6 @@ cat $CWD/doinst.sh|sed "s/SLPVERSION/$VERSION/" > install/doinst.sh
|
|||
cat $CWD/notifymsg.conf > etc/slackpkg/notifymsg.conf.new
|
||||
|
||||
chmod +x usr/libexec/slackpkg/functions.d/slackpkgplus.sh
|
||||
chmod +x usr/libexec/slackpkg/functions.d/zdialogplus.sh
|
||||
chmod +x usr/libexec/slackpkg/makeinstlog.sh
|
||||
chmod +x usr/doc/slackpkg+-$VERSION/setupmultilib.sh
|
||||
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
# vim: set tabstop=2 shiftwidth=2 expandtab
|
||||
|
||||
# Thanks to AlienBob and phenixia2003 (on LQ) for contributing
|
||||
# A special thanks to all packagers that make slackpkg+ useful
|
||||
|
||||
|
@ -49,33 +51,68 @@ fi
|
|||
|
||||
if [ "$SLACKPKGPLUS" = "on" ];then
|
||||
|
||||
if [ "$DOWNLOADONLY" == "on" ];then
|
||||
DELALL=off
|
||||
DOWNLOAD_ALL=on
|
||||
|
||||
# function internal_blacklist()
|
||||
# function applyblacklist()
|
||||
# function cleanup()
|
||||
# function handle_event()
|
||||
# function remove_pkg()
|
||||
# function upgrade_pkg()
|
||||
# function install_pkg()
|
||||
# function wgetdebug()
|
||||
# function cached_downloader()
|
||||
# function getfile()
|
||||
# function checkgpg()
|
||||
# function checkmd5()
|
||||
# function givepriority()
|
||||
# function searchPackages()
|
||||
# function searchlistEX()
|
||||
# function showlist() // dialog=on
|
||||
# function showlist() // dialog=off
|
||||
|
||||
|
||||
##### ===== BLACKLIST FUNCTIONS === #####
|
||||
|
||||
# Adds the pattern given by $(1) into the internal blacklist
|
||||
# ${TMPDIR}/blacklist.slackpkgplus
|
||||
#
|
||||
# ($1) The pattern to add.
|
||||
#
|
||||
function internal_blacklist() {
|
||||
echo "$1" >> ${TMPDIR}/blacklist.slackpkgplus
|
||||
} # END function internal_blacklist()
|
||||
|
||||
# Override original applyblackist() so that internal blacklist will
|
||||
# be applied too.
|
||||
#
|
||||
function applyblacklist() {
|
||||
# -- This is to prevent silent exclusion of multilib package
|
||||
# aaa_elflibs-compat32 when /etc/slackpkg/blacklist contains the
|
||||
# pattern aaa_elflibs.
|
||||
if ! $USEBLACKLIST ;then
|
||||
>${TMPDIR}/blacklist
|
||||
fi
|
||||
|
||||
if [ -z "$VERBOSE" ];then
|
||||
VERBOSE=1
|
||||
if $MLREPO_SELELECTED && grep -q "^aaa_elflibs$" ${TMPDIR}/blacklist && ! grep -q "^aaa_elflibs-compat32$" ${TMPDIR}/blacklist ; then
|
||||
sed -i --expression "s/^aaa_elflibs/#aaa_elflibs/" ${TMPDIR}/blacklist
|
||||
grep -vEw -f ${TMPDIR}/blacklist -f ${TMPDIR}/blacklist.slackpkgplus | grep -v "[ ]aaa_elflibs[ ]" >${TMPDIR}/blacklist.tmp
|
||||
else
|
||||
grep -vEw -f ${TMPDIR}/blacklist -f ${TMPDIR}/blacklist.slackpkgplus >${TMPDIR}/blacklist.tmp
|
||||
fi
|
||||
|
||||
|
||||
|
||||
SPKGPLUS_VERSION="1.6.1"
|
||||
VERSION="$VERSION / slackpkg+ $SPKGPLUS_VERSION"
|
||||
|
||||
|
||||
if [ ! -e "$WORKDIR" ];then
|
||||
mkdir -p "$WORKDIR"
|
||||
cat ${TMPDIR}/blacklist.tmp
|
||||
if [ "$(head -1 ${TMPDIR}/blacklist.tmp|awk '{print $1}')" != "local" ];then
|
||||
cat ${TMPDIR}/pkglist-pre
|
||||
fi
|
||||
cat $TMPDIR/greylist.* >$TMPDIR/greylist
|
||||
grep -qvEw -f $TMPDIR/greylist $TMPDIR/pkglist-pre >$TMPDIR/unchecklist
|
||||
|
||||
if [ ! -e $WORKDIR/install.log ];then
|
||||
touch $WORKDIR/install.log
|
||||
fi
|
||||
} # END function applyblacklist()
|
||||
|
||||
if [ "$CMD" == "update" ];then
|
||||
ANSWER="Y"
|
||||
fi
|
||||
##### ====== END BLACKLIST FUNCTIONS === #####
|
||||
|
||||
##### ====== INSTALL/POSTINSTALL FUNCTIONS ====== #####
|
||||
|
||||
# Override cleanup() to improve log messages and debug functions
|
||||
#
|
||||
function cleanup(){
|
||||
if [ "$CMD" == "update" ];then
|
||||
if [ "$ANSWER" != "Y" ] && [ "$ANSWER" != "y" ]; then
|
||||
|
@ -114,7 +151,250 @@ if [ "$SLACKPKGPLUS" = "on" ];then
|
|||
rm -rf $TMPDIR
|
||||
fi
|
||||
exit
|
||||
} # END cleanup()
|
||||
} # END function cleanup()
|
||||
|
||||
# -- handle the event $1 that occured on packages $SHOWLIST
|
||||
#
|
||||
# $1 the event that occurs, which can be install, upgrade, remove
|
||||
#
|
||||
function handle_event() {
|
||||
local EVENT="$1"
|
||||
local SELKEYS=""
|
||||
local KEY
|
||||
local PATLIST
|
||||
local EXPR
|
||||
local MSG
|
||||
local MSGLIST=""
|
||||
local USERKEY
|
||||
|
||||
find $ROOT/var/log/packages/ -type f -printf "%f\n" | sort > ${TMPDIR}/installed.tmp
|
||||
|
||||
# -- Get the basename of packages which have been effectively
|
||||
# installed, upgraded, or removed
|
||||
|
||||
if [ "$EVENT" == "remove" ] ; then
|
||||
echo "$SHOWLIST" | tr " " "\n" | sort > ${TMPDIR}/showlist.tmp
|
||||
|
||||
comm -1 ${TMPDIR}/installed.tmp ${TMPDIR}/showlist.tmp | rev | cut -f4- -d"-" | rev > ${TMPDIR}/basenames.tmp
|
||||
else
|
||||
echo "$SHOWLIST" | tr " " "\n" | rev | cut -f2- -d"." | rev | sort > ${TMPDIR}/showlist.tmp
|
||||
|
||||
comm -1 -2 ${TMPDIR}/installed.tmp ${TMPDIR}/showlist.tmp | rev | cut -f4- -d"-" | rev > ${TMPDIR}/basenames.tmp
|
||||
fi
|
||||
|
||||
SELKEYS=$(echo "${!NOTIFYMSG[@]}" | tr " " "\n" | grep "^on_${EVENT}@" | tr "\n" " ")
|
||||
|
||||
for KEY in $SELKEYS ; do
|
||||
PATLIST="${KEY#*@}"
|
||||
EXPR=$(echo -en "$PATLIST" | \
|
||||
tr --squeeze-repeats "," | \
|
||||
sed -e "s/,$//" -e "s/^/(&/" -e "s/,/)|(/g" -e "s/$/&)/")
|
||||
|
||||
NV_MATCHPKGS=$(grep -E "$EXPR" ${TMPDIR}/basenames.tmp | tr "\n" "," | sed -e "s/,$//")
|
||||
|
||||
if [ ! -z "$NV_MATCHPKGS" ] ; then
|
||||
MSG=$(eval "echo \"${NOTIFYMSG[$KEY]}\"")
|
||||
[ -z "MSGLIST" ] && MSGLIST="$MSG\n" || MSGLIST="$MSGLIST\n$MSG"
|
||||
fi
|
||||
done
|
||||
|
||||
if [ ! -z "$MSGLIST" ] ; then
|
||||
|
||||
if [ "$DIALOG" = "on" ] || [ "$DIALOG" = "ON" ] ; then
|
||||
dialog --title "post-$EVENT notifications" --backtitle "slackpkg $VERSION" --msgbox "$MSGLIST" 12 70
|
||||
else
|
||||
MSGLIST="====[ POST-${EVENT} NOTIFICATIONS ]===================================== \n${MSGLIST}\n======================================================================="
|
||||
echo -e "\n$MSGLIST" | more
|
||||
echo -en "Hit a key to continue or wait 10 seconds\r"
|
||||
read -t 10 USERKEY
|
||||
echo " "
|
||||
fi
|
||||
fi
|
||||
} # END functino handle_event()
|
||||
|
||||
# Overrides original remove_pkg(). Required by the notification mechanism.
|
||||
function remove_pkg() {
|
||||
local i
|
||||
|
||||
for i in $SHOWLIST; do
|
||||
echo -e "\nPackage: $i"
|
||||
echo -e "\tRemoving... "
|
||||
removepkg $i
|
||||
if [ ! -e $ROOT/var/log/packages/$i ];then
|
||||
FDATE=$(ls -ltr --full-time $ROOT/var/log/removed_packages/$i|tail -1 |awk '{print $6" "$7}'|sed -r -e 's/\.[0-9]{9}//' -e 's,-,/,' -e 's,-,/,')
|
||||
echo "$FDATE removed: $i" >> $WORKDIR/install.log
|
||||
fi
|
||||
done
|
||||
handle_event "remove"
|
||||
} # END function remove_pkg()
|
||||
|
||||
# Overrides original upgrade_pkg(). Required by the notification mechanism.
|
||||
function upgrade_pkg() {
|
||||
local i
|
||||
|
||||
if [ "$DOWNLOAD_ALL" = "on" ]; then
|
||||
OLDDEL="$DELALL"
|
||||
DELALL="off"
|
||||
for i in $SHOWLIST; do
|
||||
getpkg $i true
|
||||
done
|
||||
DELALL="$OLDDEL"
|
||||
fi
|
||||
if [ "$DOWNLOADONLY" == "on" ];then
|
||||
echo "Download only.. not upgraded!"
|
||||
return
|
||||
fi
|
||||
ls -1 $ROOT/var/log/packages > $TMPDIR/tmplist
|
||||
|
||||
for i in $SHOWLIST; do
|
||||
PKGFOUND=$(grep -m1 -e "^$(echo $i|rev|cut -f4- -d-|rev)-[^-]\+-[^-]\+-[^-]\+$" $TMPDIR/tmplist)
|
||||
REPOPOS=$(grep -m1 " $(echo $i|sed 's/\.t.z//') " $TMPDIR/pkglist|awk '{print $1}'|sed 's/SLACKPKGPLUS_//')
|
||||
getpkg $i upgradepkg Upgrading
|
||||
if [ -e "$ROOT/var/log/packages/$(echo $i|sed 's/\.t.z//')" ];then
|
||||
FDATE=$(ls -l --full-time $ROOT/var/log/packages/$(echo $i|sed 's/\.t.z//') |awk '{print $6" "$7}'|sed -r -e 's/\.[0-9]{9}//' -e 's,-,/,' -e 's,-,/,')
|
||||
echo "$FDATE upgraded: $i [$REPOPOS] (was $PKGFOUND)" >> $WORKDIR/install.log
|
||||
fi
|
||||
done
|
||||
handle_event "upgrade"
|
||||
} # END function upgrade_pkg()
|
||||
|
||||
# Overrides original install_pkg(). Required by the notification mechanism.
|
||||
function install_pkg() {
|
||||
local i
|
||||
|
||||
if [ "$DOWNLOAD_ALL" = "on" ]; then
|
||||
OLDDEL="$DELALL"
|
||||
DELALL="off"
|
||||
for i in $SHOWLIST; do
|
||||
getpkg $i true
|
||||
done
|
||||
DELALL="$OLDDEL"
|
||||
fi
|
||||
if [ "$DOWNLOADONLY" == "on" ];then
|
||||
echo "Download only.. not installed!"
|
||||
return
|
||||
fi
|
||||
for i in $SHOWLIST; do
|
||||
INSTALL_T='installed: '
|
||||
if [ -e $ROOT/var/log/packages/$(echo $i|sed 's/\.t.z//') ];then
|
||||
INSTALL_T='reinstalled:'
|
||||
fi
|
||||
REPOPOS=$(grep -m1 " $(echo $i|sed 's/\.t.z//') " $TMPDIR/pkglist|awk '{print $1}'|sed 's/SLACKPKGPLUS_//')
|
||||
getpkg $i installpkg Installing
|
||||
if [ -e "$ROOT/var/log/packages/$(echo $i|sed 's/\.t.z//')" ];then
|
||||
FDATE=$(ls -l --full-time $ROOT/var/log/packages/$(echo $i|sed 's/\.t.z//') |awk '{print $6" "$7}'|sed -r -e 's/\.[0-9]{9}//' -e 's,-,/,' -e 's,-,/,')
|
||||
echo "$FDATE $INSTALL_T $i [$REPOPOS]" >> $WORKDIR/install.log
|
||||
fi
|
||||
done
|
||||
handle_event "install"
|
||||
} # END function install_pkg()
|
||||
|
||||
##### ====== END INSTALL/POSTINSTALL FUNCTIONS ====== #####
|
||||
|
||||
|
||||
##### ====== DOWNLOADERS ====== ######
|
||||
|
||||
# Implements an improved wget version for a verbose output
|
||||
#
|
||||
function wgetdebug(){
|
||||
local SRCURL
|
||||
local DSTFILE
|
||||
SRCURL=$2
|
||||
DSTFILE=$(echo $SRCURL|sed 's|/|,|g')
|
||||
if [ ${SRCURL:0:5} == "https" ];then
|
||||
WGETOPTSL="--no-check-certificate"
|
||||
fi
|
||||
if [ ${SRCURL:0:3} == "ftp" ];then
|
||||
WGETOPTSL="--passive-ftp"
|
||||
fi
|
||||
|
||||
DOWNTIME=$(date +%s)
|
||||
|
||||
wget $WGETOPTS $WGETOPTSL -O $TMPDIR/$DSTFILE $SRCURL 2>&1|tee $TMPDIR/$DSTFILE.log
|
||||
WGETERR=${PIPESTATUS[0]}
|
||||
cp $TMPDIR/$DSTFILE $1
|
||||
echo "exit code: $WGETERR" >>$TMPDIR/$DSTFILE.log
|
||||
DOWNTIME=$[$(date +%s)-$DOWNTIME]
|
||||
if [ $WGETERR -ne 0 ];then
|
||||
echo >> $TMPDIR/error.log
|
||||
echo "$SRCURL --> BAD" >> $TMPDIR/error.log
|
||||
echo "wget $WGETOPTS $WGETOPTSL -O $DSTFILE $SRCURL" >> $TMPDIR/error.log
|
||||
echo "exit code: $WGETERR" >> $TMPDIR/error.log
|
||||
echo "download time: $DOWNTIME secs" >> $TMPDIR/error.log
|
||||
echo "details:" >> $TMPDIR/error.log
|
||||
cat $TMPDIR/$DSTFILE.log >> $TMPDIR/error.log
|
||||
ls -l $DSTFILE >> $TMPDIR/error.log 2>&1
|
||||
md5sum $DSTFILE >> $TMPDIR/error.log 2>&1
|
||||
echo >> $TMPDIR/error.log
|
||||
else
|
||||
echo "$SRCURL --> OK" >> $TMPDIR/info.log
|
||||
fi
|
||||
return $WGETERR
|
||||
|
||||
|
||||
} # END function wgetdebug()
|
||||
|
||||
|
||||
# Implements CACHEUPDATE=on
|
||||
#
|
||||
function cached_downloader(){
|
||||
local SRCURL
|
||||
local CACHEFILE
|
||||
local SRCBASE
|
||||
SRCURL=$2
|
||||
SRCBASE=$(basename $SRCURL)
|
||||
CACHEFILE=$(echo $SRCURL|md5sum|awk '{print $1}')
|
||||
|
||||
case $SRCBASE in
|
||||
CHECKSUMS.md5) TOCACHE=1 ;;
|
||||
MANIFEST.bz2) TOCACHE=1 ;;
|
||||
PACKAGES.TXT) TOCACHE=1 ;;
|
||||
*) TOCACHE=0 ;;
|
||||
esac
|
||||
|
||||
if [ $TOCACHE -eq 1 ];then
|
||||
echo
|
||||
echo "=== check cache: $SRCURL ==="
|
||||
echo -n "headers.. "
|
||||
curl --location --head $SRCURL 2>/dev/null|grep -v ^Date:|sed 's/
//' > $TMPDIR/cache.head
|
||||
echo "Url: $SRCURL" >> $TMPDIR/cache.head
|
||||
grep -q "200 OK" $TMPDIR/cache.head || echo "Header or Url Invalid!!! (`date`)"
|
||||
[ $VERBOSE -eq 3 ]&&cat $TMPDIR/cache.head|sed 's/^/ /'
|
||||
if [ -e $CACHEDIR/$CACHEFILE -a -e $CACHEDIR/$CACHEFILE.head ];then
|
||||
echo "Is cached.. "
|
||||
[ $VERBOSE -eq 3 ]&&cat $CACHEDIR/$CACHEFILE.head|sed 's/^/ /'
|
||||
if diff $CACHEDIR/$CACHEFILE.head $TMPDIR/cache.head >/dev/null;then
|
||||
echo "Cache valid! If not please remove manually $CACHEDIR/$CACHEFILE !"
|
||||
cp $CACHEDIR/$CACHEFILE $1
|
||||
return $?
|
||||
fi
|
||||
echo -n "Invalid.. "
|
||||
rm -f $CACHEDIR/$CACHEFILE $CACHEDIR/$CACHEFILE.head
|
||||
fi
|
||||
echo "Download file.. "
|
||||
$CACHEDOWNLOADER $1 $SRCURL
|
||||
ERR=$?
|
||||
if [ "$(ls -l $1 2>/dev/null|awk '{print $5}')" == "$(grep Content-Length: $TMPDIR/cache.head|awk '{print $2}')" ];then
|
||||
echo "Caching it!"
|
||||
cp $1 $CACHEDIR/$CACHEFILE
|
||||
cp $TMPDIR/cache.head $CACHEDIR/$CACHEFILE.head
|
||||
else
|
||||
echo "NOT cacheable!"
|
||||
fi
|
||||
else
|
||||
echo
|
||||
echo "=== no caching for $SRCURL ==="
|
||||
$CACHEDOWNLOADER $1 $SRCURL
|
||||
ERR=$?
|
||||
fi
|
||||
return $ERR
|
||||
|
||||
} # END function cached_downloader()
|
||||
|
||||
##### ====== END DOWNLOADERS ====== ######
|
||||
|
||||
|
||||
##### ====== CORE FUNCTION ====== ######
|
||||
|
||||
# Override the slackpkg getfile().
|
||||
# The new getfile() download all file needed from all defined repositories
|
||||
|
@ -299,7 +579,7 @@ if [ "$SLACKPKGPLUS" = "on" ];then
|
|||
rm $2-tmp
|
||||
done
|
||||
fi
|
||||
} # END getfile()
|
||||
} # END function getfile()
|
||||
|
||||
# override slackpkg checkgpg()
|
||||
# new checkgpg() is used to check gpg and to merge the CHECKSUMS.md5 files
|
||||
|
@ -333,7 +613,7 @@ if [ "$SLACKPKGPLUS" = "on" ];then
|
|||
fi
|
||||
done
|
||||
fi
|
||||
} # END checkgpg()
|
||||
} # END function checkgpg()
|
||||
|
||||
# override slackpkg checkmd5()
|
||||
# Verify if the package was corrupted by checking md5sum
|
||||
|
@ -361,7 +641,12 @@ if [ "$SLACKPKGPLUS" = "on" ];then
|
|||
else
|
||||
echo 0
|
||||
fi
|
||||
} # END checkmd5()
|
||||
} # END function checkmd5()
|
||||
|
||||
#### ====== END CORE FUNCTIONS ======= ####
|
||||
|
||||
|
||||
#### ===== PRIORITY AND SEARCH FUNCTIONS ===== #####
|
||||
|
||||
# Found packages in repository.
|
||||
# This function selects the package from the higher priority
|
||||
|
@ -496,8 +781,10 @@ if [ "$SLACKPKGPLUS" = "on" ];then
|
|||
(( PRIORITYIDX++ ))
|
||||
fi
|
||||
done
|
||||
} # END givepriority()
|
||||
} # END function givepriority()
|
||||
|
||||
# Improved 'slackpkg search'/'slackpkg file-search'
|
||||
#
|
||||
function searchPackages() {
|
||||
local i
|
||||
local GREPOPTS=""
|
||||
|
@ -576,8 +863,14 @@ if [ "$SLACKPKGPLUS" = "on" ];then
|
|||
rm ${TMPDIR}/waiting
|
||||
|
||||
echo -e "DONE\n"
|
||||
} # END searchPackages()
|
||||
} # END function searchPackages()
|
||||
|
||||
#### ===== PRIORITY AND SEARCH FUNCTIONS ===== #####
|
||||
|
||||
#### ===== SHOWLIST FUNCTIONS ====== ######
|
||||
|
||||
# generate output for 'slackpkg search'/'slackpkg file-search'
|
||||
#
|
||||
function searchlistEX() {
|
||||
local i
|
||||
local BASENAME
|
||||
|
@ -642,7 +935,117 @@ if [ "$SLACKPKGPLUS" = "on" ];then
|
|||
printf " %-16s %-24s %-40s \n" "$STATUS" "$REPO" "${RAWNAME}"
|
||||
fi
|
||||
done
|
||||
} # END searchlistEX()
|
||||
} # END function searchlistEX()
|
||||
|
||||
|
||||
if [ "$DIALOG" = "on" ] || [ "$DIALOG" = "ON" ]; then
|
||||
# Slackpkg+ Dialog functions
|
||||
# Original functions from slackpkg modified by Marek Wodzinski (majek@mamy.to)
|
||||
#
|
||||
export DIALOG_CANCEL="1"
|
||||
export DIALOG_ERROR="126"
|
||||
export DIALOG_ESC="1"
|
||||
export DIALOG_EXTRA="3"
|
||||
export DIALOG_HELP="2"
|
||||
export DIALOG_ITEM_HELP="2"
|
||||
export DIALOG_OK="0"
|
||||
|
||||
# Show the lists and asks if the user want to proceed with that action
|
||||
# Return accepted list in $SHOWLIST
|
||||
#
|
||||
function showlist() {
|
||||
if [ "$ONOFF" != "off" ]; then
|
||||
ONOFF=on
|
||||
fi
|
||||
|
||||
cat $TMPDIR/greylist.* >$TMPDIR/greylist
|
||||
if [ "$GREYLIST" == "off" ];then
|
||||
>$TMPDIR/greylist
|
||||
fi
|
||||
grep -Ew -f $TMPDIR/greylist $TMPDIR/pkglist|awk '{print $2}' >$TMPDIR/unchecklist
|
||||
rm -f $TMPDIR/dialog.tmp
|
||||
|
||||
if [ "$2" = "upgrade" ]; then
|
||||
ls -1 $ROOT/var/log/packages > $TMPDIR/tmplist
|
||||
for i in $1; do
|
||||
TMPONOFF=$ONOFF
|
||||
BASENAME=$(cutpkg $i)
|
||||
PKGFOUND=$(grep -m1 -e "^${BASENAME}-[^-]\+-[^-]\+-[^-]\+$" $TMPDIR/tmplist)
|
||||
REPOPOS=$(grep -m1 " $(echo $i|sed 's/\.t.z//') " $TMPDIR/pkglist|awk '{print $1}'|sed 's/SLACKPKGPLUS_//')
|
||||
REPOPOSFULL=$(grep -m1 " $(echo $i|sed 's/\.t.z//') " $TMPDIR/pkglist|sed 's/SLACKPKGPLUS_//'|awk '{print $0,gensub(/([0-9]+)([^0-9]*)/,"\\1 \\2_","1",$5),$6}')
|
||||
PKGVER=$(echo $i|rev|cut -f3 -d-|rev)
|
||||
ALLFOUND=$(echo $(grep " ${BASENAME} " $TMPDIR/pkglist|sed -r -e 's/SLACKPKGPLUS_//' -e 's/^([^ ]*) [^ ]* ([^ ]*) [^ ]* ([^ ]*) .*/\2-\3(\1) ,/')|sed 's/,$//')
|
||||
|
||||
grep -q "^$(echo $i|rev|cut -f4- -d-|rev)$" $TMPDIR/unchecklist && TMPONOFF="off"
|
||||
echo "$REPOPOSFULL $i \"$REPOPOS\" $TMPONOFF \"installed: $PKGFOUND --> available: $ALLFOUND\"" >>$TMPDIR/dialog.tmp.1
|
||||
done
|
||||
|
||||
# 1 2 3 4 5 6 7 8 9 1011 12-
|
||||
# repo package 1.0.12 i586 1 package-1.0.12-i586-1 ./path/to txz 1 _ package-1.0.12-i586-1 package-1.0.12-i586-1.txz "repo" on "installed: ... "
|
||||
case "$SHOWORDER" in
|
||||
"repository") SHOWORDER=1;;
|
||||
"arch") SHOWORDER=4;;
|
||||
"package") SHOWORDER=6;;
|
||||
"path") SHOWORDER=7;;
|
||||
"tag") SHOWORDER=10;;
|
||||
*) SHOWORDER=6;;
|
||||
esac
|
||||
cat $TMPDIR/dialog.tmp.1 | awk '{print $'$SHOWORDER',$0}'|sort|cut -f13- -d" " >$TMPDIR/dialog.tmp
|
||||
HINT="--item-help"
|
||||
|
||||
else # other than 'upgrade'
|
||||
|
||||
for i in $1; do
|
||||
TMPONOFF=$ONOFF
|
||||
REPOPOS=$(grep -m1 " $(echo $i|sed 's/\.t.z//') " $TMPDIR/pkglist|awk '{print $1}'|sed 's/SLACKPKGPLUS_//')
|
||||
grep -q "^$(echo $i|rev|cut -f4- -d-|rev)$" $TMPDIR/unchecklist && TMPONOFF="off"
|
||||
echo "$i \"$REPOPOS\" $TMPONOFF" >>$TMPDIR/dialog.tmp
|
||||
done
|
||||
HINT=""
|
||||
fi
|
||||
|
||||
# This is needed because dialog have a limit of arguments.
|
||||
# This limit is around 20k characters in slackware 10.x
|
||||
# Empiric tests on slackware 13.0 got a limit around 139k.
|
||||
# If we exceed this limit, dialog got a terrible error, to
|
||||
# avoid that, if the number of arguments is bigger than
|
||||
# DIALOG_MAXARGS we remove the hints. If even without hints
|
||||
# we can't got less characters than DIALOG_MAXARGS we give an
|
||||
# error message to the user ask him to not use dialog
|
||||
if [ $(wc -c $TMPDIR/dialog.tmp | cut -f1 -d\ ) -ge $DIALOG_MAXARGS ]; then
|
||||
mv $TMPDIR/dialog.tmp $TMPDIR/dialog2.tmp
|
||||
awk '{ NF=3 ; print $0 }' $TMPDIR/dialog2.tmp > $TMPDIR/dialog.tmp
|
||||
HINT=""
|
||||
fi
|
||||
DTITLE=$2
|
||||
if [ "$DOWNLOADONLY" == "on" ];then
|
||||
DTITLE="$DTITLE (download only)"
|
||||
fi
|
||||
cat $TMPDIR/dialog.tmp|xargs dialog --title "$DTITLE" --backtitle "slackpkg $VERSION" $HINT --checklist "Choose packages to $2:" 19 70 13 2>$TMPDIR/dialog.out
|
||||
case "$?" in
|
||||
0|123)
|
||||
dialog --clear
|
||||
;;
|
||||
1|124|125|126|127)
|
||||
dialog --clear
|
||||
echo -e "DIALOG ERROR:\n-------------" >> $TMPDIR/error.log
|
||||
cat $TMPDIR/dialog.out >> $TMPDIR/error.log
|
||||
echo "-------------"
|
||||
echo "If you want to continue using slackpkg, disable the DIALOG option in"
|
||||
echo "$CONF/slackpkg.conf and try again."
|
||||
echo "Help us to make slackpkg a better tool - report bugs to the slackpkg"
|
||||
echo "developers" >> $TMPDIR/error.log
|
||||
cleanup
|
||||
;;
|
||||
esac
|
||||
SHOWLIST=$(cat $TMPDIR/dialog.out | tr -d \")
|
||||
if [ -z "$SHOWLIST" ]; then
|
||||
echo "No packages selected for $2, exiting."
|
||||
cleanup
|
||||
fi
|
||||
} # END function showlist()
|
||||
|
||||
else # (DIALOG=off)
|
||||
|
||||
# Supersede original showlist() from core-functions.sh
|
||||
#
|
||||
|
@ -680,7 +1083,47 @@ function showlist() {
|
|||
SHOWLIST="$1"
|
||||
continue
|
||||
fi
|
||||
}
|
||||
} # END function showlist()
|
||||
|
||||
fi # (DIALOG=on/off)
|
||||
|
||||
#### ===== SHOWLIST FUNCTIONS ====== ######
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
### =========================== MAIN ============================ ###
|
||||
|
||||
if [ "$DOWNLOADONLY" == "on" ];then
|
||||
DELALL=off
|
||||
DOWNLOAD_ALL=on
|
||||
fi
|
||||
|
||||
if [ -z "$VERBOSE" ];then
|
||||
VERBOSE=1
|
||||
fi
|
||||
|
||||
|
||||
|
||||
SPKGPLUS_VERSION="1.6.1"
|
||||
VERSION="$VERSION / slackpkg+ $SPKGPLUS_VERSION"
|
||||
|
||||
|
||||
if [ ! -e "$WORKDIR" ];then
|
||||
mkdir -p "$WORKDIR"
|
||||
fi
|
||||
|
||||
if [ ! -e $WORKDIR/install.log ];then
|
||||
touch $WORKDIR/install.log
|
||||
fi
|
||||
|
||||
if [ "$CMD" == "update" ];then
|
||||
# answer to "Do you really want to download all other files"
|
||||
# if there are new changes
|
||||
ANSWER="Y"
|
||||
fi
|
||||
|
||||
|
||||
# Ensure each repository url has a trailing slash...
|
||||
#
|
||||
|
@ -779,267 +1222,6 @@ function showlist() {
|
|||
#
|
||||
echo -n "" > ${TMPDIR}/blacklist.slackpkgplus
|
||||
|
||||
# Adds the pattern given by $(1) into the internal blacklist
|
||||
# ${TMPDIR}/blacklist.slackpkgplus
|
||||
#
|
||||
# ($1) The pattern to add.
|
||||
#
|
||||
function internal_blacklist() {
|
||||
echo "$1" >> ${TMPDIR}/blacklist.slackpkgplus
|
||||
} # END internal_blacklist()
|
||||
|
||||
# Override original applyblackist() so that internal blacklist will
|
||||
# be applied too.
|
||||
#
|
||||
function applyblacklist() {
|
||||
# -- This is to prevent silent exclusion of multilib package
|
||||
# aaa_elflibs-compat32 when /etc/slackpkg/blacklist contains the
|
||||
# pattern aaa_elflibs.
|
||||
if ! $USEBLACKLIST ;then
|
||||
>${TMPDIR}/blacklist
|
||||
fi
|
||||
if $MLREPO_SELELECTED && grep -q "^aaa_elflibs$" ${TMPDIR}/blacklist && ! grep -q "^aaa_elflibs-compat32$" ${TMPDIR}/blacklist ; then
|
||||
sed -i --expression "s/^aaa_elflibs/#aaa_elflibs/" ${TMPDIR}/blacklist
|
||||
grep -vEw -f ${TMPDIR}/blacklist -f ${TMPDIR}/blacklist.slackpkgplus | grep -v "[ ]aaa_elflibs[ ]" >${TMPDIR}/blacklist.tmp
|
||||
else
|
||||
grep -vEw -f ${TMPDIR}/blacklist -f ${TMPDIR}/blacklist.slackpkgplus >${TMPDIR}/blacklist.tmp
|
||||
fi
|
||||
cat ${TMPDIR}/blacklist.tmp
|
||||
if [ "$(head -1 ${TMPDIR}/blacklist.tmp|awk '{print $1}')" != "local" ];then
|
||||
cat ${TMPDIR}/pkglist-pre
|
||||
fi
|
||||
cat $TMPDIR/greylist.* >$TMPDIR/greylist
|
||||
grep -qvEw -f $TMPDIR/greylist $TMPDIR/pkglist-pre >$TMPDIR/unchecklist
|
||||
|
||||
} # END applyblacklist()
|
||||
|
||||
# -- handle the event $1 that occured on packages $SHOWLIST
|
||||
#
|
||||
# $1 the event that occurs, which can be install, upgrade, remove
|
||||
#
|
||||
function handle_event() {
|
||||
local EVENT="$1"
|
||||
local SELKEYS=""
|
||||
local KEY
|
||||
local PATLIST
|
||||
local EXPR
|
||||
local MSG
|
||||
local MSGLIST=""
|
||||
local USERKEY
|
||||
|
||||
find $ROOT/var/log/packages/ -type f -printf "%f\n" | sort > ${TMPDIR}/installed.tmp
|
||||
|
||||
# -- Get the basename of packages which have been effectively
|
||||
# installed, upgraded, or removed
|
||||
|
||||
if [ "$EVENT" == "remove" ] ; then
|
||||
echo "$SHOWLIST" | tr " " "\n" | sort > ${TMPDIR}/showlist.tmp
|
||||
|
||||
comm -1 ${TMPDIR}/installed.tmp ${TMPDIR}/showlist.tmp | rev | cut -f4- -d"-" | rev > ${TMPDIR}/basenames.tmp
|
||||
else
|
||||
echo "$SHOWLIST" | tr " " "\n" | rev | cut -f2- -d"." | rev | sort > ${TMPDIR}/showlist.tmp
|
||||
|
||||
comm -1 -2 ${TMPDIR}/installed.tmp ${TMPDIR}/showlist.tmp | rev | cut -f4- -d"-" | rev > ${TMPDIR}/basenames.tmp
|
||||
fi
|
||||
|
||||
SELKEYS=$(echo "${!NOTIFYMSG[@]}" | tr " " "\n" | grep "^on_${EVENT}@" | tr "\n" " ")
|
||||
|
||||
for KEY in $SELKEYS ; do
|
||||
PATLIST="${KEY#*@}"
|
||||
EXPR=$(echo -en "$PATLIST" | \
|
||||
tr --squeeze-repeats "," | \
|
||||
sed -e "s/,$//" -e "s/^/(&/" -e "s/,/)|(/g" -e "s/$/&)/")
|
||||
|
||||
NV_MATCHPKGS=$(grep -E "$EXPR" ${TMPDIR}/basenames.tmp | tr "\n" "," | sed -e "s/,$//")
|
||||
|
||||
if [ ! -z "$NV_MATCHPKGS" ] ; then
|
||||
MSG=$(eval "echo \"${NOTIFYMSG[$KEY]}\"")
|
||||
[ -z "MSGLIST" ] && MSGLIST="$MSG\n" || MSGLIST="$MSGLIST\n$MSG"
|
||||
fi
|
||||
done
|
||||
|
||||
if [ ! -z "$MSGLIST" ] ; then
|
||||
|
||||
if [ "$DIALOG" = "on" ] || [ "$DIALOG" = "ON" ] ; then
|
||||
dialog --title "post-$EVENT notifications" --backtitle "slackpkg $VERSION" --msgbox "$MSGLIST" 12 70
|
||||
else
|
||||
MSGLIST="====[ POST-${EVENT} NOTIFICATIONS ]===================================== \n${MSGLIST}\n======================================================================="
|
||||
echo -e "\n$MSGLIST" | more
|
||||
echo -en "Hit a key to continue or wait 10 seconds\r"
|
||||
read -t 10 USERKEY
|
||||
echo " "
|
||||
fi
|
||||
fi
|
||||
} # END handle_event()
|
||||
|
||||
# Overrides original remove_pkg(). Required by the notification mechanism.
|
||||
function remove_pkg() {
|
||||
local i
|
||||
|
||||
for i in $SHOWLIST; do
|
||||
echo -e "\nPackage: $i"
|
||||
echo -e "\tRemoving... "
|
||||
removepkg $i
|
||||
if [ ! -e $ROOT/var/log/packages/$i ];then
|
||||
FDATE=$(ls -ltr --full-time $ROOT/var/log/removed_packages/$i|tail -1 |awk '{print $6" "$7}'|sed -r -e 's/\.[0-9]{9}//' -e 's,-,/,' -e 's,-,/,')
|
||||
echo "$FDATE removed: $i" >> $WORKDIR/install.log
|
||||
fi
|
||||
done
|
||||
handle_event "remove"
|
||||
} # END remove_pkg()
|
||||
|
||||
# Overrides original upgrade_pkg(). Required by the notification mechanism.
|
||||
function upgrade_pkg() {
|
||||
local i
|
||||
|
||||
if [ "$DOWNLOAD_ALL" = "on" ]; then
|
||||
OLDDEL="$DELALL"
|
||||
DELALL="off"
|
||||
for i in $SHOWLIST; do
|
||||
getpkg $i true
|
||||
done
|
||||
DELALL="$OLDDEL"
|
||||
fi
|
||||
if [ "$DOWNLOADONLY" == "on" ];then
|
||||
echo "Download only.. not upgraded!"
|
||||
return
|
||||
fi
|
||||
ls -1 $ROOT/var/log/packages > $TMPDIR/tmplist
|
||||
|
||||
for i in $SHOWLIST; do
|
||||
PKGFOUND=$(grep -m1 -e "^$(echo $i|rev|cut -f4- -d-|rev)-[^-]\+-[^-]\+-[^-]\+$" $TMPDIR/tmplist)
|
||||
REPOPOS=$(grep -m1 " $(echo $i|sed 's/\.t.z//') " $TMPDIR/pkglist|awk '{print $1}'|sed 's/SLACKPKGPLUS_//')
|
||||
getpkg $i upgradepkg Upgrading
|
||||
if [ -e "$ROOT/var/log/packages/$(echo $i|sed 's/\.t.z//')" ];then
|
||||
FDATE=$(ls -l --full-time $ROOT/var/log/packages/$(echo $i|sed 's/\.t.z//') |awk '{print $6" "$7}'|sed -r -e 's/\.[0-9]{9}//' -e 's,-,/,' -e 's,-,/,')
|
||||
echo "$FDATE upgraded: $i [$REPOPOS] (was $PKGFOUND)" >> $WORKDIR/install.log
|
||||
fi
|
||||
|
||||
done
|
||||
handle_event "upgrade"
|
||||
} # END upgrade_pkg()
|
||||
|
||||
# Overrides original install_pkg(). Required by the notification mechanism.
|
||||
function install_pkg() {
|
||||
local i
|
||||
|
||||
if [ "$DOWNLOAD_ALL" = "on" ]; then
|
||||
OLDDEL="$DELALL"
|
||||
DELALL="off"
|
||||
for i in $SHOWLIST; do
|
||||
getpkg $i true
|
||||
done
|
||||
DELALL="$OLDDEL"
|
||||
fi
|
||||
if [ "$DOWNLOADONLY" == "on" ];then
|
||||
echo "Download only.. not installed!"
|
||||
return
|
||||
fi
|
||||
for i in $SHOWLIST; do
|
||||
INSTALL_T='installed: '
|
||||
if [ -e $ROOT/var/log/packages/$(echo $i|sed 's/\.t.z//') ];then
|
||||
INSTALL_T='reinstalled:'
|
||||
fi
|
||||
REPOPOS=$(grep -m1 " $(echo $i|sed 's/\.t.z//') " $TMPDIR/pkglist|awk '{print $1}'|sed 's/SLACKPKGPLUS_//')
|
||||
getpkg $i installpkg Installing
|
||||
if [ -e "$ROOT/var/log/packages/$(echo $i|sed 's/\.t.z//')" ];then
|
||||
FDATE=$(ls -l --full-time $ROOT/var/log/packages/$(echo $i|sed 's/\.t.z//') |awk '{print $6" "$7}'|sed -r -e 's/\.[0-9]{9}//' -e 's,-,/,' -e 's,-,/,')
|
||||
echo "$FDATE $INSTALL_T $i [$REPOPOS]" >> $WORKDIR/install.log
|
||||
fi
|
||||
done
|
||||
handle_event "install"
|
||||
} # END install_pkg()
|
||||
|
||||
function wgetdebug(){
|
||||
local SRCURL
|
||||
local DSTFILE
|
||||
SRCURL=$2
|
||||
DSTFILE=$(echo $SRCURL|sed 's|/|,|g')
|
||||
if [ ${SRCURL:0:5} == "https" ];then
|
||||
WGETOPTSL="--no-check-certificate"
|
||||
fi
|
||||
if [ ${SRCURL:0:3} == "ftp" ];then
|
||||
WGETOPTSL="--passive-ftp"
|
||||
fi
|
||||
|
||||
DOWNTIME=$(date +%s)
|
||||
|
||||
wget $WGETOPTS $WGETOPTSL -O $TMPDIR/$DSTFILE $SRCURL 2>&1|tee $TMPDIR/$DSTFILE.log
|
||||
WGETERR=${PIPESTATUS[0]}
|
||||
cp $TMPDIR/$DSTFILE $1
|
||||
echo "exit code: $WGETERR" >>$TMPDIR/$DSTFILE.log
|
||||
DOWNTIME=$[$(date +%s)-$DOWNTIME]
|
||||
if [ $WGETERR -ne 0 ];then
|
||||
echo >> $TMPDIR/error.log
|
||||
echo "$SRCURL --> BAD" >> $TMPDIR/error.log
|
||||
echo "wget $WGETOPTS $WGETOPTSL -O $DSTFILE $SRCURL" >> $TMPDIR/error.log
|
||||
echo "exit code: $WGETERR" >> $TMPDIR/error.log
|
||||
echo "download time: $DOWNTIME secs" >> $TMPDIR/error.log
|
||||
echo "details:" >> $TMPDIR/error.log
|
||||
cat $TMPDIR/$DSTFILE.log >> $TMPDIR/error.log
|
||||
ls -l $DSTFILE >> $TMPDIR/error.log 2>&1
|
||||
md5sum $DSTFILE >> $TMPDIR/error.log 2>&1
|
||||
echo >> $TMPDIR/error.log
|
||||
else
|
||||
echo "$SRCURL --> OK" >> $TMPDIR/info.log
|
||||
fi
|
||||
return $WGETERR
|
||||
|
||||
|
||||
} # END wgetdebug()
|
||||
function cached_downloader(){
|
||||
local SRCURL
|
||||
local CACHEFILE
|
||||
local SRCBASE
|
||||
SRCURL=$2
|
||||
SRCBASE=$(basename $SRCURL)
|
||||
CACHEFILE=$(echo $SRCURL|md5sum|awk '{print $1}')
|
||||
|
||||
case $SRCBASE in
|
||||
CHECKSUMS.md5) TOCACHE=1 ;;
|
||||
MANIFEST.bz2) TOCACHE=1 ;;
|
||||
PACKAGES.TXT) TOCACHE=1 ;;
|
||||
*) TOCACHE=0 ;;
|
||||
esac
|
||||
|
||||
if [ $TOCACHE -eq 1 ];then
|
||||
echo
|
||||
echo "=== check cache: $SRCURL ==="
|
||||
echo -n "headers.. "
|
||||
curl --location --head $SRCURL 2>/dev/null|grep -v ^Date:|sed 's/
//' > $TMPDIR/cache.head
|
||||
echo "Url: $SRCURL" >> $TMPDIR/cache.head
|
||||
grep -q "200 OK" $TMPDIR/cache.head || echo "Header or Url Invalid!!! (`date`)"
|
||||
[ $VERBOSE -eq 3 ]&&cat $TMPDIR/cache.head|sed 's/^/ /'
|
||||
if [ -e $CACHEDIR/$CACHEFILE -a -e $CACHEDIR/$CACHEFILE.head ];then
|
||||
echo "Is cached.. "
|
||||
[ $VERBOSE -eq 3 ]&&cat $CACHEDIR/$CACHEFILE.head|sed 's/^/ /'
|
||||
if diff $CACHEDIR/$CACHEFILE.head $TMPDIR/cache.head >/dev/null;then
|
||||
echo "Cache valid! If not please remove manually $CACHEDIR/$CACHEFILE !"
|
||||
cp $CACHEDIR/$CACHEFILE $1
|
||||
return $?
|
||||
fi
|
||||
echo -n "Invalid.. "
|
||||
rm -f $CACHEDIR/$CACHEFILE $CACHEDIR/$CACHEFILE.head
|
||||
fi
|
||||
echo "Download file.. "
|
||||
$CACHEDOWNLOADER $1 $SRCURL
|
||||
ERR=$?
|
||||
if [ "$(ls -l $1 2>/dev/null|awk '{print $5}')" == "$(grep Content-Length: $TMPDIR/cache.head|awk '{print $2}')" ];then
|
||||
echo "Caching it!"
|
||||
cp $1 $CACHEDIR/$CACHEFILE
|
||||
cp $TMPDIR/cache.head $CACHEDIR/$CACHEFILE.head
|
||||
else
|
||||
echo "NOT cacheable!"
|
||||
fi
|
||||
else
|
||||
echo
|
||||
echo "=== no caching for $SRCURL ==="
|
||||
$CACHEDOWNLOADER $1 $SRCURL
|
||||
ERR=$?
|
||||
fi
|
||||
return $ERR
|
||||
|
||||
} # END cached_downloader()
|
||||
|
||||
if [ ! -z "$DOWNLOADCMD" ];then
|
||||
DOWNLOADER="$DOWNLOADCMD"
|
||||
|
@ -1247,7 +1429,8 @@ function showlist() {
|
|||
|
||||
# -- only insert "package" if not in NEWINPUTLIST
|
||||
echo "$NEWINPUTLIST" | grep -qw "${package}" || NEWINPUTLIST="$NEWINPUTLIST $package"
|
||||
done
|
||||
|
||||
done # pref in $INPUTLIST
|
||||
|
||||
INPUTLIST=$NEWINPUTLIST
|
||||
|
||||
|
@ -1272,7 +1455,7 @@ function showlist() {
|
|||
fi
|
||||
done
|
||||
fi
|
||||
fi
|
||||
fi # "$CMD" == "install" / "upgrade" / "reinstall" / "remove"
|
||||
|
||||
if [ "$CMD" == "search" ] || [ "$CMD" == "file-search" ] ; then
|
||||
PATTERN=$(echo $ARG | sed -e 's/\+/\\\+/g' -e 's/\./\\\./g' -e 's/ /\|/g')
|
||||
|
@ -1301,7 +1484,7 @@ function showlist() {
|
|||
esac
|
||||
|
||||
cleanup
|
||||
fi
|
||||
fi # "$CMD" == "search" / "file-search"
|
||||
|
||||
if [ "$CMD" == "check-updates" ] ; then
|
||||
|
||||
|
@ -1376,6 +1559,6 @@ function showlist() {
|
|||
fi
|
||||
|
||||
cleanup
|
||||
fi
|
||||
fi # "$CMD" == "check-updates"
|
||||
|
||||
fi
|
||||
|
|
|
@ -1,108 +0,0 @@
|
|||
if [ "$SLACKPKGPLUS" = "on" ];then
|
||||
# Slackpkg+ Dialog functions
|
||||
# Original functions from slackpkg modified by Marek Wodzinski (majek@mamy.to)
|
||||
#
|
||||
export DIALOG_CANCEL="1"
|
||||
export DIALOG_ERROR="126"
|
||||
export DIALOG_ESC="1"
|
||||
export DIALOG_EXTRA="3"
|
||||
export DIALOG_HELP="2"
|
||||
export DIALOG_ITEM_HELP="2"
|
||||
export DIALOG_OK="0"
|
||||
|
||||
# Show the lists and asks if the user want to proceed with that action
|
||||
# Return accepted list in $SHOWLIST
|
||||
#
|
||||
|
||||
if [ "$DIALOG" = "on" ] || [ "$DIALOG" = "ON" ]; then
|
||||
function showlist() {
|
||||
if [ "$ONOFF" != "off" ]; then
|
||||
ONOFF=on
|
||||
fi
|
||||
|
||||
cat $TMPDIR/greylist.* >$TMPDIR/greylist
|
||||
if [ "$GREYLIST" == "off" ];then
|
||||
>$TMPDIR/greylist
|
||||
fi
|
||||
grep -Ew -f $TMPDIR/greylist $TMPDIR/pkglist|awk '{print $2}' >$TMPDIR/unchecklist
|
||||
rm -f $TMPDIR/dialog.tmp
|
||||
|
||||
if [ "$2" = "upgrade" ]; then
|
||||
ls -1 $ROOT/var/log/packages > $TMPDIR/tmplist
|
||||
for i in $1; do
|
||||
TMPONOFF=$ONOFF
|
||||
BASENAME=$(cutpkg $i)
|
||||
PKGFOUND=$(grep -m1 -e "^${BASENAME}-[^-]\+-[^-]\+-[^-]\+$" $TMPDIR/tmplist)
|
||||
REPOPOS=$(grep -m1 " $(echo $i|sed 's/\.t.z//') " $TMPDIR/pkglist|awk '{print $1}'|sed 's/SLACKPKGPLUS_//')
|
||||
REPOPOSFULL=$(grep -m1 " $(echo $i|sed 's/\.t.z//') " $TMPDIR/pkglist|sed 's/SLACKPKGPLUS_//'|awk '{print $0,gensub(/([0-9]+)([^0-9]*)/,"\\1 \\2_","1",$5),$6}')
|
||||
PKGVER=$(echo $i|rev|cut -f3 -d-|rev)
|
||||
ALLFOUND=$(echo $(grep " ${BASENAME} " $TMPDIR/pkglist|sed -r -e 's/SLACKPKGPLUS_//' -e 's/^([^ ]*) [^ ]* ([^ ]*) [^ ]* ([^ ]*) .*/\2-\3(\1) ,/')|sed 's/,$//')
|
||||
|
||||
grep -q "^$(echo $i|rev|cut -f4- -d-|rev)$" $TMPDIR/unchecklist && TMPONOFF="off"
|
||||
echo "$REPOPOSFULL $i \"$REPOPOS\" $TMPONOFF \"installed: $PKGFOUND --> available: $ALLFOUND\"" >>$TMPDIR/dialog.tmp.1
|
||||
done
|
||||
# 1 2 3 4 5 6 7 8 9 1011 12-
|
||||
# slackware xf86-video-nouveau 1.0.12 i586 1 xf86-video-nouveau-1.0.12-i586-1 ./slackware/x txz 1 _ xf86-video-nouveau-1.0.12-i586-1 xf86-video-nouveau-1.0.12-i586-1.txz "slackware" on "installed: xf86-video-nouveau-git_20151119_6e6d8ac-i586-1 --> available: blacklist-1(extra) , 1.0.12-1(slackware) "
|
||||
|
||||
case "$SHOWORDER" in
|
||||
"repository") SHOWORDER=1;;
|
||||
"arch") SHOWORDER=4;;
|
||||
"package") SHOWORDER=6;;
|
||||
"path") SHOWORDER=7;;
|
||||
"tag") SHOWORDER=10;;
|
||||
*) SHOWORDER=6;;
|
||||
esac
|
||||
cat $TMPDIR/dialog.tmp.1 | awk '{print $'$SHOWORDER',$0}'|sort|cut -f13- -d" " >$TMPDIR/dialog.tmp
|
||||
HINT="--item-help"
|
||||
else
|
||||
for i in $1; do
|
||||
TMPONOFF=$ONOFF
|
||||
REPOPOS=$(grep -m1 " $(echo $i|sed 's/\.t.z//') " $TMPDIR/pkglist|awk '{print $1}'|sed 's/SLACKPKGPLUS_//')
|
||||
grep -q "^$(echo $i|rev|cut -f4- -d-|rev)$" $TMPDIR/unchecklist && TMPONOFF="off"
|
||||
echo "$i \"$REPOPOS\" $TMPONOFF" >>$TMPDIR/dialog.tmp
|
||||
done
|
||||
HINT=""
|
||||
fi
|
||||
# This is needed because dialog have a limit of arguments.
|
||||
# This limit is around 20k characters in slackware 10.x
|
||||
# Empiric tests on slackware 13.0 got a limit around 139k.
|
||||
# If we exceed this limit, dialog got a terrible error, to
|
||||
# avoid that, if the number of arguments is bigger than
|
||||
# DIALOG_MAXARGS we remove the hints. If even without hints
|
||||
# we can't got less characters than DIALOG_MAXARGS we give an
|
||||
# error message to the user ask him to not use dialog
|
||||
if [ $(wc -c $TMPDIR/dialog.tmp | cut -f1 -d\ ) -ge $DIALOG_MAXARGS ]; then
|
||||
mv $TMPDIR/dialog.tmp $TMPDIR/dialog2.tmp
|
||||
awk '{ NF=3 ; print $0 }' $TMPDIR/dialog2.tmp > $TMPDIR/dialog.tmp
|
||||
HINT=""
|
||||
fi
|
||||
DTITLE=$2
|
||||
if [ "$DOWNLOADONLY" == "on" ];then
|
||||
DTITLE="$DTITLE (download only)"
|
||||
fi
|
||||
cat $TMPDIR/dialog.tmp|xargs dialog --title "$DTITLE" --backtitle "slackpkg $VERSION" $HINT --checklist "Choose packages to $2:" 19 70 13 2>$TMPDIR/dialog.out
|
||||
case "$?" in
|
||||
0|123)
|
||||
dialog --clear
|
||||
;;
|
||||
1|124|125|126|127)
|
||||
dialog --clear
|
||||
echo -e "DIALOG ERROR:\n-------------" >> $TMPDIR/error.log
|
||||
cat $TMPDIR/dialog.out >> $TMPDIR/error.log
|
||||
echo -e "-------------
|
||||
If you want to continue using slackpkg, disable the DIALOG option in
|
||||
$CONF/slackpkg.conf and try again.
|
||||
|
||||
Help us to make slackpkg a better tool - report bugs to the slackpkg
|
||||
developers" >> $TMPDIR/error.log
|
||||
cleanup
|
||||
;;
|
||||
esac
|
||||
SHOWLIST=$(cat $TMPDIR/dialog.out | tr -d \")
|
||||
if [ -z "$SHOWLIST" ]; then
|
||||
echo "No packages selected for $2, exiting."
|
||||
cleanup
|
||||
fi
|
||||
}
|
||||
fi
|
||||
fi
|
Loading…
Reference in a new issue