Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
[HOWTO] Portage Enhancement
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

Joined: 21 Oct 2003
Posts: 1046
Location: Gentoo Forums

PostPosted: Sun Nov 14, 2004 5:15 pm    Post subject: [HOWTO] Portage Enhancement Reply with quote

Portage Enhancement

  • Ease the effort of installing packages which are masked either by package.mask or keyword
  • Show the user the functionality of portage as the installation by path is now obsolete and never was a good idea

  • some editor, bash and portage ;-)

What it does
I suggest 2 aliases and one function. The two aliases aren't really special but may come in handy: they allow you to fire up portage and let you see only the installed/not installed packages. i know that qpkg (which is a tool in portage too) can do more or less the same thing. still, i don't need another package (which means remembering the tool and syntax for it). and i'm used to the printout of portage - which is different with qpgk. with my two aliases it looks alike.
emerge -s kde | installed

*  kde-base/kde
      Latest version available: 3.3.1
      Latest version installed: 3.3.1
      Size of downloaded files: 0 kB

*  kde-base/kde-env
      Latest version available: 3-r3
      Latest version installed: 3-r3
      Size of downloaded files: 0 kB
/** snip **/

emerge -s kde | notinstalled

*  app-doc/kdelibs-apidocs
      Latest version available: 3.1.5
      Latest version installed: [ Not Installed ]
      Size of downloaded files: 10,302 kB
      Homepage:    http//
      Description: API documentation autogenerated from the kde-base/kdelibs package
      License:     GPL-2

*  app-i18n/uim-kdehelper [ Masked ]
      Latest version available: 0.1.0-r1
      Latest version installed: [ Not Installed ]
      Size of downloaded files: 603 kB
      Description: Qt replacement of toolbar, system tray, applet and candidate window for UIM library.
      License:     GPL-2
/** snip **/

the function is more sophisticated. if you want to emerge a packge you may get the following warning from portage:
pts/1 #emerge -pv licq

These are the packages that I would merge, in order:

Calculating dependencies
!!! All ebuilds that could satisfy "licq" have been masked.
!!! One of the following masked packages is required to complete your request:
- net-im/licq-1.2.7 (masked by: package.mask)
- net-im/licq-1.3.0-r1 (masked by: ~x86 keyword)
- net-im/licq-1.3.0 (masked by: ~x86 keyword)

For more information, see MASKED PACKAGES section in the emerge man page or
section 2.2 "Software Availability" in the Gentoo Handbook.

now in order to emerge a package you'll have to select the appropriate lines and add them to /etc/portage.mask and/or /etc/portage.keywords. now this is annyoing, isn't it? try to emerge the login manager entrance - you'll have to memorize 8 entries and add them to /etc/portage.keywords, very annoying. my function now selects those entries and depending on the mask reason open an editor and the appropriate file and paste it into the files (with the commented date of modification).
emerge -pv licq | key

will open /etc/package.keywords and add these entries:
###  entry added on 14.11.2004 ###
=net-im/licq-1.3.0-r1 ~x86
=net-im/licq-1.3.0 ~x86

as there was a package which was masekd by package.mask my function opened package.unmask too:
###  entry added on 14.11.2004 ###

the beauty of vi(m) is you're able to open several files and switch between them with hitting ':' (doublepoint), writing 'buffer ' (mind the emtpy space after 'buffer') and using <TAB> to select another file.
all you have to do now is what you'd have to do anyway: considering which of the masked package you want to install and removing the entries you don't want (hitting ':dd' to remove a hole line withi vim). after that you write the file and exit and may emerge your package as usual.

