Sunday, April 16, 2006

Ebuild for gretl


Gnu Library gretl is a cross-platform software package for econometric analysis, written in the C programming language, http://gretl.sourceforge.net/. It is not in portage yet, and for a long time I couldn't get it installed on my Gentoo system (which is why I had that Debian excursion). Now finally I did it and with an ebuild!

The ebuild is based on Dan's attempt (http://bugs.gentoo.org/show_bug.cgi?id=39966) and should work on a stable Gentoo system. Here's the content:

# Copyright 1999-2006 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: $

inherit eutils gnome2
DESCRIPTION="gretl is a cross-platform software package for econometric analysis"
HOMEPAGE="http://gretl.sourceforge.net/"
SRC_URI="mirror://sourceforge/${PN}/${P}.tar.bz2"
LICENSE="GPL-2"
SLOT="0"
KEYWORDS="~x86"
IUSE="gmp gnome gtk2 gtkextra ole2 readline sourceview"
DEPEND="x11-libs/gtk+
dev-libs/libxml2
sci-visualization/gnuplot
sci-libs/lapack
media-libs/gdk-pixbuf
sourceview? (x11-libs/gtksourceview)
readline? (sys-libs/readline)
gnome? (gnome-base/gnome)
gmp? (dev-libs/gmp)
!gtk2 (
ole2? (dev-libs/libole2)
)"
RDEPEND=""

src_compile() {
local myconf
if ! use gtk2 ; then
ewarn "Running ${PN} without GTK+-2.0 reduces functionality"
myconf="${myconf} --without-gtk2"
if ! use ole2 ; then
myconf="${myconf} --without-libole2"
fi
if ! use gtkextra ; then
myconf="${myconf} --without-gtkextra"
fi
fi
if ! use gnome ; then
myconf="${myconf} --without-gnome"
fi
econf || die "configure failed"
emake || die "emake failed"
}

src_install() {
make check
if use gnome ; then
gnome2_src_install gnome_prefix=${D}/usr langdir=${D}/usr/share/gtksourceview-1.0/language-specs
else
make prefix=${D}/usr bindir=${D}/usr/bin mandir=${D}/usr/share/man infodir=${D}/usr/share/info datadir=${D}/usr/share gretldir=${D}/usr/share/gretl localedir=${D}/usr/share/locale langdir=${D}/usr/share/gtksourceview-1.0/language-specs libdir=${D}/usr/$(get_libdir) sysconfdir=${D}/etc install || die
fi
}


Before you install it, don't forget to:
Code:
# ebuild /usr/local/portage/sci-mathematics/gretl/gretl-1.5.1.ebuild digest


first.

Sunday, April 09, 2006

Put portage stuff on LVM

Recently I installed LVM2 on /dev/hda3.
First use fdisk to change partition type for /dev/hda3 to 8e (Linux LVM)(turns out this is unnecessary when using LVM 2, but still a good thing for disk management).
Recompile kernel:

Device Drivers --->
Multi-device support (RAID and LVM) --->
[*] Multiple devices driver support (RAID and LVM)
< > RAID support
<*> Device mapper support
< > Crypt target support

If "Device mapper support" is compiled as a module, add the module "dm-mod" to /etc/modules.autoload.d/kernel-2.6.
Install the lvm2 package:
# emerge lvm2

Edit /etc/lvm/lvm.conf, find the line:
 filter = [ "a/.*/" ]

Replace it with the following one to scan /dev/hda and /dev/hdb and reject anything else:
 filter = [ "a|/dev/hd[ab]|", "r/.*/" ]

Then reboot. Now prepare the partition:
# pvcreate /dev/hda3

This creates a volume group descriptor at the start of the /dev/hda3 partition.
Create a volume group named "vg":
# vgcreate vg /dev/hda3

Create the logical volumes (just like creating partitions with fdisk):
# lvcreate -L3G -nportage  vg
# lvcreate -L3G -nccache vg
# vgdisplay vg | grep Free
Free PE / Size 667 / 2.61 GB
# lvcreate -l 667 vg -n tmp (let "tmp" take up all the rest)

Now you should see portage, ccache and tmp in /dev/vg/
Create filesystems on the logical volumes:
# mkreiserfs /dev/vg/portage
# mkreiserfs /dev/vg/ccache
# mkreiserfs /dev/vg/tmp

Move the stuff in /usr/portage, /var/tmp/ccache and /var/tmp/portage to another place and mount the logical volumes, then move the stuff back:
# mv /usr/portage/* /root/portage
# mv /var/tmp/ccache/* /root/ccache
# mv /var/tmp/portage/* /root/tmp
# mount /dev/vg/portage /usr/portage
# mount /dev/vg/tmp /var/tmp/portage
# mount /dev/vg/ccache /var/tmp/ccache
# mv /root/portage/* /usr/portage
# mv /root/ccache/* /var/tmp/ccache
# mv /root/tmp/* /var/tmp/portage

Add the following lines to /etc/fstab:
# Logical volumes
/dev/vg/portage /usr/portage reiserfs noatime 0 0
/dev/vg/ccache /var/tmp/ccache reiserfs noatime 0 0
/dev/vg/tmp /var/tmp/portage reiserfs noatime 0 0

Then if you restart your machine, all partitions will be automatically mounted.

Here comes the nice things about LVM, shrink logical volume "portage":
# umount /usr/portage/
# resize_reiserfs -s-1500M /dev/vg/portage (First, resize the filesystem)
# lvreduce -L-1500M /dev/vg/portage (resize the logical volume)
# mount /usr/portage

To extend a logical volume, we do it in a slightly different order:
# lvextend -L+1G /dev/vg/portage
# resize_reiserfs -f /dev/vg/portage (no need to umount nor specify size this time)

To add another physical partition to the volume group "vg":
# pvcreate /dev/hda9
# vgextend vg /dev/hda9

then you should be able to create more logical volumes.

Other useful commands:
# umount /dev/vg/tmp 
# lvremove /dev/vg/tmp (remove a logical volume)
# vgreduce vg /dev/hda9 (remove a physical volume from a group)
# vgchange -a n vg (deactivate a volume group)
# vgremove vg (remove a volume group)


P.S. I'm now thinking about the following scheme for dealing with portage stuff:
1) put /usr/portage on a reiserfs LV, perhaps 300MB is enough.

2) put sources in a directory other than /usr/portage/distfiles, probably /var/distfiles (may be on an independent ext3 LV).

3) put /var/tmp (which includes /var/tmp/ccache and /var/tmp/portage) on an ext2 LV, maybe 5G?