Barnoid’s Knowledge Base

Bits of Collected Wisdom

March 27th, 2011

Removing Evolution and Epiphany from Gnome

The Gnome herd will not provide us with a full gnome ebuild that allows conditional installation of Evolution and Epiphany based on USE flags. Luckily, it’s easy to do it yourself.

First, enable the portage overlay in make.conf:

# PORTDIR_OVERLAY is a directory where local ebuilds may be stored without
#     concern that they will be deleted by rsync updates. Default is not
#     defined.
PORTDIR_OVERLAY=/usr/local/portage

Next, copy the Gnome ebuild into our portage overlay structure while maintaining the same directory structure.
First, find out where the gnome ebuild is located:

# find /usr/portage -name gnome-*.ebuild
/usr/portage/gnome-base/gnome/gnome-2.32.1.ebuild

Second, create the same directory structure in our overlay:

# mkdir -p /usr/local/portage/gnome-base/gnome

Then, copy over the original ebuild into our overlay:

# cd /usr/local/portage/gnome-base/gnome
# cp /usr/portage/gnome-base/gnome/gnome-2.32.1.ebuild .

Currently, there are no patches for Gnome (there is no ‘files’ directory in /usr/portage/gnome-base/gnome/) hence we do not need to symlink that directory into our overlay.
Now, edit the ebuild in the overlay and delete all references to Evolution and/or Epiphany (bold lines):

    ...
    >=media-gfx/eog-2.32.1:1

    >=www-client/epiphany-2.30.6
    >=app-arch/file-roller-2.32.1
    …
    >=gnome-extra/gtkhtml-3.32.1:3.14
    >=mail-client/evolution-2.32.1-r1:2.0
    >=gnome-extra/evolution-data-server-2.32.1-r1
    >=gnome-extra/evolution-webcal-2.32.0

Save and exit, then create the manifest:

# ebuild gnome-2.32.1.ebuild manifest

Done. Emerging gnome now will not pull in Evolution/Epiphany.

January 18th, 2010

Gentoo: Installing Fonts

Lots of howtos are out there, here’s mine:
Install the fonts somewhere in the /usr/share/fonts/ directory. For Type1 fonts (only .pfb and .pfm files are present, but no .afm files), you need to run the type1afm command first to generate the necessary .afm files (otherwise the fonts won’t show up in OpenOffice, for example). Then generate the font directory and scale files and register the new font directory in the system. In shell-speak:

# cd /usr/share/fonts
# mkdir myfont
# cd myfont
# cp font files, i.e., *.afm *.pfb *.pfm .
# type1afm `ls *.pfb`
# mkfontdir /usr/share/fonts/myfont
# mkfontscale /usr/share/fonts/myfont
# xset fp+ /usr/share/fonts/myfont
# xset fp rehash
# fc-cache

If you get an error saying ‘type1afm: command not found’, you may need to install the t1lib package:

emerge -av media-libs/t1lib

Check whether the new font shows up in the font list:

# fc-list | grep -i <fontname>

Done. Restart the application (restarting the X server is not necessary)

November 5th, 2008

1001 reasons why C/C++ is evil

Consider the following C++ code:

class A
{
int do(string key, bool b)         { cout << "do('" << key << "', " << (b ? "true" : "false") << ")" << endl; };
int do(string key, string value) { cout << "do('" << key << "', '" << value << "')" << endl; };
};

...

A *a = new A();
a->do(”do”, “something”);

What is printed? Well, not what I expected:

# ./reason1
do('do', true)

Intuitively, the second method, do(string string), should be executed, but gcc (4.1) executes the first method, do(string, bool). This is because the second ’string’, “something”, is interpreted as ‘char *’.

One down, 1000 more reasons to come.

September 10th, 2008

Ebuild for nslookup / dig?

Can’t find the ebuild containing nslookup or digg? Install the bind-tools:

# emerge -avD net-dns/bind-tools

and you’re all set:

# nslookup 127.0.0.1

Server:        xxx.yyy.zzz.1
Address:    xxx.yyy.zzz.1#53

1.0.0.127.in-addr.arpa    name = localhost.
September 1st, 2008

Thunderbird + Lightning: Layout Messed Up?

If Thunderbird’s Lightning calendar extension messes with your Thunderbird layout and doesn’t work as expected, make sure to install libstdc++5 and then re-install Lightning.

# emerge -av libstdc++

[ebuild  N    ] virtual/libstdc++-3.3

September 1st, 2008

VIM: Search for selection

After yanking a piece of text into the buffer, you can search for it by pressing <ctrl>-<r> ” (that is: control-r double quotes) in search mode (”/”).

September 1st, 2008

VIM <-> X11 middle-mouse copy/paste

That one is easy: just enable the “vim-with-x” USE flag and recompile vim:

# echo "app-editors/vim vim-with-x" >> /etc/portage/packages.use

# emerge -av vim

[ebuild   R   ] app-editors/vim-7.2  USE="acl gpm nls perl python vim-with-x -bash-completion -cscope -minimal -ruby -vim-pager”
April 20th, 2008

Generating a Self-Signed, Unencrypted SSL Certificate

Generate an RSA private key:

# openssl genrsa -des3 -out server.key.encrypted 1024

Create a self-signed certificate (make sure to enter the FQDN for the ‘Common Name’)

# openssl req -new -x509 -nodes -sha1 -days 365 -key server.key.encrypted -out server.crt

Remove the password from the encrypted key

# openssl rsa -in server.key.encrypted -out server.key
# chmod 400 server.key
October 14th, 2007

ALSA Sound Problems (e.g. in Firefox when watching Videos)

Recent sound problems (for example no sound when watching Youtube videos in Firefox or Thunderbird crashes whenever it pops up a calendar alarm) are probably caused by missing plugins. ALSA_PCM_PLUGINS controls which plugins are built; by default, it should build all of them, but apparently a recent update does not set the variable.

Symptoms are, for example, no sound from flash videos within Firefox. When started from a shell various error messages are printed, such as:

ALSA lib pcm_misc.c:740:(snd_pcm_parse_control_id) Cannot get index for 0
ALSA lib pcm_dmix.c:914:(snd_pcm_dmix_open) unable to open slave
ALSA lib conf.c:3510:(_snd_config_evaluate) function snd_func_card_driver returned error: No such device
ALSA lib confmisc.c:392:(snd_func_concat) error evaluating strings
ALSA lib pcm.c:2144:(snd_pcm_open_noupdate) Unknown PCM default
ALSA lib pcm_hw.c:1351:(_snd_pcm_hw_open) Invalid value for card
ALSA lib confmisc.c:769:(parse_card) cannot find card ''

Try

# echo 'ALSA_PCM_PLUGINS="adpcm alaw copy dshare dsnoop extplug file hooks ladspa lfloat linear meter mulaw multi null rate route share shm"' >> /etc/make.conf
# emerge --oneshot alsa-lib
# /etc/init.d/alsasound restart
June 28th, 2007

Concatenate PDF Files

To concatenate two or more PDF files together into one, try

# gs -dBATCH -dNOPAUSE -sDEVICE=pdfwrite -sOutputFile=concatenated.pdf file1.pdf file2.pdf [file3.pdf [...]]

With the -dBATCH -dNOPAUSE option, ghostscript won’t show a prompt and you won’t have to press return after each page. Comes in handy if the PDFs are long.