Thursday, January 5, 2012

Setting up Android development environment

So here are my notes on the subject (using a Linux platfrom).

First install the JDK from Oracle (I had to remove previous rpm from SUN RIP to achieve this):

# rpm -e jdk-1.6.0_30-fcs.i586
# rpm -ivh jdk-6u30-linux-i586.rpm

and make it default system wide:


# update-alternatives --config java

There are 2 alternatives which provide `java'.

  Selection    Alternative
-----------------------------------------------
          1    /usr/lib/jvm/jre-1.6.0-sun/bin/java
*+        2    /usr/lib/jvm/jre-1.6.0-openjdk/bin/java

Press enter to keep the default[*], or type selection number: 1
Using '/usr/lib/jvm/jre-1.6.0-sun/bin/java' to provide 'java'.
$ java -version
java version "1.6.0_26"
Java(TM) SE Runtime Environment (build 1.6.0_26-b03)
Java HotSpot(TM) Server VM (build 20.1-b02, mixed mode)

Then install the current Android SDK, so that it ends up in  ~/android-sdk-linux and launch it with

$ ./android-sdk-linux/tools/android

Then check on all boxes from the API 14 (ICS) bundle and Tools folder, it will download a bunch of stuff.

Then from the Tools -> Manage AVD menu create a virtual device.

Now we need the Eclipse IDE, I downloaded eclipse-java-indigo-SR1-linux-gtk.tar.gz, just extract it to suitable location and run

$ ./eclipse/eclipse

then install the Google ADT plugin as per official docs.



Tuesday, January 3, 2012

Adding Amazon wishlist

So I have found instructions on how to add a widget to this blog which displays my Amazon wish-list. The reference site to create the Javascript snippet is

https://widgets.amazon.de/Amazon-Wishlist-Widget/

once you have that, go to the blog layout and add a widget (type html/javascript) to the desired position. Enter the snippet in the browser pop-up window. Done.

Friday, May 7, 2010

digging hard links

A couple of tips about hardlinks: to find all hard links in a specific namespace use something like this:

$ find -type f -links +1

this because hard links have, by definition, more than one link pointing to them, as you can see with ls or stat on one of them.

Another useful tip: to know about any hard link which is related to a specified file use something like:
$ find /home -xdev -samefile foo
this will print out all files which are hardlinked to foo. Remember that hard links have the same inode number which can be seen with
$ ls -li foo

once you know the inode number, you can also search for hard links with something like

$ find /home -xdev -inum 7465209
Have fun!

Thursday, January 14, 2010

How to run ChromeOS under VMware

Starting from this announcement

http://www.unixmen.com/news-today/706-chromium-os-zero-released-

I wanted the try out ChromeOS but under VMware and have a look at it. The first thing is to convert the downloaded raw image to VMWare disk image format:

$ qemu-img convert -f raw ChromeOS-Zero.img -O vmdk ChromeOS-Zero.vmdk

Then start VMware player and create a new virtual machine, but select "Custom". At some point during the process, it will ask you to select a disk. Choose to use an existing virtual disk, and point the installer tothe file created above.

This is the only trick you need to complete the virtual machine creation. Now to see what is all this ChromeOS fuss about ...

Friday, August 14, 2009

Yum and RPM notes for multiarch machines

When installing something on a stock 64bit installation, yum will by default install both x86_64 and i386 (if available) packages. This default behavior is often appearing when installing libraries and can be changed
by adding the following to /etc/yum.conf

multilib_policy=best

(default to all). In this way only the matching arch package will be installed.

If you don't want to make this global change, you can issue the yum command as follows to have the same outcome but for one time only:

yum install libtool-ltdl.x86_64

i.e. append the arch to the package name to avoid i386 package to be pulled along.

Querying the rpm database on x86_64 machines often shows duplicate packages, but that's normal in light of the above. You can change the default query format on the fly, e.g

rpm --qf '%{NAME}.%{ARCH}\n' -q glibc

or you can make it global by adding this to /etc/rpm/macros
%_query_all_fmt         %%{name}-%%{version}-%%{release}.%%{arch}
In this way the arch will be shown alongside other query parameters.

Sunday, July 26, 2009

Accessing the guest OS from the host using VirtualBox

To be able to access the guest OS via ssh fro the host, type the following on the host

$ VBoxManage setextradata Centos\ 5.3\ x86\ bis "VBoxInternal/Devices/pcnet/0/LUN#0/Config/SSH/HostPort" 3333
 $ VBoxManage setextradata Centos\ 5.3\ x86\ bis "VBoxInternal/Devices/pcnet/0/LUN#0/Config/SSH/GuestPort" 22
$ VBoxManage setextradata Centos\ 5.3\ x86\ bis "VBoxInternal/Devices/pcnet/0/LUN#0/Config/SSH/Protocol" TCP

(SSH is just a string, you can type anything really). Then you can login to the guest OS by typing this on the host:

$ ssh -p 2222 -X root@localhost

note the same principle applies to other services, example for httpd:

$ VBoxManage setextradata GuestName "VBoxInternal/Devices/pcnet/0/LUN#0/Config/Apache/HostPort" 8888
$ VBoxManage setextradata GuestName "VBoxInternal/Devices/pcnet/0/LUN#0/Config/Apache/GuestPort" 80
$ VBoxManage setextradata GuestName "VBoxInternal/Devices/pcnet/0/LUN#0/Config/Apache/Protocol" TCP

then you can point the host browser to http://localhost:8888. Note that you can’t use a host port lower than 1024 without running VirtualBox with escalated privileges.

To see settings use:

$ VBoxManage getextradata guestname enumerate

To clear a setting (by giving it a clear value) use:

$ VBoxManage setextradata "VBoxInternal/Devices/pcnet/0/LUN#0/Config/ssh/GuestPort"

Virtual lab with VirtualBox

To get two virtual guests to talk to each other while also being able to reach out to rpm repos etc. (i.e.  to inernet), one needs to define two interfaces on the VirtualBox guest OS settings:

  • first interface (will be eth0) should use default NAT setting. This will provide Internet access.
  • second interface (will be eth1) should use 'Internal Network'. This will provide in-between guests connectivity.

When booting the guest (Centos in my case), eth0 will come up via DHCP, then configure eth1 with a static non routable IP address. However when bringing it up, it will override DNS and default GW as set by eth0, therefore breaking internet access. The fastest path recover is to simply restart eth0 (ifdown eth0/ifup eth0) which gets again the correct settings from the dhcp server.