Local software repository for apt-get

Leave a comment

We use to apt-get the packages to install in Debian derivative of Linux. The packages are mostly downloaded from internet based repositories and locally cached at /var/cache/apt/archives directory. In case we reinstall the Linux, we need to download the packages once again to install through apt-get or synaptic GUI tool. To avoid this situation we can backup the *.deb files available in /var/cache/apt/archives path in some other partition than root. After re-installation, we can create a local repository of these packages to avoid downloading again. Another advantage is that this repository can be shared with other computers too.

  • Identify the backup partition and directory for downloaded *.deb files (e.g.: /home/<username>/packages).
  • $ mkdir -p /home/<username>/packages/archives/dists/main/myrepo/binary-i386
  • $ cp /var/cache/apt/archives/*.deb /home/<username>/packages/archives/dists/main/myrepo/
  • $ cd /home/<username>/packages/archives
  • $ apt-ftparchive packages . > ./dists/main/myrepo/binary-i386/Packages
  • $ cd ./dists/main/myrepo/binary-i386/
  • $ gzip Packages
  • Re-install the Linux distribution.
  • Add the following entry in /etc/apt/sources.list file.
  • deb file:/home/<username>/packages/archives main myrepo
  • $ sudo apt-get update

That is it. Now you have all your last downloaded files as local repository. Use apt-get or synaptic to go ahead! Enjoy the beauty of apt-get from Debian.


Android NDK C++ Exceptions and RTTI Link Errors

Leave a comment

Android NDK C++ Exceptions and RTTI Link Errors

When using Android NDK to build performance-critical portions of Android apps in native C++ code, we may get C++ link errors such as:
undefined reference to `__cxa_end_cleanup’;
undefined reference to `__gxx_personality_v0′;
undefined reference to `vtable for __cxxabiv1::__si_class_type_info’;
undefined reference to `vtable for __cxxabiv1::__class_type_info’.
The first two errors are caused by no exceptions support in Android NDK toolchain, and the last two errors are caused by no RTTI support in the toolchain, according to the latest Android NDK release note STANDALONE-TOOLCHAIN.html under the docs directory. The documentation also mentioned any C++ STL (either STLport or the GNU libstdc++) with it are also not supported.

To get around the above linking errors, add compile flags
-fno-exceptions to disable exceptions
-fno-rtti to turn off RTTI

Building the JNI Source Code for Android in Eclipse

Leave a comment

When we develop a Android project includes the JNI technique, we should use the Android NDK tool for building these source code. But, the NDK is a command line tool that not convenient to use when we develop in the IDE.

In this article, I shows an example to explain the steps to build JNI source code in Eclipse.

The key is you have to create a new Builder used to execute the NDK tool for building JNI source code. So, at first, you have to create a new Builder in the Eclipse.

In my example, I try to add a new NDK Builder for OpenCV project in the Eclipse.

Step 1: Enter to the Project’s property window, and then click the “New” button to create a new Builder.


Using NDK to Call C code from Android Apps

Leave a comment

Android NDK (Native Development Kit) allows working with native C code using a shared C library. It includes the entire toolchain needed to build for your target platform (ARM). Native C code accessible via JNI still runs inside the Dalvik VM, and as such is subject to the same life-cycle rules that any Android application lives by. The advantage of writing parts of your app code in native language is presumably speed in certain cases.

Install/Compile Linux Kernel 3.0 In Ubuntu


An RC for the Linux Kernel 3.0 was recently released. The change in the version number is mostly to mark the 3rd decade of the Linux Kernel, it doesn’t bring any major changes. Still, why not try to setup the new version on your system?

Downloading kernel

# cd /tmp
# wget http://www.kernel.org/pub/linux/kernel/v3.0/testing/linux-3.0-rc6.tar.bz2
# tar -xvjf linux-3.0-rc6.tar.bz2 -C /usr/src
# cd /usr/src/linux-3.0-rc6

Configure kernel
Before you configure kernel make sure you have development tools
(gcc compilers and related tools) are installed on your system.

This step may save you time, if you want to reuse the old settings.
Whenever you install the kernel, generally you put the config file
in /boot. So, you can use the existing version of config file:

# mv /usr/src/linux-3.0-rc6/.config  /usr/src/linux-3.0-rc6/.config.save
# cp /boot/config-`uname -r`  /usr/src/linux-3.0-rc6/.config

Now you can start kernel configuration by typing any one of the command:

# make menuconfig -	Text based color menus, radiolists & dialogs.
			This option also useful on remote server if you 
			wanna compile kernel remotely. 
# make xconfig 	-	X windows (Qt) based configuration tool, works best under KDE desktop
# make gconfig 	-	X windows (Gtk) based configuration tool, works best under Gnome 
*** End of the configuration.
*** Execute 'make' to start the build or try 'make help'.

Give a unique name to your new Kernel –
Edit /usr/src/linux-3.0-rc6/Makefile and change EXTRAVERSION

Once you have finished, save and exit. It is now time to compile.

However to speed up the build if you have a dual core processor type,


The general rule is 1 + the number of processor cores.

Compile kernel

# make -j4

Start compiling to kernel modules:

# make modules
# make modules_install

***** Not recommended Goto “Follow this” *****

# make install

It will install three files into /boot directory as well as modification to your kernel grub configuration file:




***** End *****

***** Follow this *****

cp ./arch/x86/boot/bzImage /boot/vmlinuz-3.0.0-rc6
cp System.map /boot/System.map-3.0.0-rc6

Create an initrd image

# cd /boot
# update-initramfs -c -k 3.0.0-rc6

Finally we need to add the initramfs image to the grub.cfg
file located at /boot/grub/grub.cfg

# update-grub

Now just reboot and your new kernel should automatically load.

Install PAE kernel

Leave a comment

Physical Address Extension or  PAE as it is generally called, is a technology which allows 32 bit operating systems to use up to 64 Gb of memory (RAM), something which is normally achieved by switching to a 64 bit system.

Read more about it HERE

If your Linux box has 4GB RAM or above, you need to install PAE kernel

On RHEL / CentOS

yum install kernel-PAE


Ubuntu 10.04 – Lucid Lynx and newer iterations automatically installs the PAE kernel if it detects more than 3G of memory. If you need to install it manually.

sudo aptitude install linux-generic-pae linux-headers-generic-pae

Once installed ensure that the grub has the pae kernel as the default and then reboot your machine.

Linux USB structure

Leave a comment

Linux USB device driver sits above USB core( USB controller) and read device.

A USB endpoint has 4 types: control, interrupt, bulk, ISOCHRONOUS.

struct usb_host_endpoint contains struct usb_endpoint_descriptor, which contains: bEndpointAddress( IN, OUT),bmAttributes

(endpoint type),wMaxPacketSize, bInterval (in my subsequent I plan to use an endpoint of this to tell camera take an image!)

A USB interface has several endpoints, is a logic connection. One USB driver only has one USB interface.

A USB configuration has multiple USB interfaces.

USB mouse example:


How to write Linux USB device driver article:


Older Entries