Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
retrieving $CATEGORY and $PN
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Other Things Gentoo
View previous topic :: View next topic  
Author Message
CaptainBlood
Advocate
Advocate


Joined: 24 Jan 2010
Posts: 3628

PostPosted: Mon Dec 25, 2023 7:01 pm    Post subject: retrieving $CATEGORY and $PN Reply with quote

Here's a local script that starts as:
Code:
if [ -z $1 ]; then
    echo param 1 is empty\; [package_category/]package_name[-x.y.z-abcd][:slot][::repo] expected
else
    tmpfile=$(mktemp /tmp/mrgl.XXXXXX)   
    if ! emerge --nodeps -p $1>$tmpfile; then
        echo error emerging package $1 #not detected
        echo $0 cancelled
        rm $tmpfile
    else
        fullpckname=$(grep ebuild $tmpfile|awk '{ print $4 }')
        rm $tmpfile
        echo package $fullpckname requested
        catname=$(dirname $fullpckname)
        pckname=$(basename $fullpckname)
where $catname = $CATEGORY.
Unfortunately $packname = $PF = ${PN}-${PVR}.

How to extract $PN?

Thks 4 ur attention, interest & support.
_________________
USE="-* ..." in /etc/portage/make.conf here.
LT: "I've been doing a passable imitation of the Fontana di Trevi, except my medium is mucus. Sooo much mucus. "


Last edited by CaptainBlood on Mon Dec 25, 2023 7:49 pm; edited 1 time in total
Back to top
View user's profile Send private message
Zucca
Moderator
Moderator


Joined: 14 Jun 2007
Posts: 3345
Location: Rasi, Finland

PostPosted: Mon Dec 25, 2023 7:16 pm    Post subject: Reply with quote

I think you're looking for qatom.
Try with
Code:
qatom -F '%{PN}' "$fullpckname"


For what purpose you use your script, if I may ask?
_________________
..: Zucca :..
Gentoo IRC channels reside on Libera.Chat.
--
Quote:
I am NaN! I am a man!
Back to top
View user's profile Send private message
Ionen
Developer
Developer


Joined: 06 Dec 2018
Posts: 2720

PostPosted: Mon Dec 25, 2023 7:24 pm    Post subject: Reply with quote

... or alternatively *cough*, app-portage/iwdevtools:
Code:
$ atomf "name = %n\nversion = %V\nrevision = %R\n" category/packagename-1.0.0-r1
name = packagename, version = 1.0.0, revision = 1

$ cat test.sh
#!/usr/bin/env bash
. "$(pkg-config iwdevtools --variable=atomf)" || exit

atomset 'category/packagename-1.0.0-r1'

echo "${PF}"
echo "${CATEGORY}"
echo "${PN}"
echo "${PV}"

$ ./test.sh
packagename-1.0.0-r1
category
packagename
1.0.0
Back to top
View user's profile Send private message
CaptainBlood
Advocate
Advocate


Joined: 24 Jan 2010
Posts: 3628

PostPosted: Mon Dec 25, 2023 8:01 pm    Post subject: Reply with quote

Currently testing... Nice.

Can't refrain from saying how crazy it sounds to me that emerge command can not output all lexical atoms that compose a valid CATEGORY/PN-PV-PR::SLOT::REPOSITORY

Thks 4 ur attention, interest & support;
_________________
USE="-* ..." in /etc/portage/make.conf here.
LT: "I've been doing a passable imitation of the Fontana di Trevi, except my medium is mucus. Sooo much mucus. "
Back to top
View user's profile Send private message
CaptainBlood
Advocate
Advocate


Joined: 24 Jan 2010
Posts: 3628

PostPosted: Mon Dec 25, 2023 8:41 pm    Post subject: Reply with quote

Zucca wrote:
I think you're looking for qatom.
Try with
Code:
qatom -F '%{PN}' "$fullpckname"
For what purpose you use your script, if I may ask?

As far as LTO is concerned here, file/package size is an easy decision helper.
You'd be surprised how many packages have LTO cancelled here because of size increase:
Code:
grep "#bigger lto-full-bfd.conf" /etc/portage/package.env/* | wc -l
123
Or how many don't bother
Code:
grep "#unchanged lto-full-bfd.conf" /etc/portage/package.env/* | wc -l
311
LTOized here
Code:
grep lto-full-bfd.conf /etc/portage/package.env/*|awk '{ print $1" "$2 }'  | grep lto-full-bfd.conf | wc -l
801


Sorry I didn't scroll back enough...
qatom is the right thing indeed!

Thks 4 ur attention, interest & support.
_________________
USE="-* ..." in /etc/portage/make.conf here.
LT: "I've been doing a passable imitation of the Fontana di Trevi, except my medium is mucus. Sooo much mucus. "
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Other Things Gentoo All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum