January 5, 2011

An example of semi-large update

It seems that updating outdated systems is a quite common headache, and that often people advise to just reinstall. Recently I was updating a system that was first installed in 2005 (amd64 stable), and last updated in April 2010 (about 8 months before this blog post). Fortunately I didn't hit major problems (like "masked by EAPI" errors when updating portage), but I hit a few minor ones, and I'd like to share the solutions and the overview of such an update with the community.

Note: I update most of my systems much more frequently (monthly or weekly depending on the system). This post is meant to show that while it's not trivial to update rarely, it's not as complicated as one might think.

Note 2: I'm not sure about distributions that have 6-months release cycle, but it's quite possible they have their own problems on updates (I guess most common problems are that X, sound, or wireless network card stop working).

I started with updating the portage tree using eix-sync. There were some news items so I read them using eselect news read new. There was also an automatic update to my package.keywords file (some packages were moved, i.e. changed names), so I ran dispatch-conf.

At that point I'd usually run emerge -uDNa world, but for a large update I decided to proceed in smaller steps for more safety. I updated portage (emerge -1av portage), and it complained about some licenses:

!!! The following installed packages are masked:
- net-im/skype- (masked by: skype-eula license(s))
A copy of the 'skype-eula' license is located at '/usr/portage/licenses/skype-eula'.

- app-emulation/emul-linux-x86-java- (masked by: dlj-1.1 license(s))
A copy of the 'dlj-1.1' license is located at '/usr/portage/licenses/dlj-1.1'.

For more information, see the MASKED PACKAGES section in the emerge man page or refer to the Gentoo Handbook.

And indeed after reading "man emerge" you can get all needed information, but the fix is actually very simple. All I needed to do was adding a line like the one below to /etc/make.conf:

ACCEPT_LICENSE="skype-eula dlj-1.1"

I also hit an issue with flash:

- www-plugins/adobe-flash- (masked by: package.mask, AdobeFlash-10 license(s))
# Tobias Heinlein (05 Jul 2010)
# Severe security issues (bug #322855)

And I just unmerged it temporarily (emerge -C adobe-flash). Generally when you're updating a system and something blocks you, unmerging non-critical packages is often the right action.

Then I updated the kernel to avoid a weird issue with touch: No such file or directory:

# emerge -1av gentoo-sources
[ebuild  NS   ] sys-kernel/gentoo-sources-2.6.36-r5 [2.6.31-r10] USE="-build -deblob -symlink" 68,751 kB
# eselect kernel list
# eselect kernel set 5
# cd /usr/src/linux
# zcat /proc/config.gz > .config
# make oldconfig
# make && make modules_install install
# module-rebuild -X rebuild
# reboot

If you wonder what module-rebuild is, it's a very useful utility to rebuild kernel modules after updating kernel (sys-kernel/module-rebuild). The system rebooted just fine, and I proceeded with updating the toolchain.

# emerge -1av coreutils gcc binutils glibc

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

Calculating dependencies... done!
[ebuild     U ] sys-devel/binutils-2.20.1-r1 [2.18-r3] USE="nls -multislot -multitarget -test -vanilla" 17,106 kB
[ebuild     U ] sys-apps/coreutils-8.5 [7.5-r1] USE="acl caps gmp nls unicode%* xattr (-selinux) -static -vanilla" 10,494 kB
[ebuild     U ] sys-libs/glibc-2.11.2-r3 [2.10.1-r1] USE="(multilib) nls -debug -gd -glibc-omitfp (-hardened) -profile (-selinux) -vanilla" 16,008 kB
[ebuild  NS   ] sys-devel/gcc-4.4.4-r2 [4.3.4] USE="fortran gtk mudflap (multilib) nls nptl openmp (-altivec) -bootstrap -build -doc (-fixed-point) -gcj -graphite (-hardened) (-libffi) -multislot (-n32) (-n64) -nocxx -nopie -nossp -objc -objc++ -objc-gc -test -vanilla" 61,588 kB

Total: 4 packages (3 upgrades, 1 in new slot), Size of downloads: 105,195 kB

After that, I ran dispatch-conf, which merged all updates automatically, and then switched to the updated gcc:

# gcc-config -l
 [1] x86_64-pc-linux-gnu-4.3.4 *
 [2] x86_64-pc-linux-gnu-4.4.4
# gcc-config 2
# source /etc/profile

The GCC upgrade guide says to re-emerge everything, so I did just that:

# emerge -e system && emerge -e world

