16 May 2013

417. Briefly: Patching kernel 3.9 with the CK patchset: 3.9-ck-1

Nothing strange here -- basically the same as http://verahill.blogspot.com.au/2013/04/395-ck-kernel-on-debian-and-patching.html but with updated links.

I haven't found a good and succinct description of what the -ck patch set does and that I could link to here, but here's what it says on the Arch -ck page:
"..many Archers elect to use this package for the BFS' excellent desktop interactivity and responsiveness under any load situation. Additionally, the bfs imparts performance gains beyond interactivity"

I don't know if there are objective benchmarks that one can use to demonstrate an improvement in 'responsiveness and interactivity'. Subjectively, however, I feel that there's a slight improvement. You decide for yourself.

Begin here

sudo apt-get install kernel-package fakeroot build-essential ncurses-dev
mkdir ~/tmp
cd ~/tmp
wget https://www.kernel.org/pub/linux/kernel/v3.x/linux-3.9.2.tar.xz
tar xvf linux-3.9.2.tar.xz
cd linux-3.9.2/
wget http://ck.kolivas.org/patches/3.0/3.9/3.9-ck1/patch-3.9-ck1.bz2
bunzip2 patch-3.9-ck1.bz2
patch -p1 < patch-3.9-ck1
patching file arch/powerpc/platforms/cell/spufs/sched.c patching file Documentation/scheduler/sched-BFS.txt patching file Documentation/sysctl/kernel.txt patching file fs/proc/base.c patching file include/linux/init_task.h patching file include/linux/ioprio.h patching file include/linux/sched.h Hunk #6 succeeded at 2738 (offset -10 lines). patching file init/Kconfig patching file init/main.c patching file kernel/delayacct.c patching file kernel/exit.c patching file kernel/posix-cpu-timers.c patching file kernel/sysctl.c patching file lib/Kconfig.debug patching file include/linux/jiffies.h patching file drivers/cpufreq/cpufreq.c patching file drivers/cpufreq/cpufreq_ondemand.c patching file drivers/cpufreq/cpufreq_conservative.c patching file kernel/sched/bfs.c patching file kernel/sched/Makefile patching file include/uapi/linux/sched.h patching file include/linux/sched/rt.h patching file kernel/stop_machine.c patching file include/linux/swap.h patching file mm/memory.c patching file mm/swapfile.c patching file mm/vmscan.c patching file arch/x86/Kconfig patching file kernel/Kconfig.hz patching file kernel/Kconfig.preempt patching file Makefile
make-kpkg clean cat /boot/config-`uname -r`>.config make oldconfig

