26 February 2012

80. Compiling octave 3.6.1 on Debian Testing

I originally was hesitant towards building my own packages, not so much because it is difficult (well-maintained packages are easy to build using configure/make), but because you can end up with a system where dependencies break and you constantly have to manually track new releases of packages you want.

Having had to struggle with outdated or bug-ridden debian packages during the past year has made me change my mind. It obviously depends on what you use you computer for -- the debian packages are supposed to be of high quality and they do unarguably go through a lot of stability testing before being released down the chain from SID to Stable. But I also get the impression that some debian maintainers aren't...well...maintaining their packages sufficiently.

Take the alt+f2 gnome bug for example -- in an ideal world a fix should've been rolled out within 24 hours, rather than just waiting for future version increments to take care of it. The gnuplot bug is another example. There's no solution in sight, even though it has been solved in upstream. Maybe there are reasons to which I'm oblivious for this, but the end result is that I'm a lot more cautious with trusting the debian vs upstreams maintainers now.

So, as part of the  series of science packages that you should compile yourself, here's Octave 3.6.1
At the moment of writing the versions in the deb repos are 3.4.2-8, 3.4.2-12 and 3.4.2-12+b1.

As an aside, if you know what you'll be doing with each software package, create a couple of test scripts so you can track regressions. That way you can be just a little bit more confident in the results you obtain -- if you publish incorrect data you will have to go through the humiliating experience of a retraction or correction.

In addition to everything listed below you need to have a working build environment  with a good fortran compiler.
sudo apt-get install gfortran build-essential 
at a minimum thus.

-- START HERE ---
sudo apt-get install libqhull-dev libpcre++-dev libblas-dev liblapack-dev libreadline-dev
sudo apt-get install libcurl4-openssl-dev libfltk1.3-dev libgraphicsmagick++-dev libhdf5-serial-dev libqrupdate-dev libsuitesparse-metis-dev glpk gperf flex bison libfontconfig1-dev
 wget ftp://ftp.gnu.org/gnu/octave/octave-3.6.1.tar.gz
tar -xvf octave-3.6.1.tar.gz
cd octave-3.6.1/
./configure
make -j4

where 4 is the number of cores +1 (for me 3 cores)

To validate your  compiled version, run
make check

Summary:
  PASS  10008
  FAIL      0
There were 2 expected failures (see fntests.log for details).
Expected failures are known bugs.  Please help improve Octave
by contributing fixes for them.



To install
either
sudo checkinstall
or
sudo make install
Done.


Error:
checking for qhull.h... no
configure: WARNING: Qhull library not found -- this will result in loss of functionality of some geometry functions.
Solution:
sudo apt-get libqhull-dev


Error:
checking pcre.h usability... no
checking pcre.h presence... no
checking for pcre.h... no
checking pcre/pcre.h usability... no
checking pcre/pcre.h presence... no
checking for pcre/pcre.h... no
checking whether pcre.h defines the macros we need... no
configure: error: to build Octave, you must have the PCRE library and header files installed

Solution:
sudo apt-get install libpcre++-dev


Error:
checking if sgemm_ is being linked in already... no
checking for ATL_xerbla in -latlas... no
checking for sgemm_ in -lblas... no
checking for sgemm_ in -lmkl... no
checking for sgemm_ in -framework vecLib... no
checking for sgemm_ in -lcxml... no
checking for sgemm_ in -ldxml... no
checking for sgemm_ in -lscs... no
checking for sgemm_ in -lcomplib.sgimath... no
checking for sgemm_ in -lblas... (cached) no
checking for sgemm_ in -lblas... (cached) no
configure: error: You are required to have BLAS and LAPACK libraries
Solution:
sudo apt-get install libblas-dev

(libopenblas-dev is still only in the unstable repo)


Error:

checking for cheev_... no
checking for cheev_ in -llapack... no
checking for cheev_ in -llapack_rs6k... no
configure: error: You are required to have BLAS and LAPACK libraries
Solution:
sudo apt-get install liblapack-dev


Error:
configure: WARNING: I need GNU Readline 4.2 or later
configure: error: this is fatal unless you specify --disable-readline
Solution:
sudo apt-get install libreadline-dev


Error:

