I’ve been using Gentoo for about two years now and I took notes on managing my system. These are those notes. I’ve since created a bash script that does many of the functions and I’ll just post it here because it is pretty self-explanatory. For more details read below.
If you’re interested in installing Gentoo take a look at Gentoo Quick Install.
#!/bin/sh
# /root/.bin/Gentoo/e - portage management tool
if [[ -z $@ ]]; then
echo "e <option> <*option2/pkg> - portage management tasks:
1 | oneshot - adds a package as a dependency
- | flagrem - removes a global USE flag
+ | flagadd - adds a global USE flag
b | blocked - blocked pkg workaround - <blocking> <tomerge>
c | clean - cleans (removes) package sources no longer in portage tree
d | depclean - remove unneeded dependencies
e | elog - view elog (developer notes for merged packages)
f | flag - add flag to package - <category/pkg flag>
g | flaginfo - information on a package's USE flags
h | flaghas - programs using USE flag
i | install - installs package (will use binary if available)
k | keyword - add keyword for unsupport archtechtures
l | list - lists files installed to a package
o | owns - check the file's owning package
p | pretend - check details of how a package is going to be added
q | query - search for an installed package
r | remove - remove package(s)
s | search - search for a package
t | searchdes - search the description of packages
u | upgrade - emerge world (upgrade everything)
x | check - check installed pkg(s) integrity
y | sync - sync the portage database
z | revdep - rebuild dependencies
freeze - freeze a pkg update - <cat/pkg> <cat/pkg-version>
unfreeze - unfreeze a package - <package>
unmask - unmask package - <category/pkg-*version>
gcl - list installed gcc compilers
gcs - set new gcc compiler
kl - list available kernels
ks - select new kernel (will require bootloader update)"
exit
fi
# change to ebuild directory, put in ~/.bashrc:
# cde () { cd "$(dirname `equery ewhich "$@"`)" ; }
# b | blocked - untested
# unfreeze - generic matching will delete any line that matches
# forcerm(add?) - removes package that can't otherwise be uninstalled
# forcerm ) shift
# emerge --force "$@"
# ;;
# etc-update (add?)
# --resume --skipfirst (add?)
case $1 in
1 | oneshot ) shift
emerge --oneshot "$@"
;;
- | flagrem ) shift
if [[ -z "$@" ]]; then
echo " exiting: flag required"
exit; else
euse -D "$@"
fi
;;
+ | flagadd ) shift
if [[ -z "$@" ]]; then
echo " exiting: flag required"
exit; else
euse -E "$@"
fi
;;
B | Block ) shift
quickpkg $1
emerge --unmerge $1
emerge $2
emerge --usepkgonly --nodeps $1
;;
c | clean ) eclean distfiles
;;
d | depclean ) emerge --depclean
;;
e | elog ) less /var/log/portage/elog/summary.log
;;
f | flag ) shift
echo "$@" >> /etc/portage/package.use
;;
g | useinfo ) shift
equery uses "$@"
;;
h | flaghas ) shift
equery hasuse "$@"
;;
i | install ) shift
emerge --usepkg --ask "$@"
;;
k | keyword ) shift
echo -e "$@ **" >> /etc/portage/package.keywords
;;
l | ls | list ) shift
equery files "$@"
;;
o | own ) shift
equery belongs "$@"
;;
p | pretend ) shift
emerge -pv "$@"
;;
q | query ) shift
equery list "*$@*"
;;
r | remove ) shift
emerge --unmerge "$@"
;;
s | search ) shift
eix "$@"
;;
t | searchdes ) shift
eix -S "$@"
;;
u | upgrade ) emerge --update --newuse --deep --ask world
;;
x | check ) shift
equery check "$@"
;;
y | sync ) eix-sync
;;
z | revdep ) revdep-rebuild
;;
freeze ) shift
echo "$1" >> /etc/portage/package.mask
echo "$2" >> /etc/portage/package.unmask
;;
unfreeze ) shift
sed -i "/$@/d" /etc/portage/package.mask
sed -i "/$@/d" /etc/portage/package.unmask
;;
unmask ) shift
echo "$@" >> /etc/portage/package.unmask
;;
gcl ) gcc-config -l
;;
gcs ) shift
gcc-config "$@"
;;
kl ) eselect kernel list
;;
ks ) shift
eselect kernel set "$@"
;;
* ) emerge "$@"
esac
About Portage
Gentoo Linux uses a package management system called Portage. Portage offers one of the most extensible and customizable package systems available in Linux.
System Update
Update all packages on the computer. This process involves: syncing Portage, creating a text file to review updates, updating the system, merging new configuration files, remove orphaned dependencies.
Sync the portage tree:
eix-sync # preferrable for faster searches (eix search)
Examine update before install:
If unexpected dependencies are being pull in, use the –tree variable to track it down.
Complete update:
etc-update
revdep-rebuild
glsa-check -f affected
eclean distfiles
- In the first command, portage wiil update all packages on the system
- etc-update is Portages configuration replacement tool. To merge configurations consider using dispatch-conf.
- revdep-rebuild will check that all programs and libraries are linked correctly.
- glsa-check is Gentoo’s security patches
- eclean distfiles will remove package sources that aren’t installed anymore.
Remove Abandoned Dependencies:
Failed Package Emerge in a Compilation String
At times in a long list of package emerges like a system update, a package will fail to emerge. Bugzilla and the forums usually have information about known problems with the package, if not, it’s possible the package needs a newer version of a package that has not yet been installed in the compilation string. Skipping the problem package and emerging it again when the rest of the packages are compiled may fix the problem.
Blocked Packages
Packages that block other packages from being emerged can be fixed by removing the obstructing packages and reinstalling it after blocked package is emerged.
emerge -C $BLOCKER
emerge $BLOCKED
emerge –usepkgonly $BLOCKER
Specify USE Flags per package in /etc/portage/package.use:
To add a USE flag temporarily (not recommended):
Masked Packages (keyword)
The “missing keyword” mask states an ebuild doesn’t support or hasn’t been tested on the current architecture (x86, amd, ppc… ). Keywording can be added to /etc/portage/package.keywords:
Masked Packages (hard)
Gentoo hards masks some packages for security concerns, collisions… Packages are hard masked in /usr/portage/profiles/package.mask. If you like living on the edge, packages can be unmasked in /etc/portage/package.unmask.
Emerge dependency of a package
Packages that are dependencies of other packages (i.e. have no use on their own) should be emerged as “oneshot”. This is because if the main package is removed so too will this package when “emerge –depclean” is run. Otherwise these dependent packages are added to the world file.
Freeze a Package
If a rebuild of a package isn’t necessary or undesired, a package can be frozen. This is useful for kernels and other such packages.
Mask the generic package (i.e. without version) in /etc/portage/package.mask:
Add the specific version to /etc/portage/package.unmask:
Create a Binary Package
If enough disk space is available its may be a good idea to create binary of a package so it is quicker to re-install.
To install a binary package:
Info About the Portage System
This information can be useful for reporting bugs:
Other Portage Tools
Info about USE flags (equery is part of gentoolkit):
Programs built with a specific USE flag:
View what files are installed by program:
View what packages install to a folder:
List all installed packages:
Select a new system profile (With each new revision (i.e. 2006.1 to 2007) new profiles are added. Profiles define basic system USE flags…):
eselect profile set 4
then “Update System”.
Select new kernel:
eselect kernel set 2
Rebuild modules added from Portage. Some drivers build against the kernel (video drivers, sound drivers…).
GCC Update. Update System for new GCC toolchain (yes both are recommended):
emerge -eav world
See installed GCC profiles and select one:
gcc-config 2
Then update the environment:
Create a binary of an already installed package:
Clean portage world file:
Udept is a program that can speed up emerge by reducing the amount of calculations required by emerge. It does so by erasing repeat entries and dependencies in the world file (/var/lib/portage/world).
emerge –depclean” will removed “epiphany”.Layman / Overlays
Overlays are package systems that run on top of Portage. Many Gentoo users eventually create their own overlay to be able to customize packages or build packages that are not yet in Gentoo Portage. A good number of third party overlays are available.
Local Overlay
Portage ebuilds can be edited to the users needs but once Portage has been synced all changes will be lost. Create a local overlay to edit ebuilds or make your own.
It’s best to see if the program has an ebuild in bugzilla or is in one of the third party overlays.
To make a personal overlay, create the overlay directory and let make.conf known of it (this folder can be almost anywhere).
In make.conf:
Ebuilds must be placed in a category that already exists in Portage.
Keyword if necessary:
ekeyword ~ppc package-1.2.1.2.ebuild
Create a manifest and build:
emerge <package>
Layman
Layman is a manager for third party overlays (the most popular being sunrise).
emerge layman
Add to make.conf:
layman –list # -Lk for a more complete list
To add an overlay:
Sunrise is the most popular overlay in portage. If it’s not in the regular portage tree check sunrise.
Update layman overlays:
Good and refreshing article. :)
Sums up pretty much the need to know stuff in Gentoo.
“Package states ‘missing keyword’”: A note on this. The safest way to get it is /etc/portage/package.keywords. An entry looks like that:
cat-egory/package **
Christian,
I never really understood the use for package.keywords. I’ve actually seen people use it to unmask packages which seems odd to me. But now that I’ve looked into it this is alot better way to do keywording.
Thanks for the tip.
Great post.
Do you know how to block packages from an overlay repository?
or…
How to add a single package from an overlay?
Some times you need some overlay for one or two ebuilds and its a bit insane update the rest of your system with other that do you prefeer the gentoo oficials repository ebuilds….
Thanks a lot for the post.. very instructive.
Straight to the point. Excelent!
Some good info but: Never use etc-update! Use dispatch-conf instead.
@ AlanR
yes using dispach-conf is a lot better for not overwritting existing configs. when i used gnome i had meld in /etc/etc-update.conf:
diff_command=”meld %file1 %file2″
I’ve tried Kompare but its not quite as good.
Thanks for the info. The way you described oneshot helped!
[...] For more on managing Gentoo take a look at Gentoo Linux Tidbits. [...]