MG-P: EMERGE_DEFAULT_OPTS

Gentoo users tend to do a lot of emerge's and most of the time your using the same command line options. To make life easier you can use EMERGE_DEFAULT_OPTS to set your favorite command line options as defaults.

Note: Some of the options used is only available in Portage 2.2.

The attached file contains updated copies of what I use on my production systems.

You can use this variable in make.conf or in your shells environment.

Setting it in make.conf has one drawbacks, if you set --ask it breaks things like eix-sync.

Having EMERGE_DEFAULT_OPTS being set in many different places makes it harder to maintain, so what I do is make a /etc/portage/edopts file, I can then source this file from make.conf and bash startup scripts.


Edopts example.

#!/bin/bash /etc/portage/edopts
# EMERGE_DEFAULT_OPTS: --ask --update --deep --usepkg --reinstall changed-use --with-bdeps=y
EDO_MAIN="--reinstall changed-use --usepkg"
EDO_SHELL="--ask --verbose"
EDO_CLEAN="--with-bdeps y --jobs 3 --load-average=5.00"

EMERGE_DEFAULT_OPTS="$EDO_MAIN $EDO_CLEAN"


Make.conf example.

#/etc/make.conf
source /etc/portage/edopts


Emerge front end.

This script works as a simple front end for emerge. It changes it's behavior based on how you call it. To activate the other modes create symlinks to this file: ln -s emerge emergex
  • emerge - Runs it in a default shell user mode.
  • emergey - Clean mode without options.
  • emergex - Remove --usepkg and --reinstall changed-use.
  • emergeu - Update the system and run some common commands to ensure a clean update.
#!/bin/bash /usr/local/bin/emerge

# If the shell has EDO set we save it before sourcing edopts thats sets the default EDO
if [[ -e $EMERGE_DEFAULT_OPTS ]]; then
edo=$EMERGE_DEFAULT_OPTS
fi

# edopts is a bunch of emerge option variables and it also sets a default EDO value for use by make.conf
source /etc/portage/edopts

# The name we are called with effects how we run
bname=$(basename $0)

case $bname in
emergey | mergey)
# y - squickY clean emerge
edo="--ignore-default-opts"
;;
emergex | mergex)
# x - Run without factorX, --reinstall changed-use and --usepkg that prevents us from doing a recompile
edo="--ignore-default-opts $EDO_SHELL $EDO_CLEAN"
;;
emergeu | mergeu)
# u - Update run with kernel protection, depclean, dispatch-conf and checkrestart
edo="$edo --update --deep --ask @world"
;;
esac

/usr/bin/emerge $edo $*

# After an update @world we run some clean and check jobs.
#
# Protect kernels so they aren't depcleaned just after an upgrade.
#
# Run depclean to cleanup any unneeded packages.
#
# Run dispatch-conf to update configuration files.
#
# Run checkrestart to warn us about any running software that needs restarting.
#
if [[ $? = 0 && ( $bname = "emergeu" || $bname = "mergeu" ) ]]; then
for a in $(qfile -Cv /usr/src/linux-*); do

echo $a;
done | for a in $( grep -v "/usr/src"); do
name=$(echo $a | grep -Eo ".+/[[:alpha:]]+-[[:alpha:]]+")
version=$(echo $a | grep -Eo "\w{1}\.\w{1}\.\w.*")

grep -qs "$name:$version" /var/lib/portage/world || echo =$a
done | xargs -r emergey --noreplace &&
emergey --depclean --ask &&
dispatch-conf &&
#revdep-rebuild &&
checkrestart
fi


Memory compile front end.

#!/bin/bash /usr/local/bin/merge
bname=$(basename $0)

if ! grep /var/tmp/portage /proc/mounts > /dev/null ; then
mount -t tmpfs tmpfs /var/tmp/portage -o "size=3072M"
fi

source $(which e$bname)

if grep /var/tmp/portage /proc/mounts > /dev/null ; then
umount /var/tmp/portage
fi
AttachmentSizeHitsLast download
emergepack-189.tar.bz22.35 KB1165 weeks 1 day ago

Improved emerge frontends

Sometimes lady luck is on your side, while fiddling with the old EDO scripts I suddenly had these scripts instead. They seem way nicer than the old ones and I hope they will be useful to someone.

Enjoy.

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

Post new comment

  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Lines and paragraphs break automatically.

More information about formatting options

CAPTCHA
This question is for testing whether you are a human visitor and to prevent automated spam submissions.
Image CAPTCHA
Enter the characters shown in the image.

client = pub-0221006129483283
slot = 3780496060
width = 728
height = 90

Copyright (c) 2007, 2008 Steen Eugen Poulsen

Syndicate content Syndicate content
ignorethis