You might now be asked a long series of questions about how the kernel should be configured (or you might not be -- depending on what kernel version you're currently running). In MOST cases you can select the default option (i.e. hit enter) but you should still read each question and consider it. Making a mistake won't break your computer, so don't be scared.

Next, start the compilation (will take a while):

time fakeroot make-kpkg -j4 --initrd kernel_image kernel_headers
sudo dpkg -i ../linux*3.9-ck*.deb

where 4 is the number of cores on your machine (note: it only has to do with compiling -- you can use the compiled binaries on any number of cores).

Anyway, that's all -- you've now patched, compiled and installed a new kernel. And it didn't even hurt.

416. Compiling Wine 1.5.30 in a chroot (fixed)

Update 2, 22 May 2013: Thanks to the Anonymous poster who pointed out that wine 1.5.30 was broken! Anyway, I've updated this post with instructions how to patch the wine 1.5.30 sources so that it includes libwine in the final .deb package.

(I normally attached a screenshot of the winecfg about tab, but not this time -- had I done that I would've realised something was wrong. )

It's fixed now. Wine 1.5.30 is OK again.






Update 22 May 2013: libwine.so.1 doesn't get included in the deb package, which causes severely reduced functionality. I've confirmed that Wine 1.5.28 built as shown in http://verahill.blogspot.com.au/2013/04/387-compiling-wine-1528-in-i386-chroot.html works fine though.

I'll update here when I've figured out why the compiled libraries don't get included.

It's similar to what is mentioned in these bug reports:
https://bugs.archlinux.org/task/35189
https://bugs.archlinux.org/task/35190
https://bugs.archlinux.org/task/35191

There's a fix here: http://bugs.winehq.org/attachment.cgi?id=44422


Original post:
While it'd be absolutely fair to accuse me of recycling posts, I have a reasonably good reason for doing so: posting build instructions for the latest version -- even if identical to instructions for earlier versions -- confirms that it 'works'. Also, it shows that the instructions are current.

I'm too much of a hoarder to go back and update old posts.

Anyway, here's a generic way of building wine which works for 1.5.30 (and 1.5.28 and everything in between). And yes, I've copy/pasted from my old 1.5.28 post...

See here for information about 3D acceleration using libGL/U: http://verahill.blogspot.com.au/2013/05/429-briefly-wine-libglliubglu-blender.html

Getting started:
If you set up a chroot to build 1.5.28 before, you don't need to set up a new chroot to build 1.5.30. In that case, skip the set-up step below and instead re-enter your existing chroot like this:
sudo mount -o bind /proc wine32/proc
sudo cp /etc/resolv.conf wine32/etc/resolv.conf
sudo chroot wine32
su sandbox
cd ~/tmp

Setting up the Chroot
sudo apt-get install debootstrap
mkdir $HOME/tmp/architectures/wine32 -p
cd $HOME/tmp/architectures
sudo debootstrap --arch i386 wheezy $HOME/tmp/architectures/wine32 http://ftp.au.debian.org/debian/
sudo mount -o bind /proc wine32/proc
sudo cp /etc/resolv.conf wine32/etc/resolv.conf
sudo chroot wine32

You're now in the chroot:
apt-get update
apt-get install locales sudo vim
echo 'export LC_ALL="C"'>>/etc/bash.bashrc
echo 'export LANG="C"'>>/etc/bash.bashrc
echo '127.0.0.1 localhost beryllium' >> /etc/hosts
source /etc/bash.bashrc
adduser sandbox
usermod -g sudo sandbox
echo 'Defaults !tty_tickets' >> /etc/sudoers
su sandbox
cd ~/

Replace 'beryllium' with the name your host system (it's just to suppress error messages)

Building Wine
While still in the chroot, continue (the i386 is ok; don't worry about it -- you don't actually need it):

sudo apt-get install libx11-dev:i386 libfreetype6-dev:i386 libxcursor-dev:i386 libxi-dev:i386 libxxf86vm-dev:i386 libxrandr-dev:i386 libxinerama-dev:i386 libxcomposite-dev:i386 libglu-dev:i386 libosmesa-dev:i386 libglu-dev:i386 libosmesa-dev:i386 libdbus-1-dev:i386 libgnutls-dev:i386 libncurses-dev:i386 libsane-dev:i386 libv4l-dev:i386 libgphoto2-2-dev:i386 liblcms-dev:i386 libgstreamer-plugins-base0.10-dev:i386 libcapi20-dev:i386 libcups2-dev:i386 libfontconfig-dev:i386 libgsm1-dev:i386 libtiff-dev:i386 libpng-dev:i386 libjpeg-dev:i386 libmpg123-dev:i386 libopenal-dev:i386 libldap-dev:i386 libxrender-dev:i386 libxml2-dev:i386 libxslt-dev:i386 libhal-dev:i386 gettext:i386 prelink:i386 bzip2:i386 bison:i386 flex:i386 oss4-dev:i386 checkinstall:i386 ocl-icd-libopencl1:i386 opencl-headers:i386 libasound2-dev:i386 build-essential
mkdir ~/tmp
cd ~/tmp
wget http://prdownloads.sourceforge.net/wine/wine-1.5.30.tar.bz2
tar xvf wine-1.5.30.tar.bz2
cd wine-1.5.30/
wget http://bugs.winehq.org/attachment.cgi?id=44422 -O diff.patch
patch -p1 < diff .patch
patching file configure patching file configure.ac patching file libs/wine/Makefile.in
./configure time make -j3 sudo checkinstall --install=no
checkinstall 1.6.2, Copyright 2009 Felipe Eduardo Sanchez Diaz Duran This software is released under the GNU GPL. The package documentation directory ./doc-pak does not exist. Should I create a default set of package docs? [y]: Preparing package documentation...OK Please write a description for the package. End your description with an empty line or EOF. >> wine 1.5.30-2 >> ***************************************** **** Debian package creation selected *** ***************************************** This package will be built according to these values: 0 - Maintainer: [ root@beryllium ] 1 - Summary: [ wine 1.5.30-2 ] 2 - Name: [ wine ] 3 - Version: [ 1.5.30-2 ] 4 - Release: [ 1 ] 5 - License: [ GPL ] 6 - Group: [ checkinstall ] 7 - Architecture: [ i386 ] 8 - Source location: [ wine-1.5.30 ] 9 - Alternate source location: [ ] 10 - Requires: [ ] 11 - Provides: [ wine ] 12 - Conflicts: [ ] 13 - Replaces: [ ]
Compilation took ca 13 minutes with three threads. Checkinstall takes a little while (In particular this step: 'Copying files to the temporary directory...').

Installing Wine

Exit the chroot
sandbox@beryllium:~/tmp/wine-1.5.30$ exit
exit
root@beryllium:/# exit
exit
me@beryllium:~/tmp/architectures$ 

On your host system
 Enable multiarch* and install ia32-libs, since you've built a proper 32 bit binary:

sudo dpkg --add-architecture i386
sudo apt-get update
sudo apt-get install ia32-libs

*At some point I think ia32-libs may be replaced by proper multiarch packages, but maybe not. So we're kind of doing both here.

 Copy the .deb package and install it
sudo cp wine32/home/sandbox/tmp/wine-1.5.30/wine_1.5.30-1_i386.deb .
sudo chown $USER wine_1.5.30-1_i386.deb
sudo dpkg -i wine_1.5.30-1_i386.deb

15 May 2013

415. Briefly: making a polyhedral molecular figure in gdis

This post is mainly directed towards a particular PhD student, hence the specificity in terms of workflow.

The example I use, http://www.crystallography.net/information_card.php?cif=4308402, is random, however.

0. Install stuff
sudo apt-get install gdis openbabel wget

Also turns out that there's no povray in Debian anymore! Instead, compile it as shown here: http://verahill.blogspot.com.au/2013/05/413-povray-37-rc7-on-debian-wheezy.html

1. Get the CIF
wget http://www.crystallography.net/cif/4/30/84/4308402.cif

2. Open the cif
gdis 4308402.cif




3. Optional: Trim the content and save as xyz
Select parts to delete (e.g. counter-ions and solvent) by left-clicking and dragging, then delete by hitting the Del key. Hold right-click and drag the mouse to rotate.

It doesn't need to be perfect at this stage.

Save as xyz by going to Save.. and selecting XYZ as the format.

You can also edit the xyz by hand at this point to remove e.g. all sodium ions etc.

4. Open the XYZ file you just saved

5. Delete the remaining undesirable atoms.


6. Optional: If there are bonds missing
An atom needs to bond to six other atoms for gdis to render it as an octahedral polygon, so make sure that all the bonds are there.

Open Tools/Building/Editing. Click on Add Single Bonds.
This bit is a bit frustrating -- mark one atom, then mark another. You mark by double left-clicking (don't hold shift), which sounds easy enough, but actually managing to select an atom can be frustratingly difficult sometimes and zooming doesn't help for some reason.

Note: all bonds will be gone as soon as you close gdis...

7. Turn it into polyhedral representation
Go to View/Display Properties.Click on Polyhedral
8. Generate POV file
Click on the POVRay tab. Make sure to UNCHECK the "Delete intermediate files..." button. To save time, check 'Create files, then stop'.

Click on Render. Looks like nothing happened, but a dummy_0.pov file was written to the working directory.

If the rendered image doesn't 'fit', you might have to zoom out in gdis before hitting render.

9. Render the POV file.
Run
povray +W1000 +H1000 +A0.01 dummy_0.pov

to generate a 1000x1000 png image with anti-aliasing (the lower the number following A, the 'nicer' the figure)
Final image


Appendix

* Changing Colour
1. The permanent way: edit /usr/share/gdis/gdis.elements
gksu gedit /usr/share/gdis/gdis.elements

Find the element you want to change, e.g. Selenium:
341 %gdis_elem 342 symbol: Se 343 name: Selenium 344 number: 34 345 weight: 78.959999 346 cova: 1.220000 347 vdw: 2.000000 348 charge: 4.000000 349 colour: 65535 52860 59880 350 %gdis_end

Change the colour block -- it's a simple RGB (Red:Green:Blue) 16 bit formula which ranges from 0 to 65535. 655365 655365 65535 is white, 0 0 0 is black, and 0 20000 0 is a dark green.

Using octave you can automatically convert HTML RGB codes:
octave:1> rgb = @ (a) 257.*[hex2dec(a(1:2)), hex2dec(a(3:4)) ,hex2dec(a(5:6))] rgb = @(a) 257 .* [hex2dec(a (1:2)), hex2dec(a (3:4)), hex2dec(a (5:6))] octave:2> rgb('FFB00F') ans = 65535 45232 3855 octave:3>
Make your changes and save. Now open the XYZ file you want to work with and the colours should be 'right'.

2. The temporary way
If you've already generate a POV and/or you don't want to make all those single bonds again, you can edit the POV directly. It does take a bit of script-fu, but isn't unreasonably difficult:

A. First figure out what colours are actually used:
cat dummy_0.pov |grep -v '#'|grep RGB|uniq|sort
texture_list { RGB_2899 RGB_2899 RGB_2899 }} texture_list { RGB_32040 RGB_32040 RGB_32040 }} texture_list { RGB_32040 RGB_32040 RGB_32040 }} texture_list { RGB_32382 RGB_32382 RGB_32382 }} texture_list { RGB_32382 RGB_32382 RGB_32382 }} texture_list { RGB_3637 RGB_3637 RGB_3637 }} texture_list { RGB_3637 RGB_3637 RGB_3637 }}