configure: WARNING: I didn't find gperf, but it's only a problem if you need to reconstruct oct-gperf.h
configure: WARNING: UMFPACK not found.  This will result in some lack of functionality for sparse matrices.
configure: WARNING: qrupdate not found.  The QR & Cholesky updating functions will be slow.
configure: WARNING: AMD library not found.  This will result in some lack of functionality for sparse matrices.
configure: WARNING: COLAMD library not found.  This will result in some lack of functionality for sparse matrices.
configure: WARNING: CCOLAMD library not found.  This will result in some lack of functionality for sparse matrices.
configure: WARNING: CHOLMOD library not found.  This will result in some lack of functionality for sparse matrices.
configure: WARNING: CXSparse library not found.  This will result in some lack of functionality for sparse matrices.
configure: WARNING: cURL library not found.  The ftp objects, urlread and urlwrite functions will be disabled.
configure: WARNING: GLPK library not found.  The glpk function for solving linear programs will be disabled.
configure: WARNING: GraphicsMagick++ library not found.  The imread function for reading image files will not be fully functional.
configure: WARNING: HDF5 library not found.  Octave will not be able to save or load HDF5 data files.
configure: WARNING: FLTK config script not found.  Native graphics will be disabled.
configure: WARNING: 
configure: WARNING: I didn't find the necessary libraries to compile native
configure: WARNING: graphics.  It isn't necessary to have native graphics,
configure: WARNING: but you will need to have gnuplot installed or you won't
configure: WARNING: be able to use any of Octave's plotting commands
configure: WARNING: 
configure: 
configure: NOTE: libraries may be skipped if a library is not found OR
configure: NOTE: if the library on your system is missing required features.

Solution:
First, make a few decisions:
Package libhdf5-dev is a virtual package provided by:
  libhdf5-serial-dev 1.8.4-patch1-3
  libhdf5-openmpi-dev 1.8.4-patch1-3
  libhdf5-mpich-dev 1.8.4-patch1-3
  libhdf5-lam-dev 1.8.4-patch1-3
You should explicitly select one to install.
Package libcurl-dev is a virtual package provided by:
  libcurl4-openssl-dev 7.24.0-1
  libcurl4-nss-dev 7.24.0-1
  libcurl4-gnutls-dev 7.24.0-1
You should explicitly select one to install.
Package libfltk-dev is a virtual package provided by:
  libfltk1.3-dev 1.3.0-5
  libfltk1.1-dev 1.1.10-10
You should explicitly select one to install.
Package libumfpack4-dev is a virtual package provided by:
  libsuitesparse-metis-dev 3.1.0-2
  libsuitesparse-dev 1:3.4.0-2
You should explicitly select one to install.
I chose thusly:

sudo apt-get install libcurl4-openssl-dev libfltk1.3-dev libgraphicsmagick++-dev libhdf5-serial-dev libqrupdate-dev libsuitesparse-metis-dev

The following errors/mesages remain:

  Do internal array bounds checking:  false
  Use octave_allocator:               false
  Build static libraries:             false
  Build shared libraries:             true
  Dynamic Linking:                    true (dlopen)
  Include support for GNU readline:   true
  64-bit array dims and indexing:     false

configure: WARNING: I didn't find gperf, but it's only a problem if you need to reconstruct oct-gperf.h
configure: WARNING: GLPK library not found.  The glpk function for solving linear programs will be disabled.
configure: 
configure: NOTE: libraries may be skipped if a library is not found OR
configure: NOTE: if the library on your system is missing required features.


The 64 bit issue can probably  be solved using ./configure --enable-64 BUT requires BLAS that is compatible with 64 bit integers.


Links to this page:
http://tata-box-blog.blogspot.nl/2012/04/install-octave-361-in-debian-squeeze.html
http://askubuntu.com/questions/124731/when-will-octave-3-6-1-be-available-to-be-installed

79. Bankid/nexus personal and iceweasel on Debian Testing

Update 19 Feb. 2013:
Here's an updated post: http://verahill.blogspot.com.au/2013/02/341-upgradinginstalling-bankid-on-64.html -- see that one instead, in particularly if you're upgrading.

Note that you may have to compile your own nspluginwrapper:
http://verahill.blogspot.com.au/2013/03/366-nspluginwrapper-on-debian.html

and you will need to enable multiarch to install ia32-libs:
sudo dpkg --add-architecture i386
sudo apt-get update

Original post:
Swedish banks and government institutions use bankid/nexus personal for electronic id verification. Sadly, it's a horrible solution -- it seems to be closed source, the bankid website is a POS which prevents me from downloading the 64 bit version claiming that it's not supported (I've used it for a few years now, so it's clearly bunkum).

Note that there's a FOSS alternative in Fribid (http://verahill.blogspot.se/2012/02/debian-testing-wheezy-64-fribid-as.html) which seems to be working perfectly -- and if you can use it, use it. The main limitation is that in practice you'll have to collect your certificate/ID with it, since newer versions of BankID saves the ID in an incompatible format. Like many foreigners, I don't have the opportunity to visit Sweden for the sole sake of picking up a new ID, so I'm stuck with BankID. But you may not be.

