Checkinstall on Maemo

checkinstall is a tool which helps to create Debian packages. (It also could help to create RedHat's and Slackware's packages). Instead of typing "make install" user can just write "checkinstall" and build .deb package for a software.

Building Debian package, instead of just installing software to a prefix, has several advantages:

  • you may put the package into your own package repository and share with other people.
  • you have advantages of package management, like ability to list package files, check which package installed a particular file, and, package manager won't allow to overwrite existing files, while "make install" does not care about this.

As far as I know, you cannot commit packages generated in this way into official Maemo repositories.

[edit] Instructions

ATTENTION! ACHTUNG! Doing things described in this manual is dangerous. Don't follow these instructions unless you are confident GNU/Linux user, have a backup of a running system and know how to reflash bricked phone.

First, let's get the source:

wget http://www.asic-linux.com.mx/~izto/checkinstall/files/source/checkinstall-1.6.2.tar.gz

Untar it:

tar -jxvf checkinstall-1.6.2.tar.gz

cd to the directory and modify Makefile:

#PREFIX=/usr/local
PREFIX=/opt/checkinstall

Also, change the Makefile in the installwatch directory"

#PREFIX=/usr/local
PREFIX=/opt/checkinstall

Now you also need to install gettext. For that, temporarily add the SDK repository to the custom apt list:

vi /etc/apt/sources.list.d/dev.list

and add the line:

deb http://repository.maemo.org fremantle/sdk free non-free

DO NOT UPGRADE YOUR SYSTEM WITH THIS CONFIG LINE ENABLED!

apt-get update
apt-get install gettext

You also need to install sed-gnu. It's in fremantle/free repository

apt-get install sed-gnu

The GNU sed binary is now located in /usr/bin/gnu, so we need to have that directory in the path first, otherwise /bin/sed from busybox will be executed

export PATH=/usr/bin/gnu:$PATH

At the moment of successful compilation I also have in the system following packages with the gnu ending:

dpkg -l | grep gnu
ii  coreutils-gnu                                       8.4-2maemo1                      GNU core utilities
ii  diffutils-gnu                                       1:2.8.1-18maemo3                 File comparison utilities
ii  sed-gnu                                             4.2.1-6maemo5                    The GNU sed stream editor
ii  tar-gnu                                             1.22-2maemo5                     GNU version of the tar archiving utility

I also have GCC and GNU make installed. We will need bash; I always have it as my defailt shell:

apt-get install bash3


So, now it's time to type "make"

make
for file in locale/checkinstall-*.po ; do \
	case ${file} in \
		locale/checkinstall-template.po)  ;; \
		*) \
			out=`echo $file | sed -s 's/po/mo/'` ; \
			msgfmt -o ${out} ${file} ; \
			if [ $? != 0 ] ; then \
				exit 1 ; \
			fi ; \
		;; \
	esac ; \
done	
make -C installwatch
make[1]: Entering directory `/media/mmc1/noch/src0/checkinstall-1.6.2/installwatch'
./create-localdecls
Checking truncate argument type... off_t
Checking readlinkat result type... ssize_t
Checking libc version... libc.so.6
Checking glibc subversion... gcc -Wall -c -D_GNU_SOURCE -DPIC -fPIC -D_REENTRANT -DVERSION=\"0.7.0beta7\" installwatch.c
ld -shared -o installwatch.so installwatch.o -ldl -lc
make[1]: Leaving directory `/media/mmc1/noch/src0/checkinstall-1.6.2/installwatch'

Now we can use checkinstall which we installed in the prefix:

export PATH=/opt/checkinstall/bin:/opt/checkinstall/sbin:$PATH

We need findutils-gnu for checkinstall to work.

apt-get install findutils-gnu

In order to build a package well, you also need to install debianutils. However, you cannot install debianutils, because it conflicts with busybox. This is a dirty hack I suggest to use:

cp /var/lib/dpkg/status /var/lib/dpkg/status.bak
vi /var/lib/dpkg/status

Find in this file the "busybox" section.

