Difference between revisions of "Using portage"

From gr0x0rd
Jump to navigation Jump to search
(Created page with " one of the best (and worst) things about gentoo is the portage system. think of portage as the equivalent of the windows installer, but without a graphical user interface, that…")
 
Line 1: Line 1:
  
one of the best (and worst) things about gentoo is the portage system. think of
+
=== Portage basics ===
portage as the equivalent of the windows installer, but without a graphical user
 
interface, that acts as an "agent" between your computer and the software you
 
want to install.
 
  
portage is run by using the command "emerge". the syntax is as follows:
+
Portage is run by using the command "emerge". The syntax is as follows:
  
emerge -<flags> <what to emerge>
+
'''$''' sudo emerge -<flags> <what to emerge>
  
portage will read the contents of your /etc/make.conf file to determine which
+
To determine the version and locations of the latest packages, portage communicates with an rsync server, which will update the local information available to portage so it has the latest list of packages. To sync portage, use the command  
gentoo mirror to download packages from. your make.conf file also contains an  
 
rsync server, which will update the local information available to portage so
 
it has the latest list of packages. To sync portage, use the command  
 
  
emerge --sync
+
'''$''' sudo emerge --sync
  
 
Portage flags tell portage which action to take. Some of the available flags are
 
Portage flags tell portage which action to take. Some of the available flags are
 
+
<pre>
 
-u : update the package in question.
 
-u : update the package in question.
 
-D : update the package in question, and any packages it depends on
 
-D : update the package in question, and any packages it depends on
Line 26: Line 20:
 
-s : search for package(s) in question.
 
-s : search for package(s) in question.
 
-p : pretend to emerge package (see what would happen)
 
-p : pretend to emerge package (see what would happen)
 +
</pre>
 +
 +
'''It is good practice to always use the -av flags before emerging any package.'''
  
*** always use the -p flag before emerging any package. ***
+
=== Checking if a newer package is available ===
  
If I had just run an emerge --sync and wanted to see if there was a new version  
+
If I had just run an ''emerge --sync'' and wanted to see if there was a new version of the ati video drivers, I would issue the command
of the ati video drivers, I would issue the command
 
  
emerge -p ati-drivers
+
'''$''' emerge -p ati-drivers
  
If I wanted to search for vlc media player, I would issue the command
+
You can also search for packages using portage. If I wanted to search for vlc media player, I would issue the command
  
emerge -s vlc
+
'''$''' emerge -s vlc
  
To see all the packages on my system that could be updated,
+
To see all the packages on a system that could be updated,
  
emerge -uDNvp world
+
'''$''' emerge -uDNvp world
  
Your etc/make.conf contains your global USE flags. Portage reads these flags
+
Your etc/make.conf contains your global USE flags. Portage reads these flags before emerging any package, and will use them to compile and optimize the package based on the flags you have set. To view a list of the packages available in portage, and the USE flags available for each package, visit  
before emerging any package, and will use them to compile and optimize the package  
 
based on the flags you have set. To view a list of the packages available in  
 
portage, and the USE flags available for each, visit  
 
  
 
http://gentoo-portage.com/Browse
 
http://gentoo-portage.com/Browse
  
If there is a USE flag you want to use for a specific package but don't want to
+
=== Global and per-package USE flags ===
use globally, you can specify the package and USE flag in /etc/portage/package.use.
 
 
 
nano -w /etc/portage/package.use
 
 
 
For example, if we wanted to emerge conky without the ivp6 USE flag, but we had
 
the ipv6 USE flag in our make.conf, we would add a line such as
 
 
 
app-admin/conky truetype audacious -ipv6
 
 
 
to specify that portage emerge conky with the truetype and audacious USE flags, but
 
not the ipv6 USE flag.
 
 
 
Some packages in portage may be masked (or blocked) for various reasons. You may run
 
into an issue where you can't install a certain package because it or one of its
 
dependencies are masked. To unmask a package, edit your /etc/portage/package.keywords
 
file:
 
 
 
nano -w /etc/portage/package.keywords
 
 
 
to unmask a specific package, you'll need to package type and package name in the
 
format <package-type>/<package-name>. For example, if we wanted to emerge masked
 
versions of portage, we would add
 
 
 
sys-apps/portage **
 
 
 
to our package.keywords file. This strategy can be used to emerge any masked package.
 
 
 
Since there may be many different versions of each package in portage, and in many
 
cases, the latest package may not always be the best. You can specify specific package
 
versions and prevent portage from upgrading them by specifying
 
 
 
=pkg-type/pkg-name-version
 
 
 
in your package.keywords file. you can also tell portage to install a specific package
 
on-the-fly using the syntax
 
 
 
emerge =pkg-type/pkg-name-version
 
 
 
The most common problem when using portage is circular dependencies and blocked or
 
masked packages. package x may require package y which may require package z which
 
cannot coexist with package x. there are a number of ways to circumvent these types
 
of issues.
 
  
* uninstall packages blocking other packages. *
+
If there is a USE flag you want to use for a specific package but don't want to use globally, you can specify the package and USE flag in ''/etc/portage/package.use''.  
  
to do this, use portage's -C flag.
+
'''$''' sudo nano -w /etc/portage/package.use
  
emerge -C <package to uninstall>
+
For example, if we wanted to emerge conky without the ivp6 USE flag, but we had the ipv6 USE flag in our make.conf, we would add a line such as
  
* upgrade or downgrade packages. *
+
app-admin/conky truetype audacious -ipv6
  
change your package.keywords file and try to emerge problematic packages individually.
+
to specify that portage emerge conky with the truetype and audacious USE flags, but not the ipv6 USE flag.  
to do this, you can specify the package version in your package.keywords file, or do
 
