summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrandon Low <lostlogic@gentoo.org>2002-06-07 21:13:29 +0000
committerBrandon Low <lostlogic@gentoo.org>2002-06-07 21:13:29 +0000
commit2b4e746b2d746162c0699311a9c078aafac1ef03 (patch)
tree93e6d55829ff1a715a5ba506f64328574d19043e /app-admin
parent#3250 and some new patches (diff)
downloadgentoo-2-2b4e746b2d746162c0699311a9c078aafac1ef03.tar.gz
gentoo-2-2b4e746b2d746162c0699311a9c078aafac1ef03.tar.bz2
gentoo-2-2b4e746b2d746162c0699311a9c078aafac1ef03.zip
Fix display of installed vs. uninstalled versions in -nc mode, code cleanups
Diffstat (limited to 'app-admin')
-rw-r--r--app-admin/gentoolkit/files/scripts/qpkg285
1 files changed, 148 insertions, 137 deletions
diff --git a/app-admin/gentoolkit/files/scripts/qpkg b/app-admin/gentoolkit/files/scripts/qpkg
index 6b6408881e2c..ef7cd4571913 100644
--- a/app-admin/gentoolkit/files/scripts/qpkg
+++ b/app-admin/gentoolkit/files/scripts/qpkg
@@ -2,23 +2,25 @@
#
# qpkg - query portage package system for various information
#
-# Copiright (c) Vitaly Kushneriuk <vitaly_kushneriuk@yahoo.com>
+# Copyright (c) Vitaly Kushneriuk <vitaly_kushneriuk@yahoo.com>
# This program is distributed under the terms of GPL version 2.
#
-# $Header: /var/cvsroot/gentoo-x86/app-admin/gentoolkit/files/scripts/qpkg,v 1.5 2002/06/05 02:45:33 lostlogic Exp $
-ID='$Id: qpkg,v 1.5 2002/06/05 02:45:33 lostlogic Exp $'
-VERSION=0.`echo $ID | cut -d\ -f3`
+# Maintainer: Brandon Low <lostlogic@gentoo.org>
+#
+# $Header: /var/cvsroot/gentoo-x86/app-admin/gentoolkit/files/scripts/qpkg,v 1.6 2002/06/07 21:13:29 lostlogic Exp $
+ID='$Id: qpkg,v 1.6 2002/06/07 21:13:29 lostlogic Exp $'
+VERSION=0.`echo ${ID} | cut -d\ -f3`
-PROG=`basename $0`
+PROG=`basename ${0}`
# Parse args
verb=0
group='*'
-while [ $# -gt 0 ]
+while [ ${#} -gt 0 ]
do
- a=$1
+ a=${1}
shift
- case "$a" in
+ case "${a}" in
-h|--help)
usage=y
@@ -29,8 +31,9 @@ do
info=y
;;
- --dups)
+ -d|--dups)
dups=y
+ inst=y
;;
-f|--find-file)
@@ -92,13 +95,13 @@ do
;;
-*)
- echo -e $CY$PROG$NO:$YL Invalid option $RD$a 1>&2
+ echo -e ${CY}${PROG}${NO}:${YL} Invalid option $RD$a 1>&2
usage=y
break
;;
*)
- if [ -n "$arg" ]; then
- echo -e $CY$PROG: ${YL}Only one argument supported
+ if [ -n "${arg}" ]; then
+ echo -e ${CY}${PROG}: ${YL}Only one argument supported
usage=y
break
fi
@@ -112,7 +115,7 @@ done
T="\t"
#Set up colors
-if [ ! "$nocolor" ]; then
+if [ ! "${nocolor}" ]; then
NO="\x1b[0;0m"
BR="\x1b[0;01m"
CY="\x1b[36;01m"
@@ -120,204 +123,213 @@ if [ ! "$nocolor" ]; then
YL="\x1b[33;01m"
BL="\x1b[34;01m"
STAR=" *"
+elif [ ! "${inst}" ] && [ ! "${uninst}" ]; then
+ STAR=" *"
fi
# check for option conflicts
-if [ "$inst" -a "$uninst" \
- -o \( "$ffind" -o "$list" -o "$tcheck" -o "$mcheck" \) \
- -a "$uninst" ]; then
- echo -e $CY$PROG$NO:$YL conflicting options/modes$NO
+if [ "${inst}" -a "${uninst}" \
+ -o \( "${ffind}" -o "${list}" -o "${tcheck}" -o "${mcheck}" \) \
+ -a "${uninst}" ]; then
+ echo -e ${CY}${PROG}${NO}:${YL} conflicting options/modes${NO}
usage=y
fi
-if [ "$usage" ]; then
- echo -e "$CY$PROG v. $VERSION$NO
+if [ "${usage}" ]; then
+ echo -e "${CY}${PROG} v. ${VERSION}${NO}
${BR}Usage:
-$T$CY$PROG$NO [$BR options$NO ] [$YL pkgname $NO|$BL-g$YL group$NO|$BL-f$YL <file>$NO ]
-$T$CY$PROG$NO $BL--dups$NO
-$T$CY$PROG$NO $BL-h$NO|$BL--help$NO
+${T}${CY}${PROG}${NO} [${BR}options${NO}] [${YL}pkgname${NO}] [${BL}-g${YL} group${NO}] [${BL}-f${YL} <file>${NO}]
+${T}${CY}${PROG}${NO} ${BL}-d${NO}|${BL}--dups${NO}
+${T}${CY}${PROG}${NO} ${BL}-h${NO}|${BL}--help${NO}
${BR}Package Selection:
- $BL-f, --find-file$NO$T finds package that owns file <file>
- $BL-fp, --find-pattern$NO$T finds to package that owns file matching *<file>*
- $BL-I, --installed$NO$T Include$YL only$NO installed packages
- $BL-U, --uninstalled$NO$T Include$YL only$NO uninstalled packages
- $BL-g, --group$NO$T$T Find by goup (can be combined with other searches)
- $BL--dups$NO$T$T print packages that have multiple versions installed
+ ${BL}-f, --find-file${NO}${T} finds package that owns file <file>
+ ${BL}-fp, --find-pattern${NO}${T} finds to package that owns file matching *<file>*
+ ${BL}-I, --installed${NO}${T} Include${YL} only${NO} installed packages
+ ${BL}-U, --uninstalled${NO}${T} Include${YL} only${NO} uninstalled packages
+ ${BL}-g, --group${NO}${T}${T} Find by goup (can be combined with other searches)
+ ${BL}-d, --dups${NO}${T}${T} print packages that have multiple versions installed
${BR}Information selection:
- $BL-l, --list$NO$T$T List package content
- $BL-i, --info$NO$T$T Get package description and home page.
- $BL-ct, --check-time$NO
- $BL-tc, --time-check$NO$T Verify package files timestamps
- $BL-cm, --check-md5$NO
- $BL-mc, --md5-check$NO$T Verify package files md5
- $BL-c, --check$NO$T$T Verify mtimes$YL and$NO md5.
+ ${BL}-l, --list${NO}${T}${T} List package content
+ ${BL}-i, --info${NO}${T}${T} Get package description and home page.
+ ${BL}-ct, --check-time${NO}
+ ${BL}-tc, --time-check${NO}${T} Verify package files timestamps
+ ${BL}-cm, --check-md5${NO}
+ ${BL}-mc, --md5-check${NO}${T} Verify package files md5
+ ${BL}-c, --check${NO}${T}${T} Verify mtimes${YL} and${NO} md5.
${BR}Operation modifiers:
- $BL-nc, --no-color$NO$T don't use colors
- $BL-v, --verbose$NO$T Be more verbose [ can be repeated twise ]
- $BL-vv$NO$T$T$T Same as $BL-v -v$NO
-
-${YL}Notes$NO:
-$YL*$NO $BL-l$NO, $BL-ct$NO, and $BL-cm$NO apply only to installed packages
-$YL*$NO When using$BL -f$NO with $BL-l$NO or $BL--check.. -v$NO options,
- only matching files will be displayed, unless $BL-v$NO is doubled,
- (yet more verbose) or $BL-vv$NO is used.
-
-
-${YL}Examples$NO:
- $PROG --dups print duplicates oldest first
- $PROG --dups -v .. with versions
- $PROG print list of installed packages
- $PROG porta -I print versions of installed portage
- $PROG porta -i .. + versions in portage tree + descriptions
+ ${BL}-nc, --no-color${NO}${T} don't use colors
+ ${BL}-v, --verbose${NO}${T} Be more verbose [ can be repeated twise ]
+ ${BL}-vv${NO}${T}${T}${T} Same as ${BL}-v -v${NO}
+
+${YL}Notes${NO}:
+${YL}*${NO} ${BL}-f${NO}, ${BL}-fp, ${BL}-d${NO}, ${BL}-l${NO}, ${BL}-ct${NO}, ${BL}-cm${NO}, and ${BL}-c${NO} apply only to installed packages.
+${YL}*${NO} Short options may not be combined on the command-line, yet.
+${YL}*${NO} When using${BL} -f${NO} with ${BL}-l${NO} or ${BL}--check.. -v${NO} options, only
+ matching files will be displayed, unless ${BL}-v${NO} is doubled,
+ (yet more verbose) or ${BL}-vv${NO} is used.
+
+
+${YL}Examples${NO}:
+ ${PROG} --dups print duplicates oldest first
+ ${PROG} --dups -v .. with versions
+ ${PROG} print list of installed packages
+ ${PROG} porta -I print versions of installed portage
+ ${PROG} porta -i .. + versions in portage tree + descriptions
and homepages
- $PROG gawk -c -v check integrity all installed versions of gawk
- the older will have \"demaged\" files.
- $PROG -f /bin/ls print package(s) that own /bin/ls
+ ${PROG} gawk -c -v check integrity all installed versions of gawk
+ the older will have \"damaged\" files.
+ ${PROG} -f /bin/ls print package(s) that own /bin/ls
"
exit
fi
#For the --dups switch only
-if [ "$dups" ]; then
+if [ "${dups}" ]; then
#First dig out the list of packages with duplicates
dups=`/usr/lib/portage/bin/pkglist |
sed -e 's:-r[0-9]*::' -e 's:-[^-]*$::' |
sort |
uniq -d`
+
#Next get all the exact versions
- duppak=`ls /var/db/pkg/*/*/*$arg*.ebuild 2>/dev/null | fgrep "$dups"`
+ duppak=`ls /var/db/pkg/*/*/*${arg}*.ebuild 2>/dev/null | fgrep "${dups}"`
+
#Now cut that down to the directory name so we can be smart
- dirs=`echo $duppak|sed -e "s:\ :\n:g"|sed -e "s:/[^/]*$::"`
+ dirs=`echo ${duppak}|sed -e "s:\ :\n:g"|sed -e "s:/[^/]*$::"`
+
#Go through each package's DB and create a sortable file
#to play with
- for DIR in $dirs
+ for DIR in ${dirs}
do #Package COUNTER
- NUM=`cat "$DIR/COUNTER"`
+ NUM=`cat "${DIR}/COUNTER"`
#Package fullname
- PKG=`ls $DIR/*.ebuild|cut -f5,7 -d"/"`
+ PKG=`ls ${DIR}/*.ebuild|cut -f5,7 -d"/"`
#Package basename
- NAME=`echo "$PKG"|sed -e "s:\.ebuild$::" \
- -e "s:-r[0-9]\+$::" \
- -e "s:-[0-9][^-]*$::"`
- echo "$NUM $PKG $NAME"
+ NAME=`echo "${PKG}"|sed -e "s:\.ebuild$::" \
+ -e "s:-r[0-9]\+$::" \
+ -e "s:-[0-9][^-]*$::"`
+ echo "${NUM} ${PKG} ${NAME}"
#Finish loop, and sort that nice sortable file based on
#installation order, and then based on package basename
#bash hates me so I decided to use a temp file
done |sort -t " " -k1g,2 |sort -t " " -k3> /tmp/qpkg.lst
duppak=`cat /tmp/qpkg.lst`
rm /tmp/qpkg.lst
+
#If max verbosity is set output with full path to each ebuild
- if [ "$verb" -gt 1 ]; then
- echo "$duppak"|cut -f2 -d" "| \
+ if [ "${verb}" -gt 1 ]; then
+ echo "${duppak}"|cut -f2 -d" "| \
sed -e "s:^:${BL}/var/db/pkg/${BR}:" \
-e "s:\(/\)\([^/]*\)\(.ebuild\):\1${CY}\2${NO}\1\2\3:"
+
#If normal verbosity output package group, package name and package version
- elif [ "$verb" -gt 0 ]; then
- echo "$duppak"|cut -f2 -d" "| \
+ elif [ "${verb}" -gt 0 ]; then
+ echo "${duppak}"|cut -f2 -d" "| \
sed -e "s:\(^[^/]*/\)\(.*\)\(\.ebuild\):${BR}\1${CY}\2${NO}:"
+
#Otherwise just output package group and package name
else
- echo "$dups"|sed -e "s:\(^[^/]*/\)\(.*\):${BR}\1${CY}\2${NO}:"
+ echo "${dups}"|sed -e "s:\(^[^/]*/\)\(.*\):${BR}\1${CY}\2${NO}:"
fi
exit
fi
# get list of ebuilds to work on
-if [ "$ffind" ]; then
+if [ "${ffind}" ]; then
# file find mode - list all ebuilds for
# package/CONTENTS containing <arg>
- if [ "$fpat" ]; then
- dirs=`ls /var/db/pkg/$group/*/CONTENTS \
- | xargs grep -l "$arg" \
+ if [ "${fpat}" ]; then
+ dirs=`ls /var/db/pkg/${group}/*/CONTENTS \
+ | xargs grep -l "${arg}" \
| xargs --no-run-if-empty -n 1 dirname`
else
- dirs=`ls /var/db/pkg/$group/*/CONTENTS \
- | xargs grep -l " $arg\( .*\)*$" \
+ dirs=`ls /var/db/pkg/${group}/*/CONTENTS \
+ | xargs grep -l " ${arg}\( .*\)*$" \
| xargs --no-run-if-empty -n 1 dirname`
fi
ipak=`(
- for d in $dirs -;do
+ for d in ${dirs} -;do
[ "-" = "$d" ] && break
- ls $d/*.ebuild
+ ls ${d}/*.ebuild
done)`
else
# normal mode - list ebuilds for ebuild name containing <arg>
# installed packages
- [ ! "$uninst" ] &&
- ipak=`ls /var/db/pkg/*$group*/*/*$arg*.ebuild 2>/dev/null`
+ [ ! "${uninst}" ] &&
+ ipak=`ls /var/db/pkg/*${group}*/*/*${arg}*.ebuild 2>/dev/null`
# not installed packages (yet:-)
- [ ! "$inst" ] &&
- upak=`ls /usr/portage/*$group*/*/*$arg*.ebuild 2>/dev/null`
+ [ ! "${inst}" ] &&
+ upak=`ls /usr/portage/*${group}*/*/*${arg}*.ebuild 2>/dev/null`
fi
X="\([^/]*\)"
-for p in $ipak $upak -;do
- [ "$p" = "-" ] && break
+for p in ${ipak} ${upak} -;do
+ [ "${p}" = "-" ] && break
# cut common prefix from ebuild name and mark installed/uninstalled packages
# Note: iii/uuu will be replaced by the pipe at the end
- n=`echo $p | sed -e "s:^/var/db/pkg/$X/$X/$X.ebuild:iii \1/\3:" \
- -e "s:^/usr/portage/$X/$X/$X\.ebuild:uuu \1/\3:"`
- d=`dirname $p`
- echo $n
- if [ $verb -gt 0 ];then
- echo "vvv $p"
+ n=`echo $p | sed -e "s:^/var/db/pkg/${X}/${X}/${X}.ebuild:iii \1/\3:" \
+ -e "s:^/usr/portage/${X}/${X}/${X}\.ebuild:uuu \1/\3:"`
+ d=`dirname ${p}`
+ echo ${n}
+ if [ ${verb} -gt 0 ];then
+ echo "vvv ${p}"
fi
- if [ "$info" ]; then
- home=`grep HOMEPAGE $p| cut -d\" -f2`
- desc=`grep DESCRIPTION $p| cut -d\" -f2`
- echo -e "$T$BL$desc$NO [ $YL$home$NO ]"
+ if [ "${info}" ]; then
+ home=`grep HOMEPAGE ${p}| cut -d\" -f2`
+ desc=`grep DESCRIPTION ${p}| cut -d\" -f2`
+ echo -e "${T}${BL}${desc}${NO} [ ${YL}${home}${NO} ]"
fi
# cat package content, remove obj/sym/dir, md5 and mtime when not verbose
# display only match in file-find mode unless extra verbose
- if [ "$list" ]; then
- echo -e ${BL}CONTENTS:$NO
+ if [ "${list}" ]; then
+ echo -e ${BL}CONTENTS:${NO}
- if [ $verb -gt 1 ]; then
- cat $d/CONTENTS
+ if [ ${verb} -gt 1 ]; then
+ cat ${d}/CONTENTS
else
- if [ "$ffind" ]; then
- if [ "$fpat" ]; then
- grep "$arg" $d/CONTENTS
+ if [ "${ffind}" ]; then
+ if [ "${fpat}" ]; then
+ grep "${arg}" $d/CONTENTS
else
- grep " $arg\( .*\)*$" $d/CONTENTS
+ grep " ${arg}\( .*\)*$" $d/CONTENTS
fi
else
cat $d/CONTENTS
fi |
- if [ $verb -gt 0 ]; then
+ if [ ${verb} -gt 0 ]; then
cat
else
- sed -e "s:obj \([^ ]*\).*:$BR\1$NO:" \
- -e "s:sym \([^ ]*\) -> \([^ ]*\).*:$CY\1 $NO-> \2:" \
- -e "s:dir \([^ ]*\).*:$YL\1$NO:"
+ sed -e "s:obj \([^ ]*\).*:${BR}\1${NO}:" \
+ -e "s:sym \([^ ]*\) -> \([^ ]*\).*:${CY}\1 ${NO}-> \2:" \
+ -e "s:dir \([^ ]*\).*:${YL}\1${NO}:"
fi
fi
echo
# check files mtime and md5, display summary at the end
- elif [ "$tcheck" -o "$mcheck" ]; then
+ elif [ "${tcheck}" -o "${mcheck}" ]; then
# counters
fe=0
fs=0
# read the CONTENTS file and check md5 and mtime if needed
# process only matching files in find-file mode unless extra verbose
- cat $d/CONTENTS |
- if [ "$ffind" -a $verb -lt 2 ];then
- if [ "$fpat" ]; then
- grep "$arg"
+ cat ${d}/CONTENTS |
+ if [ "${ffind}" -a ${verb} -lt 2 ];then
+ if [ "${fpat}" ]; then
+ grep "${arg}"
else
- grep " $arg "
+ grep " ${arg} "
fi
else
cat
@@ -336,69 +348,68 @@ for p in $ipak $upak -;do
name=${line[1]}
missing=
- [ ! -e $name ] && missing=1
+ [ ! -e ${name} ] && missing=1
# colorize name and compute mtime/md5
if [ "obj" = ${line[0]} ]; then
- [ -e $name ] && {
- [ "$tcheck" ] && mtime=${line[3]}
- [ "$tcheck" ] && _mtime=`date -r $name +%s`
+ [ -e ${name} ] && {
+ [ "${tcheck}" ] && mtime=${line[3]}
+ [ "${tcheck}" ] && _mtime=`date -r ${name} +%s`
- [ "$mcheck" ] && md5=${line[2]}
- [ "$mcheck" ] && _md5=`md5sum $name|cut -f1 -d" "`
+ [ "${mcheck}" ] && md5=${line[2]}
+ [ "${mcheck}" ] && _md5=`md5sum ${name}|cut -f1 -d" "`
}
- name=$BR$name$NO
+ name=${BR}${name}${NO}
elif [ "sym" = ${line[0]} ]; then
- name=$CY$name$NO
+ name=${CY}${name}${NO}
elif [ "dir" = ${line[0]} ]; then
- name=$YL$name$NO
+ name=${YL}${name}${NO}
fi
# compare
if [ "$missing" ]; then
err=1
- name="$name $RD!not exist!$NO"
+ name="${name} $RD!not exist!${NO}"
fi
- if [ "$md5" != "$_md5" ]; then
+ if [ "${md5}" != "${_md5}" ]; then
#If the md5 fails the first time check it with
#everything changed to lowercase :-D
- md5=`echo "$md5"|tr A-Z a-z`
- if [ "$md5" != "$_md5" ]; then
+ md5=`echo "${md5}"|tr A-Z a-z`
+ if [ "${md5}" != "${_md5}" ]; then
err=1
- name="$name $RD!md5!$NO"
+ name="${name} $RD!md5!${NO}"
fi
fi
- if [ "$mtime" != "$_mtime" ]; then
+ if [ "${mtime}" != "${_mtime}" ]; then
err=1
- name="$name $RD!mtime!$NO"
+ name="${name} $RD!mtime!${NO}"
fi
- [ $verb -gt 1 ] && echo -e $name
- [[ $verb -eq 1 ]] && [[ $err -eq 1 ]] && echo -e $name
+ [ ${verb} -gt 1 ] && echo -e ${name}
+ [[ ${verb} -eq 1 ]] && [[ $err -eq 1 ]] && echo -e ${name}
fe=$((fe + err))
done
if [ "$fe" = "0" ]; then
- echo -e $YL$fe$CY/$fs$NO
+ echo -e ${YL}$fe${CY}/$fs${NO}
else
- echo -e $RD$fe$CY/$fs$NO
+ echo -e $RD$fe${CY}/$fs${NO}
fi
echo
)
fi
done | (
- if [ ! \( "$tcheck" -o "$mcheck" -o "$info" -o "$list" -o $verb -gt 0 \) ]; then
+ if [ ! \( "${tcheck}" -o "${mcheck}" -o "${info}" -o "${list}" -o ${verb} -gt 0 \) ]; then
sort -k 2 | uniq -1
else
cat
fi | sed \
- -e "s:^iii $X/$X:$BR\1/$CY\2$STAR$NO:" \
- -e "s:^uuu $X/$X:$BR\1/$YL\2$NO:" \
- -e "s:^vvv \(.*\)$:$BL\1$NO:"
+ -e "s:^iii ${X}/${X}:${BR}\1/${CY}\2${STAR}${NO}:" \
+ -e "s:^uuu ${X}/${X}:${BR}\1/${YL}\2${NO}:" \
+ -e "s:^vvv \(.*\)$:${BL}\1${NO}:"
)
-