mirror of
https://github.com/sbopkg/sbopkg
synced 2024-12-29 10:24:11 +01:00
Tweak info_item()
Cleanup and tweak info_item(): - the code to detect already available packages in $OUTPUT is now more robust and readable; - the code to determine already installed versions of the package is now more robust and readable; - the "Installed:" line now also lists non-SBo packages (this is useful for Slackware-current users, as well as for people using non-SBo third-party packages) - the window title now also shows the package tag, to remove some ambiguity (e.g. as of now, Slackware-current has a libzip package with the same "signature" as the SBo one, and from the info_item() dialog it looks like they are the same package when in fact they are not). Signed-off-by: Mauro Giachero <mauro.giachero@gmail.com>
This commit is contained in:
parent
d21b989c27
commit
2b553679e8
2 changed files with 30 additions and 43 deletions
|
@ -78,4 +78,7 @@ enhancements:
|
|||
queuefiles much easier and more intuitive.
|
||||
* Add ability to load more than one queuefile at a time when building
|
||||
from command line interface.
|
||||
* The info_item dialog now shows non-SBo installed packages and gained a
|
||||
more robust approach to finding both the installed package names and
|
||||
the available packages in $OUTPUT.
|
||||
+--------------------------+
|
||||
|
|
|
@ -961,9 +961,9 @@ info_item() {
|
|||
# Returns 0 unless the user asked to jump back to the main menu.
|
||||
|
||||
local OLDPKG CATEGORY SHORTPATH CURVERSION CURARCH CURBUILD
|
||||
local CURAPP LONGAPP SHORTAPP
|
||||
local CURAPP OUTPUTFILES
|
||||
local STRING INDEX NAME INST_ARCH VER BUILD DEFAULTITEM
|
||||
local CURPACKAGE INSTALLEDPACKAGE MENUPACKAGE TITLEPACKAGE RENAMEDPACKAGE
|
||||
local CURPACKAGE INSTALLEDPACKAGE MENUPACKAGE TITLEPACKAGE
|
||||
local CHOICE PARSED_SLACK_DESC
|
||||
local APP="$(< $SBOPKGTMP/sbopkg_item_selection)"
|
||||
local RETVAL=0
|
||||
|
@ -971,7 +971,7 @@ info_item() {
|
|||
# We need to check and see if the APP has ever been renamed.
|
||||
get_old_name OLDPKG $APP
|
||||
|
||||
CATEGORY="$(< $SBOPKGTMP/sbopkg_category_selection)"
|
||||
CATEGORY=$(< $SBOPKGTMP/sbopkg_category_selection)
|
||||
SHORTPATH=$REPO_DIR/$CATEGORY/$APP
|
||||
CURVERSION=$(grep VERSION $SHORTPATH/$APP.info |
|
||||
cut -d= -f2 | sed s/\"//g)
|
||||
|
@ -981,57 +981,41 @@ info_item() {
|
|||
CURBUILD=$(egrep -m1 "^BUILD" $SHORTPATH/$APP.SlackBuild |
|
||||
sed -e 's/^.*[=-]//;s/\"//;s/[ #}\t].*$//g;s/\"//g')
|
||||
while :; do
|
||||
CURAPP=$(ls /var/log/packages/*$REPO_TAG* 2> /dev/null |
|
||||
grep "$APP\|$OLDPKG")
|
||||
unset INSTALLEDPACKAGE
|
||||
for i in $CURAPP; do
|
||||
LONGAPP=$(echo $i | sed "s/$REPO_TAG$//;s/-[^-]*-[^-]*-[^-]*$//")
|
||||
SHORTAPP=$(echo $LONGAPP | sed -e 's/^.*\///g')
|
||||
INSTALLEDPACKAGE=$(ls /var/log/packages |
|
||||
egrep "^($APP|$OLDPKG)-[^-]*-[^-]*-[^-]*\$")
|
||||
# Only get the first package (not that the same package should be
|
||||
# installed more than once on a sane system...)
|
||||
INSTALLEDPACKAGE=$(head -n 1 <<< "$INSTALLEDPACKAGE")
|
||||
# Find the available package to install, if any, using several
|
||||
# "strictness levels" (to pick the right one if available, but falling
|
||||
# back to "less right" alternatives when appropriate)
|
||||
OUTPUTFILES=$(ls -1 $OUTPUT)
|
||||
CURPACKAGE=$( \
|
||||
grep "^$APP-$CURVERSION-$CURARCH-$CURBUILD$REPO_TAG\\.t.z\$" \
|
||||
<<< "$OUTPUTFILES")
|
||||
[[ -z $CURPACKAGE ]] && CURPACKAGE=$( \
|
||||
grep "^$APP-$CURVERSION-[^-]*-$CURBUILD$REPO_TAG\\.t.z\$" \
|
||||
<<< "$OUTPUTFILES")
|
||||
[[ -z $CURPACKAGE ]] && CURPACKAGE=$( \
|
||||
grep "^$APP-$CURVERSION-[^-]*-[^-]*$REPO_TAG\\.t.z\$" \
|
||||
<<< "$OUTPUTFILES")
|
||||
[[ -z $CURPACKAGE ]] && CURPACKAGE=$( \
|
||||
grep "^$APP-[^-]*-[^-]*-[^-]*$REPO_TAG\\.t.z\$" \
|
||||
<<< "$OUTPUTFILES")
|
||||
|
||||
if [[ $SHORTAPP == $APP || $SHORTAPP == $OLDPKG ]]; then
|
||||
# Again, code from pkgtool
|
||||
STRING=$(basename $i $REPO_TAG)
|
||||
INDEX="$(echo $STRING | tr -d -c -)"
|
||||
INDEX="$(expr length $INDEX + 1)"
|
||||
NAME=$(expr $INDEX - 3)
|
||||
NAME="$(echo $STRING | cut -f 1-$NAME -d -)"
|
||||
VER=$(expr $INDEX - 2)
|
||||
VER="$(echo $STRING | cut -f $VER -d -)"
|
||||
INST_ARCH=$(expr $INDEX - 1)
|
||||
INST_ARCH="$(echo $STRING | cut -f $INST_ARCH -d -)"
|
||||
BUILD="$(echo $STRING | cut -f $INDEX -d -)"
|
||||
|
||||
if [[ $SHORTAPP == $APP ]]; then
|
||||
INSTALLEDPACKAGE=$NAME-$VER-$INST_ARCH-$BUILD
|
||||
else # Must be a renamed app
|
||||
RENAMEDPACKAGE=$NAME-$VER-$INST_ARCH-$BUILD
|
||||
fi
|
||||
fi
|
||||
done
|
||||
if $(echo $(ls -1 $OUTPUT) | grep -E -q "$APP.*$CURVERSION"); then
|
||||
CURPACKAGE="$(
|
||||
basename $(ls -1 $OUTPUT/${APP}*${CURVERSION}*${CURBUILD}*t?z|
|
||||
head -n 1)
|
||||
)"
|
||||
else
|
||||
unset CURPACKAGE
|
||||
fi
|
||||
if [[ -z $CURPACKAGE ]]; then
|
||||
unset MENUPACKAGE
|
||||
else
|
||||
CURPACKAGE=$(head -n 1 <<< "$CURPACKAGE")
|
||||
MENUPACKAGE="Install $CURPACKAGE"
|
||||
fi
|
||||
if [[ -z $INSTALLEDPACKAGE ]]; then
|
||||
if [[ -z $RENAMEDPACKAGE ]]; then
|
||||
TITLEPACKAGE="$APP (Not Installed)"
|
||||
else
|
||||
TITLEPACKAGE="$APP (Installed: $RENAMEDPACKAGE)"
|
||||
fi
|
||||
else
|
||||
TITLEPACKAGE="$APP (Installed: $INSTALLEDPACKAGE)"
|
||||
fi
|
||||
dialog --default-item "$DEFAULTITEM" \
|
||||
--title "$APP ($CURVERSION-$CURARCH-$CURBUILD)" \
|
||||
--title "$APP ($CURVERSION-$CURARCH-$CURBUILD$REPO_TAG)" \
|
||||
--backtitle "$TITLEPACKAGE" --extra-button --extra-label "Back" \
|
||||
--cancel-label "Main Menu" --menu \
|
||||
"$(crunch "Please choose an item or press <Back> to go back \
|
||||
|
|
Loading…
Reference in a new issue