it on-the-fly using
 
  
emerge =pkg-type/pkg-name-version
+
=== Masked Packages ===
  
* run revdep-rebuild. *
+
Some packages in portage may be masked (or blocked) for various reasons. You may run into an issue where you can't install a certain package because it or one of its dependencies are masked. To unmask a package, edit your ''/etc/portage/package.keywords'' file:
  
to run gentoo's revdep-rebuild (review dependencies and rebuild packages) command, you
+
'''$''' sudo nano -w /etc/portage/package.keywords
will need to emerge the gentoolkit.
 
  
emerge gentoolkit
+
To unmask a specific package, you'll need to package type and package name in the format ''<package-type>/<package-name>''. For example, if we wanted to emerge masked versions of portage, we would add
  
revdep-rebuild
+
sys-apps/portage **
  
this will rebuild any libraries that have broken associations. it is recommended to run
+
to our ''package.keywords'' file. This strategy can be used to emerge any masked package. Some packages are hard masked, meaning the devs have gone out of their way to prevent a certain package from being installed. This is usually due to stability or security concerns. If you really need to install a hard masked package, you'll need to comment out the package atom listed in the file ''/usr/portage/profiles/package.mask''.
revdep-rebuild every time you emerge packages that have significant impact on your system.
 
  
* try using a beta version of portage. *
+
=== Emerging specific versions ===
  
add
+
Since there may be many different versions of each package in portage, and in many cases, the latest package may not always be the best. You can specify specific package versions and prevent portage from upgrading them by specifying
  
sys-apps/portage **
+
=pkg-type/pkg-name-version
  
to your /etc/portage/package.keywords file and then run
+
in your package.keywords file. You can also tell portage to install a specific package on-the-fly using the syntax
  
emerge portage
+
emerge =pkg-type/pkg-name-version
  
unsupported versions of portage may pull in other masked packages, so you'll have to
+
The most common problem when using portage is circular dependencies and blocked or masked packages. package x may require package y which may require package z which cannot coexist with package x. There are a number of ways to circumvent these types of issues, one of which is uninstalling a certain package.
note these packages and add them to your package.keywords in similar fashion. Once a
 
newer version of portage is installed, you'll want to run
 
  
emerge --sync
+
=== Uninstalling packages ==
  
and try emerging your packages again.  
+
To uninstall or unmerge a package, use portage's -C flag.
  
you don't need to understand all of this information- just remember that it is here
+
'''$''' sudo emerge -avC ''packagename''
and you can use it as a reference if needed.
 

Revision as of 21:24, 13 March 2011

Portage basics

Portage is run by using the command "emerge". The syntax is as follows:

$ sudo emerge -<flags> <what to emerge>

To determine the version and locations of the latest packages, portage communicates with an rsync server, which will update the local information available to portage so it has the latest list of packages. To sync portage, use the command

$ sudo emerge --sync

Portage flags tell portage which action to take. Some of the available flags are

-u : update the package in question.
-D : update the package in question, and any packages it depends on
-N : re-emerge the package with new USE flags
-v : verbose mode
-a : ask before emerging the package(s)
-C : uninstall the package in question.
-s : search for package(s) in question.
-p : pretend to emerge package (see what would happen)

It is good practice to always use the -av flags before emerging any package.

Checking if a newer package is available

If I had just run an emerge --sync and wanted to see if there was a new version of the ati video drivers, I would issue the command

$ emerge -p ati-drivers

You can also search for packages using portage. If I wanted to search for vlc media player, I would issue the command

$ emerge -s vlc

To see all the packages on a system that could be updated,

$ emerge -uDNvp world

Your etc/make.conf contains your global USE flags. Portage reads these flags before emerging any package, and will use them to compile and optimize the package based on the flags you have set. To view a list of the packages available in portage, and the USE flags available for each package, visit

http://gentoo-portage.com/Browse

Global and per-package USE flags

If there is a USE flag you want to use for a specific package but don't want to use globally, you can specify the package and USE flag in /etc/portage/package.use.

$ sudo nano -w /etc/portage/package.use

For example, if we wanted to emerge conky without the ivp6 USE flag, but we had the ipv6 USE flag in our make.conf, we would add a line such as

app-admin/conky truetype audacious -ipv6

to specify that portage emerge conky with the truetype and audacious USE flags, but not the ipv6 USE flag.

Masked Packages

Some packages in portage may be masked (or blocked) for various reasons. You may run into an issue where you can't install a certain package because it or one of its dependencies are masked. To unmask a package, edit your /etc/portage/package.keywords file:

$ sudo nano -w /etc/portage/package.keywords

To unmask a specific package, you'll need to package type and package name in the format <package-type>/<package-name>. For example, if we wanted to emerge masked versions of portage, we would add

sys-apps/portage **

to our package.keywords file. This strategy can be used to emerge any masked package. Some packages are hard masked, meaning the devs have gone out of their way to prevent a certain package from being installed. This is usually due to stability or security concerns. If you really need to install a hard masked package, you'll need to comment out the package atom listed in the file /usr/portage/profiles/package.mask.

Emerging specific versions

Since there may be many different versions of each package in portage, and in many cases, the latest package may not always be the best. You can specify specific package versions and prevent portage from upgrading them by specifying

=pkg-type/pkg-name-version

in your package.keywords file. You can also tell portage to install a specific package on-the-fly using the syntax

emerge =pkg-type/pkg-name-version

The most common problem when using portage is circular dependencies and blocked or masked packages. package x may require package y which may require package z which cannot coexist with package x. There are a number of ways to circumvent these types of issues, one of which is uninstalling a certain package.

= Uninstalling packages

To uninstall or unmerge a package, use portage's -C flag.

$ sudo emerge -avC packagename