Unmasking packages using portage

Not so far ago I found an interesting feature in portage-2.2. Two wonderful options had been appeared in emerge: --autounmask and --autounmask-write. They allow users not to install additional package app-portage/autounmask saving easy and safe handling with package unmasking.

–autounmask [ y | n ]

Automatically unmask packages and generate package.use settings as necessary to satisfy dependencies. This option is enabled by default. If any configuration changes are required, then they will be displayed after the merge list and emerge will immediately abort.

–autounmask-write [ y | n ]

If --autounmask is enabled, changes are written to config files. Of course, respecting CONFIG_PROTECT and --ask. If CONFIG_PROTECT is not empty running etc-update would be reminded for config files updating in /etc/portage/.

For example: let’s install media-sound/audacious-2.5.3 and media-plugins/audacious-plugins-2.5.3. By the time this article being written theese packages were unstable (~x86). Unmasking is possible by running

emerge -av --autounmask-write =media-sound/audacious-2.5.3 =media-plugins/audacious-plugins-2.5.3

Output we get:

calculate ~ # emerge -av --autounmask-write =media-sound/audacious-2.5.3 =media-plugins/audacious-plugins-2.5.3

These are the packages that would be merged, in order:

Calculating dependencies... done!
[ebuild     U ~] dev-libs/libmowgli-0.9.50 [0.7.0] USE="-examples" 103 kB
[ebuild     U ~] media-sound/audacious-2.5.3 [2.4.4] USE="nls session sse2 (-altivec) -chardet" 1,191 kB
[ebuild     U ~] media-plugins/audacious-plugins-2.5.3 [2.4.4-r1] USE="aac alsa cdda cue ffmpeg 
flac gnome ipv6 libnotify lirc mp3 nls scrobbler sdl sse2 vorbis wavpack -adplug (-aqua) -bs2b 
-fluidsynth (-jack) -lame -libsamplerate -midi -mms -mtp -oss -pulseaudio -sid -sndfile" 3,408 kB

Total: 3 packages (3 upgrades), Size of downloads: 4,701 kB

The following keyword changes are necessary to proceed:
#required by media-plugins/audacious-plugins-2.5.3, 
required by =media-plugins/audacious-plugins-2.5.3 (argument)
>=media-sound/audacious-2.5.3 ~x86
#required by media-sound/audacious-2.5.3, 
required by media-plugins/audacious-plugins-2.5.3, 
required by =media-plugins/audacious-plugins-2.5.3 (argument)
>=dev-libs/libmowgli-0.9.50 ~x86
#required by media-sound/audacious-2.5.3, 
required by =media-sound/audacious-2.5.3 (argument)
>=media-plugins/audacious-plugins-2.5.3 ~x86

NOTE: This --autounmask behavior can be disabled by setting
      EMERGE_DEFAULT_OPTS="--autounmask=n" in make.conf.

Would you like to add these changes to your config files? [Yes/No] yes

Autounmask changes successfully written. Remember to run etc-update.

Take an attention: we’ve taken no deal with dev-libs/libmowgli, everything was done automatically. We’re remembered to run etc-update. Running.

calculate ~ # 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/portage/package.keywords/deps (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'): -3
Replacing /etc/portage/package.keywords/deps with /etc/portage/package.keywords/._cfg0000_deps
mv: rewrite «/etc/portage/package.keywords/deps»? y
Exiting: Nothing left to do; exiting. :)

Now we can install packages we need:

emerge -av =media-sound/audacious-2.5.3 =media-plugins/audacious-plugins-2.5.3

Take a look: we don’t use --autounmask-write option now because emerge would offer to write the changes to configs again.

Note. If you are to unmask unstable version of package with existing stable version (in our example, media-sound/audacious-2.4.4 - stable, media-sound/audacious-2.5.3 - unstable) you should specify exact version of package you unmask, as it was mentioned above. If needed package don’t have stable versions in slot, as, for example, by this time, dev-java/java-service-wrapper, specifying the exact version is not necessarily.

calculate ~ # eix dev-java/java-service-wrapper
* dev-java/java-service-wrapper
     Available versions:  ~3.2.3 ~3.3.1 ~3.3.3 {doc elibc_FreeBSD source test}
     Homepage:            http://wrapper.tanukisoftware.org/
     Description:         A wrapper that makes it possible to install a Java Application as daemon.

calculate ~ # emerge -av --autounmask-write dev-java/java-service-wrapper

These are the packages that would be merged, in order:

Calculating dependencies... done!
[ebuild  N     ] dev-java/javatoolkit-0.3.0-r6  17 kB
[ebuild  N     ] dev-java/java-config-wrapper-0.16  8 kB
[ebuild  N     ] dev-java/java-config-2.1.11-r3  60 kB
[ebuild  N     ] dev-java/icedtea6-bin-1.10.2  USE="X alsa nsplugin -doc -examples -source" 36,141 kB
[ebuild  N     ] virtual/jdk-1.6.0  0 kB
[ebuild  N     ] virtual/jre-1.6.0  0 kB
[ebuild  N     ] dev-java/ant-core-1.8.1  USE="-doc -source" 5,740 kB
[ebuild  N     ] dev-java/ant-nodeps-1.8.1  0 kB
[ebuild  N    ~] dev-java/java-service-wrapper-3.3.3  USE="-doc -source -test" 294 kB

Total: 9 packages (9 new), Size of downloads: 42,257 kB

The following keyword changes are necessary to proceed:
#required by dev-java/java-service-wrapper (argument)
>=dev-java/java-service-wrapper-3.3.3 ~x86

NOTE: This --autounmask behavior can be disabled by setting
      EMERGE_DEFAULT_OPTS="--autounmask=n" in make.conf.

Would you like to add these changes to your config files? [Yes/No]

Note, that in this case newer version would be selected automatically.
Important. You should have files (even empty) in catalogs /etc/portage/package.*/ for this method worked properly or you would be informed about absence of file for writing in.