Alexander Nasonov's shared items

Friday, April 20, 2007

[boost] Announce: scope_exit version 0.03

Version 0.03 is available for download at http://tinyurl.com/yps8zs

You can read documentation online: http://194.6.223.221/~nasonov/scope_exit-0.03/libs/scope_exit/doc/html/

What's new in this version:

- Based on simpler 0.01 interface but with a better implementation - Found a problem on MSVC. It doesn't link when a block in a header file is included by more than one cpp file. I tried __declspec(selectany) and __forceinline. - Added experimental BOOST_SCOPE_EXIT_FASTER_IMPL. See documentation for details.

I'd like to remind you that nobody volunteered to be a review manager yet.

Thursday, March 15, 2007

I thought I found a bug in OpenBSD ...

... but someone else found that bug a bit earlier. I spent a funny evening tracking it down to the same lines as in the fix.

Sunday, February 25, 2007

How to run print/acroread7 on FreeBSD 6.2

This instruction explains how to install and run print/acroread7 on FreeBSD 6.2 using pkgsrc. Before you start, please check that it's still broken. I hope it'll be fixed soon after my post and you would only need to follow configuration of /compat/linux.

  1. Go to emulators/suse100_base and suppress an execution of /dev/MAKEDEV - this file doesn't exist (/dev is devfs mount point on FreeBSD 6.2)
  2. % cvs diff -u Makefile
    Index: Makefile
    ===================================================================
    RCS file: /cvsroot/pkgsrc/emulators/suse100_base/Makefile,v
    retrieving revision 1.7
    diff -u -r1.7 Makefile
    --- Makefile    22 Feb 2007 19:26:27 -0000      1.7
    +++ Makefile    25 Feb 2007 18:38:10 -0000
    @@ -53,8 +53,8 @@
              ${INSTALL_SCRIPT} $$FILE ${PREFIX}/sbin/`basename $$FILE .sh`; \
            done
            ${INSTALL_DATA_DIR} ${EMULDIR}/dev
    -       ${INSTALL_DATA} /dev/MAKEDEV ${EMULDIR}/dev
    -       cd ${EMULDIR}/dev && ${SH} ./MAKEDEV  std audio
    +#      ${INSTALL_DATA} /dev/MAKEDEV ${EMULDIR}/dev
    +#      cd ${EMULDIR}/dev && ${SH} ./MAKEDEV  std audio
            cd ${EMULDIR}/dev && ${LN} -fs sound dsp
            @${CP} ${PKGDIR}/PLIST ${PLIST_SRC}
            ${RPM2PKG} ${RPM2PKGARGS}
  3. Go to print/acroread7 and patch Makefile.
  4. % cvs diff -u Makefile
    Index: Makefile
    ===================================================================
    RCS file: /cvsroot/pkgsrc/print/acroread7/Makefile,v
    retrieving revision 1.17
    diff -u -r1.17 Makefile
    --- Makefile    11 Jan 2007 11:52:17 -0000      1.17
    +++ Makefile    25 Feb 2007 19:29:36 -0000
    @@ -32,7 +32,7 @@
     # Default (overridden below)
     PLATFORM=      unknown
     
    -.if ${OPSYS} == "NetBSD" || ${OPSYS} == "DragonFly"
    +.if ${OPSYS} == "NetBSD" || ${OPSYS} == "DragonFly" || ${OPSYS} == "FreeBSD"
     . if (${MACHINE_ARCH} == "i386")
     DEPENDS+=      suse_gtk2>=10.0:../../emulators/${SUSE_DIR_PREFIX}_gtk2
     DEPENDS+=      suse_libcups>=10.0:../../emulators/${SUSE_DIR_PREFIX}_libcups
  5. Run bmake with properly set $BRANDELF. For some reason, this variable is not set when building suse100_base and it would break an installation of that package.
  6. % env BRANDELF=brandelf bmake
  7. Run
  8. % sed -i '' -e 's/\(NetBSD | DragonFly\)/\1 | FreeBSD/' work/AdobeReader/INSTALL
  9. Install acroread7
  10. % bmake install
  11. Run as root
  12. # sed -i '' -e 's/\(NetBSD | DragonFly\)/\1 | FreeBSD/' /usr/pkg/bin/acroread7
  13. Set LD_LIBRARY_PATH to
  14. LD_LIBRARY_PATH=/usr/pkg/emul/linux/usr/lib/:/usr/pkg/emul/linux/opt/gnome/lib:/usr/pkg/Acrobat7/Reader/intellinux/lib