Package: busybox                                             
Status: install ok installed                                          
Priority: optional                                                  
Section: utils                                                       
Installed-Size: 500                                                      
Maintainer: Yauheni Kaliuta <yauheni.kaliuta@nokia.com>              
Architecture: armel                                             
Version: 3:1.10.2.legal-1osso30+0m5     
Replaces: ash, bsdutils, coreutils, debianutils, diff, findutils, grep, gzip, hostname, login, mktemp, mount, ncurses-bin, sed, sysvinit-utils, tar,
Provides: ash, awk, bsdutils, coreutils, debianutils, diff, editor, findutils, grep, gzip, hostname, login, mktemp, mount, ncurses-bin, sed, sysvini
Depends: libc6 (>= 2.5.0-1), libgcc1 (>= 1:4.2.1), busybox-symlinks-busybox (= 3:1.10.2.legal-1osso30+0m5)                             
Conflicts: ash, bsdutils, coreutils, debianutils, diff, findutils, grep, gzip, hostname, login, mktemp, mount, ncurses-bin, sed, sysvinit-utils, tar
Description: Tiny utilities for small and embedded systems
 BusyBox combines tiny versions of many common UNIX utilities into a single
 small executable. It provides minimalist replacements for the most common
 utilities you would usually find on your desktop system (i.e., ls, cp, mv,
 mount, tar, etc.). The utilities in BusyBox generally have fewer options than
 their full-featured GNU cousins; however, the options that are included
 provide the expected functionality and behave very much like their GNU
 counterparts.                                               
...

Remove "debianutils" from the Replaces and Conflicts sections.

Now let's change apt configuration in order to allow to overwrite busybox links:

vi /etc/apt/apt.conf.d/23overwrite

This file did not exist.

Paste there following lines:

APT {
             Get {
               Fix-Broken "true";
             };
};
DPkg
{
  Options {"--force-overwrite";}
}

Otherwise you will need to download package yourself, and install it with:

dpkg --force-overwrite.
apt-get install debianutils
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following NEW packages will be installed:
  debianutils
0 upgraded, 1 newly installed, 0 to remove and 21 not upgraded.
Need to get 55,3kB of archives.
After this operation, 279kB of additional disk space will be used.
Get:1 http://repository.maemo.org fremantle/free debianutils 2.30 [55,3kB]
Fetched 55,3kB in 0s (94,7kB/s)
Selecting previously deselected package debianutils.
(Reading database ... 44101 files and directories currently installed.)
Unpacking debianutils (from .../debianutils_2.30_armel.deb) ...
dpkg - warning, overriding problem because --force enabled:
 trying to overwrite `/bin/tempfile', which is also in package busybox
dpkg - warning, overriding problem because --force enabled:
 trying to overwrite `/bin/which', which is also in package busybox
dpkg - warning, overriding problem because --force enabled:
 trying to overwrite `/bin/run-parts', which is also in package busybox
dpkg - warning, overriding problem because --force enabled:
 trying to overwrite `/usr/bin/which', which is also in package busybox
Setting up debianutils (2.30) ...
/usr/bin/which: line 22: getopts: not found
/usr/bin/which: shift: line 23: Illegal number: -1

As you see, /usr/bin/which does not work, because it cannot find getopts. However, getopts is a bash command, so we can fix it by changing interpreter in the /usr/bin/which script from #!/bin/sh (which is a symlink to busybox) to #!/bin/bash. Then, also change the interpreter in the following scripts

/usr/bin/sensible-pager
/usr/bin/savelog
/usr/bin/sensible-browser
/usr/bin/sensible-editor

Now, type checkinstall:

checkinstall 1.6.2, Copyright 2009 Felipe Eduardo Sanchez Diaz Duran
           This software is released under the GNU GPL.

The checkinstallrc file was not found at:
/opt/checkinstall/sbin/../checkinstallrc

Assuming default values.

The package documentation directory ./doc-pak does not exist. 
Should I create a default set of package docs?  [y]: 

