sakana

very short memo

package management on ubuntu

Why did you choose ubuntu as your platform? Every one must have reason(s) for that.

For me, one of main reasons is easy access of software packages. (Remember the days of Solaris 8 when one had to install all the necessary packages manually by pkgadd...)

How are software packages repositories maintained on ubuntu? Take google-chrome as example and see how it goes.

apt & dpkg

Ubuntu makes use of apt (Advanced Packaging Tool) for package maintenance. apt resolves depency among packages and gives user a convenient way of package utilization.

And apt is dependent upon dpkg. dpkg is a tool to manipulate deb format packages.

Setup & Installation

In case that you add some repository, you need to trust this repository by adding its public key. Retrieve public key and add it into key repository.

$ wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | sudo apt-key add -

The relevant public key will be stored into /etc/apt/trusted.gpg file.

$ sudo apt-key list
/etc/apt/trusted.gpg
--------------------

pub   1024D/7FAC5991 2007-03-08
uid                  Google, Inc. Linux Package Signing Key <linux-packages-keymaster@google.com>
sub   2048g/C07CB649 2007-03-08

Then add google repository in source list.

$ sudo sh -c 'echo "deb http://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google.list'

Finally install google-chrome.

$ sudo apt-get update
$ sudo apt-get install google-chrome-stable

Summary

Software package related items are stored under /etc/apt directory. In case that you add new software package, which are not listed in default repository, you need to add.

  • public key (trusted.gpg)
  • package location (<package>.list)

vmplayer abnormal exit on ubuntu

These days on my ubuntu box I encounter abnormal exit of vmplayer upon start-up. Specifically speaking vmplayer asks for me to update kernel modules and it fails.

sigh.

problem description

It goes as follows.

$ vmplayer
Logging to /tmp/vmware-ayamada/vmware-modconfig-12999.log
... "VMWare Kernel Module Updater" windows comes up ...
$ echo $?
1

vmware-modconfig logs ends up here.

Failed to find /lib/modules/3.8.0-30-generic/build/include/linux/version.h
/lib/modules/3.8.0-30-generic/build/include/linux/version.h not found, looking for generated/uapi/linux/version.h instead.

core file indicates that the process exited by receiving SEGV.

Core was generated by /usr/lib/vmware/bin/vmware-gksu –su-mode –message=Please enter the root passw’.
Program terminated with signal 11, Segmentation fault.
#0 __strcmp_ssse3 () at ../sysdeps/i386/i686/multiarch/strcmp-ssse3.S:229

workaround

It seems to be known issue. Please refer to following thread in askubuntu.

So workaround is to:

  1. create symbolic link of version.h header for current kernel revision
  2. compile

Procedure is as follows.

$ uname -r
3.8.0-30-generic
$ sudo ln -s /usr/src/linux-headers-`uname -r`/include/generated/uapi/linux/version.h /usr/src/linux-headers-`uname -r`/include/linux/version.h
$ sudo vmware-modconfig --console --install-all

Now you can enjoy vmplayer again.

remark

There are so many headers...

$ ls -ld /usr/src/linux-headers-3.8.0-*-generic
drwxr-xr-x 7 root root 4096 May 18 14:34 /usr/src/linux-headers-3.8.0-21-generic
drwxr-xr-x 7 root root 4096 May 25 08:59 /usr/src/linux-headers-3.8.0-22-generic
drwxr-xr-x 7 root root 4096 May 31 09:59 /usr/src/linux-headers-3.8.0-23-generic
drwxr-xr-x 7 root root 4096 Jun 19 10:01 /usr/src/linux-headers-3.8.0-25-generic
drwxr-xr-x 7 root root 4096 Jul  5 09:58 /usr/src/linux-headers-3.8.0-26-generic
drwxr-xr-x 7 root root 4096 Jul 31 09:22 /usr/src/linux-headers-3.8.0-27-generic
drwxr-xr-x 7 root root 4096 Aug 21 10:07 /usr/src/linux-headers-3.8.0-29-generic
drwxr-xr-x 7 root root 4096 Sep  6 09:52 /usr/src/linux-headers-3.8.0-30-generic

python tools invocation

There are many tools (e.g. yum/hg), which are written in python, on Linux platform. For example, on my ubuntu 13.04 box there are 45 python scripts under /usr/local/bin directory.

$ file /usr/local/bin/*|grep -ic python
45

So I should say that one can not live without them.

How are these python tools invoked?

Take tikerer as example.

$ which tinker
/usr/local/bin/tinker
$ file /usr/local/bin/tinker
/usr/local/bin/tinker: Python script, ASCII text executable

So executing tinker command will hook python package.

#!/usr/bin/python
# EASY-INSTALL-ENTRY-SCRIPT: 'Tinkerer==1.2.1','console_scripts','tinker'
__requires__ = 'Tinkerer==1.2.1'
import sys
from pkg_resources import load_entry_point

if __name__ == '__main__':
    sys.exit(
        load_entry_point('Tinkerer==1.2.1', 'console_scripts', 'tinker')()
    )

Where does this package come from? Let’s search for its location with primitive way.

$ strace -o test.txt -e open tinker -d "test"
$ grep tinker test.txt |grep -iv enoent
...
open("/usr/local/lib/python2.7/dist-packages/tinkerer/__init__.py", O_RDONLY|O_LARGEFILE) = 3
open("/usr/local/lib/python2.7/dist-packages/tinkerer/__init__.pyc", O_RDONLY|O_LARGEFILE) = 4

Ok, here is the location where relevant python package resides.

$ ls /usr/local/lib/python2.7/dist-packages/tinkerer
__init__.py   __templates  cmdline.pyc      draft.pyc  master.py   page.py   paths.py   post.py   static  utils.py   writer.py
__init__.pyc  cmdline.py   draft.py ext        master.pyc  page.pyc  paths.pyc  post.pyc  themes  utils.pyc  writer.pyc

So when one installs python package, say, with pip command, packages will be deployed under dist-packages directory. And at the same time, a wrapper script will be deployed on search path so that it invokes relevant package by making use of pkg_resources.