I encountered a few blockers:

  (sys-libs/talloc-2.0.1-r1, ebuild scheduled for merge) pulled in by
    sys-libs/talloc required by (net-fs/samba-3.4.9, ebuild scheduled for merge)

  (sys-libs/tdb-1.2.1, ebuild scheduled for merge) pulled in by
    sys-libs/tdb required by (net-fs/samba-3.4.9, ebuild scheduled for merge)

  (net-fs/samba-3.0.37, installed) pulled in by
     >=net-fs/samba-3.0.8 required by (net-print/cups-1.3.11-r4, ebuild scheduled for merge)
     >=net-fs/samba-3.0.25 required by (app-emulation/wine-1.1.38, installed)
    net-fs/samba required by (app-misc/mc-, installed)
    (and 4 more)

  (media-libs/mesa-7.8.2, ebuild scheduled for merge) pulled in by
    media-libs/mesa required by (virtual/glu-7.0, ebuild scheduled for merge)
    media-libs/mesa required by (virtual/opengl-7.0, ebuild scheduled for merge)
    media-libs/mesa required by (app-emulation/emul-linux-x86-xlibs-20100220, installed)
    (and 1 more)

  (x11-base/xorg-server-1.6.5-r1, installed) pulled in by
    x11-base/xorg-server required by (x11-drivers/xf86-video-nv-2.1.16, installed)
     >=x11-base/xorg-server-1.6.3 required by (x11-drivers/xf86-input-keyboard-1.4.0, installed)
     >=x11-base/xorg-server- required by (x11-drivers/xf86-input-mouse-1.5.0, installed)
    (and 2 more)

I just unmerged the blockers for now. Note that it means no working X for a while.

# emerge -C samba xorg-server
# emerge -e system && emerge -e world

After that I hit the libpng-1.2 to libpng-1.4 update problem:

/bin/grep: /usr/lib64/libpng12.la: No such file or directory
/usr/bin/sed: can't read /usr/lib64/libpng12.la: No such file or directory
libtool: link: `/usr/lib64/libpng12.la' is not a valid libtool archive
make: *** [pangocairo.la] Error 1
make: *** Waiting for unfinished jobs....
mv -f .deps/atk_la-atk.Tpo .deps/atk_la-atk.Plo
emake failed
 * ERROR: dev-python/pygtk-2.17.0 failed:
 *   Building failed with CPython 2.6 in python_default_function() function

/usr/lib/gcc/x86_64-pc-linux-gnu/4.4.4/../../../../x86_64-pc-linux-gnu/bin/ld: cannot find -lpng12    
collect2: ld returned 1 exit status                                                                   
make: *** [pangocairo.la] Error 1                                                                     
make: *** Waiting for unfinished jobs....                                                             
mv -f .deps/atk_la-atk.Tpo .deps/atk_la-atk.Plo                                                       
emake failed                                                                                          
 * ERROR: dev-python/pygtk-2.17.0 failed:                                                             
 *   Building failed with CPython 2.6 in python_default_function() function

I probably did a bit more than strictly required, but here is the sequence of commands I executed:

# fix_libtool_files 4.3.4
# lafilefixer --justfixit
# libpng-1.4.x-update.sh
# lafilefixer --justfixit
# emerge --resume && emerge -e world

Then I got a weird issue with ghostscript-gpl:

* The path /usr/share/fonts/default/ghostscript exists and is not a         
 * symlink. It must be removed for app-text/ghostscript-gpl to be installed. 
 * Use the following command to check to which packages it belongs:          
 *   emerge gentoolkit ; equery belongs /usr/share/fonts/default/ghostscript
 * And remove packages listed. If it doesn't belong to any package, remove
 * it manually and then re-emerge app-text/ghostscript-gpl.
 * See bug #311923 for more details.
 * ERROR: app-text/ghostscript-gpl-8.71-r6 failed:
 *   Path /usr/share/fonts/default/ghostscript is not a symlink

# equery belongs /usr/share/fonts/default/ghostscript/
[ Searching for file(s) /usr/share/fonts/default/ghostscript in *... ]
# rm -rf /usr/share/fonts/default/ghostscript/

It wasn't obvious what happened, but removing the leftover file fixed it. Some time later emerge -e world encountered another problem. After thinking about it now, I could probably avoid it at the beginning by running emerge -pv world early.

# emerge --resume && emerge -e world
emerge: there are no ebuilds to satisfy "sys-apps/slocate".
(dependency required by "@selected")
(dependency required by "@world" [argument])

emerge: there are no ebuilds built with USE flags to satisfy ">=dev-db/sqlite-3.6.22[extensions]".
!!! One of the following packages is required to complete your request:
- dev-db/sqlite-3.7.2 (Change USE: +extensions)
(dependency required by "dev-perl/DBD-SQLite-1.31" [ebuild])
(dependency required by "net-proxy/squid-3.1.8" [ebuild])
(dependency required by "@selected")
(dependency required by "@world" [argument])

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

I read the news (eselect news read new), and temporarily unmerged slocate (emerge -C slocate). Finally, I enabled the extensions flag for sqlite (echo "dev-db/sqlite extensions" >> /etc/portage/package.use).

# emerge -C slocate
# emerge -eav world

It finished successfully, so I decided to install Flash again. Unfortunately, the current stable version on amd64 doesn't support 64-bit, so I just unmasked the more recent version:

# echo "=www-plugins/adobe-flash-" >> /etc/portage/package.keywords
# emerge -av adobe-flash mlocate

I also had to update ACCEPT_LICENSE in /etc/make.conf. Then I hit no optical drive found problem in k3b. Remember to change hd* to sd* in /boot/grub/grub.conf and /etc/fstab before rebooting!

And that was it! Not trivial, but not too hard either.