Preparing package documentation...OK

Please choose the packaging method you want to use.
Slackware [S], RPM [R] or Debian [D]? D

****************************************
**** Debian package creation selected ***
*****************************************
/opt/checkinstall/sbin/checkinstall: line 1272: rev: command not found
/opt/checkinstall/sbin/checkinstall: line 1272: rev: command not found
/opt/checkinstall/sbin/checkinstall: line 1299: rev: command not found
/opt/checkinstall/sbin/checkinstall: line 1299: rev: command not found

This package will be built according to these values: 

0 -  Maintainer: [ root@Nokia-N900 ]
1 -  Summary: [ CheckInstall installations tracker, version 1.6.2 ]
2 -  Name:    [  ]
3 -  Version: [  ]
4 -  Release: [ 1 ]
5 -  License: [ GPL ]
6 -  Group:   [ checkinstall ]
7 -  Architecture: [ armel ]
8 -  Source location: [ checkinstall-1.6.2 ]
9 -  Alternate source location: [  ]
10 - Requires: [  ]
11 - Provides: [  ]
12 - Conflicts: [  ]
13 - Replaces: [  ]

"rev" utility is a part of util-linux. We can safely ignore the warning. However, checkinstall won't build a package unless we explicitly specify Name and Version of the package.

This is it

Enter a number to change any of them or press ENTER to continue: 2
Enter new name: 
>> checkinstall
/opt/checkinstall/sbin/checkinstall: line 1299: rev: command not found
/opt/checkinstall/sbin/checkinstall: line 1299: rev: command not found

This package will be built according to these values: 

0 -  Maintainer: [ root@Nokia-N900 ]
1 -  Summary: [ CheckInstall installations tracker, version 1.6.2 ]
2 -  Name:    [ checkinstall ]
3 -  Version: [  ]
4 -  Release: [ 1 ]
5 -  License: [ GPL ]
6 -  Group:   [ checkinstall ]
7 -  Architecture: [ armel ]
8 -  Source location: [ checkinstall-1.6.2 ]
9 -  Alternate source location: [  ]
10 - Requires: [  ]
11 - Provides: [ checkinstall ]
12 - Conflicts: [  ]
13 - Replaces: [  ]

Enter a number to change any of them or press ENTER to continue: 3
Enter new version: 
>> 1.6.2

This package will be built according to these values: 

0 -  Maintainer: [ root@Nokia-N900 ]
1 -  Summary: [ CheckInstall installations tracker, version 1.6.2 ]
2 -  Name:    [ checkinstall ]
3 -  Version: [ 1.6.2 ]
4 -  Release: [ 1 ]
5 -  License: [ GPL ]
6 -  Group:   [ checkinstall ]
7 -  Architecture: [ armel ]
8 -  Source location: [ checkinstall-1.6.2 ]
9 -  Alternate source location: [  ]
10 - Requires: [  ]
11 - Provides: [ checkinstall ]
12 - Conflicts: [  ]
13 - Replaces: [  ]

Enter a number to change any of them or press ENTER to continue: 

Installing with make install...

========================= Installation results ===========================
for file in locale/checkinstall-*.po ; do \
	case ${file} in \
		locale/checkinstall-template.po)  ;; \
		*) \
			out=`echo $file | sed -s 's/po/mo/'` ; \
			msgfmt -o ${out} ${file} ; \
			if [ $? != 0 ] ; then \
				exit 1 ; \
			fi ; \
		;; \
	esac ; \
