年末なので #gentooinstallbattle 実況しつつPlay2の開発環境作ります。(その2：ミドルウェアインストール編)

年末とか関係なく恒例 #gentooinstallbattle しましょうということで、今回はVirtualBox上にGentoo Linuxをインストールし、Scala+Play2の開発環境を作る様子を実況します。
[「その1：OSインストール編」はこちら](http://qiita.com/mazgi/items/b9ccfc28b72b5e6bdeec)
[「その3：Scala+Playインストール編」はこちら](http://qiita.com/mazgi/items/b9ccfc28b72b5e6bdeec)

----

## 本編

さっき入れ忘れたパッケージを入れます。

```shell-session
localhost ~ # emerge -uavq tmux git

 * IMPORTANT: 8 news items need reading for repository 'gentoo'.
 * Use eselect news to read news items.



!!! The short ebuild name "git" is ambiguous. Please specify
!!! one of the following fully-qualified ebuild names instead:

    dev-ruby/git
    dev-vcs/git
```

「 `git` ってパッケージが複数あってわかりません」とか言われたので `dev-vcs/git` を指定してLet's emerge!

```shell-session
localhost ~ # emerge -uavq tmux dev-vcs/git
```

emerge中の様子は長いので割愛。

・・・というかgitの依存パッケージなんでこんなに多いの・・・？

```shell-session
localhost ~ # emerge -pv dev-vcs/git

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

Calculating dependencies... done!
[ebuild  N     ] app-crypt/gnupg-2.0.22  USE="bzip2 nls readline -adns -doc -ldap -mta (-selinux) -smartcard -static -usb" 0 kB
[ebuild  N     ] virtual/perl-IO-Compress-2.60.0  0 kB
[ebuild  N     ] virtual/perl-CPAN-Meta-Requirements-2.122.0  0 kB
[ebuild  N     ] dev-perl/Net-SMTP-SSL-1.10.0  0 kB
[ebuild  N     ] dev-perl/Digest-HMAC-1.30.0  0 kB
[ebuild  N     ] perl-core/Archive-Tar-1.900.0  0 kB
[ebuild  N     ] perl-core/Module-Load-Conditional-0.540.0  0 kB
[ebuild  N     ] dev-perl/Authen-SASL-2.160.0  USE="-kerberos" 0 kB
[ebuild  N     ] virtual/perl-Archive-Tar-1.900.0  0 kB
[ebuild  N     ] virtual/perl-Module-Load-Conditional-0.540.0  0 kB
[ebuild  N     ] perl-core/IPC-Cmd-0.780.0  0 kB
[ebuild  N     ] virtual/perl-IPC-Cmd-0.780.0  0 kB
[ebuild  N     ] perl-core/ExtUtils-CBuilder-0.280.205  0 kB
[ebuild  N     ] virtual/perl-ExtUtils-CBuilder-0.280.205  0 kB
[ebuild  N     ] perl-core/ExtUtils-ParseXS-3.180.0  0 kB
[ebuild  N     ] virtual/perl-ExtUtils-ParseXS-3.180.0  0 kB
[ebuild  N     ] perl-core/ExtUtils-MakeMaker-6.640.0  0 kB
[ebuild  N     ] virtual/perl-ExtUtils-MakeMaker-6.640.0  0 kB
[ebuild  N     ] perl-core/CPAN-Meta-2.120.921  0 kB
[ebuild  N     ] virtual/perl-CPAN-Meta-2.120.921  0 kB
[ebuild  N     ] perl-core/Module-Build-0.400.300  USE="{-test}" 0 kB
[ebuild  N     ] virtual/perl-Module-Build-0.400.300  0 kB
[ebuild  N     ] dev-perl/Error-0.170.160  USE="{-test}" 0 kB
[ebuild  N     ] dev-vcs/git-1.8.3.2-r1  USE="blksha1 curl gpg iconv nls pcre perl python threads webdav -cgi -cvs -doc -emacs -gnome-keyring -gtk -highlight (-ppcsha1) -subversion {-test} -tk -xinetd" PYTHON_SINGLE_TARGET="python2_7 -python2_6" PYTHON_TARGETS="python2_7 -python2_6" 0 kB

Total: 24 packages (24 new), Size of downloads: 0 kB

 * IMPORTANT: 8 news items need reading for repository 'gentoo'.
 * Use eselect news to read news items.
```

oh…ワタシperl要リマセン。。
あわてて `^C` を押して `flaggie` をインストールします。

```shell-session
localhost ~ # emerge -uavq flaggie

 * IMPORTANT: 8 news items need reading for repository 'gentoo'.
 * Use eselect news to read news items.

[ebuild  N    ] app-portage/flaggie-0.2.1  PYTHON_TARGETS="python2_7 python3_3 (-pypy2_0) -python2_6 -python3_2" 

Would you like to merge these packages? [Yes/No] 
>>> Verifying ebuild manifests
>>> Emerging (1 of 1) app-portage/flaggie-0.2.1
>>> Installing (1 of 1) app-portage/flaggie-0.2.1
>>> Recording app-portage/flaggie in "world" favorites file...
>>> Jobs: 1 of 1 complete                           Load avg: 1.77, 1.98, 1.21

 * Messages for package app-portage/flaggie-0.2.1:

 * Please denote that flaggie creates backups of your package.* files
 * before performing each change through appending a single '~'.
 * If you'd like to keep your own backup of them, please use another
 * naming scheme (or even better some VCS).
 * 
 * bash-completion support requires:
 * 	app-shells/gentoo-bashcomp

 * IMPORTANT: 8 news items need reading for repository 'gentoo'.
 * Use eselect news to read news items.
```

`flaggie` で `git` の依存から `perl` を外してあげると、ほら。
なんということでしょう〜♪

```shell-session
localhost ~ # flaggie -perl dev-vcs/git
localhost ~ # emerge -pv dev-vcs/git

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

Calculating dependencies... done!
[ebuild  N     ] app-crypt/gnupg-2.0.22  USE="bzip2 nls readline -adns -doc -ldap -mta (-selinux) -smartcard -static -usb" 0 kB
[ebuild  N     ] dev-vcs/git-1.8.3.2-r1  USE="blksha1 curl gpg iconv nls pcre python threads webdav -cgi -cvs -doc -emacs -gnome-keyring -gtk -highlight -perl (-ppcsha1) -subversion {-test} -tk -xinetd" PYTHON_SINGLE_TARGET="python2_7 -python2_6" PYTHON_TARGETS="python2_7 -python2_6" 0 kB

Total: 2 packages (2 new), Size of downloads: 0 kB

 * IMPORTANT: 8 news items need reading for repository 'gentoo'.
 * Use eselect news to read news items.
```

Scalaの開発環境なので、そうですね、JDKでも入れますか。

X関連のパッケージを入れると時間かかりそうなので、再度 `make.conf` を編集します。

```shell-session
localhost ~ # vi /etc/portage/make.conf
localhost ~ # grep -vE '^\w*(^#|$)' /etc/portage/make.conf
CFLAGS="-O2 -pipe"
CXXFLAGS="${CFLAGS}"
CHOST="x86_64-pc-linux-gnu"
USE="bindist mmx sse sse2"
USE="$USE bash-completion zsh-completion vim-syntax"
USE="$USE git"
USE="$USE -introspection"
USE="$USE dbus avahi"
USE="$USE -X"
MAKEOPTS="-j8"
PORTDIR="/usr/portage"
DISTDIR="${PORTDIR}/distfiles"
PKGDIR="${PORTDIR}/packages"
SYNC="rsync://rsync.jp.gentoo.org/gentoo-portage"
GENTOO_MIRRORS="ftp://ftp.iij.ad.jp/pub/linux/gentoo/ http://ftp.iij.ad.jp/pub/linux/gentoo/ rsync://ftp.iij.ad.jp/pub/linux/gentoo/"
```

そして `oracle-jdk-bin` の `emerge` を試みます。

```shell-session
localhost ~ # emerge -uavq oracle-jdk-bin
[ebuild  N    ] media-libs/giflib-4.1.6-r2  USE="-X -rle -static-libs" 
[ebuild  N    ] app-text/poppler-data-0.4.6 
[ebuild  N    ] media-libs/jpeg-6b-r9 
[ebuild  N    ] media-fonts/dejavu-2.33  USE="-X -fontforge" 
[ebuild  N    ] media-libs/freetype-2.4.11  USE="bindist bzip2 -X -auto-hinter -debug -doc -fontforge -infinality -static-libs -utils" 
[ebuild  N    ] media-libs/lcms-2.5  USE="zlib -doc -jpeg -static-libs {-test} -tiff" 
[ebuild  N    ] media-libs/libpng-1.5.17-r1  USE="-apng (-neon) -static-libs" 
[ebuild  N    ] app-text/libpaper-1.1.24-r1 
[ebuild  N    ] dev-java/java-config-wrapper-0.16 
[ebuild  N    ] media-libs/alsa-lib-1.0.27.1  USE="-alisp -debug -doc -python" PYTHON_SINGLE_TARGET="python2_7" PYTHON_TARGETS="python2_7" 
[ebuild  N    ] media-libs/tiff-4.0.3-r4  USE="cxx zlib -jbig -jpeg -lzma -static-libs" 
[ebuild  N    ] media-libs/jbig2dec-0.11-r1  USE="-png -static-libs {-test}" 
[ebuild  N    ] app-arch/rpm2targz-9.0.0.5g 
[ebuild  N    ] app-text/qpdf-4.1.0  USE="-doc -examples -static-libs {-test}" 
[ebuild  N    ] app-text/enscript-1.6.6  USE="nls -ruby" 
[ebuild  N    ] dev-lang/nasm-2.10.07  USE="-doc" 
[ebuild  N    ] virtual/ttf-fonts-1 
[ebuild  N    ] sys-apps/dbus-1.6.12  USE="-X -debug -doc (-selinux) -static-libs -systemd {-test}" 
[ebuild  N    ] media-fonts/urw-fonts-2.4.9  USE="-X" 
[ebuild  N    ] app-arch/libarchive-3.1.2-r1  USE="acl bzip2 e2fsprogs iconv lzma zlib -expat -lzo -nettle -static-libs -xattr" 
[ebuild  N    ] media-libs/libjpeg-turbo-1.3.0  USE="-java -static-libs" 
[ebuild  N    ] virtual/jpeg-0  USE="-static-libs" 
[ebuild  N    ] dev-util/cmake-2.8.11.2  USE="ncurses vim-syntax -emacs -qt4 (-qt5) {-test}" 
[ebuild  N    ] media-libs/fontconfig-2.10.92  USE="-doc -static-libs" ABI_X86="(64) (-32) (-x32)" 
[ebuild  N    ] app-admin/eselect-fontconfig-1.1 
[ebuild  N    ] app-text/poppler-0.24.3  USE="cxx jpeg lcms utils -cairo -cjk -curl -debug -doc -introspection -jpeg2k -png -qt4 -tiff" 
[ebuild  N    ] net-print/cups-1.6.4  USE="acl dbus filters pam ssl threads -X -debug -gnutls -java -kerberos -lprng-compat -python (-selinux) -static-libs -usb -xinetd -zeroconf" LINGUAS="ca es fr ja ru" PYTHON_SINGLE_TARGET="python2_7 -python2_6" PYTHON_TARGETS="python2_7 -python2_6" 
[ebuild  N    ] app-text/ghostscript-gpl-9.05-r1  USE="bindist cups dbus -X -djvu -gtk -idn -jpeg2k -static-libs" LINGUAS="-ja -ko -zh_CN -zh_TW" 
[ebuild  N    ] net-print/foomatic-filters-4.0.17-r1  USE="dbus -cups" 
[ebuild  N    ] net-print/cups-filters-1.0.36-r1  USE="-jpeg -perl -png -static-libs -tiff -zeroconf" 
[ebuild  N    ] dev-java/java-config-2.1.12-r1  PYTHON_TARGETS="python2_7 python3_3 -python2_6 -python3_2" 
[ebuild  N    ] dev-java/icedtea-bin-6.1.12.7  USE="alsa cups -X -cjk -doc -examples -nsplugin -source" 
[ebuild  N    ] virtual/jdk-1.6.0-r2 
[ebuild  N    ] virtual/jre-1.6.0-r1 
[ebuild  N F  ] dev-java/oracle-jdk-bin-1.7.0.45  USE="fontconfig -X -alsa (-aqua) -derby -doc -examples -jce -nsplugin -pax_kernel -source" 

Fetch instructions for dev-java/oracle-jdk-bin-1.7.0.45:
 * 
 * Oracle requires you to download the needed files manually after
 * accepting their license through a javascript capable web browser.
 * 
 * Download the following files:
 *   jdk-7u45-linux-x64.tar.gz
 * at 'http://www.oracle.com/technetwork/java/javase/downloads/jdk7-downloads-1880260.html'
 * and move them to '/usr/portage/distfiles'
 * 

The following USE changes are necessary to proceed:
 (see "package.use" in the portage(5) man page for more details)
# required by net-print/cups-1.6.4
# required by dev-java/icedtea-bin-6.1.12.7[cups]
# required by virtual/jdk-1.6.0-r2
# required by virtual/jre-1.6.0-r1
# required by dev-java/java-config-2.1.12-r1
# required by dev-java/oracle-jdk-bin-1.7.0.45
# required by oracle-jdk-bin (argument)
=app-text/ghostscript-gpl-9.05-r1 cups

The following license changes are necessary to proceed:
 (see "package.license" in the portage(5) man page for more details)
# required by oracle-jdk-bin (argument)
>=dev-java/oracle-jdk-bin-1.7.0.45 Oracle-BCLA-JavaSE

Use --autounmask-write to write changes to config files (honoring
CONFIG_PROTECT). Carefully examine the list of proposed changes,
paying special attention to mask or keyword changes that may expose
experimental or unstable packages.
```

まず必要だと言われた `jdk-7u45-linux-x64.tar.gz` を http://www.oracle.com/technetwork/java/javase/downloads/jdk7-downloads-1880260.html からダウンロードします。

![Screen Shot 2013-12-30 at 8.28.41 PM.png](https://qiita-image-store.s3.amazonaws.com/0/9676/3ae3d1f3-76d1-ab08-91f6-8848ecdc97b2.png)

ダウンロードしたファイルをSCPで送る前に、まだ公開鍵を登録していなかったので登録しておきます。
コピーして、

```shell-session
[mazgi@Ardbeg] $ pbcopy < .ssh/id_rsa.pub
```

`~/.ssh/authorized_keys` ファイルに貼付けます。

```shell-session
localhost ~ # mkdir -p ~/.ssh
localhost ~ # vi .ssh/authorized_keys
```

そしてSCP。

```shell-session
[mazgi@Ardbeg] $ scp ~/Downloads/jdk-7u45-linux-x64.tar.gz root@192.168.56.102:/usr/portage/distfiles/
jdk-7u45-linux-x64.tar.gz                                                                         100%  132MB  26.3MB/s   00:05    
```

続いて `--autounmask-write` 付きでemergeします。

```shell-session
localhost ~ # emerge -uavq oracle-jdk-bin --autounmask-write
[ebuild  N    ] media-libs/giflib-4.1.6-r2  USE="-X -rle -static-libs" 
[ebuild  N    ] app-text/poppler-data-0.4.6 
[ebuild  N    ] media-libs/jpeg-6b-r9 
[ebuild  N    ] media-fonts/dejavu-2.33  USE="-X -fontforge" 
[ebuild  N    ] media-libs/freetype-2.4.11  USE="bindist bzip2 -X -auto-hinter -debug -doc -fontforge -infinality -static-libs -utils" 
[ebuild  N    ] media-libs/lcms-2.5  USE="zlib -doc -jpeg -static-libs {-test} -tiff" 
[ebuild  N    ] media-libs/libpng-1.5.17-r1  USE="-apng (-neon) -static-libs" 
[ebuild  N    ] app-text/libpaper-1.1.24-r1 
[ebuild  N    ] dev-java/java-config-wrapper-0.16 
[ebuild  N    ] media-libs/alsa-lib-1.0.27.1  USE="-alisp -debug -doc -python" PYTHON_SINGLE_TARGET="python2_7" PYTHON_TARGETS="python2_7" 
[ebuild  N    ] app-text/qpdf-4.1.0  USE="-doc -examples -static-libs {-test}" 
[ebuild  N    ] media-libs/tiff-4.0.3-r4  USE="cxx zlib -jbig -jpeg -lzma -static-libs" 
[ebuild  N    ] media-libs/jbig2dec-0.11-r1  USE="-png -static-libs {-test}" 
[ebuild  N    ] app-arch/rpm2targz-9.0.0.5g 
[ebuild  N    ] app-text/enscript-1.6.6  USE="nls -ruby" 
[ebuild  N    ] dev-lang/nasm-2.10.07  USE="-doc" 
[ebuild  N    ] virtual/ttf-fonts-1 
[ebuild  N    ] sys-apps/dbus-1.6.12  USE="-X -debug -doc (-selinux) -static-libs -systemd {-test}" 
[ebuild  N    ] app-arch/libarchive-3.1.2-r1  USE="acl bzip2 e2fsprogs iconv lzma zlib -expat -lzo -nettle -static-libs -xattr" 
[ebuild  N    ] media-fonts/urw-fonts-2.4.9  USE="-X" 
[ebuild  N    ] media-libs/libjpeg-turbo-1.3.0  USE="-java -static-libs" 
[ebuild  N    ] virtual/jpeg-0  USE="-static-libs" 
[ebuild  N    ] dev-util/cmake-2.8.11.2  USE="ncurses vim-syntax -emacs -qt4 (-qt5) {-test}" 
[ebuild  N    ] media-libs/fontconfig-2.10.92  USE="-doc -static-libs" ABI_X86="(64) (-32) (-x32)" 
[ebuild  N    ] app-admin/eselect-fontconfig-1.1 
[ebuild  N    ] app-text/poppler-0.24.3  USE="cxx jpeg lcms utils -cairo -cjk -curl -debug -doc -introspection -jpeg2k -png -qt4 -tiff" 
[ebuild  N    ] net-print/cups-1.6.4  USE="acl dbus filters pam ssl threads -X -debug -gnutls -java -kerberos -lprng-compat -python (-selinux) -static-libs -usb -xinetd -zeroconf" LINGUAS="ca es fr ja ru" PYTHON_SINGLE_TARGET="python2_7 -python2_6" PYTHON_TARGETS="python2_7 -python2_6" 
[ebuild  N    ] app-text/ghostscript-gpl-9.05-r1  USE="bindist cups dbus -X -djvu -gtk -idn -jpeg2k -static-libs" LINGUAS="-ja -ko -zh_CN -zh_TW" 
[ebuild  N    ] net-print/cups-filters-1.0.36-r1  USE="-jpeg -perl -png -static-libs -tiff -zeroconf" 
[ebuild  N    ] net-print/foomatic-filters-4.0.17-r1  USE="dbus -cups" 
[ebuild  N    ] dev-java/java-config-2.1.12-r1  PYTHON_TARGETS="python2_7 python3_3 -python2_6 -python3_2" 
[ebuild  N    ] dev-java/icedtea-bin-6.1.12.7  USE="alsa cups -X -cjk -doc -examples -nsplugin -source" 
[ebuild  N    ] virtual/jdk-1.6.0-r2 
[ebuild  N    ] virtual/jre-1.6.0-r1 
[ebuild  N f  ] dev-java/oracle-jdk-bin-1.7.0.45  USE="fontconfig -X -alsa (-aqua) -derby -doc -examples -jce -nsplugin -pax_kernel -source" 

The following USE changes are necessary to proceed:
 (see "package.use" in the portage(5) man page for more details)
# required by net-print/cups-1.6.4
# required by net-print/cups-filters-1.0.36-r1
=app-text/ghostscript-gpl-9.05-r1 cups

The following license changes are necessary to proceed:
 (see "package.license" in the portage(5) man page for more details)
# required by oracle-jdk-bin (argument)
>=dev-java/oracle-jdk-bin-1.7.0.45 Oracle-BCLA-JavaSE

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

Autounmask changes successfully written.

 * IMPORTANT: 2 config files in '/etc/portage' need updating.
 * See the CONFIGURATION FILES section of the emerge
 * man page to learn how to update config files.
```

`dispatch-conf` を実行して設定変更を確定させます。

まず、 `oracle-jdk-bin` のライセンス。

```shell-session
localhost ~ # dispatch-conf 

--- /etc/portage/package.license        1970-01-01 00:00:00.000000000 +0000
+++ /etc/portage/._cfg0000_package.license      2013-12-30 12:04:07.817397718 +0000
@@ -0,0 +1,2 @@
+# required by oracle-jdk-bin (argument)
+>=dev-java/oracle-jdk-bin-1.7.0.45 Oracle-BCLA-JavaSE

>> (1 of 2) -- /etc/portage/package.license
>> q quit, h help, n next, e edit-new, z zap-new, u use-new
   m merge, t toggle-merge, l look-merge:  
```

そして `ghostscript-gpl` のUSEフラグ。

```shell-session
--- /etc/portage/package.use    2013-12-30 10:59:25.901704150 +0000
+++ /etc/portage/._cfg0000_package.use  2013-12-30 12:04:07.817397718 +0000
@@ -1 +1,4 @@
 dev-vcs/git -perl
+# required by net-print/cups-1.6.4
+# required by net-print/cups-filters-1.0.36-r1
+=app-text/ghostscript-gpl-9.05-r1 cups

>> (2 of 2) -- /etc/portage/package.use
>> q quit, h help, n next, e edit-new, z zap-new, u use-new
   m merge, t toggle-merge, l look-merge:  
```

ついでに `oracle-jdk-bin` のUSEフラグから `fontconfig` を外して、もう一度emerge。

```shell-session
localhost ~ # flaggie -fontconfig oracle-jdk-bin
localhost ~ # emerge -uavq oracle-jdk-bin
[ebuild  N    ] media-libs/giflib-4.1.6-r2  USE="-X -rle -static-libs" 
[ebuild  N    ] app-text/poppler-data-0.4.6 
[ebuild  N    ] media-fonts/dejavu-2.33  USE="-X -fontforge" 
[ebuild  N    ] media-libs/jpeg-6b-r9 
[ebuild  N    ] media-libs/freetype-2.4.11  USE="bindist bzip2 -X -auto-hinter -debug -doc -fontforge -infinality -static-libs -utils" 
[ebuild  N    ] media-libs/lcms-2.5  USE="zlib -doc -jpeg -static-libs {-test} -tiff" 
[ebuild  N    ] media-libs/libpng-1.5.17-r1  USE="-apng (-neon) -static-libs" 
[ebuild  N    ] app-text/libpaper-1.1.24-r1 
[ebuild  N    ] dev-java/java-config-wrapper-0.16 
[ebuild  N    ] media-libs/alsa-lib-1.0.27.1  USE="-alisp -debug -doc -python" PYTHON_SINGLE_TARGET="python2_7" PYTHON_TARGETS="python2_7" 
[ebuild  N    ] app-text/qpdf-4.1.0  USE="-doc -examples -static-libs {-test}" 
[ebuild  N    ] media-libs/jbig2dec-0.11-r1  USE="-png -static-libs {-test}" 
[ebuild  N    ] media-libs/tiff-4.0.3-r4  USE="cxx zlib -jbig -jpeg -lzma -static-libs" 
[ebuild  N    ] app-arch/rpm2targz-9.0.0.5g 
[ebuild  N    ] app-text/enscript-1.6.6  USE="nls -ruby" 
[ebuild  N    ] dev-lang/nasm-2.10.07  USE="-doc" 
[ebuild  N    ] virtual/ttf-fonts-1 
[ebuild  N    ] sys-apps/dbus-1.6.12  USE="-X -debug -doc (-selinux) -static-libs -systemd {-test}" 
[ebuild  N    ] app-arch/libarchive-3.1.2-r1  USE="acl bzip2 e2fsprogs iconv lzma zlib -expat -lzo -nettle -static-libs -xattr" 
[ebuild  N    ] media-fonts/urw-fonts-2.4.9  USE="-X" 
[ebuild  N    ] media-libs/libjpeg-turbo-1.3.0  USE="-java -static-libs" 
[ebuild  N    ] virtual/jpeg-0  USE="-static-libs" 
[ebuild  N    ] dev-util/cmake-2.8.11.2  USE="ncurses vim-syntax -emacs -qt4 (-qt5) {-test}" 
[ebuild  N    ] media-libs/fontconfig-2.10.92  USE="-doc -static-libs" ABI_X86="(64) (-32) (-x32)" 
[ebuild  N    ] app-admin/eselect-fontconfig-1.1 
[ebuild  N    ] app-text/poppler-0.24.3  USE="cxx jpeg lcms utils -cairo -cjk -curl -debug -doc -introspection -jpeg2k -png -qt4 -tiff" 
[ebuild  N    ] net-print/cups-1.6.4  USE="acl dbus filters pam ssl threads -X -debug -gnutls -java -kerberos -lprng-compat -python (-selinux) -static-libs -usb -xinetd -zeroconf" LINGUAS="ca es fr ja ru" PYTHON_SINGLE_TARGET="python2_7 -python2_6" PYTHON_TARGETS="python2_7 -python2_6" 
[ebuild  N    ] app-text/ghostscript-gpl-9.05-r1  USE="bindist cups dbus -X -djvu -gtk -idn -jpeg2k -static-libs" LINGUAS="-ja -ko -zh_CN -zh_TW" 
[ebuild  N    ] net-print/foomatic-filters-4.0.17-r1  USE="dbus -cups" 
[ebuild  N    ] net-print/cups-filters-1.0.36-r1  USE="-jpeg -perl -png -static-libs -tiff -zeroconf" 
[ebuild  N    ] dev-java/java-config-2.1.12-r1  PYTHON_TARGETS="python2_7 python3_3 -python2_6 -python3_2" 
[ebuild  N    ] dev-java/icedtea-bin-6.1.12.7  USE="alsa cups -X -cjk -doc -examples -nsplugin -source" 
[ebuild  N    ] virtual/jdk-1.6.0-r2 
[ebuild  N    ] virtual/jre-1.6.0-r1 
[ebuild  N f  ] dev-java/oracle-jdk-bin-1.7.0.45  USE="-X -alsa (-aqua) -derby -doc -examples -fontconfig -jce -nsplugin -pax_kernel -source" 

Would you like to merge these packages? [Yes/No] 
>>> Verifying ebuild manifests
>>> Emerging (1 of 35) media-libs/giflib-4.1.6-r2
>>> Installing (1 of 35) media-libs/giflib-4.1.6-r2
>>> Emerging (2 of 35) app-text/poppler-data-0.4.6
>>> Installing (2 of 35) app-text/poppler-data-0.4.6
>>> Emerging (3 of 35) media-fonts/dejavu-2.33
>>> Installing (3 of 35) media-fonts/dejavu-2.33
>>> Emerging (4 of 35) media-libs/jpeg-6b-r9
>>> Installing (4 of 35) media-libs/jpeg-6b-r9
>>> Emerging (5 of 35) media-libs/freetype-2.4.11
>>> Installing (5 of 35) media-libs/freetype-2.4.11
>>> Emerging (6 of 35) media-libs/lcms-2.5
>>> Installing (6 of 35) media-libs/lcms-2.5
>>> Emerging (7 of 35) media-libs/libpng-1.5.17-r1
>>> Installing (7 of 35) media-libs/libpng-1.5.17-r1
>>> Emerging (8 of 35) app-text/libpaper-1.1.24-r1
>>> Installing (8 of 35) app-text/libpaper-1.1.24-r1
>>> Emerging (9 of 35) dev-java/java-config-wrapper-0.16
>>> Installing (9 of 35) dev-java/java-config-wrapper-0.16
>>> Emerging (10 of 35) media-libs/alsa-lib-1.0.27.1
>>> Installing (10 of 35) media-libs/alsa-lib-1.0.27.1
>>> Emerging (11 of 35) app-text/qpdf-4.1.0
>>> Installing (11 of 35) app-text/qpdf-4.1.0
>>> Emerging (12 of 35) media-libs/jbig2dec-0.11-r1
>>> Installing (12 of 35) media-libs/jbig2dec-0.11-r1
>>> Emerging (13 of 35) media-libs/tiff-4.0.3-r4
>>> Installing (13 of 35) media-libs/tiff-4.0.3-r4
>>> Emerging (14 of 35) app-arch/rpm2targz-9.0.0.5g
>>> Installing (14 of 35) app-arch/rpm2targz-9.0.0.5g
>>> Emerging (15 of 35) app-text/enscript-1.6.6
>>> Installing (15 of 35) app-text/enscript-1.6.6
>>> Emerging (16 of 35) dev-lang/nasm-2.10.07
>>> Installing (16 of 35) dev-lang/nasm-2.10.07
>>> Emerging (17 of 35) virtual/ttf-fonts-1
>>> Installing (17 of 35) virtual/ttf-fonts-1
>>> Emerging (18 of 35) sys-apps/dbus-1.6.12
>>> Installing (18 of 35) sys-apps/dbus-1.6.12
>>> Emerging (19 of 35) app-arch/libarchive-3.1.2-r1
>>> Installing (19 of 35) app-arch/libarchive-3.1.2-r1
>>> Emerging (20 of 35) media-fonts/urw-fonts-2.4.9
>>> Installing (20 of 35) media-fonts/urw-fonts-2.4.9
>>> Emerging (21 of 35) media-libs/libjpeg-turbo-1.3.0
>>> Installing (21 of 35) media-libs/libjpeg-turbo-1.3.0
>>> Emerging (22 of 35) virtual/jpeg-0
>>> Installing (22 of 35) virtual/jpeg-0
>>> Emerging (23 of 35) dev-util/cmake-2.8.11.2
>>> Installing (23 of 35) dev-util/cmake-2.8.11.2
>>> Emerging (24 of 35) media-libs/fontconfig-2.10.92
>>> Installing (24 of 35) media-libs/fontconfig-2.10.92
>>> Emerging (25 of 35) app-admin/eselect-fontconfig-1.1
>>> Installing (25 of 35) app-admin/eselect-fontconfig-1.1
>>> Emerging (26 of 35) app-text/poppler-0.24.3
>>> Installing (26 of 35) app-text/poppler-0.24.3
>>> Emerging (27 of 35) net-print/cups-1.6.4
>>> Installing (27 of 35) net-print/cups-1.6.4
>>> Emerging (28 of 35) app-text/ghostscript-gpl-9.05-r1
>>> Installing (28 of 35) app-text/ghostscript-gpl-9.05-r1
>>> Emerging (29 of 35) net-print/foomatic-filters-4.0.17-r1
>>> Installing (29 of 35) net-print/foomatic-filters-4.0.17-r1
>>> Emerging (30 of 35) net-print/cups-filters-1.0.36-r1
>>> Installing (30 of 35) net-print/cups-filters-1.0.36-r1
>>> Emerging (31 of 35) dev-java/java-config-2.1.12-r1
>>> Installing (31 of 35) dev-java/java-config-2.1.12-r1
>>> Emerging (32 of 35) dev-java/icedtea-bin-6.1.12.7
>>> Installing (32 of 35) dev-java/icedtea-bin-6.1.12.7
>>> Emerging (33 of 35) virtual/jdk-1.6.0-r2
>>> Installing (33 of 35) virtual/jdk-1.6.0-r2
>>> Emerging (34 of 35) virtual/jre-1.6.0-r1
>>> Installing (34 of 35) virtual/jre-1.6.0-r1
>>> Emerging (35 of 35) dev-java/oracle-jdk-bin-1.7.0.45
>>> Installing (35 of 35) dev-java/oracle-jdk-bin-1.7.0.45
>>> Recording dev-java/oracle-jdk-bin in "world" favorites file...
>>> Jobs: 35 of 35 complete                         Load avg: 4.51, 3.95, 2.83

 * Messages for package media-fonts/dejavu-2.33:

 * The following fontconfig configuration files have been installed:
 * 
 *   20-unhint-small-dejavu-sans-mono.conf
 *   20-unhint-small-dejavu-sans.conf
 *   20-unhint-small-dejavu-serif.conf
 *   57-dejavu-sans-mono.conf
 *   57-dejavu-sans.conf
 *   57-dejavu-serif.conf
 * 
 * Use `eselect fontconfig` to enable/disable them.

 * Messages for package app-text/libpaper-1.1.24-r1:

 * run e.g. "paperconfig -p letter" as root to use letter-pagesizes

 * Messages for package app-text/enscript-1.6.6:

 * Now, customize /etc/enscript.cfg.

 * Messages for package sys-apps/dbus-1.6.12:

 * To start the D-Bus system-wide messagebus by default
 * you should add it to the default runlevel :
 * `rc-update add dbus default`
 * 
 * Some applications require a session bus in addition to the system
 * bus. Please see `man dbus-launch` for more information.
 * 

 * Messages for package media-fonts/urw-fonts-2.4.9:

 * If you upgraded from urw-fonts-2.1-r2 some fonts will look a bit
 * different. Take a look at bug #208990 if interested.

 * Messages for package media-libs/fontconfig-2.10.92:

 * Please make fontconfig configuration changes using `eselect
 * fontconfig`. Any changes made to /etc/fonts/fonts.conf will be
 * overwritten. If you need to reset your configuration to upstream
 * defaults, delete the directory /etc/fonts/conf.d/ and re-emerge
 * fontconfig.
 * 
 * (Note: Above message is only printed the first time package is
 * installed. Please look at /usr/share/doc/fontconfig-2.10.92/README.gentoo*
 * for future reference)

 * Messages for package net-print/cups-1.6.4:

 * If you plan to use USB printers you should enable the USB_PRINTER
 * support in your kernel.
 * Please enable it:
 *     CONFIG_USB_PRINTER=y
 * in /usr/src/linux/.config or
 *     Device Drivers --->
 *         USB support  --->
 *             [*] USB Printer support
 * Alternatively, enable the usb useflag for cups and use the libusb code.
 * For information about installing a printer and general cups setup
 * take a look at: http://www.gentoo.org/doc/en/printing-howto.xml

 * Messages for package net-print/cups-filters-1.0.36-r1:

 * This version of cups-filters includes cups-browsed, a daemon that autodiscovers
 * remote queues via avahi or cups-1.5 browsing protocol and adds them to your cups
 * configuration. You may want to add it to your default runlevel.

 * IMPORTANT: 1 news items need reading for repository 'gentoo'.
 * Use eselect news to read news items.
```

JDKが入ったので早速バージョンを確認してみます。

```shell-session
localhost ~ # java -version
java version "1.6.0_27"
OpenJDK Runtime Environment (IcedTea6 1.12.7) (Gentoo build 1.6.0_27-b27)
OpenJDK 64-Bit Server VM (build 20.0-b12, mixed mode)
```

・・・OpenJDKですね。

`java-config` でJDKを切り替えます。

```shell-session
localhost ~ # java-config -L
The following VMs are available for generation-2:
*)	IcedTea JDK 6.1.12.7 [icedtea-bin-6]
2)	Oracle JDK 1.7.0.45 [oracle-jdk-bin-1.7]
localhost ~ # java-config -S 2
Now using oracle-jdk-bin-1.7 as your generation-2 system JVM
localhost ~ # java-config -L
The following VMs are available for generation-2:
1)	IcedTea JDK 6.1.12.7 [icedtea-bin-6]
*)	Oracle JDK 1.7.0.45 [oracle-jdk-bin-1.7]
```

これでシステムのJDKがOracke JDKになりました。

```shell-session
localhost ~ # java -version
java version "1.7.0_45"
Java(TM) SE Runtime Environment (build 1.7.0_45-b18)
Java HotSpot(TM) 64-Bit Server VM (build 24.45-b08, mixed mode)
```

あとrootでやっとくことは…そうですね、MySQLでも入れますか。

```shell-session
localhost ~ # emerge -uavq mysql

 * IMPORTANT: 1 news items need reading for repository 'gentoo'.
 * Use eselect news to read news items.

[ebuild  N    ] dev-perl/Net-Daemon-0.480.0 
[ebuild  N    ] perl-core/Storable-2.390.0 
[ebuild  N    ] perl-core/Sys-Syslog-0.320.0 
[ebuild  N    ] dev-db/mysql-init-scripts-2.0_pre1-r6 
[ebuild  N    ] virtual/perl-Storable-2.390.0 
[ebuild  N    ] virtual/perl-Sys-Syslog-0.320.0 
[ebuild  N    ] dev-perl/PlRPC-0.202.0 
[ebuild  N    ] dev-perl/DBI-1.623.0  USE="{-test}" 
[ebuild  N    ] dev-db/mysql-5.1.70  USE="community perl ssl -big-tables -cluster -debug -embedded -extraengine -latin1 -max-idx-128 -minimal -pbxt -profiling (-selinux) -static {-test} -xtradb" 
[ebuild  N    ] virtual/mysql-5.1  USE="-embedded -minimal -static" 
[ebuild  N    ] dev-perl/DBD-mysql-4.20.0  USE="-embedded" 

Would you like to merge these packages? [Yes/No] n

Quitting.
```

`5.1` ではちょっと古いですね。Semi-Sync使えないし。ま、開発環境なんでたぶんSemi-Sync使いませんけど。
maskされてはいますが、 `5.5` のパッケージがあるのでそちらをインストールすることにします。

```shell-session
localhost ~ # ls -l /usr/portage/dev-db/mysql/
total 176
-rw-r--r-- 1 portage portage  16146 Aug 29 15:01 ChangeLog
-rw-r--r-- 1 portage portage 108404 Jan  1  2012 ChangeLog-2010
-rw-r--r-- 1 portage portage  10750 Aug 29 15:01 Manifest
drwxr-xr-x 2 portage portage     48 Jan 20  2013 files
-rw-r--r-- 1 portage portage   1512 Nov  2  2012 metadata.xml
-rw-r--r-- 1 portage portage   1105 Dec 14  2008 mysql-4.0.27-r1.ebuild
-rw-r--r-- 1 portage portage   1343 Jul  8  2011 mysql-4.1.22-r1.ebuild
-rw-r--r-- 1 portage portage   7175 Jan 20  2013 mysql-5.0.96.ebuild
-rw-r--r-- 1 portage portage   8874 Aug  6 13:01 mysql-5.1.70.ebuild
-rw-r--r-- 1 portage portage   4239 Jun  6  2013 mysql-5.5.32.ebuild
localhost ~ # emerge -uavq =dev-db/mysql-5.5.32

 * IMPORTANT: 1 news items need reading for repository 'gentoo'.
 * Use eselect news to read news items.

[ebuild  N    ] dev-libs/libaio-0.3.109-r4  USE="(multilib) -static-libs {-test}" 
[ebuild  N    ] dev-perl/Net-Daemon-0.480.0 
[ebuild  N    ] perl-core/Storable-2.390.0 
[ebuild  N    ] perl-core/Sys-Syslog-0.320.0 
[ebuild  N    ] dev-db/mysql-init-scripts-2.0_pre1-r6 
[ebuild  N    ] virtual/perl-Storable-2.390.0 
[ebuild  N    ] virtual/perl-Sys-Syslog-0.320.0 
[ebuild  N    ] dev-perl/PlRPC-0.202.0 
[ebuild  N    ] dev-perl/DBI-1.623.0  USE="{-test}" 
[ebuild  N    ] dev-db/mysql-5.5.32  USE="community perl ssl -cluster -debug -embedded -extraengine -jemalloc -latin1 -max-idx-128 -minimal -profiling (-selinux) -static -systemtap -tcmalloc {-test}" 
[ebuild  N    ] virtual/mysql-5.5  USE="-embedded -minimal -static" 
[ebuild  N    ] dev-perl/DBD-mysql-4.20.0  USE="-embedded" 

The following keyword changes are necessary to proceed:
 (see "package.accept_keywords" in the portage(5) man page for more details)
# required by =dev-db/mysql-5.5.32 (argument)
=dev-db/mysql-5.5.32 ~amd64
# required by dev-perl/DBD-mysql-4.20.0
# required by dev-db/mysql-5.5.32[perl]
# required by =dev-db/mysql-5.5.32 (argument)
=virtual/mysql-5.5 ~amd64

Use --autounmask-write to write changes to config files (honoring
CONFIG_PROTECT). Carefully examine the list of proposed changes,
paying special attention to mask or keyword changes that may expose
experimental or unstable packages.
```

ついでに `extraengine` なる素敵そうなUSEフラグがあるので有効にしておきます。

```shell-session
localhost ~ # flaggie +extraengine mysql
At argv[1]='+extraengine': extraengine seems to be an incorrect global flag
localhost ~ # emerge -uavq =dev-db/mysql-5.5.32 --autounmask-write

 * IMPORTANT: 1 news items need reading for repository 'gentoo'.
 * Use eselect news to read news items.

[ebuild  N    ] dev-libs/libaio-0.3.109-r4  USE="(multilib) -static-libs {-test}" 
[ebuild  N    ] dev-perl/Net-Daemon-0.480.0 
[ebuild  N    ] perl-core/Storable-2.390.0 
[ebuild  N    ] perl-core/Sys-Syslog-0.320.0 
[ebuild  N    ] dev-db/mysql-init-scripts-2.0_pre1-r6 
[ebuild  N    ] virtual/perl-Storable-2.390.0 
[ebuild  N    ] virtual/perl-Sys-Syslog-0.320.0 
[ebuild  N    ] dev-perl/PlRPC-0.202.0 
[ebuild  N    ] dev-perl/DBI-1.623.0  USE="{-test}" 
[ebuild  N    ] dev-db/mysql-5.5.32  USE="community extraengine perl ssl -cluster -debug -embedded -jemalloc -latin1 -max-idx-128 -minimal -profiling (-selinux) -static -systemtap -tcmalloc {-test}" 
[ebuild  N    ] virtual/mysql-5.5  USE="-embedded -minimal -static" 
[ebuild  N    ] dev-perl/DBD-mysql-4.20.0  USE="-embedded" 

The following keyword changes are necessary to proceed:
 (see "package.accept_keywords" in the portage(5) man page for more details)
# required by dev-perl/DBD-mysql-4.20.0
# required by dev-db/mysql-5.5.32[perl]
# required by =dev-db/mysql-5.5.32 (argument)
=virtual/mysql-5.5 ~amd64
# required by =dev-db/mysql-5.5.32 (argument)
=dev-db/mysql-5.5.32 ~amd64

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

Autounmask changes successfully written.

 * IMPORTANT: config file '/etc/portage/package.accept_keywords' needs updating.
 * See the CONFIGURATION FILES section of the emerge
 * man page to learn how to update config files.
localhost ~ # dispatch-conf 
--- /etc/portage/package.accept_keywords        1970-01-01 00:00:00.000000000 +0000
+++ /etc/portage/._cfg0000_package.accept_keywords      2013-12-30 13:06:23.792877238 +0000
@@ -0,0 +1,6 @@
+# required by dev-perl/DBD-mysql-4.20.0
+# required by dev-db/mysql-5.5.32[perl]
+# required by =dev-db/mysql-5.5.32 (argument)
+=virtual/mysql-5.5 ~amd64
+# required by =dev-db/mysql-5.5.32 (argument)
+=dev-db/mysql-5.5.32 ~amd64

>> (1 of 1) -- /etc/portage/package.accept_keywords
>> q quit, h help, n next, e edit-new, z zap-new, u use-new
   m merge, t toggle-merge, l look-merge:  
```

さて改めて、Let's emerge!

```shell-session
localhost ~ # emerge -uavq =dev-db/mysql-5.5.32

 * IMPORTANT: 1 news items need reading for repository 'gentoo'.
 * Use eselect news to read news items.

[ebuild  N    ] dev-libs/libaio-0.3.109-r4  USE="(multilib) -static-libs {-test}" 
[ebuild  N    ] dev-perl/Net-Daemon-0.480.0 
[ebuild  N    ] perl-core/Storable-2.390.0 
[ebuild  N    ] perl-core/Sys-Syslog-0.320.0 
[ebuild  N    ] dev-db/mysql-init-scripts-2.0_pre1-r6 
[ebuild  N    ] virtual/perl-Storable-2.390.0 
[ebuild  N    ] virtual/perl-Sys-Syslog-0.320.0 
[ebuild  N    ] dev-perl/PlRPC-0.202.0 
[ebuild  N    ] dev-perl/DBI-1.623.0  USE="{-test}" 
[ebuild  N    ] dev-db/mysql-5.5.32  USE="community extraengine perl ssl -cluster -debug -embedded -jemalloc -latin1 -max-idx-128 -minimal -profiling (-selinux) -static -systemtap -tcmalloc {-test}" 
[ebuild  N    ] virtual/mysql-5.5  USE="-embedded -minimal -static" 
[ebuild  N    ] dev-perl/DBD-mysql-4.20.0  USE="-embedded" 

Would you like to merge these packages? [Yes/No] 
>>> Verifying ebuild manifests
>>> Emerging (1 of 12) dev-libs/libaio-0.3.109-r4
>>> Installing (1 of 12) dev-libs/libaio-0.3.109-r4
>>> Emerging (2 of 12) dev-perl/Net-Daemon-0.480.0
>>> Installing (2 of 12) dev-perl/Net-Daemon-0.480.0
>>> Emerging (3 of 12) perl-core/Storable-2.390.0
>>> Installing (3 of 12) perl-core/Storable-2.390.0
>>> Emerging (4 of 12) perl-core/Sys-Syslog-0.320.0
>>> Installing (4 of 12) perl-core/Sys-Syslog-0.320.0
>>> Emerging (5 of 12) dev-db/mysql-init-scripts-2.0_pre1-r6
>>> Installing (5 of 12) dev-db/mysql-init-scripts-2.0_pre1-r6
>>> Emerging (6 of 12) virtual/perl-Storable-2.390.0
>>> Installing (6 of 12) virtual/perl-Storable-2.390.0
>>> Emerging (7 of 12) virtual/perl-Sys-Syslog-0.320.0
>>> Installing (7 of 12) virtual/perl-Sys-Syslog-0.320.0
>>> Emerging (8 of 12) dev-perl/PlRPC-0.202.0
>>> Installing (8 of 12) dev-perl/PlRPC-0.202.0
>>> Emerging (9 of 12) dev-perl/DBI-1.623.0
>>> Installing (9 of 12) dev-perl/DBI-1.623.0
>>> Emerging (10 of 12) dev-db/mysql-5.5.32
>>> Jobs: 9 of 12 complete, 1 running               Load avg: 0.95, 0.33, 0.23^C

 * Messages for package dev-db/mysql-5.5.32:

 * MySQL MY_DATADIR is /var/lib/mysql
```

あ、今回perl要らないです！

```shell-session
localhost ~ # flaggie -perl mysql
localhost ~ # dispatch-conf 
localhost ~ # emerge -uavq =dev-db/mysql-5.5.32
```

ごはん食べてきます。

```shell-session
 * IMPORTANT: 1 news items need reading for repository 'gentoo'.
 * Use eselect news to read news items.

[ebuild  N    ] dev-db/mysql-5.5.32  USE="community extraengine ssl -cluster -debug -embedded -jemalloc -latin1 -max-idx-128 -minimal -perl -profiling (-selinux) -static -systemtap -tcmalloc {-test}" 
[ebuild  N    ] virtual/mysql-5.5  USE="-embedded -minimal -static" 

Would you like to merge these packages? [Yes/No] 
>>> Verifying ebuild manifests
>>> Emerging (1 of 2) dev-db/mysql-5.5.32
>>> Installing (1 of 2) dev-db/mysql-5.5.32
>>> Recording dev-db/mysql in "world" favorites file...
>>> Emerging (2 of 2) virtual/mysql-5.5
>>> Installing (2 of 2) virtual/mysql-5.5
>>> Jobs: 2 of 2 complete                           Load avg: 3.85, 3.80, 1.84

 * Messages for package dev-db/mysql-5.5.32:

 * MySQL MY_DATADIR is /var/lib/mysql
 * You might want to run:
 * "emerge --config =dev-db/mysql-5.5.32"
 * if this is a new install.
 * If you are upgrading major versions, you should run the
 * mysql_upgrade tool.

 * IMPORTANT: 1 news items need reading for repository 'gentoo'.
 * Use eselect news to read news items.
```

ごはん食べてる間にmysqlが入ったので初期設定をします。

```shell-session
localhost ~ # emerge --config mysql


Configuring pkg...

 * ERROR: dev-db/mysql-5.5.32::gentoo failed (config phase):
 *   Your machine must NOT be named localhost
 * 
 * Call stack:
 *     ebuild.sh, line   93:  Called pkg_config
 *   environment, line 3503:  Called mysql-v2_pkg_config
 *   environment, line 3116:  Called die
 * The specific snippet of code:
 *       [[ "${HOSTNAME}" == "localhost" ]] && die "Your machine must NOT be named localhost";
 * 
 * If you need support, post the output of `emerge --info '=dev-db/mysql-5.5.32::gentoo'`,
 * the complete build log and the output of `emerge -pqv '=dev-db/mysql-5.5.32::gentoo'`.
 * The complete build log is located at '/var/tmp/portage/dev-db/mysql-5.5.32/temp/build.log'.
 * The ebuild environment file is located at '/var/tmp/portage/dev-db/mysql-5.5.32/temp/environment'.
 * Working directory: '/usr/lib64/portage/pym'
 * S: '/var/tmp/portage/dev-db/mysql-5.5.32/work/mysql-5.5.32'
```

ホスト名が `localhost` のままではダメだそうです…。

```shell-session
localhost ~ # vi /etc/conf.d/hostname 
localhost ~ # grep -vE '^\w*(^#|$)' /etc/conf.d/hostname 
hostname="PlayGentoo2"
localhost ~ # /etc/init.d/hostname restart
 * WARNING: you are stopping a boot service
 * Caching service dependencies ...                                                                                                                                                                                                                                                                                                                                                                                                [ ok ]
 * Setting hostname to PlayGentoo2 ...                                                                                                                                                                                                                                                                                                                                                                                             [ ok ]
localhost ~ # hostname 
PlayGentoo2
```

ホストに名前つけてもう一度 `emerge --config` してみます。

```shell-session
localhost ~ # emerge --config mysql


Configuring pkg...

 * Please provide a password for the mysql 'root' user now, in the
 * MYSQL_ROOT_PASSWORD env var or through the /root/.my.cnf file.
 * Avoid ["'\_%] characters in the password
    >
 * Retype the password
    >
 * Command: '/usr/share/mysql/scripts/mysql_install_db' '--basedir=/usr' --log-warnings=0 --loose-skip-grant-tables --loose-skip-host-cache --loose-skip-name-resolve --loose-skip-networking --loose-skip-slave-start --loose-skip-federated --loose-skip-innodb --loose-skip-ssl --loose-skip-log-bin --loose-skip-relay-log --loose-skip-slow-query-log --loose-skip-external-locking --loose-skip-log-slave-updates --user=mysql
 * Creating the mysql database and setting proper
 * permissions on it ...
 * Starting mysqld ...
 * Command //usr/sbin/mysqld 		--log-warnings=0 --loose-skip-grant-tables --loose-skip-host-cache --loose-skip-name-resolve --loose-skip-networking --loose-skip-slave-start --loose-skip-federated --loose-skip-innodb --loose-skip-ssl --loose-skip-log-bin --loose-skip-relay-log --loose-skip-slow-query-log --loose-skip-external-locking --loose-skip-log-slave-updates --user=mysql 		--user=mysql 		--log-warnings=0 		--basedir=//usr 		--datadir=///var/lib/mysql 		--max_allowed_packet=8M 		--net_buffer_length=16K 		--default-storage-engine=MyISAM 		--socket=//var/run/mysqld/mysqld5241.sock 		--pid-file=//var/run/mysqld/mysqld9175.pid                                                                                         [ ok ]
 * Setting root password ...                                                                                                                                                                                                                                                                                                                                                                                                      [ ok ]
 * Loading "zoneinfo", this step may require a few seconds ... ...                                                                                                                                                                                                                                                                                                                                                                [ ok ]
 * Stopping the server ...
 * Done
```

今度は初期設定できました！
続けて `mysql_secure_installation` を実行します。

```shell-session
localhost ~ # /etc/init.d/mysql start
 * Starting mysql ...                                                                                                                                                                                                                                                                                                                                                                                                              [ ok ]
localhost ~ # mysql_secure_installation 




NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MySQL
      SERVERS IN PRODUCTION USE!  PLEASE READ EACH STEP CAREFULLY!


In order to log into MySQL to secure it, we'll need the current
password for the root user.  If you've just installed MySQL, and
you haven't set the root password yet, the password will be blank,
so you should just press enter here.

Enter current password for root (enter for none): 
OK, successfully used password, moving on...

Setting the root password ensures that nobody can log into the MySQL
root user without the proper authorisation.

You already have a root password set, so you can safely answer 'n'.

Change the root password? [Y/n] n
 ... skipping.

By default, a MySQL installation has an anonymous user, allowing anyone
to log into MySQL without having to have a user account created for
them.  This is intended only for testing, and to make the installation
go a bit smoother.  You should remove them before moving into a
production environment.

Remove anonymous users? [Y/n] 
 ... Success!

Normally, root should only be allowed to connect from 'localhost'.  This
ensures that someone cannot guess at the root password from the network.

Disallow root login remotely? [Y/n] 
 ... Success!

By default, MySQL comes with a database named 'test' that anyone can
access.  This is also intended only for testing, and should be removed
before moving into a production environment.

Remove test database and access to it? [Y/n] 
 - Dropping test database...
 ... Success!
 - Removing privileges on test database...
 ... Success!

Reloading the privilege tables will ensure that all changes made so far
will take effect immediately.

Reload privilege tables now? [Y/n] 
 ... Success!

Cleaning up...



All done!  If you've completed all of the above steps, your MySQL
installation should now be secure.

Thanks for using MySQL!
```

mysqlへの接続を確認してみます。

```shell-session
localhost ~ # mysql -uroot -p
Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 7
Server version: 5.5.32-log Source distribution

Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| performance_schema |
+--------------------+
3 rows in set (0.00 sec)

mysql> use mysql
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Database changed
mysql> select user,host from user;
+------+-----------+
| user | host      |
+------+-----------+
| root | 127.0.0.1 |
| root | ::1       |
| root | localhost |
+------+-----------+
3 rows in set (0.00 sec)

mysql> quit
Bye
```

[続きます](http://qiita.com/mazgi/items/b9ccfc28b72b5e6bdeec)