Wednesday, November 10, 2010

package installation log on Ubuntu (dpkg, apt-get, aptitude)

Dpkg log

All deb package operations must go through deb system. So no matter you use apt-get install or deb -I, it will be logged in /var/log/dpkg.log.

lesspipe can show content of .gz files directly. But it cannot show normal text file Sad smile.

Show install and upgrade history for dkg.log.#.gz files:

ls /var/log/dpkg.log*|sort -r|xargs -I{} lesspipe {}|egrep "^[0-9\-]+[[:space:]][0-9:]+[[:space:]](install|upgrade)[[:space:]]"

Show install and upgrade history for dkg.log and dpkg.log.# files:

ls /var/log/dpkg.log*|sort -r|grep -v ".gz"|xargs -I{} cat {}|egrep "^[0-9\-]+[[:space:]][0-9:]+[[:space:]](install|upgrade)[[:space:]]"

apt-get log

apt-get logges to /var/log/apt/term.log

aptitude

/var/log/aptitude

Resources

http://superuser.com/questions/6338/how-do-you-track-which-packages-were-installed-on-ubuntu-linux

As far as logs, apt-get notoriously doesn't have one;
dpkg does (at /var/log/dpkg.log) but it's famously hard to parse and can only be read with root privileges;
aptitude has one at /var/log/aptitude and you can page through it with regular user privileges.

paratrac on Ubuntu

Compile ftrack

Dependencies

Depends on: fuse-dev, glib-dev, gthread-dev

    sudo apt-get install libfuse-dev  libglib2.0-dev

Use following commands to check whether they are installed successfully

    pkg-config --libs --cflags glib-2.0
    pkg-config --libs --cflags fuse

Build

cd fuse/ftrac/
./configure prefix=your_prefix
make
make install

Add ftrack to PATH:
  export PATH=your_prefix/bin:$PATH
  which ftrac

Use fusetrac.py

add parent directory of paratrac to PYTHONPATH

  python fusetrac.py -t /tmp/fuse/

FUSE FS is mounted and a monitoring page is shown. From now on, when you access /tmp/fuse, data on monitoring page will be changed.

  cd /tmp/fuse

Tuesday, November 09, 2010

Python in Ubuntu/Debian

http://www.debian.org/doc/packaging-manuals/python-policy/ch-python.html

site module

http://docs.python.org/library/site.html

I assume sys.prefix and sys.exec_prefix are /usr. It may be different on your machine.

/usr/lib/pythonX.Y/site-packages

/usr/lib/site-python

"It sees if it refers to an existing directory, and if so, adds it to sys.path and also inspects the newly added path for configuration files."

Note: sub-directories are not added.

If .pth files exist in those directories, its contents are additional items (one per line) to be added to sys.path.

local admin

A special directory is dedicated to public Python modules installed by the local administrator, /usr/local/lib/pythonX.Y/dist-packages for python2.6 and later, and /usr/local/lib/pythonX.Y/site-packages for python2.5 and earlier. For a local installation by the administrator of python2.6 and later, a special directory is reserved to Python modules which should only be available to this Python, /usr/local/lib/pythonX.Y/site-packages. Unfortunately, for python2.5 and earlier this directory is also visible to the system Python. Additional information on appending site-specific paths to the module search path is available in the official documentation of the site module.

Central repository

It seems all (not all?) modules are installed into directory /usr/share/pyshared. It's a central module repository for python. Python modules in other system directories are symbolic references to files in this directory.

/usr/lib/pyshared/python2.6/: .so python extensions?

python-central

python-central is a tool for Python module management.

pycentral:  register and build utility for Python packages. It manages python modules you installed.

pyversions  prints  information  about installed, supported python runtimes,

py_compilefiles: compiles Python .py source files into .pyc or .pyo bytecode format.

It adds hooks for runtime change:

/usr/share/python/runtime.d/pycentral.rtinstall
/usr/share/python/runtime.d/pycentral.rtremove
/usr/share/python/runtime.d/pycentral.rtupdate

python-support

python-central is another tool for Python module management.

modules managed by python-support are installed in another directory which is added to the sys.path using the .pth mechanism. The .pth mechanism is documented in the Python documentation of the site module. 

During installation, it adds a file /usr/lib/python2.6/dist-packages/python-support.pth which contains /usr/lib/pymodules/pythonX.Y/. This directory also contains the byte-compiled modules for version pythonX.Y.

update-python-modules can be used to rebuild those modules.