done	
make -C installwatch
make[1]: Entering directory `/media/mmc1/noch/src0/checkinstall-1.6.2/installwatch'
make[1]: Nothing to be done for `all'.
make[1]: Leaving directory `/media/mmc1/noch/src0/checkinstall-1.6.2/installwatch'
export
export AF_DEFINES_SOURCED='1'
export AF_INIT_DIR='/etc/osso-af-init'
export AF_PIDDIR='/tmp/af-piddir'
export DBUS_SESSION_BUS_ADDRESS='unix:abstract=/tmp/dbus-eWtibmqbgo,guid=8e2b2d5d9dbd2e469e4db2720000000f'
export DISABLE_GATEWAY='1'
export DISPLAY=':0.0'
export GTK2_RC_FILES='/etc/hildon/theme/gtk-2.0/gtkrc'
export HILDON_FM_OBEX_ROOT='obex://'
export HOME='/root'
export ILLEGAL_FAT_CHARS='\/:*?<>|'
export INSTW_BACKUP='1'
export INSTW_DBGFILE='/var/tmp/tmp.wti2T1hGGv/dbgfile'
export INSTW_DBGLVL='0'
export INSTW_EXCLUDE='/dev,/media/mmc1/noch/src0/checkinstall-1.6.2,/proc,/tmp,/var/tmp,'
export INSTW_LOGFILE='/var/tmp/tmp.wti2T1hGGv/newfiles.tmp'
export INSTW_ROOTPATH='/var/tmp/tmp.wti2T1hGGv'
export INSTW_TRANSL='1'
export INTERNAL_MMC_MOUNTPOINT='/home/user/MyDocs'
export INTERNAL_MMC_SWAP_LOCATION='/home/user/MyDocs'
export LANG='en_US'
export LAUNCHWRAPPER='/etc/osso-af-init/launch-wrapper.sh'
export LAUNCHWRAPPER_NICE='/etc/osso-af-init/nice-launch-wrapper.sh'
export LAUNCHWRAPPER_NICE_KILL='/etc/osso-af-init/nice-kill-launch-wrapper.sh'
export LAUNCHWRAPPER_NICE_TRYRESTART='/etc/osso-af-init/nice-launch-wrapper-tryrestart.sh'
export LAUNCHWRAPPER_TRYRESTART='/etc/osso-af-init/launch-wrapper-tryrestart.sh'
export LC_ADDRESS='de_DE'
export LC_IDENTIFICATION='de_DE'
export LC_MEASUREMENT='de_DE'
export LC_MESSAGES='en_US'
export LC_MONETARY='de_DE'
export LC_NAME='de_DE'
export LC_NUMERIC='de_DE'
export LC_PAPER='de_DE'
export LC_TELEPHONE='de_DE'
export LC_TIME='en_US'
export LD_PRELOAD='/opt/checkinstall/lib/installwatch.so'
export LOGNAME='root'
export MAIL='/var/mail/root'
export MAKEFLAGS=''
export MAKELEVEL='1'
export MAX_FILENAME_LENGTH='255'
export MFLAGS=''
export MMC_DEVICE_FILE='/dev/mmcblk0p1'
export MMC_MOUNTPOINT='/media/mmc1'
export MMC_SWAP_LOCATION='/media/mmc1'
export MYDOCSDIR='/home/user/MyDocs'
export OLDPWD='/media/mmc1/noch/src0/checkinstall-1.6.2'
export OSSO_PRODUCT_FULL_NAME='Nokia N900'
export OSSO_PRODUCT_HARDWARE='RX-51'
export OSSO_PRODUCT_KEYBOARD='English, Dutch'
export OSSO_PRODUCT_NAME='N900'
export OSSO_PRODUCT_REGION='English America'
export OSSO_PRODUCT_RELEASE_FULL_NAME='Maemo 5'
export OSSO_PRODUCT_RELEASE_NAME='Maemo 5'
export OSSO_PRODUCT_RELEASE_VERSION='20.2010.36-2.003'
export OSSO_PRODUCT_SHORT_NAME='Nokia N900'
export OSSO_PRODUCT_WLAN_CHANNEL='fcc/us'
export OSSO_SWAP='/home/user/MyDocs'
export OSSO_VERSION='RX-51_2009SE_20.2010.36-2.003_PR_003'
export PATH='/opt/checkinstall/bin:/opt/checkinstall/sbin:/usr/bin/gnu:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/bin/X11'
export PWD='/media/mmc1/noch/src0/checkinstall-1.6.2'
export SDL_AUDIODRIVER='pulse'
export SESSION_BUS_ADDRESS_FILE='/tmp/session_bus_address.user'
export SESSION_BUS_PID_FILE='/tmp/dbus_session_bus.pid.user'
export SHELL='/bin/sh'
export SHLVL='3'
export SSH_CLIENT='10.0.0.1 56492 22'
export SSH_CONNECTION='10.0.0.1 56492 10.0.0.3 22'
export SSH_TTY='/dev/pts/1'
export STATESAVEDIR='/tmp/osso-appl-states'
export TERM='xterm'
export TEXTDOMAIN='checkinstall'
export TEXTDOMAINDIR='/opt/checkinstall/sbin/../lib/checkinstall/locale'
export TMPDIR='/var/tmp'
export UPNP_ROOT='upnpav://'
export USER='root'
export _='/var/tmp/tmp.wti2T1hGGv/installscript.sh'
make -C installwatch install
make[1]: Entering directory `/media/mmc1/noch/src0/checkinstall-1.6.2/installwatch'
mkdir -p /opt/checkinstall/lib
mkdir -p /opt/checkinstall/bin
if [ -r /opt/checkinstall/lib/installwatch.so ]; then \
	rm -f  /opt/checkinstall/lib/installwatch.so; \