How to do it
  • open your /root/.bashrc (if not existing create it) and add the following lines to it:
    alias installed="egrep -A2 -B3 'installed: [0-9]+.*' --colour=always"

    alias notinstalled="egrep -A2 -B3 '\[+.*' --colour=always"


    function key
            stty_settings=`stty -F /dev/tty -g`
            all=`grep .`
            v1=`echo "$all" | grep "masked by: ~x86 keyword" | egrep -o '\w+\-\w+\/\w+(\-?(\w*\.)*\w*)*'`
            v2=`echo "$all" | grep "masked by: package.mask" | egrep -o '\w+\-\w+\/\w+(\-?(\w*\.)*\w*)*'`

            if [ "$v1" != "" ] ; then
                    if  [ "$v2" != "" ]  ; then
                            echo "" >> $keywords
                            echo "###  entry added on `date +\%d.\%m.\%Y` ###" >> $keywords
                            for line in $v1; do echo "=$line ~$arch" >> $keywords ; done
                            echo "" >> $unmask
                            echo "###  entry added on `date +\%d.\%m.\%Y` ###" >> $unmask
                            for line in $v2; do echo "=$line" >> $unmask ; done
                            $editor $keywords $unmask
                            echo "" >> $keywords
                            echo "###  entry added on `date +\%d.\%m.\%Y` ###" >> $keywords
                            for line in $v1; do echo "=$line ~$arch" >> $keywords ; done
                            $editor $keywords
            elif [ "$v2" != "" ]  ; then
                    echo "" >> $unmask
                    echo "###  entry added on `date +\%d.\%m.\%Y` ###" >> $unmask
                    for line in $v2; do echo "=$line" >> $unmask ; done
                    $editor $unmask

            stty -F /dev/tty $stty_settings

  • Modification
    depending on your setup you may adjust the variables set in the function key and/or the names of the function/aliases to something you remember mor easily.

  • source it:
    source /root/.bashrc

  • try it:
    emerge -s kde | installed

    emerge -s kde | notinstalled

    emerge entrance -pv | key

    to install entrance you'll still have to fire up portage 8 times as there are 8 packages masked, but i can't do nothing about that as portage notifies you about masked packages step by step.

AddOn / Offtopic
Just another useful .bashrc command i stumbled across in this forum and most of the user should know about:
alias confcat="sed -e 's/#.*//;/^\s*$/d' "$@""

I suggest this alias because a lot of users are posting their configs with all the comments included and this is annoying.
pts/1 # confcat /etc/postfix/
queue_directory = /var/spool/postfix
command_directory = /usr/sbin
daemon_directory = /usr/lib/postfix
mail_owner = postfix
myhostname = somename
mydomain = somedomain
inet_interfaces = all
mydestination = $myhostname, localhost.$mydomain
unknown_local_recipient_reject_code = 450
mynetworks_style = host
home_mailbox = .maildir/
mail_spool_directory = /var/spool/mail
smtpd_banner = $myhostname ESMTP $mail_name ($mail_version)
debug_peer_level = 2
debugger_command =
         xxgdb $daemon_directory/$process_name $process_id & sleep 5
sendmail_path = /usr/sbin/sendmail
newaliases_path = /usr/bin/newaliases
mailq_path = /usr/bin/mailq
setgid_group = postdrop
html_directory = no
manpage_directory = /usr/share/man
sample_directory = /etc/postfix
readme_directory = /usr/share/doc/postfix-2.1.5-r1/readme
default_destination_concurrency_limit = 2
alias_database = hash:/etc/mail/aliases
local_destination_concurrency_limit = 2
alias_maps = hash:/etc/mail/aliases
home_mailbox = .maildir/
smtp_sasl_auth_enable = yes
smtp_sasl_password_maps = hash:/etc/postfix/saslpass
smtp_sasl_security_options = noanonymous

ToDo / Help needed

  1. I'd like to surpress the warning from vim about the input not being from a terminal.
  2. I don't know why vim takes so long to start.
  3. Backspace loses it's normal functionality within vim, i don't know why

Feel free to contact me with correction and modifications, suggestions and enhancements.
Easily backup up your system? klick
Get rid of SSH Brute Force Attempts / Script Kiddies klick
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