georgeprowse
.co.uk
Useful Stuff
Based on a design from Open Source Web Design . Relased under the Creative Commons "Share and ShareAlike (sa)". You may distribute derivative works only under a license identical to the license that governs the original work.
##UNDER CONSTRUCTION!!!
Portage
- What is Portage?
- Basic commands
- More advanced commands
- Masking and unmasking packages
- Updating config files
What is Portage?
Portage is a package manager and it is what makes Gentoo "Gentoo". You have a "tree" in /usr/portage where each package and seperate version has their own folder and ebuild. An ebuild is basically file containing some BASH code telling portage where to get the file. As new versions of packages get released then new ebuilds have to be made for the new versions so it is a good idea to sync (see below) your tree once a day. "tree" in this sense means a hierarchical filing system like:[portage directory]
-->[package group]
-->[package name]
-->[package version]
Basic Commands
The command you'll find yourself using most of the time is "emerge". There are others like "equery" but this is a beginners guide and is designed to get you up and running in your installation.To install a package it is as simple as
emerge foo
To sync your tree run emerge --sync
To update a package run emerge --update
To update every package on your computer run emerge --update world
To have a look which packages will be installed whn you run your commands use --pretend or --ask emerge --pretend rxvtemerge --ask foo
To get a more verbose output on the above commands add --verbose emerge --pretend --verbose world
To search for a package use emerge --search foo
All that above is quite a lot of typing so the devlopers have added shortcuts to the commands: --update --> -u
--search --> -s
--verbose --> -v
--pretend --> -p
--ask --> -a
All of these extra commands can be added together, so for instance if you wanted to update world but get a detailed output of what was going to be installed the best way would be emerge -upv worldThen, all you need to do is remove the "p" and it will all go through.
More advanced Commands
Sometimes you will need to do a special big of updating which may necssitate the use of --newuse or --deep. If you have changed USE flags in make.conf then doing a emerge -uN world (-N is short for --newuse) is a good idea.When you --update world, portage looks for updated versions of the packages you have specifically installed. If you want portage to look for updates for all packages - including dependencies - you have to add the --deep (or -D) switch like so:
emerge -upDv world
Masking and unmasking packages
Gentoo has a 2 trees for packages: stable and testing. Packages that aren't considered 100% stable are "keyworded" testing and packages that are considered possibly dangerous are "masked". Sometimes (but not usually) a package that you want will depend on a package or package version that is considered "testing" so you will have to weigh up whether you want the package or not. If you decide that you cannot do without it then you need to add it to a little text file called package.keywords in /etc/portage (NOT /usr/portage! /etc is used for system-wide configuration but /usr is used for read-only system-wide files). Don't worry if the file is not ther yet, just open your favourite editor and create it! Remember you will need to be root for this so su or sudo to root and open gvim, nano, kedit, gedit or just echo it from the command line.Here is how it works, first you must know that
= means is equal to
> means is more than
< means is less than. Also you must add which architecture (arch) you are using - this will more than likely either be ~x86 or ~amd64
sys-devel/gcc ~x86This will upgrade/install the latest version in portage that isn't hard-masked and will always keep it at the latest version=sys-devel/gcc-4.4.2 ~amd64This will upgrade/install that exact version (4.4.2)>=sys-devel/gcc-4.4.0This will install that specific version (there can be unlimited testing versions of packages) but later upgrades will keep it at the latest versionThere is also package.unmask but that allows you to install potentially dangerous packages and as such you will have to us the official Gentoo documentation for that. Portage will tell you if a package has ben masked like so:
!!! All ebuilds that could satisfy "games-fps/doom3" have been masked.
!!! One of the following masked packages is required to complete your request:
- games-fps/doom3-1.3.1304 (masked by: package.mask, DOOM3 license(s))
/usr/portage/profiles/package.mask:
# Chris Gianelloni <wolf31o2@gentoo.org> (3 Mar 2008)
# Masking due to security bug #194607 and security bug #204067
That basically is saying "DON'T install it! And if you do then dont blame us is your system gets hosed or some script kiddie wipes your hard drive!"Updating config files
VERY important. Every time you update packages there will invariably be some packages that have updated or upgrades parts so new config files need to be addressed. Here you have 2 options: etc-update, cfg-update or dist-upgrade. First you will see* IMPORTANT: 11 config files in '/etc' need updating.etc-update is the old one has less features than the other two but it looks like this: hostname ~ # etc-update
Scanning Configuration files...
The following is the list of files which need updating, each
configuration file is followed by a list of possible replacement files.
1) /etc/init.d/bootmisc (1)
...snip for size
11) /etc/init.d/swclock (1)
Please select a file to edit by entering the corresponding number.
(don't use -3, -5, -7 or -9 if you're unsure what to do)
(-1 to exit) (-3 to auto merge all remaining files)
(-5 to auto-merge AND not use 'mv -i')
(-7 to discard all updates)
(-9 to discard all updates AND not use 'rm -i'):
dispatch-conf looks like this: --- /etc/init.d/bootmisc 2009-10-22 13:11:15.000000000 +0100
+++ /etc/init.d/._cfg0000_bootmisc 2009-11-10 21:57:06.000000000 +0000
@@ -95,7 +95,7 @@
for x in "" $xtra; do
mkutmp /var/run/utmp$x
done
- [ -e /var/log/wtmp ] && mkutmp /var/log/wtmp
+ [ -e /var/log/wtmp ] || mkutmp /var/log/wtmp
eend 0
ebegin "Cleaning /var/run"
>> (1 of 11) -- /etc/init.d/bootmisc
>> q quit, h help, n next, e edit-new, z zap-new, u use-new
m merge, t toggle-merge, l look-merge: As you can see it has taken you straight to the first file and shown you the differences between the two. On the left, the minus sign denotes a line that is there currently and the plus sign denotes the line it wishes to replace. In this example the only differences are the two && in the middle changing to two pipes: || so it is safe to merge this. Basically stick by the rule that if you have manually changed any part of it then check twice because it will always want to take it back to the original version of the file (before you changed it). The third option is the new kid on the block and it has a GUI (graphical user interface) so you can use your mouse and point and click as much as you want. I have no experience of this but if it is as good as it promises to be then I would recommend that to you simply for its usability.