autounmaskはもう使うな

みんなPortageに入っている最新のパッケージを活用するのに、autounmaskで楽してきたと思います。ところがところが最近emergeすると…

# Markos Chandras <hwoarang@gentoo.org> (04 Feb 2012)
# No maintainer. Functionality is now embedded in portage
# Bug #398935. Removal in 30 days
app-portage/autounmask

とか出てくるではないですか…! autounmaskが消え去るだと…!? どういうことだ…!?

心配する必要はありません。 メッセージにも書いてあるように「この機能はPortageに内蔵された」(Functionality is now embedded in portage)のです。

それでは、Portageでのautounmaskを見てみましょう。 google-chrome:unstable (Chromeのバイナリパッケージのunstable版)を入れてみます。

$ emerge -av google-chrome:unstable
[ebuild   R   #] www-client/google-chrome-19.0.1041.0_alpha121843  USE="plugins" LINGUAS="ja -am -ar -bg -bn -ca -cs -da -de -el -en_GB -es -es_LA -et -fa -fi -fil -fr -gu -he -hi -hr -hu -id -it -kn -ko -lt -lv -ml -mr -nb -nl -pl -pt_BR -pt_PT -ro -ru -sk -sl -sr -sv -sw -ta -te -th -tr -uk -vi -zh_CN -zh_TW" 0 kB

Total: 1 package (1 reinstall), Size of downloads: 0 kB

The following mask changes are necessary to proceed:
#required by google-chrome:unstable (argument)
# /usr/portage/profiles/package.mask:
# Mike Gilbert <floppym@gentoo.org> (09 Feb 2012)
# Dev channel releases are only for people who are developers or want more
# experimental features and accept a more unstable release.
=www-client/google-chrome-19.0.1041.0_alpha121843

NOTE: The --autounmask-keep-masks option will prevent emerge
      from creating package.unmask or ** keyword changes.

Use --autounmask-write to write changes to config files (honoring CONFIG_PROTECT).
$

なにやらだらだらと出てきましたね。まず注目するのはこの部分です。

The following mask changes are necessary to proceed:
#required by google-chrome:unstable (argument)
# /usr/portage/profiles/package.mask:
# Mike Gilbert <floppym@gentoo.org> (09 Feb 2012)
# Dev channel releases are only for people who are developers or want more
# experimental features and accept a more unstable release.
=www-client/google-chrome-19.0.1041.0_alpha121843

google-chrome:unstable」 をインストールするには 「/usr/portage/profiles/package.mask」 の以下のマスクの変更が必要だと書いてあります。 わざわざファイルを開いて編集しろだと? どれを? どういうふうに? めんどいですね。ここでemergeの山力の一番下を見てみると

Use --autounmask-write to write changes to config files (honoring CONFIG_PROTECT).

とあります。 ようするにemergeに --autounmask-write をつければ Portageが変わりにその「お仕事」をこなしてくれるってわけです。

$ emerge -av google-chrome:unstable --autounmask-write
[ebuild   R   #] www-client/google-chrome-19.0.1041.0_alpha121843  USE="plugins" LINGUAS="ja -am -ar -bg -bn -ca -cs -da -de -el -en_GB -es -
es_LA -et -fa -fi -fil -fr -gu -he -hi -hr -hu -id -it -kn -ko -lt -lv -ml -mr -nb -nl -pl -pt_BR -pt_PT -ro -ru -sk -sl -sr -sv -sw -ta -te 
-th -tr -uk -vi -zh_CN -zh_TW" 0 kB

Total: 1 package (1 reinstall), Size of downloads: 0 kB

The following mask changes are necessary to proceed:
#required by google-chrome:unstable (argument)
# /usr/portage/profiles/package.mask:
# Mike Gilbert <floppym@gentoo.org> (09 Feb 2012)
# Dev channel releases are only for people who are developers or want more
# experimental features and accept a more unstable release.
=www-client/google-chrome-19.0.1041.0_alpha121843

NOTE: The --autounmask-keep-masks option will prevent emerge
      from creating package.unmask or ** keyword changes.

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

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

これで無事に設定が書かれ………ていません! 「Remember to run etc-update.」とありましたね。 etc-updateなり、COOLなあなたなら dispatch-confなりを動かしてこの変更を実際に反映させましょう。

それすらもめんどい? その気持ちよくわかります。 CONFIG_PROTECT_MASKを使ってやりましょう。

$ CONFIG_PROTECT_MASK="/etc" emerge -av google-chrome:unstable --autounmask-write

こうすれば etc-updateやdispatch-confなしで設定ファイルが変更されます。

さて、これで楽しくautounmaskなしのPortageライフが送れますね!と言いたいところですがもう一つ注意を。上の例では package.unmaskに

#required by google-chrome:unstable (argument)
# /usr/portage/profiles/package.mask:
# Mike Gilbert <floppym@gentoo.org> (09 Feb 2012)
# Dev channel releases are only for people who are developers or want more
# experimental features and accept a more unstable release.
=www-client/google-chrome-19.0.1041.0_alpha121843

として、きっちりバージョンを指定してunmaskが書かれています。ということは、Chromeが更新されて新しい unstableのバージョンが来ても emerge -uDN worldで更新されないってことですね。まあさくっと "www-client/google-chrome:unstable" とかに変更しときましょう。まあ、最後になんかひょうしぬけですね。

おまけ 時代はflaggie

こんなふうにpackage.unmaskとかを開かずによくなってくると package.use を開くのもめんどくなってきますよね。 USEフラグを変更するなら、時代は flaggieなので使いましょう。まずはいつも通りemerge

$ emerge flaggie

使い方はこんな感じ

$ flaggie ffmpeg +rtmp +network
$ flaggie gnome-control-center -socialweb
$ flaggie +pulseaudio

パッケージごとなら、パッケージ名を書く。追加したいUSEフラグは先頭に+、削除したいものは先頭に-。シンプルですね。ちなみに%をつけるとデフォルトに戻し、また

$ flaggie gnome-control-center '?socialweb'
gnome-base/gnome-control-center -socialweb

とすれば、現在の設定の状態を見ることもできます。

ついでに、やたらめったらいままで package.useをいじっているときっとぐちゃぐちゃになっていることでしょうから、

$ flaggie --sort 

$ flaggie --cleanup

で、綺麗にしておくといいかもしれませんね。

さて、flaggieを使うとなにがいいか、というと…。もしtypoした時に

$ flaggie gnome-control-center -spcialweb
At argv[2]='-spcialweb': spcialweb seems to be an incorrect flag for gnome-base/gnome-control-center

こんな感じで、なにかおかしいんじゃないか?と聞いてきてくれます。ミスがなくなっていい感じですね。