It also adds hooks for runtime change:

    /usr/share/python/runtime.d/python-support.rtinstall
    /usr/share/python/runtime.d/python-support.rtremove
    /usr/share/python/runtime.d/python-support.rtupdate

Saturday, November 06, 2010

euca2tools

Resources:

http://wiki.debian.org/euca2ools

http://open.eucalyptus.com/wiki/Euca2oolsUsing

 

If you choose to use REST APIs, following options are necessary:

-U: endpoint to which requests are sent

-a: access key ID

-s: secret key

Note: for some tools, access key ID is specified via option "-A" instead of "-a", "-S" instead of "-s".

Install a package from Debian repository for Ubuntu

You can directly use Debian repository. But Debian packages may or may not be compatible with Ubuntu. So you take your own risks by doing so. Another way is to download source and build the package, which is described below.

1) Add a line to /etc/apt/sources.list

    deb-src repo-url

2) Update package index

    sudo apt-get update

3) Install dependencies: (These dependencies are downloaded from Ubuntu repository, not Debian repository)

    sudo apt-get build-dep pkg_name

4) Download source and build package

    apt-get -b source pkg_name

Now you should have a pkg_name.deb file generated in current directory.

5) Install the package

    sudo dpkg -I pkg_name.deb

6) Revert /etc/apt/sources.list file by removing the line added in step 1).

7) Rebuild package index

    sudo apt-get update

 

You are done!

Wednesday, November 03, 2010

Saturday, October 30, 2010

Arrays in Bash (Cheatsheet)

Description Indexed array Associative array
Declare an array declare -a array declare -A array
Assignment array=(value1 value2 … valuen) array=([sub1]=value1 … [subN]=valueN)
Note:You must declare it first you can use
declare -A array=([sub1]=value1 … [subN]=valueN)
Expand to all values ${array[@]}  or ${array[*]} ${array[@]}  or ${array[*]}
Expand to all keys ${!array[@]}  or ${!array[*]} ${!array[@]}  or ${!array[*]}
length of an array ${#array[@]} or ${#array[*]} ${#array[@]} or ${#array[*]}
Remove entire array unset array or unset array[@] or unset array[*] unset array or unset array[@] or unset array[*]
Remove an element unset array[index] unset array[index]
Array join array1+=(${array2[@]}) or array1+=(v1 v2 … vN) array1+=([sub1]=v1 [sub2]=v2 … [subN]=vN)
Length of an element: ${#array[index]} ${#array[index]}

 

Resources

http://tldp.org/LDP/abs/html/arrays.html

Friday, October 29, 2010

Bash config file loading order

interactive login files sourced Related option
Y Y

/etc/profile, {~/.bash_profile| ~/.bash_login| ~/.profile }
Only one of the files in brackets will be executed.

--noprofile
N Y
Y N /etc/bash.bashrc, ~/.bashrc --norc
       

Kindle 3rd generation

 

I got problems when I tried to read some books in Chinese.

I will basically investigate following questions

  1. What encodings are supported by Kindle
  2. What fonts are supported
  3. If the fonts used in the PDF cannot be found, how Kindle handles it.
  4. What formats are supported?

Wednesday, October 27, 2010

GNOME notes

GDM

/etc/init.d/gdm, /etc/init/gdm.conf: these two files are used to start gdm (actually gdm-binary).

Default display manager is stored here: /etc/X11/default-display-manager

GDM configuration: http://library.gnome.org/admin/gdm/2.32/gdm.html#configuration

Tools: gdmsetup

/etc/gdm

/user/share/gdm/

After the user logins in, gnome-session is invoked.

http://library.gnome.org/admin/system-admin-guide/stable/sessions-1.html.en

man gnome-session

Default session is specified at /desktop/gnome/session/default_session.

Use gconf-editor to view value of /desktop/gnome/session/default_session. In my case the value is "gnome-settings-daemon".
/usr/lib/gnome-settings-daemon/gnome-settings-daemon --gconf-prefix=/apps/gdm/simple-greeter/settings-manager-plugins. The description of option "--gconf-prefix" is "GConf prefix from which to load plugin settings"

 

Some resources:

http://live.gnome.org/SessionManagement/GnomeSession

http://standards.freedesktop.org/desktop-entry-spec/latest/

Autostart-spec:  http://standards.freedesktop.org/autostart-spec/autostart-spec-latest.html

http://lists.freedesktop.org/archives/xdg/2007-January/007436.html

Autostart apps are specified in directory /etc/xdg/autostart/, ~/.config/autostart/

 

Use /usr/bin/gnome-session-properties to set session properties (e.g. autostart programs). Those changes are specific to a user.