Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
Script: Change USE flags according to ebuild to be merged
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Documentation, Tips & Tricks
View previous topic :: View next topic  
Author Message
nichao
n00b
n00b


Joined: 24 Nov 2002
Posts: 17
Location: Germany

PostPosted: Sun Nov 24, 2002 10:33 am    Post subject: Script: Change USE flags according to ebuild to be merged Reply with quote

Well, I was searching for a script/program to change the USE flags of an ebuild - and that means only the USE flags it has specified in the .ebuild - interactively before merging it. Unfortunately, I didn't find one, so I had to do a little shell script by myself :D

It might really suck, but here is it - I placed it as /usr/sbin/cemerge (custom emerge):

Code:

#!/bin/sh

# Change USE flags according to the ebuild to be merged
# and emerge it afterwards.

# --- BEGINNING OF USER SETTINGS ---
# Set your favourite editor
EDITOR=$EDITOR
# Set this to your PORTDIR_OVERLAY setting in make.conf
PO=/usr/portage.local
# Set temporary directory
TEMP=/tmp
# --- END OF USER SETTINGS ---

DIR=`emerge -s ^$1$ | grep \*.*$1 | head -n1 | sed -e 's/*\ //' | tr -d '[:space:]'`

if [ "$DIR" == "" ]
then
        echo ""
        echo "The specified ebuild does not exist."
        echo ""
        exit
fi

VERSION=`emerge -s ^$1$ | grep "Latest version available:" | head -n1 | sed -e 's/Latest\ version\ available\://' | tr -d '[:space:]'`

EBUILD=$PO/$DIR/$1-$VERSION.ebuild

if [ ! -f "$EBUILD" ]
then
        EBUILD=/usr/portage/$DIR/$1-$VERSION.ebuild

        if [ ! -f "$EBUILD" ]
        then

        echo ""
        echo "FATAL ERROR: I can't find the ebuild!"
        echo ""
        exit

        fi
fi

USEFLAGS=`cat $EBUILD | grep IUSE | head -n1 | sed -e 's/IUSE/USE/'`

if [ "$USEFLAGS" == "" ]
then
        echo ""
        echo "NOTICE: There are no USE flags to be set or available USE flags are not defined in the ebuild."
        echo ""
        emerge $1
        exit
fi

if [ -f /tmp/$1-$VERSION.use_flags.temp ]
then
        rm /tmp/$1-$VERSION.use_flags.temp
fi

echo $USEFLAGS >> /tmp/$1-$VERSION.use_flags.temp
$EDITOR /tmp/$1-$VERSION.use_flags.temp

FLAGS=`cat /tmp/$1-$VERSION.use_flags.temp | grep USE= | head -n1`

if [ -f /tmp/$1-$VERSION.use_flags.temp ]
then
        rm /tmp/$1-$VERSION.use_flags.temp
fi

FLAGS=`echo "$FLAGS" | sed -e 's/USE=//'`
export USE=$FLAGS
emerge $1

# EOF.


Maybe someone finds it useful.. :)
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Documentation, Tips & Tricks 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