fi
install installwatch.so /opt/checkinstall/lib
sed -e "s|#PREFIX#|/opt/checkinstall|" < installwatch > /opt/checkinstall/bin/installwatch
chmod 755 /opt/checkinstall/bin/installwatch
make[1]: Leaving directory `/media/mmc1/noch/src0/checkinstall-1.6.2/installwatch'
mkdir -p /opt/checkinstall/sbin
install checkinstall makepak /opt/checkinstall/sbin
for file in locale/*.mo ; do \
	LANG=`echo $file | sed -e 's|locale/checkinstall-||' \
		-e 's|\.mo||'` && \
	mkdir -p /opt/checkinstall/lib/checkinstall/locale/${LANG}/LC_MESSAGES && \
	cp $file /opt/checkinstall/lib/checkinstall/locale/${LANG}/LC_MESSAGES/checkinstall.mo || \
	exit 1 ; \
done
mkdir -p /opt/checkinstall/lib/checkinstall
install -m644  checkinstallrc-dist /opt/checkinstall/lib/checkinstall
if ! [ -f /opt/checkinstall/lib/checkinstall/checkinstallrc ]; then \
	cp /opt/checkinstall/lib/checkinstall/checkinstallrc-dist /opt/checkinstall/lib/checkinstall/checkinstallrc; \
else \
	echo; \
	echo; \
	echo ======================================================== ;\
	echo; \
	echo An existing checkinstallrc file has been found. ;\
	echo The one from this distribution can be found at: ; \
	echo; \
	echo -e \\t/opt/checkinstall/lib/checkinstall/checkinstallrc-dist ; \
	echo; \
	echo; \
	echo ======================================================== ;\
	echo; \
fi


========================================================

An existing checkinstallrc file has been found.
The one from this distribution can be found at:

	/opt/checkinstall/lib/checkinstall/checkinstallrc-dist


========================================================


======================== Installation successful ==========================

Copying documentation directory...
./
./TODO
./INSTALL
./README
./COPYING
./RELNOTES
./BUGS
./Changelog
./FAQ
./CREDITS

Copying files to the temporary directory...OK

Stripping ELF binaries...OK

Compressing man pages...OK

Building file list...OK

Building Debian package...OK

NOTE: The package will not be installed

Erasing temporary files...OK

Deleting doc-pak directory...OK

Writing backup package...OK
OK

Deleting temp dir...OK


**********************************************************************

 Done. The new package has been saved to

 /media/mmc1/noch/src0/checkinstall-1.6.2/checkinstall_1.6.2-1_armel.deb
 You can install it in your system anytime using: 

      dpkg -i checkinstall_1.6.2-1_armel.deb

**********************************************************************

Now, you can use checkinstall in order to create Debian packages for Maemo.