* A Swedish how-to is available here: http://ubuntu-se.org/wiki/NexusPersonal#Installation_p.C3.A5_64-bitarssystem

* Another, more recent how-to is here: http://popqvarnstrom.blogspot.com.au/2011/06/bankid-nexus-personal-on-ubuntu-1104-64.html

Note: I have never 'exported' my ID, but have always copied the ~/.personal directory between computers. The problem with exporting is that you are only allowed to do it once. The problem with Nexus allowing your to copy the file itself is that anyone with physical access to your computer can copy the key.

--START HERE --
 Here's a summary of how to get it working on debian testing wheezy:

In theory you should install nexus personal from here:
https://install.bankid.com/

I've got v 4.17.0.11 installed on a 64 bit system. The message on this page is a load of bollocks:


Whatever -- the good guys over at Arch supply a link:
wget http://install.bankid.com/Repository/BISP-4.19.0.11351.tar.gz

EDIT: you can use this generic url instead  https://install.bankid.com/Download?defaultFileId=Linux

tar -xvf  BISP-4.19.0.11351.tar.gz
cd  BISP-4.19.0.11351
 sudo sh install.4.19.0.11351.sh i
 Installing BankID Security Application
ln: failed to create symbolic link `/usr/lib/firefox-addons/plugins': No such file or directory
WARNING: Failed installing plugin for Firefox 3. Manually add symlink to libplugins.so in your Firefox 3 plugin directory if this browser is to be used.
Installation complete.

Since the plugin is 32 bit, you need to link it with nspluginwrapper, and you need 32 bit libs, so

sudo apt-get install nspluginwrapper ia32-libs




Also, as far as I can tell, you need iceweasel/firefox. Chrome/ium won't work.

sudo nspluginwrapper -i /usr/local/lib/personal/libplugins.so  

Check to see if it's installed:
nspluginwrapper -l
 /usr/lib/mozilla/plugins/npwrapper.libplugins.so 
 Original plugin: /usr/local/lib/personal/libplugins.so 
Plugin viewer: /usr/lib/nspluginwrapper/i386/linux/npviewer
Wrapper version string: 1.3.0  
And visit  the following page to make sure
 https://test.bankid.com/
Or your bank.


Your  key -- on a computer where you've used bankid before -- will be in ~/.personal -- don't bother trying to import or export it using the bankid/nexus personal programme (http://popqvarnstrom.blogspot.com.au/2011/06/bankid-nexus-personal-on-ubuntu-1104-64.html) since you're apparently only allowed to do that a certain number of times.

If you just plain copy the files, however, you can do it as many times as you want. I told you the programme is a POS. Anyway,

tree .personal
.personal
|-- backup
|   |-- config
|   |   `-- Personal.cfg
|   `-- store
|-- config
|   `-- Personal.cfg
`-- store
    |-- 1.ngp
    `-- 2.ngp


Nexus Personal/BankID is installed in /usr/local/lib/personal/

Links to this page:
http://popqvarnstrom.blogspot.se/2011/06/bankid-nexus-personal-on-ubuntu-1104-64.html

78. Fribid as an alternative to nexus personal on debian

Anyone who has needs to interact electronically with banks and government agencies in Sweden will become a victim of BankID/Nexus Personal.

It's a piece of crap. I've used it for several years, and have managed to get by. Now, however, if you try to download a newer version (I currently have 4.17.0.11) from a 64 bit debian machine you end up on a page that says:
 And there's little hope of getting past it.

Luckily, there's apparently an open-source project, fribid, which may be able to replace bankid/nexus personal for those who don't want to get stuck with 32 bit linux (seriously -- why does 4.17 work on 64 bit and future versions won't? And why won't you let me download an older, supported version? And why can't I chose what version I download? 32 bit windows from a 64 bit linux box -- and vice versa -- SHOULD BE POSSIBLE)

Anyway, fribid:


wget http://fribid.se/releases/source/fribid-1.0.0.tar.bz2
tar -xvf fribid-1.0.0.tar.bz2
cd fribid-1.0.0
./configure
make
sudo make install



I didn't have to do anything to 'install' it beyond that. Navigating in iceweasel to a website requiring bankid started fribid as it should and prompted me for the key file.

I can't explore the functionality beyond this, as fribid can only read keys downloaded with bankid/nexus v 4.10 or earlier -- pk12. The clincher here is that you can download the keys using fribid to begin with instead of first downloading them with bankid.

Lock-in, anyone?





Error:
ERROR: Unsatisfied dependencies:
  gtk+-2.0 >= 2.12
  gdk-2.0
  glib-2.0

Solution:
sudo apt-get install libgtk2.0-dev