Saturday, June 28, 2008

Customizing Asus AM200g - IV. jabberd configuration

The following is a sequence of trial and errors, one by one, covering the path from the default config file to a working one. It is intended to be a search engine trap for people trying to resolve configuration problems.




$ telnet 192.168.1.1
Trying 192.168.1.1...
Connected to r (192.168.1.1).
Escape character is '^]'.
BCM96348 ADSL Router
Login: admin
Password:
> sh
BusyBox v1.00 (2005.04.12-18:11+0000) Built-in shell (msh)
Enter 'help' for a list of built-in commands.
# /var/usb/usb_1/bin/jabberd
Not writing pidfile /var/usb/usb_1/var/run/jabberd/jabber.pid: Read-only file system

In my setup, the jabberd ecosystem resides on a readonly filesystem, so the very first thing to do is to copy the etc/jabber.xml file to the vfat partition and make sure the files that need to be dynamically created/modified are there as well.

# mkdir /var/usb/usb_2/jabberd
# cp /var/usb/usb_1/etc/jabber.xml /var/usb/usb_2/jabberd
# /var/usb/usb_1/bin/vim /var/usb/usb_2/jabberd/jabber.xml


If you're not familiar with vi, here's quick help:

To quit without saving type ':q' (colon q Enter)

To save changes and quit type ':wq' (colon w q Enter)

To move around use the arrow keys

To start writing at cursor press 'i'

To get out of the writing mode (so that you can move somewhere else) press 'Esc'

To delete character at cursor press 'x'




The changes I did at first were:


1.

To prevent the message


Not writing pidfile /var/usb/usb_1/var/run/jabberd/jabber.pid: Read-only file system

I changed /var/usb/usb_1/var/run/jabberd/jabber.pid to /var/usb/usb_2/jabberd/jabber.pid.

2.


Next I launched jabberd in debug mode (-D) and pointed it to the alternate config file (-c path/to/file):


# /var/usb/usb_1/bin/jabberd -D -c /var/usb/usb_2/jabberd/jabber.xml
Mon Jan  3 20:31:13 2000  mio_tls.cc:921 MIO TLS init (GNU TLS)
Mon Jan  3 20:31:14 2000  log.cc:221 <log xmlns='jabber:server' type='warn' from='-internal'>
Cannot open /var/usb/usb_1/etc/dhparams.pem for reading dhparams: No such file or directory</log>
...

The comments in the file say:
<!-- With the <dhparams/> element right inside the <tls/> element,  -->
<!-- you can configure a file containing parameters for Diffie      -->
<!-- Hellmann key exchanges. If this configuration setting is not   -->
<!-- present, jabberd14 will generated these parameters             -->
<!-- automatically on each startup. This takes some time, therefore -->
<!-- you get a faster startup, if this setting is present.          -->

So I commented out <dhparams type='pem'>/var/usb/usb_1/etc/dhparams.pem</dhparams> as I don't know how to make it properly and don't mind waiting a few seconds more at startup. To start a comment, you write "<!--", you close it with "-->".

3.

# /var/usb/usb_1/bin/jabberd -D -c /var/usb/usb_2/jabberd/jabber.xml
...
Mon Jan  3 20:47:02 2000  xdb_sql.cc:911 using the following query on SQL connection establishment: SET NAMES utf8
Mon Jan  3 20:47:02 2000  log.cc:221 <log xmlns='jabber:server' type='alert' from='xdbsql.localhost'>Your xdb_sql is compiled without support
for the selected database driver 'mysql'.</log>
Mon Jan  3 20:47:02 2000  xdb_sql.cc:813 processing handler definition: <handler xmlns='jabber:config:xdb_sql' ns='jabber:iq:last'>
...
Mon Jan  3 20:47:03 2000  deliver.cc:837 delivering to instance 'elogger.localhost'
Mon Jan  3 20:47:03 2000  deliver.cc:614 DELIVER 3:xdbsql.localhost <log xmlns='jabber:server' type='alert' from='xdbsql.localhost'>Your
xdb_sql is compiled without support for the selected database driver 'mysql'.</log>


Yes, this is true, the daemon was compiled without any sql support. I've followed the steps in README.filespool to setup jabber to store data in files - I definitely don't want to run sql server on the machine. Of course I replaced the <xdb_file>$PREFIX/lib/libjabberdxdbfile.so</xdb_file> with <xdb_file>/var/usb/usb_1/lib/libjabberdxdbfile.so</xdb_file>, and <spool><jabberd:cmdline flag='s'>$PREFIX/var/spool/jabberd</jabberd:cmdline></spool> with <spool><jabberd:cmdline flag='s'>/var/usb/usb_2/jabberd/jabberdspool</jabberd:cmdline></spool> - then made sure the directory exists:
# mkdir /var/usb/usb_2/jabberd/jabberdspool



4.


# /var/usb/usb_1/bin/jabberd -D -c /var/usb/usb_2/jabberd/jabber.xml
...
Mon Jan  3 21:17:58 2000  log.cc:221 <log xmlns='jabber:server' type='alert' from='inject.localhost'>
could not open directory /var/usb/usb_1/var/spool/jabberd/inject.localhost for reading</log>
...

inject.localhost is a directory, where some other process can put messages. jabberd then automatically sends them. To make it working I changed
<in>/var/usb/usb_1/var/spool/jabberd/inject.localhost</in> to <in>/var/usb/usb_2/jabberd/inject.localhost</in> and created the directory with
# mkdir /var/usb/usb_2/jabberd/inject

5.
# /var/usb/usb_1/bin/jabberd -D -c /var/usb/usb_2/jabberd/jabber.xml
...
Mon Jan  3 21:33:15 2000  jabberd.cc:336 main load check of 1.00 with 4 total threads
Mon Jan  3 21:33:16 2000  users.cc:209 0        total users
Mon Jan  3 21:33:17 2000  dialback.cc:1207 dialback idle check

hmm, seems to be working ..., time to launch kopete and try registering a user hajma@192.168.1.1. It failed, of course. The message I got from Kopete was definitely not helpful: "There was an error in the protocol stream: There was a conflict in the information received." and "Unable to create account on the server. The Jabber ID is probably already in use.". What a nonsense ... a brief look into the konsole shows the infamous "bouncing a routed packet" message:
Mon Jan  3 21:35:40 2000  deliver.cc:614 DELIVER 4:192.168.1.1 <route xmlns='jabber:server' type='auth'
to='hajma@192.168.1.1' from='14@c2s/100E0278'><iq type='set' to='192.168.1.1' id='aab0a'>
<query xmlns='jabber:iq:register'>
<username>hajma</username>
<password>qwertyuiop</password>
</query>
</iq></route>
Mon Jan  3 21:35:40 2000  deliver.cc:837 delivering to instance 'dnsrv.localhost'
Mon Jan  3 21:35:40 2000  deliver.cc:766 delivery failed (Internal Delivery Error)
Mon Jan  3 21:35:40 2000  log.cc:221 <log xmlns='jabber:server' type='notice' from='192.168.1.1'>bouncing a routed
packet to hajma@192.168.1.1 from 14@c2s/100E0278: Internal Delivery Error</log>

In short, to make jabberd working correctly, you have to replace all occurences of 'localhost' by the domain or IP jabberd is listening at. Now I replaced localhost with 192.168.1.1.

6.

# /var/usb/usb_1/bin/jabberd -D -c /var/usb/usb_2/jabberd/jabber.xml
...

Registering with Kopete again ... This time I only got one error: "Unable to create account on the server. The Jabber ID is probably already in use.". And again it was completely unrelated - in the konsole I found this:
Mon Jan  3 21:50:02 2000  mod_register.cc:278 we got a reply for: username
Mon Jan  3 21:50:02 2000  mod_register.cc:278 we got a reply for: password
Mon Jan  3 21:50:03 2000  mod_register.cc:298 returned err msg: Missing data field: name
...
<error code='400' type='modify'><bad-request xmlns='urn:ietf:params:xml:ns:xmpp-stanzas'/>
<text xmlns='urn:ietf:params:xml:ns:xmpp-stanzas'>Missing data field: name</text></error></iq></route>