When I completed these steps, I was able to run /usr/pkg/bin/acroread7 but later I removed packages installed from ports and I couldn't run the program anymore. To fix this, I replaced FreeBSD linux compatibility directory with pkgsrc linux emulator and regenerated gdk-pixbuf.loaders:

# mv /compat/linux /compat/linux.freebsd
# ln -s /usr/pkg/emul/linux /compat/linux
# /usr/pkg/emul/linux/opt/gnome/bin/gdk-pixbuf-query-loaders > /usr/pkg/emul/linux/etc/opt/gnome/gtk-2.0/gdk-pixbuf.loaders

This method proves that suse100 linux emulator works on FreeBSD but since it could "interfere" in a bad way with FreeBSD update procedure I went another route:

# ln -s /usr/pkg/emul/linux/opt/gnome /compat/linux/opt/gnome
# ln -s /usr/pkg/emul/linux/etc/opt/gnome /compat/linux/etc/opt/gnome
# ln -s /usr/pkg/emul/linux/opt/gnome/lib/pango /compat/linux/usr/lib/pango

You can always find these three foreign links with the find command:

% find /compat/linux -type l | xargs file | grep pkg
/compat/linux/etc/opt/gnome:                               symbolic link to `/usr/pkg/emul/linux/etc/opt/gnome'
/compat/linux/usr/lib/pango:                               symbolic link to `/usr/pkg/emul/linux/opt/gnome/lib/pango'
/compat/linux/opt/gnome:                                   symbolic link to `/usr/pkg/emul/linux/opt/gnome'

UPDATE: I thought that /compat/linux belongs to FreeBSD base system but it has been installed from linux_base port. So I can easily remove it and use suse100_base from pkgsrc. Another cool idea is to mount a real Linux to /compat/linux as described here.

Monday, November 27, 2006

Thursday, November 23, 2006

Quote generator

I'm a happy user of mutt but I always wanted dynamically generated signature with a cool content. And I finally did it! This simple script retrieves a random quote from www.quotedb.com, formats it and finally prints most interesting part of itself:
#!/bin/sh
cat ~/.signature
/usr/pkg/bin/curl -L http://tinyurl.com/veusy           | sed -e 's/^document\.write(.//' -e 's/.);$//'             -e 's/<[^>]*>//g' -e 's/^More quotes from //'   | fmt | tee ~/.signature-quote
echo ""
echo "This quote is generated by: "
cat -n $0 | grep -e '^[ ]*[3-6]' | sed 's/^[ ]*[0-9]*[ ]*//'
A typical result looks like this:
--
Alexander Nasonov
http://nasonov.blogspot.com

Diligence is the mother of good luck.  Benjamin Franklin

This quote is generated by:
      /usr/pkg/bin/curl -L http://tinyurl.com/veusy                 | sed -e 's/^document\.write(.//' -e 's/.);$//'                   -e 's/<[^>]*>//g' -e 's/^More quotes from //'         | fmt | tee ~/.signature-quote

Monday, November 20, 2006

How to remember arguments order in ln -s command

I couldn't remember for a long time what should go first after ln -s. It came to me when I learnt about !$ (last argument of last executed command). $ touch x $ ln -s x y $ file !$ file y y: symbolic link to x

Monday, November 13, 2006

Writing A Lisp Interpreter In Haskell

I'm reading Writing A Lisp Interpreter In Haskell right now. The author refers to Boost Spirit to introduce Haskell's Parsec library. Very interesting reading.

Saturday, September 30, 2006

CLFS 1.0.0 x86 report: Compile GNU/Linux from FreeBSD

I was able to build a temporary system on my Pentium M notebook but I couldn't boot it :( Few words about my system. It runs recently compiled FreeBSD 6.2 PRERELEASE. For package management I use ports and pkgsrc. Some tools required to build CLFS are either missing in the base FreeBSD system or don't understand an option. In these cases, I either appended /usr/pkg/bin to the $PATH or provided a full path to required tool. 1. Never run make, it's different from GNU make: run /usr/pkg/bin/gmake. 2. FreeBSD's cp doesn't accept -a: use /usr/local/bin/gcp. 3. FreeBSD's install doesn't accept -D: use /usr/local/bin/ginstall. 4. tic is in /usr/pkg/bin directory. 5. Other installed pkgsrc packages that were used when I appended /usr/pkg/bin to the $PATH. Many CLFS packages compile fine. Reported only those sections that I had to complete differently. 5.3. Build Variables CLFS_HOST=i386-cross-freebsd6 CLFS_TARGET=i686-pc-linux-gnu 4.5. Setting Up the Environment Specify full path to bash and env programs in .bash_profile: cat > ~/.bash_profile << "EOF" exec /usr/bin/env -i HOME=${HOME} TERM=${TERM} PS1='\u:\w\$ ' /usr/pkg/bin/bash EOF 5.7. Glibc-2.4 Make sure that gmake is in the $PATH. $ PATH=$PATH:/usr/pkg/bin BUILD_CC="gcc" CC="${CLFS_TARGET}-gcc" AR="${CLFS_TARGET}-ar" RANLIB="${CLFS_TARGET}-ranlib" ../glibc-2.4/configure --prefix=/tools --host=${CLFS_TARGET} --build=${CLFS_HOST} --disable-profile --enable-add-ons --with-tls --enable-kernel=2.6.0 --with-__thread --with-binutils=/cross-tools/bin --with-headers=/tools/include --cache-file=config.cache $ PATH=$PATH:/usr/pkg/bin /usr/pkg/bin/gmake $ PATH=$PATH:/usr/pkg/bin /usr/pkg/bin/gmake install 6.5.1. Installation of Ncurses Make sure that tic is in the $PATH when installing ncurses. $ PATH=$PATH:/usr/pkg/bin /usr/pkg/bin/gmake install 6.6.1. Installation of Bash Linking of bash 3.1 fails with "/usr/bin/ld: cannot find -ldl" error. Strange that the command is gcc -rdynamic -g -O2 -o mkbuiltins mkbuiltins.o -ldl I would assume that i686-pc-linux-gnu-gcc would be a better compiler for cross build. To get rid of this error, I appended --enable-static-link option to ./configure: $ ./configure --prefix=/tools --build=${CLFS_HOST} --host=${CLFS_TARGET} --without-bash-malloc --cache-file=config.cache --enable-static-link 6.13.1. Installation of Grep Extra packages are required. It's still an open issue which ones, though. $ PATH=$PATH:/usr/pkg/bin ./configure --prefix=/tools --build=${CLFS_HOST} --host=${CLFS_TARGET} --disable-perl-regexp $ PATH=$PATH:/usr/pkg/bin /usr/pkg/bin/gmake $ PATH=$PATH:/usr/pkg/bin /usr/pkg/bin/gmake install 6.17.1. Installation of Sed It fails to compile because ./intl/Makefile and ./po/Makefile are empty after configure stage. To fix it, remove intl and po from SUBDIRS variable in ./Makefile. 7.9.1. Installation of Udev FreeBSD's install doesn't support -D option. You should use ginstall instead: cp Makefile{,.orig} sed -e 's/^\(INSTALL = \)\/usr\/bin\/install/\1\/usr\/local\/bin\/ginstall/' Makefile.orig > Makefile Make sure that a path to ginstall is correct. 7.11. Linux-2.6.17.13 I couldn't cross-compile it. 7.12. GRUB-0.97 I skipped this step. 7.17. Populating /dev I couldn't make nodes even with gmknod. Presumaly, ext2 driver on FreeBSD doesn't support this operation. 7.18. Changing Ownership You can't run chown successfully on FreeBSD because group "root" doesn't exist. Replace it with a numeric form: chown -Rv root:0 ${CLFS} Resulting system couldn't run /sbin/init. I booted from LFS 6.2-3 LiveCD and chroot'ed to /mnt/clfs. Bash started, buildins seemed to work but when I ran /sbin/init it printed "wait_for(1099): Invalid argument." and exited from /tools/bin/bash. Most successfull command was "cat /etc/passwd" which printed the content of /etc/passwd but it also broke execution of /tools/bin/bash.