View previous topic :: View next topic |
Author |
Message |
ulenrich Veteran
Joined: 10 Oct 2010 Posts: 1483
|
Posted: Sun Jun 30, 2024 7:02 pm Post subject: using the cache to quickly get package info |
|
|
Code: | #!/bin/bash
if [[ "$1" = "--help" ]] ||[[ "$1" = "-h" ]];then
echo "Search for Gentoo package names, like:"
echo "$0 /ash dev/ gcc$ ^sys"
echo "This makes use of a cache REPOPATHNAME/metadata/pkg_desc_index"
echo "If your REPO doesn't have the cache, then put an executable at"
echo "/etc/portage/repo.postsync.d/SCRIPT"
echo 'having the line: egencache --update-pkg-desc-index --repo $1'
exit
fi
function repoLocation() {
D="";repo="$1"
conF="/etc/portage/repos.conf/${repo%.conf}.conf"
[ ! -s "${conF}" ] &&echo "cannot find repository ${repo}" &&return
D=$(sed -n -e's/#.*//' -e'y/"/ /' -e"y/'/ /"\
-e'/^location[ =]*/{s_.*=__;s_[[:blank:]]*\(.*\)[[:blank:]]*_\1_p;q}'\
${conF})
[[ -d "$D" ]] &&echo $D
}
dfile=""
for i in /etc/portage/repos.conf/* ;do
b=$(basename $i)
L="$(repoLocation $b)/metadata/pkg_desc_index"
[ -f $L ] \
&&dfile="${dfile} $L" \
||echo "missing cache, use egencache to create $L" >&2
done
if [[ "${dfile}" = "" ]] ;then
dfile="/var/db/repos/gentoo/metadata/pkg_desc_index"
[[ ! -f $dfile ]] \
&&echo "missing cache - try the egencache tool" \
&&exit
fi
T=""
while [ "$1" != "" ] ;do
sed -E -n -e's/ .*$//' -e"\,$1, p" ${dfile}
shift
done |sort -u \
|while read p ;do
q=$(echo /var/db/pkg/${p}-[0-9]* )
if [ -d "${q}" ] ;then
echo -e -n "emerged\t ${q#/var/db/pkg/} " \
&&sed -e"s/amd64.*$/amd64/" -e"s/.* //" $q/KEYWORDS
T=$(cat $q/DESCRIPTION )
grep -e"^${p} " ${dfile} \
|sed -e's%^.*/\(.*\)/metadata/pkg_desc_index:%\1\t %' -e's/:.*$//'
else
grep -e"^${p} " ${dfile} \
|sed -e's%^.*/\(.*\)/metadata/pkg_desc_index:%\1\t %' -e's/:/\n\t/'
fi
[ "$T" != "" ] \
&&echo -e -n "\t $T " \
&&T="" \
&&[ -f "$q/HOMEPAGE" ] \
&&cat $q/HOMEPAGE
echo ""
done
exit
|
Sorry my coding style. |
|
Back to top |
|
|
ulenrich Veteran
Joined: 10 Oct 2010 Posts: 1483
|
Posted: Sun Jun 30, 2024 9:24 pm Post subject: |
|
|
Output sample:
Code: | $ genlist app.*/portage
gentoo app-metrics/portage-exporter 0.1.0
Prometheus exporter for Gentoo Portage
guru app-portage/portage-lostfiles 0.5.5
A simple script to identify files not tracked by Portage package manager
emerged app-portage/portage-utils-0.96.1 amd64
gentoo app-portage/portage-utils 0.95-r1 0.96-r1 0.96.1 0.97 9999
Small and fast Portage helper tools written in C https://wiki.gentoo.org/wiki/Portage-utils
emerged sys-apps/portage-3.0.65 ~amd64
gentoo sys-apps/portage 3.0.61-r1 3.0.63-r1 3.0.64-r3 3.0.65 9999
The package management and distribution system for Gentoo https://wiki.gentoo.org/wiki/Project:Portage |
|
|
Back to top |
|
|
pietinger Moderator
Joined: 17 Oct 2006 Posts: 5166 Location: Bavaria
|
|
Back to top |
|
|
|