We have four colour formulae: 2899, 32040, 32382 and 3637 (the spaces are important below).

B. Take a look at the colours:
cat dummy_0.pov |grep '#'|egrep 'RGB_2899 | RGB_32040 |RGB_32382 |RGB_3637 '
#declare RGB_2899 = texture{pigment{color rgb <0.064516,0.838710,0.612903> } finish { Phong_Shiny } } #declare RGB_3637 = texture{pigment{color rgb <0.096774,0.548387,0.677419> } finish { Phong_Shiny } } #declare RGB_32040 = texture{pigment{color rgb <1.000000,0.290323,0.258065> } finish { Phong_Shiny } } #declare RGB_32382 = texture{pigment{color rgb <1.000000,0.612903,0.967742> } finish { Phong_Shiny } }
Looking at the colours and comparing with gdis/elements I'd say that the elements are in this order: Cerium, Tungsten, Oxygen, Arsenic

C. Rename all instances of RGB_2899 to Cerium etc. Note that this can't be undone if you make a mistake.
sed -i 's/RGB_2899/Cerium/g' dummy_0.pov
sed -i 's/RGB_3637/Tungsten/g' dummy_0.pov
sed -i 's/RGB_32040/Oxygen/g' dummy_0.pov
sed -i 's/RGB_32382/Arsenic/g' dummy_0.pov

D. Change the colours by opening dummy_0.pov with e.g. vim, and editing the declare lines, e.g.
#declare Tungsten = texture{pigment{color rgb <1.0,1.0,0.0> } finish { Phong_Shiny } }

You can use the rgb script above to calculate the colour values from hex codes:
octave:3> [rgb('FFB00F')]./65535 ans = 1.000000 0.690196 0.058824

E. Then render:
I accidentally screwed up the sed step and couldn't be bothered to make all the bonds again so the polyhedra look awful.
* Transparent polyhedra
Note that this increases rendering times by orders of magnitude.

Anyway, it's simple to set up: just change from rgb to rgbf, e.g.
#declare Tungsten = texture{pigment{color rgb <1.0,1.0,0.0> } finish { Phong_Shiny } }
to
#declare Tungsten = texture{pigment{color rgbf <1.0,1.0,0.0,0.5> } finish { Phong_Shiny } }
With rgbf you have four values <a,b,c,d>, where the higher the value of d, the more transparent the object. d=0 means that it's completely opaque.