The stupid thing Kopete completely ignores XEP-0077, does not ask the server what is needed for registration and just sends username and password. To support Kopete, I had to delete
<name/> and <email/> from the <register xmlns="jabber:iq:register" notify="yes"> section.


After this change I am able to register a new user and send messages.
Just to be perfect I also changed /var/usb/usb_1/var/log/jabberd/error.log to /var/usb/usb_2/jabberd/error.log.
Off to the next level!

7.


To have it available from outside world, I replaced 192.168.1.1 with my_domain.cz.
To open a port in the AM-200g router, issue the following command:

iptables -I INPUT -p tcp -i ppp_8_48_1 --dport 5222 -m state --state NEW -j ACCEPT



8.

The main reason for running own jabber server is more privacy and that is impossible without encryption - let's do it.
To be able to use TLS I had to generate a self-signed certificate. I've used the procedure described at http://www.vanemery.com/Linux/Jabber/jabberd.html:

$ openssl req -new -x509 -newkey rsa:1024 -days 3650 -keyout privkey.pem -out key.pem

Generating a 1024 bit RSA private key

...........++++++

.........++++++

writing new private key to 'privkey.pem'

Enter PEM pass phrase:

Verifying - Enter PEM pass phrase:

Tuesday, June 17, 2008

Customizing Asus AM200g - III. jabberd and vim


It took me some time to actually make the jabber server working, few people seem to really care about cross-compiling their stuff, but I succeeded and here's the howto:




0. Errata


First of all, during the testing I found out I have to modify the environment settings - the static build of jabber did not work at all. I also added the location of newly compiled libs and headers so that they can be used by programs that depend on them. Some programs were in C++, so the CXX variable had to be set as well. Here's the final environment (P.S. in the end it seems some additions like CPPFLAGS would be needed for perfection, but I'm not in the mood of retrying):


$ cat environment
TOOLCHAINS_HOME=/opt/toolchains/uclibc-crosstools
export LIBS="-L${TOOLCHAINS_HOME}/lib/gcc/mips-linux/3.4.2 \
-L/var/usb/usb_1/lib \
"
export INCLUDES="-I${TOOLCHAINS_HOME}/include/c++/3.4.2 \
-I${TOOLCHAINS_HOME}/mips-linux/sys-include \
-I/var/usb/usb_1/include \
-I/home/hajma/Documents/GPL_AM604G_ForRussia/GENERIC_6348_WLAN_A34_3-06-02-01/kernel/linux/include \
-I/var/usb/usb_1/include/ncurses \
"
#export CFLAGS="${INCLUDES} ${LIBS} -static"
#export LDFLAGS="-static"
export CFLAGS="${INCLUDES} ${LIBS}"
export LDFLAGS=""
export CC="${TOOLCHAINS_HOME}/bin/mipsel-uclibc-gcc"
export CXX="${TOOLCHAINS_HOME}/bin/mipsel-uclibc-g++"
export LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:${TOOLCHAINS_HOME}/lib
export PATH="${TOOLCHAINS_HOME}/bin:${PATH}"

Let's use it:

. environment



Also the symlinking of the uclibc toolchain needed to be further enhanced for some package to get built:

# cd /opt/toolchains/uclibc-crosstools/bin
# for A in mips-linux-uclibc-* ; do
> ln -s ${A} mipsel-linux-${A#mips-linux-uclibc-}
> done

1a. jabberd

$ cd GENERIC_6348_WLAN_A34_3-06-02-01/userapps/opensource
$ wget http://download.jabberd.org/jabberd14/jabberd14-1.6.1.1.tar.gz
$ tar xvf jabberd14-1.6.1.1.tar.gz
$ cd jabberd14-1.6.1.1
$./configure --build=i686-pc-linux-gnu --host=mipsel-linux --target=mipsel-linux --prefix=/var/usb/usb_1

This ends badly:
...
checking for libpopt... configure: error: no


Apparently the library for parsing command line parameters is needed. This was reported a year ago ...


2. popt

$ cd GENERIC_6348_WLAN_A34_3-06-02-01/userapps/opensource
$ wget http://freshmeat.net/redir/popt/72854/url_tgz/popt-1.14.tar.gz
$ tar xvf popt-1.14.tar.gz
$ cd popt-1.14
$ ./configure --build=i686-pc-linux-gnu --host=mipsel-linux --target=mipsel-linux --prefix=/var/usb/usb_1
...
checking for va_copy() function... configure: error: cannot run test program while cross compiling
See `config.log' for more details.

WTF! There's bug 25 about it that the developers closed, saying "va_copy is no longer needed or used in popt-1.14.". Hell, when it's not needed, why did you keep the check ... :-(

I added a comment to the bug and sucessfully run:
$ ./configure --build=i686-pc-linux-gnu --host=mipsel-linux --target=mipsel-linux --prefix=/var/usb/usb_1 ac_cv_va_copy=no
$ make
$ make install

1b. jabberd

Retry:
$ cd ../jabberd14-1.6.1.1
$ ./configure --build=i686-pc-linux-gnu --host=mipsel-linux --target=mipsel-linux --prefix=/var/usb/usb_1
...
checking for libpopt... configure: error: no

The previous step did not help much ... The configure script does not search for the popt.h in the provided directories - again something reported a year ago. It forced me to rise bug 93.

Retry:

$ CPPFLAGS="-I/var/usb/usb_1/include" ./configure --build=i686-pc-linux-gnu --host=mipsel-linux --target=mipsel-linux --prefix=/var/usb/usb_1
...
checking for GNUTLS... no
No package 'gnutls' found
configure: error: Couldn't find required GnuTLS installation

Fine, let's get GnuTLS working first. Furthermore, ./configure --help reveals that some more libraries are needed by jabberd:
--with-libidn=DIR       Where to find libidn (required)
--with-libpth=DIR       Where to find libpth (required)
--with-expat=DIR        Where to find libexpat (required)


In addition GnuTLS requires some other libraries, libtasn1 and libgcrypt, so let's get them all first.


3. GNU Portable Threads
$ cd ..
$ wget ftp://ftp.gnu.org/gnu/pth/pth-2.0.7.tar.gz
$ tar xvf pth-2.0.7.tar.gz
$ cd pth-2.0.7
$ ./configure --build=i686-pc-linux-gnu --host=mipsel-linux --target=mipsel-linux --prefix=/var/usb/usb_1
$ make
$ make install

4. Expat XML Parser
$ cd ..
$ wget http://downloads.sourceforge.net/expat/expat-2.0.1.tar.gz?modtime=1181083143&big_mirror=0
$ tar xvf expat-2.0.1.tar.gz
$ cd expat-2.0.1
$ ./configure --build=i686-pc-linux-gnu --host=mipsel-linux --target=mipsel-linux --prefix=/var/usb/usb_1
$ make
$ make install

5. GNU IDN Library - Libidn
$ cd ..
$ wget ftp://alpha.gnu.org/pub/gnu/libidn/libidn-1.8.tar.gz
$ tar xvf libidn-1.8.tar.gz
$ cd libidn-1.8
$ ./configure --build=i686-pc-linux-gnu --host=mipsel-linux --target=mipsel-linux --prefix=/var/usb/usb_1
$ make
$ make install

6. Tiny ASN.1 library - Libtasn1
$ cd ..
$ wget http://josefsson.org/gnutls/releases/libtasn1/libtasn1-1.4.tar.gz
$ tar xvf libtasn1-1.4.tar.gz
$ cd libtasn1-1.4
$ ./configure --build=i686-pc-linux-gnu --host=mipsel-linux --target=mipsel-linux --prefix=/var/usb/usb_1
$ make
$ make install

To save me from
checking for gpg-error-config... no
checking for GPG Error - version >= 1.4... no
configure: error: libgpg-error is needed.
See ftp://ftp.gnupg.org/gcrypt/libgpg-error/ .


when configuring libgcrypt, libgpg-error has to be done in advance.


7. libgpg-error
$ cd ..
$ wget ftp://ftp.gnupg.org/gcrypt/libgpg-error/libgpg-error-1.6.tar.bz2
$ tar xvf libgpg-error-1.6.tar.bz2
$ cd libgpg-error-1.6
$ ./configure --build=i686-pc-linux-gnu --host=mipsel-linux --target=mipsel-linux --prefix=/var/usb/usb_1
$ make
$ make install

8. libgcrypt
$ cd ..
$ wget ftp://ftp.gnupg.org/gcrypt/libgcrypt/libgcrypt-1.4.1.tar.gz
$ tar xvf libgcrypt-1.4.1.tar.gz
$ cd libgcrypt-1.4.1

The path to libggpg-error has to be specified explicitly:
$ ./configure --build=i686-pc-linux-gnu --host=mipsel-linux --target=mipsel-linux --prefix=/var/usb/usb_1 --with-gpg-error-prefix=/var/usb/usb_1 --with-pth-prefix=/var/usb/usb_1

But it still does not help!:
$ make
...
/opt/toolchains/uclibc-crosstools/bin/mipsel-uclibc-gcc -I/var/usb/usb_1/include -I/opt/toolchains/uclibc-crosstools/include/c++/3.4.2 -I/opt/toolchains/uclibc-crosstools/mips-linux/sys-include -I/var/usb/usb_1/include -I/home/hajma/Documents/GPL_AM604G_ForRussia/GENERIC_6348_WLAN_A34_3-06-02-01/kernel/linux/include -I/var/usb/usb_1/include/ncurses -Wall -Wpointer-arith -o .libs/version version.o  -L/opt/toolchains/uclibc-crosstools/lib/gcc/mips-linux/3.4.2 -L/var/usb/usb_1/lib ../src/.libs/libgcrypt.so -Wl,--rpath -Wl,/var/usb/usb_1/lib
/opt/toolchains/uclibc-crosstools_gcc-3.4.2_uclibc-20050502/bin/../lib/gcc/mips-linux-uclibc/3.4.2/../../../../mips-linux-uclibc/bin/ld: warning: libgpg-error.so.0, needed by ../src/.libs/libgcrypt.so, not found (try using -rpath or -rpath-link)
../src/.libs/libgcrypt.so: undefined reference to `gpg_err_code_from_syserror'
../src/.libs/libgcrypt.so: undefined reference to `gpg_err_code_from_errno'
../src/.libs/libgcrypt.so: undefined reference to `gpg_strerror'
../src/.libs/libgcrypt.so: undefined reference to `gpg_strsource'
collect2: ld returned 1 exit status
make[2]: *** [version] Error 1
make[2]: Leaving directory `/home/hajma/Dokumenty/GPL_AM604G_ForRussia/GENERIC_6348_WLAN_A34_3-06-02-01/userapps/opensource/libgcrypt-1.4.1/tests'
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory `/home/hajma/Dokumenty/GPL_AM604G_ForRussia/GENERIC_6348_WLAN_A34_3-06-02-01/userapps/opensource/libgcrypt-1.4.1'
make: *** [all] Error 2
$

I found out the guys at OpenWRT had the same problem and have a patch available.
I wanted to file a bug to the GnuPG bug tracker, but did not receive the confirmation mail when registering...
Actually this was told to the author two years ago and he does not care at all.

So here goes the needed modification:
$ diff -u tests/Makefile.in.old tests/Makefile.in
--- tests/Makefile.in.old       2008-06-12 00:01:05.000000000 +0200
+++ tests/Makefile.in   2008-06-12 00:01:11.000000000 +0200
@@ -313,7 +313,7 @@
# a built header.
AM_CPPFLAGS = -I../src -I$(top_srcdir)/src
AM_CFLAGS = $(GPG_ERROR_CFLAGS)
-LDADD = ../src/libgcrypt.la
+LDADD = ../src/libgcrypt.la @LTLIBOBJS@ @GPG_ERROR_LIBS@
# pkbench uses mmap for no good reason.  Needs to be fixed.  Code for
# this can be found in libksba/tests.

and try again:
$ make clean
$ ./configure --build=i686-pc-linux-gnu --host=mipsel-linux --target=mipsel-linux --prefix=/var/usb/usb_1 --with-gpg-error-prefix=/var/usb/usb_1 --with-pth-prefix=/var/usb/usb_1
$ make
$ make install

9. The GNU Transport Layer Security Library
$ cd ..
$ wget ftp://ftp.gnutls.org/pub/gnutls/gnutls-2.2.5.tar.bz2
$ tar xvf gnutls-2.2.5.tar.bz2
$ cd gnutls-2.2.5

To prevent a configure error
checking for libgcrypt-config... no
checking for LIBGCRYPT - version >= 1.2.4... no
configure: error:
***
*** libgcrypt was not found. You may want to get it from
*** ftp://ftp.gnupg.org/gcrypt/libgcrypt/
***

the prefix to libgcrypt has to be specified (and libtasn1 too, to avoid using the built-in one):
$ ./configure --build=i686-pc-linux-gnu --host=mipsel-linux --target=mipsel-linux --prefix=/var/usb/usb_1 --with-libgcrypt-prefix=/var/usb/usb_1 --with-libtasn1-prefix=/var/usb/usb_1

but it still does not work:
$ make
...
/opt/toolchains/uclibc-crosstools/bin/mipsel-uclibc-gcc -std=gnu99 -I/opt/toolchains/uclibc-crosstools/include/c++/3.4.2 -I/opt/toolchains/uclibc-crosstools/mips-linux/sys-include -I/var/usb/usb_1/include -I/home/hajma/Documents/GPL_AM604G_ForRussia/GENERIC_6348_WLAN_A34_3-06-02-01/kernel/linux/include -I/var/usb/usb_1/include/ncurses -D_REENTRANT -D_THREAD_SAFE -pipe -I/var/usb/usb_1/include -I/opt/toolchains/uclibc-crosstools/include/c++/3.4.2 -I/opt/toolchains/uclibc-crosstools/mips-linux/sys-include -I/var/usb/usb_1/include -I/home/hajma/Documents/GPL_AM604G_ForRussia/GENERIC_6348_WLAN_A34_3-06-02-01/kernel/linux/include -I/var/usb/usb_1/include/ncurses -D_REENTRANT -D_THREAD_SAFE -o ex-cert-select ex-cert-select.o  -L/opt/toolchains/uclibc-crosstools/lib/gcc/mips-linux/3.4.2 -L/var/usb/usb_1/lib ./.libs/libexamples.a ../../gl/.libs/libgnu.a /var/usb/usb_1/lib/libgcrypt.so /var/usb/usb_1/lib/libgpg-error.so ../../lib/.libs/libgnutls.so ../../libextra/.libs/libgnutls-extra.so  -Wl,--rpath -Wl,/var/usb/usb_1/lib -Wl,--rpath -Wl,/home/hajma/Dokumenty/GPL_AM604G_ForRussia/GENERIC_6348_WLAN_A34_3-06-02-01/userapps/opensource/gnutls-2.2.5/lib/.libs -Wl,--rpath -Wl,/home/hajma/Dokumenty/GPL_AM604G_ForRussia/GENERIC_6348_WLAN_A34_3-06-02-01/userapps/opensource/gnutls-2.2.5/libextra/.libs -Wl,--rpath -Wl,/var/usb/usb_1/lib
/opt/toolchains/uclibc-crosstools_gcc-3.4.2_uclibc-20050502/bin/../lib/gcc/mips-linux-uclibc/3.4.2/../../../../mips-linux-uclibc/bin/ld: warning: libtasn1.so.3, needed by ../../lib/.libs/libgnutls.so, not found (try using -rpath or -rpath-link)
../../lib/.libs/libgnutls.so: undefined reference to `asn1_write_value@LIBTASN1_0_3'
../../lib/.libs/libgnutls.so: undefined reference to `asn1_delete_structure@LIBTASN1_0_3'
../../lib/.libs/libgnutls.so: undefined reference to `asn1_get_length_der@LIBTASN1_0_3'
../../lib/.libs/libgnutls.so: undefined reference to `asn1_get_tag_der@LIBTASN1_0_3'
../../lib/.libs/libgnutls.so: undefined reference to `asn1_der_decoding_startEnd@LIBTASN1_0_3'
../../lib/.libs/libgnutls.so: undefined reference to `asn1_der_decoding@LIBTASN1_0_3'
../../lib/.libs/libgnutls.so: undefined reference to `asn1_create_element@LIBTASN1_0_3'
../../lib/.libs/libgnutls.so: undefined reference to `asn1_copy_node@LIBTASN1_0_3'
../../lib/.libs/libgnutls.so: undefined reference to `asn1_read_value@LIBTASN1_0_3'
../../lib/.libs/libgnutls.so: undefined reference to `asn1_number_of_elements@LIBTASN1_0_3'
../../lib/.libs/libgnutls.so: undefined reference to `asn1_array2tree@LIBTASN1_0_3'
../../lib/.libs/libgnutls.so: undefined reference to `asn1_check_version@LIBTASN1_0_3'
../../lib/.libs/libgnutls.so: undefined reference to `asn1_find_node@LIBTASN1_0_3'
../../lib/.libs/libgnutls.so: undefined reference to `asn1_find_structure_from_oid@LIBTASN1_0_3'
../../lib/.libs/libgnutls.so: undefined reference to `asn1_der_coding@LIBTASN1_0_3'
collect2: ld returned 1 exit status
make[4]: *** [ex-cert-select] Error 1
make[4]: Leaving directory `/home/hajma/Dokumenty/GPL_AM604G_ForRussia/GENERIC_6348_WLAN_A34_3-06-02-01/userapps/opensource/gnutls-2.2.5/doc/examples'
make[3]: *** [all-recursive] Error 1
make[3]: Leaving directory `/home/hajma/Dokumenty/GPL_AM604G_ForRussia/GENERIC_6348_WLAN_A34_3-06-02-01/userapps/opensource/gnutls-2.2.5/doc'
make[2]: *** [all] Error 2
make[2]: Leaving directory `/home/hajma/Dokumenty/GPL_AM604G_ForRussia/GENERIC_6348_WLAN_A34_3-06-02-01/userapps/opensource/gnutls-2.2.5/doc'
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory `/home/hajma/Dokumenty/GPL_AM604G_ForRussia/GENERIC_6348_WLAN_A34_3-06-02-01/userapps/opensource/gnutls-2.2.5'
make: *** [all] Error 2

After some experimentation (I told you I am no programmer) I found the following to work:
$ LIBS="-ltasn1 $LIBS" ./configure --build=i686-pc-linux-gnu --host=mipsel-linux --target=mipsel-linux --prefix=/var/usb/usb_1 --with-libgcrypt-prefix=/var/usb/usb_1 --with-libtasn1-prefix=/var/usb/usb_1
$ make
$ make install


Also I found that the two official mirrors have both different directory structure, so I was missing the devel branch of GnuTLS. The above works with http://www.gnu.org/software/gnutls/releases/gnutls-2.3.14.tar.bz2 (and breaks with 2.2.5).


1c. jabberd

Let's not try to find more bugs and specify the needed components to the configure script now:
$ cd ../jabberd14-1.6.1.1
$ CPPFLAGS="-I/var/usb/usb_1/include" ./configure --build=i686-pc-linux-gnu --host=mipsel-linux --target=mipsel-linux --prefix=/var/usb/usb_1 --with-libidn=/var/usb/usb_1 --with-libpth=/var/usb/usb_1 --with-expat=/var/usb/usb_1

but still bad luck:
checking for GnuTLS... checking for mipsel-linux-pkg-config... no
checking for pkg-config... /usr/bin/pkg-config
configure: WARNING: In the future, Autoconf will not detect cross-tools
whose name does not start with the host triplet.  If you think this
configuration is useful to you, please write to autoconf@gnu.org.
checking pkg-config is at least version 0.9.0... yes
checking for GNUTLS... no
No package 'gnutls' found
configure: error: Couldn't find required GnuTLS installation

And again, reported a year ago.
We can fix that, but the show is still not at the end:
$ PKG_CONFIG_PATH=/var/usb/usb_1/lib/pkgconfig CPPFLAGS="-I/var/usb/usb_1/include" ./configure --build=i686-pc-linux-gnu --host=mipsel-linux --target=mipsel-linux --prefix=/var/usb/usb_1 --with-libidn=/var/usb/usb_1 --with-libpth=/var/usb/usb_1 --with-expat=/var/usb/usb_1
...
checking for GnuTLS... checking for mipsel-linux-pkg-config... no
checking for pkg-config... /usr/bin/pkg-config
configure: WARNING: In the future, Autoconf will not detect cross-tools
whose name does not start with the host triplet.  If you think this
configuration is useful to you, please write to autoconf@gnu.org.
checking pkg-config is at least version 0.9.0... yes
checking for GNUTLS... yes
checking for TLS 1.2 support in GnuTLS... yes
checking for GNUTLSEXTRA... yes
checking idna.h usability... yes
checking idna.h presence... yes
checking for idna.h... yes
checking for stringprep_check_version in -lidn... no
configure: error: Couldn't find required libidn installation

Quick look into config.log reveals something familiar:
/opt/toolchains/uclibc-crosstools_gcc-3.4.2_uclibc-20050502/bin/../lib/gcc/mips-linux-uclibc/3.4.2/../../../../mips-linux-uclibc/bin/ld: warning: libtasn1.so.3, needed by /var/usb/usb_1/lib/libgnutls-extra.so, not found (try using -rpath or -rpath-link)
/var/usb/usb_1/lib/libgnutls.so: undefined reference to `asn1_write_value@LIBTASN1_0_3'
/var/usb/usb_1/lib/libgnutls.so: undefined reference to `gcry_sexp_release@GCRYPT_1.2'
...

Let's see if the GnuTLS fix works here as well:
LIBS="-ltasn1 $LIBS" PKG_CONFIG_PATH=/var/usb/usb_1/lib/pkgconfig CPPFLAGS="-I/var/usb/usb_1/include" ./configure --build=i686-pc-linux-gnu --host=mipsel-linux --target=mipsel-linux --prefix=/var/usb/usb_1 --with-libidn=/var/usb/usb_1 --with-libpth=/var/usb/usb_1 --with-expat=/var/usb/usb_1
...
checking for stringprep_check_version in -lidn... no

No, it doesn't :-(, but config.log reveals we got one step further:
...
/opt/toolchains/uclibc-crosstools/bin/mipsel-uclibc-g++ -o conftest -g -O2 -I/va
r/usb/usb_1/include -I/var/usb/usb_1/include -I/var/usb/usb_1/include -I/var/usb
/usb_1/include conftest.cpp  -L/var/usb/usb_1/lib /var/usb/usb_1/lib/libgnutls-e
xtra.so /var/usb/usb_1/lib/libgnutls.so /var/usb/usb_1/lib/libidn.so -lresolv /v
ar/usb/usb_1/lib/libtasn1.so -L/opt/toolchains/uclibc-crosstools/lib/gcc/mips-li
nux/3.4.2 -ldl -Wl,--rpath -Wl,/var/usb/usb_1/lib -Wl,--rpath -Wl,/var/usb/usb_1
/lib
/opt/toolchains/uclibc-crosstools_gcc-3.4.2_uclibc-20050502/bin/../lib/gcc/mips-
linux-uclibc/3.4.2/../../../../mips-linux-uclibc/bin/ld: warning: libgcrypt.so.1
1, needed by /var/usb/usb_1/lib/libgnutls-extra.so, not found (try using -rpath
or -rpath-link)
...

Finally, this works:
LIBS="-ltasn1 -lgpg-error -lgcrypt $LIBS" PKG_CONFIG_PATH=/var/usb/usb_1/lib/pkgconfig CPPFLAGS="-I/var/usb/usb_1/include" ./configure --build=i686-pc-linux-gnu --host=mipsel-linux --target=mipsel-linux --prefix=/var/usb/usb_1 --with-libidn=/var/usb/usb_1 --with-libpth=/var/usb/usb_1 --with-expat=/var/usb/usb_1

but make fails:
$ make
...
/var/usb/usb_1/include/gnutls/openpgp.h: In function `void mio_tls_process_credentials(xmlnode_t*, const std::list<std::string, std::allocator<std::string> >&, const std::list<std::string, std::allocator<std::string> >&, gnutls_dh_params_int*, const std::list<std::string, std::allocator<std::string> >&, const std::list<std::string, std::allocator<std::string> >&)':
/var/usb/usb_1/include/gnutls/openpgp.h:247: error: too few arguments to function `int gnutls_certificate_set_openpgp_key_file(gnutls_certificate_credentials_st*, const char*, const char*, gnutls_openpgp_crt_fmt_t)'
mio_tls.cc:615: error: at this point in file
/var/usb/usb_1/include/gnutls/openpgp.h:271: error: too few arguments to function `int gnutls_certificate_set_openpgp_keyring_file(gnutls_certificate_credentials_st*, const char*, gnutls_openpgp_crt_fmt_t)'
mio_tls.cc:634: error: at this point in file
mio_tls.cc:653: error: `gnutls_certificate_set_openpgp_trustdb' undeclared (first use this function)
mio_tls.cc:653: error: (Each undeclared identifier is reported only once for each function it appears in.)
make[3]: *** [mio_tls.lo] Error 1
make[3]: Leaving directory `/home/hajma/Dokumenty/GPL_AM604G_ForRussia/GENERIC_6348_WLAN_A34_3-06-02-01/userapps/opensource/jabberd14-1.6.1.1/jabberd'
make[2]: *** [all-recursive] Error 1
make[2]: Leaving directory `/home/hajma/Dokumenty/GPL_AM604G_ForRussia/GENERIC_6348_WLAN_A34_3-06-02-01/userapps/opensource/jabberd14-1.6.1.1/jabberd'
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory `/home/hajma/Dokumenty/GPL_AM604G_ForRussia/GENERIC_6348_WLAN_A34_3-06-02-01/userapps/opensource/jabberd14-1.6.1.1'
make: *** [all] Error 2

This turned out to be easy, the Gentoo folks found and patched it couple of months ago (and it looks it is in the jabberd cvs now) and after applying it, the journey ends:
$ make
$ make install


Wow, congratulations!!


Let's get an editor so that we can modify the config files in place:


10a. vim
$ cd ..
$ wget ftp://ftp.vim.org/pub/vim/unix/vim-7.1.tar.bz2
$ tar xvf vim-7.1.tar.bz2
$ cd vim71
$ ./configure --build=i686-pc-linux-gnu --host=mipsel-linux --target=mipsel-linux --prefix=/var/usb/usb_1 --with-features=tiny
...
checking for strip... strip
configure: error: cannot compile a simple program, check CC and CFLAGS
(cross compiling doesn't work)

Would you expect an opensource app as big and widespread as Vim to be so broken? I would now. Fortunately the OpenWRT and FreeWRT people come to help again.
$ wget --no-check-certificate https://dev.openwrt.org/browser/packages/utils/vim/patches/001-cross_compile.patch?format=txt
$ patch -p1 <001-cross_compile.patch\?format\=txt
$ ./configure --build=i686-pc-linux-gnu --host=mipsel-linux --target=mipsel-linux --prefix=/var/usb/usb_1 --with-features=tiny
...
checking --with-tlib argument... empty: automatic terminal library selection
checking for tgetent in -lncurses... no
checking for tgetent in -ltermlib... no
checking for tgetent in -ltermcap... no
checking for tgetent in -lcurses... no
no terminal library found
checking for tgetent()... configure: error: NOT FOUND!
You need to install a terminal library; for example ncurses.
Or specify the name of the library with --with-tlib.

Seems some terminal library is needed ...
11. The Ncurses (new curses) library
$ cd ..
$ wget http://ftp.gnu.org/pub/gnu/ncurses/ncurses-5.6.tar.gz
$ tar xvf ncurses-5.6.tar.gz
$ cd ncurses-5.6
$ ./configure --build=i686-pc-linux-gnu --host=mipsel-linux --target=mipsel-linux --prefix=/var/usb/usb_1
$ make
$ make install

10b. vim
$ cd ../vim71
$ ./configure --build=i686-pc-linux-gnu --host=mipsel-linux --target=mipsel-linux --prefix=/var/usb/usb_1 --with-features=tiny
...
checking for tgetent in -lncurses... yes
ncurses library is not usable
checking for tgetent in -ltermlib... no
checking for tgetent in -ltermcap... no
checking for tgetent in -lcurses... no
no terminal library found
checking for tgetent()... configure: error: NOT FOUND!
You need to install a terminal library; for example ncurses.
Or specify the name of the library with --with-tlib.

seems we have to force it:
$ ./configure --build=i686-pc-linux-gnu --host=mipsel-linux --target=mipsel-linux --prefix=/var/usb/usb_1 --with-features=tiny --with-tlib=ncurses
$ make
...
Starting make in the src directory.
If there are problems, cd to the src directory and run make there
cd src && make first
make[1]: Entering directory `/home/hajma/Dokumenty/GPL_AM604G_ForRussia/GENERIC_6348_WLAN_A34_3-06-02-01/userapps/opensource/vim71/src'
CC="/opt/toolchains/uclibc-crosstools/bin/mipsel-uclibc-gcc -Iproto -DHAVE_CONFIG_H   -I/var/usb/usb_1        " srcdir=. sh ./osdef.sh
osdef0.c:10:44: termcap.h: No such file or directory
...
In file included from term.c:33:
/var/usb/usb_1/include/ncurses/termcap.h:64: error: conflicting types for 'tgoto'
...

hmm, I guess I really need to use the CPPFLAGS, shouldn't I modify the environment file? Perhaps, but now it's too late, it's finished:
$ make distclean
$ CPPFLAGS="-I/var/usb/usb_1/include/ncurses" ./configure --build=i686-pc-linux-gnu --host=mipsel-linux --target=mipsel-linux --prefix=/var/usb/usb_1 --with-features=tiny --with-tlib=ncurses --disable-gui --disable-gtktest --disable-xim --without-x --disable-multibyte --disable-netbeans --disable-cscope --disable-gpm
$ make
$ make install
...
strip /var/usb/usb_1/bin/vim
strip: Unable to recognise the format of the input file `/var/usb/usb_1/bin/vim'
make[1]: *** [installvimbin] Error 1
make[1]: Leaving directory `/home/hajma/Dokumenty/GPL_AM604G_ForRussia/GENERIC_6348_WLAN_A34_3-06-02-01/userapps/opensource/vim71/src'
make: *** [install] Error 2

No, it's not finished... Let's just hack it:
$ diff -u src/Makefile.old src/Makefile
--- src/Makefile.old    2008-06-17 02:16:32.000000000 +0200
+++ src/Makefile        2008-06-17 02:16:47.000000000 +0200
@@ -999,7 +999,7 @@
INSTALL_DATA_R = cp -r
### Program to run on installed binary
-#STRIP = strip
+STRIP = echo
### Permissions for binaries  {{{1
BINMOD = 755
$ make install


I was quite surprised with the size of some files. Performing

/opt/toolchains/uclibc-crosstools/bin/mipsel-linux-sstrip
on bin/ and lib/ helped a bit, but 1MB of vim suggests there's still place for optimizations.



Final creation and writing of the squashfs image:


# /home/hajma/Dokumenty/asus/squashfs2.0r2/squashfs-tools/mksquashfs /var/usb/usb_1 /tmp/new.sqsh -be -noI -noD -noF
# dd if=/tmp/new.sqsh of=/dev/sda1

In the next part I'll try to correctly configure jabberd and make it start at router boot.



Customizing Asus AM200g - V. firmware modification

Customizing Asus AM200g - IV. jabberd configuration

Customizing Asus AM200g - II. Preparing the environment

Customizing Asus AM200g - I. PREPARATION

Monday, June 2, 2008

Customizing Asus AM200g - II. Preparing the environment

I know I promised you a jabber server, but in the end it was not so easy and the entry would be perhaps too long, so let's start with simple stuff :-)


Note I am not a programmer, have no C skills, so there can be a glitch here and there, but in the end all steps below led me to something that worked. If you find something really nasty, please let me know.

I took most of the inspiration at Daniel Fišer's page on Asus WL-600g hacking and just tweaked it to suit my setup.

1. On a fresh Mandriva 2008.1 installation some of the necessary tools are missing. Install them as root:

# urpmi make gcc autoconf automake


2. Since Asus still did not release the sources for AM200g, I used the GPL setup provided for AM604g, which uses the same chipset and seems to be almost identical (it even comes in the same box, except for missing USB port and second antenna). Follow these steps to install it:

$ wget http://dlsvr02.asus.com/pub/ASUS/Broadband/xDSL/GPL_AM604G_ForRussia.zip
$ unzip GPL_AM604G_ForRussia.zip
$ cd GPL_AM604G_ForRussia
$ tar xvf GENERIC_6348_WLAN_A34_3-06-02-01_GPL.tar.gz
$ su
# ./consumer_install

3. Not surprisingly, the AM604g source is just as broken as the AM600g one, so the same steps as described by Daniel need to be done:

# cd /opt/toolchains/uclibc-crosstools/bin
# for A in mips-linux-uclibc-* ; do
> ln -s ${A} mipsel-uclibc-${A#mips-linux-uclibc-}
> done
# cd /home/hajma/Documents/GPL_AM604G_ForRussia/GENERIC_6348_WLAN_A34_3-06-02-01
# wget http://daniel.fiser.cz/IT/asus_WL-600g/cur_menu.patch
# patch -p0 <cur_menu.patch


4. Now you can try to build the firmware, just for fun:

# make PROFILE=GENERIC_6348_WLAN_A34

The firmware is created in the images directory. Since I have no replacement for the router, I'm not going to try it, although it might actually work.

5. To prepare the environment, create a file containing:

$ cat environment
TOOLCHAINS_HOME=/opt/toolchains/uclibc-crosstools
export LIBS="-L${TOOLCHAINS_HOME}/lib/gcc/mips-linux/3.4.2"
export INCLUDES="-I${TOOLCHAINS_HOME}/include/c++/3.4.2 \
-I${TOOLCHAINS_HOME}/mips-linux/sys-include \
-I/home/hajma/Documents/GPL_AM604G_ForRussia/GENERIC_6348_WLAN_A34_3-06-02-01/kernel/linux/include"
export CFLAGS="${INCLUDES} ${LIBS} -static"
export LDFLAGS="-static"
export CC="${TOOLCHAINS_HOME}/bin/mipsel-uclibc-gcc"
export LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:${TOOLCHAINS_HOME}/lib
export PATH="${PATH}:${TOOLCHAINS_HOME}/bin"

and set the environment before doing anything else:
# . ./environment

(yes, this is "dot space dot ...")

6. Let's proceed to the helloworld example. Create it's own folder:

mkdir /home/hajma/Documents/GPL_AM604G_ForRussia/GENERIC_6348_WLAN_A34_3-06-02-01/userapps/opensource/helloworld

and follow the steps described in the automake manual:

Create the following files in an empty directory.

  • src/main.c is the source file for the hello program. We
    store it in the src/ subdirectory, because later, when the package
    evolves, it will ease the addition of a man/ directory for man
    pages, a data/ directory for data files, etc.
    ~/amhello % cat src/main.c
    #include <config.h>
    #include <stdio.h>
    int
    main (void)
    {
    puts ("Hello World!");
    puts ("This is " PACKAGE_STRING ".");
    return 0;
    }
    

  • README contains some very limited documentation for our little
    package.
    ~/amhello % cat README
    This is a demonstration package for GNU Automake.
    Type `info Automake' to read the Automake manual.
    

  • Makefile.am and src/Makefile.am contain Automake
    instructions for these two directories.
    ~/amhello % cat src/Makefile.am
    bin_PROGRAMS = hello
    hello_SOURCES = main.c
    ~/amhello % cat Makefile.am
    SUBDIRS = src
    dist_doc_DATA = README
    

  • Finally, configure.ac contains Autoconf instructions to
    create the configure script.
    ~/amhello % cat configure.ac
    AC_INIT([amhello], [1.0], [bug-automake@gnu.org])
    AM_INIT_AUTOMAKE([-Wall -Werror foreign])
    AC_PROG_CC
    AC_CONFIG_HEADERS([config.h])
    AC_CONFIG_FILES([
    Makefile
    src/Makefile
    ])
    AC_OUTPUT
    

Once you have these five files, it is time to run the Autotools to instantiate the build system. Do this using the autoreconf command as follows:
~/amhello % autoreconf --install
configure.ac: installing `./install-sh'
configure.ac: installing `./missing'
src/Makefile.am: installing `./depcomp'
At this point the build system is complete.
In addition to the three scripts mentioned in its output, you can see that autoreconf created four other files: configure, config.h.in, Makefile.in, and src/Makefile.in. The latter three files are templates that will be adapted to the system by configure under the names config.h, Makefile, and src/Makefile. Let's do this:
In addition to the manual's instructions, the details of host architecture must be provided when compiling for another platform. Also I set the prefix as the flash drive gets mounted as /var/usb/usb_1:
# ./configure --build=i686-pc-linux-gnu --host=mipsel-linux --target=mipsel-linux --prefix=/var/usb/usb_1/hello
# make
# make install
7. Optionally you can strip (remove all unnecessary bits) the binary:
# cd /var/usb/usb_1/hello/bin
# /opt/toolchains/uclibc-crosstools/bin/mipsel-uclibc-strip -o hellostripped hello
8. Copy the files to the flash:
# /home/hajma/Documents/squashfs2.0r2/squashfs-tools/mksquashfs /var/usb/usb_1 /tmp/dir.sqsh -be -noI -noD -noF
# dd if=/tmp/dir.sqsh of=/dev/sdb1
9. Plug the flash drive to the router and verify all runs fine:
$ telnet 192.168.1.1
Trying 192.168.1.1...
Connected to 192.168.1.1 (192.168.1.1).
Escape character is '^]'.
BCM96348 ADSL Router
Login: admin
Password:
> sh
BusyBox v1.00 (2005.04.12-18:11+0000) Built-in shell (msh)
Enter 'help' for a list of built-in commands.
# cd /var/usb/usb_1/hello/bin
# ./hello
Hello World!
This is amhello 1.0.
# ./hellostripped
Hello World!
This is amhello 1.0.
Final note: if you get "hello: applet not found" instead, it means you somehow did not compile the program for correct platform and BusyBox was not able to execute it.
Customizing Asus AM200g - V. firmware modification Customizing Asus AM200g - IV. jabberd configuration Customizing Asus AM200g - III. jabberd and vim Customizing Asus AM200g - I. PREPARATION

Tuesday, May 20, 2008

Customizing Asus AM200g - I. PREPARATION


As a fresh ADSL subscriber I became the owner of Asus AM200g ADSL modem/wireless router. The box is quite powerful - it is run by a 256 MHz processor, has 16 MB of RAM and is running Linux, so I'd like to use it for some other useful tasks. Since Asus has not yet released the source code it's not going to be that easy.



I want to touch the original firmware the least possible, so I'm going to add everything to an attached flash drive.
But the firmware only supports vfat and squashfs! Because of vfat filesystem limitations I decided to use a squashfs partition to store program files and a vfat one to store data that need to be modified, let's see how it works out. Note that all is done using Mandriva Linux 2008.1.



# urpmi squashfs-tools
$ mksquashfs /tmp/directory /tmp/dir.sqsh
Parallel mksquashfs: Using 1 processor
Creating little endian 3.1 filesystem on /tmp/dir.sqsh, block size 131072.
[==============================================================] 6136/6136 100%
Exportable Little endian filesystem, data block size 131072, compressed data, compressed metadata, compressed fragments, duplicates are removed
Filesystem size 4586.44 Kbytes (4.48 Mbytes)
8.61% of uncompressed filesystem size (53255.07 Kbytes)
Inode table size 53222 bytes (51.97 Kbytes)
23.13% of uncompressed inode table size (230058 bytes)
Directory table size 73178 bytes (71.46 Kbytes)
31.71% of uncompressed directory table size (230774 bytes)
Number of duplicate files found 3581
Number of inodes 7327
Number of files 6092
Number of fragments 224
Number of symbolic links  0
Number of device nodes 0
Number of fifo nodes 0
Number of socket nodes 0
Number of directories 1235
Number of uids 1
hajma (500)
Number of gids 0

Now I wrote the created image to the flash drive's first partition:
# dd if=/tmp/dir.sqsh of=/dev/sdb1

Rather surprisingly, the firmware only supports squashfs v2.0, so after plugging the flash to the router, it shows in the logs
kernel: SQUASHFS error: Major/Minor mismatch, filesystem is (3:1), I support (1 : x) or (2 : <= 0)
and in addition squashfs v3 does not support creating v2 images. Oh fsck. So I downloaded squashfs2.0-r2.tar.gz and
# urpmi make
# urpmi zlib1-devel
$ tar -xvf squashfs2.0-r2.tar.gz # note that tar now automatically gunzips the file too!
$ cd squashfs2.0-r2/squashfs-tools/
$ make
cc -I. -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -O2   -c -o mksquashfs.o mksquashfs.c
mksquashfs.c: In function ‘create_inode’:
mksquashfs.c:476: warning: integer constant is too large for ‘long’ type
mksquashfs.c:489: error: lvalue required as left operand of assignment
mksquashfs.c:541: warning: integer constant is too large for ‘long’ type
mksquashfs.c:546: warning: integer constant is too large for ‘long’ type
mksquashfs.c:549: error: lvalue required as left operand of assignment
mksquashfs.c:568: warning: integer constant is too large for ‘long’ type
mksquashfs.c: In function ‘write_file’:
mksquashfs.c:1030: warning: integer constant is too large for ‘long’ type
mksquashfs.c:1096: warning: integer constant is too large for ‘long’ type
mksquashfs.c: In function ‘dir_scan’:
mksquashfs.c:1275: warning: integer constant is too large for ‘long’ type
mksquashfs.c:1352: warning: integer constant is too large for ‘long’ type
make: *** [mksquashfs.o] Error 1
$
hmm, okay, the old crap does not want to be compiled with gcc 4 ...
# urpmi gcc3.3
$ CC=gcc-3.3.6 make
$ ./mksquashfs /tmp/directory /tmp/dir.sqsh
# dd if=/tmp/dir.sqsh of=/dev/sdb1
After plugging it into the router,
kernel: SQUASHFS: Mounting a different endian SQUASHFS filesystem on sda1
shows up in the logs. Okay, time to try
$ ./mksquashfs /tmp/directory /tmp/dir.sqsh -be
# dd if=/tmp/dir.sqsh of=/dev/sdb1
and I am getting one error message less! But I still see an ugly
kernel: SQUASHFS error: lzma_fs error while decompressing!
kernel: SQUASHFS error: Unable to read cache block [4bea97:7ae]
kernel: SQUASHFS error: Unable to read inode [4bea97:7ae]
kernel: SQUASHFS error: Root inode create failed" and it does not get mounted.
Googling reveals three links that do not help much. But since decompression is mentioned ... let's try to turn off compression ... :
$ ./mksquashfs /tmp/opends/src /tmp/dir.sqsh -be -noI -noD -noF
# dd if=/tmp/dir.sqsh of=/dev/sdb1
and voila, it gets mounted!
kernel: usb 1-1: new high speed USB device using address 7
kernel: scsi5 : SCSI emulation for USB Mass Storage devices
kernel: Vendor: USB 2.0 Model: Flash Disk Rev: 0.00
kernel: Type: Direct-Access ANSI SCSI revision: 02
kernel: SCSI device sda: 2047999 512-byte hdwr sectors (1049 MB)
kernel: sda: assuming Write Enabled
kernel: sda: assuming drive cache: write through
kernel: sda1 sda2
kernel: Attached scsi removable disk sda at scsi5, channel 0, id 0, lun 0
kernel: Attached scsi generic sg0 at scsi5, channel 0, id 0, lun 0, type 0
kernel: USB Mass Storage device found at 7
syslog: mkdir -p /var/usb/usb_1
syslog: mount /dev/sda1 /var/usb/usb_1
Next time I'll try to get a jabber server running, time to go sleep now. Customizing Asus AM200g - V. firmware modification Customizing Asus AM200g - IV. jabberd configuration Customizing Asus AM200g - III. jabberd and vim Customizing Asus AM200g - II. Preparing the environment

Sunday, May 18, 2008

Rychlost opravy chyb aneb úpadek Gnome a KDE

Před více než rokem jsem porovnával rychlost opravy chyb, a teď mě napadlo podívat se, jak se od té doby situace změnila.



Metodika zůstala stejná:



Vyberou se chyby z bugzilly za šestiměsíční období (leden-červen 2006 a květen-říjen 2007). Zajímavé jsou jen opravdové chyby, takže nepočítáme duplicity, neplatné chyby a chyby způsobené původním kódem (upstream). Pokud nebyla chyba opravena do 6 měsíců, počítá se jako neopravená.



Oproti původnímu srovnání jsem v Mandriví Bugzille počítal jen položku Mandriva Linux (i když ty ostatní položky měly dohromady jen pár desítek bugů) a v Novellí Bugzille jen položku openSUSE. Vynechal jsem RedHat, anžto jsem nakonec nějak nepochopil, jakým způsobem tu Bugzillu vedou.



A výsledek je na obrázcích.



Mandriva si polepšila, očividně je to důsledek změn, které zavedl Adam Williamson. (Nahlášená chyba je nejprve prozkoumána členy triage teamu, kteří se postarají, aby se nejednalo o duplicitu a aby hlášení obsahovalo všechny potřebné informace. Teprve pak je předána vývojářům, kteří tak neztrácejí čas.)



openSUSE je stabilní, Gentoo si mírně polepšilo.


Ale velké překvapení mě čekalo u KDE a Gnome.

U KDE očividně platilo, že chyba je buďto opravena v den nahlášení anebo nikdy. Teď silně polevili, a to i přes výrazně nižší počet hlášení.



Největší překvapení bylo ale u Gnome. Z 50% úspěšnosti se dostali na 16 %. Musí se ale uznat, že měli trochu těžší situaci - počet hlášení se jim ztrojnásobil a polovina z nich byly duplicity (<flame>tipnul bych si na ubunťáky - je jich hodně, mají Gnome jako default a mají vyšší podíl BFU</flame>) (za duplicity mohou hlavně automatická hlášení při pádu aplikací, hlavně od uživatelů Fedory a Ubuntu)


Data 2006


Data 2007

Data:


Mandriva old
(2006-01-01 - 2006-06-30)
Celkový počet chyb: 2634
Z nich nás ale zajímá jen: 2089
(Protože nepočítáme 215 DUPLICATE, 46 WORKSFORME, 175 INVALID, 74 WONTFIX a 35 REPORTEDUPSTREAM)
Neopraveno zůstalo: 1050
Opraveno bylo: 1039
Celkem bugů opravených do 1 dne: 207
Celkem bugů opravených do 7 dnů: 205
Celkem bugů opravených do 14 dnů: 85
Celkem bugů opravených do 30 dnů: 112
Celkem bugů opravených do 61 dnů: 127
Celkem bugů opravených do 183 dnů: 303
Mandriva new
(2007-05-01 - 2007-10-30)
Celkový počet chyb: 4174
Z nich nás ale zajímá jen: 3128
(Protože nepočítáme 479 DUPLICATE, 54 WORKSFORME, 306 INVALID, 154 WONTFIX a 53 REPORTEDUPSTREAM)
Neopraveno zůstalo: 1278
Opraveno bylo: 1850
Celkem bugů opravených do 1 dne: 334
Celkem bugů opravených do 7 dnů: 456
Celkem bugů opravených do 14 dnů: 201
Celkem bugů opravených do 30 dnů: 237
Celkem bugů opravených do 61 dnů: 192
Celkem bugů opravených do 183 dnů: 430
openSUSE old
Celkový počet chyb: 7005
Z nich nás ale zajímá jen: 4297
(Protože nepočítáme 1093 DUPLICATE, 263 WORKSFORME, 801 INVALID a 551 WONTFIX)
Neopraveno zůstalo: 1525
Opraveno bylo: 2772
Celkem bugů opravených do 1 dne: 474
Celkem bugů opravených do 7 dnů: 707
Celkem bugů opravených do 14 dnů: 337
Celkem bugů opravených do 30 dnů: 431
Celkem bugů opravených do 61 dnů: 359
Celkem bugů opravených do 183 dnů: 464
openSUSE new
Celkový počet chyb: 7368
Z nich nás ale zajímá jen: 4710
(Protože nepočítáme 1221 DUPLICATE, 294 WORKSFORME, 611 INVALID a 532 WONTFIX)
Neopraveno zůstalo: 1674
Opraveno bylo: 3036
Celkem bugů opravených do 1 dne: 457
Celkem bugů opravených do 7 dnů: 775
Celkem bugů opravených do 14 dnů: 389
Celkem bugů opravených do 30 dnů: 454
Celkem bugů opravených do 61 dnů: 425
Celkem bugů opravených do 183 dnů: 536
gentoo old
Celkový počet chyb: 20603
Z nich nás ale zajímá jen: 13871
(Protože nepočítáme 4179 DUPLICATE, 630 WORKSFORME, 1412 INVALID a 511 WONTFIX)
Neopraveno zůstalo: 5088
Opraveno bylo: 8783
Celkem bugů opravených do 1 dne: 2218
Celkem bugů opravených do 7 dnů: 2037
Celkem bugů opravených do 14 dnů: 851
Celkem bugů opravených do 30 dnů: 989
Celkem bugů opravených do 61 dnů: 1006
Celkem bugů opravených do 183 dnů: 1682
gentoo new
Celkový počet chyb: 13675
Z nich nás ale zajímá jen: 10103
(Protože nepočítáme 2153 DUPLICATE, 355 WORKSFORME, 763 INVALID a 301 WONTFIX)
Neopraveno zůstalo: 3348
Opraveno bylo: 6755
Celkem bugů opravených do 1 dne: 1557
Celkem bugů opravených do 7 dnů: 1518
Celkem bugů opravených do 14 dnů: 695
Celkem bugů opravených do 30 dnů: 855
Celkem bugů opravených do 61 dnů: 935
Celkem bugů opravených do 183 dnů: 1195
kde old
Celkový počet chyb: 10724
Z nich nás ale zajímá jen: 7142
(Protože nepočítáme 1364 DUPLICATE, 966 WORKSFORME, 995 INVALID a 257 WONTFIX)
Neopraveno zůstalo: 5176
Opraveno bylo: 1966
Celkem bugů opravených do 1 dne: 1731
Celkem bugů opravených do 7 dnů: 16
Celkem bugů opravených do 14 dnů: 0
Celkem bugů opravených do 30 dnů: 27
Celkem bugů opravených do 61 dnů: 85
Celkem bugů opravených do 183 dnů: 107
kde new
Celkový počet chyb: 6689
Z nich nás ale zajímá jen: 4612
(Protože nepočítáme 825 DUPLICATE, 425 WORKSFORME, 678 INVALID a 149 WONTFIX)
Neopraveno zůstalo: 3648
Opraveno bylo: 964
Celkem bugů opravených do 1 dne: 276
Celkem bugů opravených do 7 dnů: 145
Celkem bugů opravených do 14 dnů: 61
Celkem bugů opravených do 30 dnů: 81
Celkem bugů opravených do 61 dnů: 117
Celkem bugů opravených do 183 dnů: 284
gnome old
Celkový počet chyb: 20740
Z nich nás ale zajímá jen: 15018
(Protože nepočítáme 3809 DUPLICATE, 0 WORKSFORME, 406 INVALID, 695 NOTABUG, 481 NOTGNOME, 0 NOTXIMIAN a 331 WONTFIX)
Neopraveno zůstalo: 7627
Opraveno bylo: 7391
Celkem bugů opravených do 1 dne: 1843
Celkem bugů opravených do 7 dnů: 1753
Celkem bugů opravených do 14 dnů: 748
Celkem bugů opravených do 30 dnů: 908
Celkem bugů opravených do 61 dnů: 851
Celkem bugů opravených do 183 dnů: 1288
gnome new
Celkový počet chyb: 63421
Z nich nás ale zajímá jen: 35707
(Protože nepočítáme 25159 DUPLICATE, 0 WORKSFORME, 449 INVALID, 645 NOTABUG, 1184 NOTGNOME, 0 NOTXIMIAN a 277 WONTFIX)
Neopraveno zůstalo: 29887
Opraveno bylo: 5820
Celkem bugů opravených do 1 dne: 1447
Celkem bugů opravených do 7 dnů: 1262
Celkem bugů opravených do 14 dnů: 513
Celkem bugů opravených do 30 dnů: 620
Celkem bugů opravených do 61 dnů: 700
Celkem bugů opravených do 183 dnů: 1278

Monday, January 14, 2008

man-pages-cs 0.17.20080113


Chvilku jsem přemýšlel, jestli to dát jako zprávičku, ale jsem spíš zastánce linie "necpat do zpráviček každou betu", takže zaplácnu blog :-)



Vydal jsem novou verzi man-pages-cs-0.17.20080113.
Přišlo mi pár oprav a zlepšení, ať už přímo pro manuály nebo pro doprovodné skripty, díky za ně. Víceméně se ale jedná "jen" o aktualizaci k současné verzi originálních man-pages, na manuály z ostatních balíků jsem neměl čas :-(



Vypadá to ale, že oživení se podařilo.
Balík se dostal do hlavních distribucí - je v Mandrivě, Source Mage, openSUSE a teď už i v Debianu (takže i v Ubuntu?). Existuje ebuild pro Gentoo.
Od jednoho nadšence tu mám aktualizované a dopřeložené všechny manuály z coreutils, ale ještě potřebují revizi. Jen houšť a větší kapky!



Monday, January 7, 2008

Solaris na 40


I přes varování mé nejdražší jsem pokračoval v praxi odkládání literatury na pračku stojící před hajzlíkem, až se mi to, viď Jaromíre, nevyplatilo. Posuďte sami, co dokáže běžný prací prášek na 40:




Solaris by Lem after washing

Když už jsme u toho Solarisu, v čerstvě vydaném VirtualBoxu 1.5.4 už jde konečně nainstalovat a spustit, to jim to chlapcům trvalo ...


Solaris by Sun after boot

Dál - pod stromkem se objevily dvě placky. VCD Tradiční české pohádky a Čtyřlístek Vzhůru na myši. Momentální stav zprovoznění je tak 50/50.
VCD nefunguje menu, hudba v něm přeskakuje. Pohádky lze přehrát pouze pomocí 'mplayer vcd://x' , kde x je číslo stopy, kaffeine i xine jsou nepoužitelné. Naštěstí jsou pohádky dostatečně odpudivé a není důvod je spouštět.
Čtyřlístek se přes wine spustí v pořádku, dokonce i v DirectX modu, jenom nefunguje přehrávání řeči ... což je asi tak 80% smyslu toho CD ... Chvíli (n hodin) jsem hledal co a kde, ale na nic jsem nedošel.