Installing GNU Gift on Debian Lenny
Assumptions
We're going to assume:
- you want to place all gift related files in /home/gift/gift/
- you are logging in as a user named gift, and can use sudo to execute tasks as root.
Packages
First, install both gnuift (the debian name for the gift package), and apache 2 (the preforking version, so we can install PHP5 later).
sudo apt-get install gnuift apache2-mpm-prefork
Compiling from Source
first, install gift's build dependencies
sudo apt-get install cvs automake autoconf libtool libexpat1-dev make g++
per the directions on Savannah, use CVS to download the newest version:
mkdir -p /home/gift/gift/src/ cd /home/gift/gift/src/ cvs -z3 -d:pserver:anonymous@cvs.savannah.gnu.org:/sources/gift co gift
Generate files required to build:
cd gift ./bootstrap-cvs.sh
Set up the build system:
./configure
Build Gift:
make
Obtaining Sample Image Data
I grabbed my sample image data from The Open Clip Art Project.
Specifically, I downloaded their 0.19 release, then ran the following command, to move all the .png files into one flat directory, for gift to index:
cd /home/gift/ wget http://www.openclipart.org/downloads/0.19/openclipart-0.19.tar.bz2 tar -xjf openclipart-0.19.tar.bz2 mkdir -p gift/clipart/ cp -a `find openclipart-0.19 -name *.png` gift/clipart/
Indexing your Collection
To index your collection, call gift-add-collection with the full path of the images you want to import.
(in addition, touch the config file, to prevent a lenny specific defect, described below)
gift-add-collection.pl /home/gift/gift/clipart/
now wait a long, long time.
Speeding this up
Downloading and installing the new version from CVS results in this step taking half(!) as long.
In addition, you can create the thumbnails using a separate script, at the same time. the gift-add-collection.pl will skip generating a thumbnail if you create them for it.
generate_thumbnails.sh
#!/bin/bash
# first argument: path to images to thumbnail
target=`dirname $1`/`basename $1`
echo $target
cd $target
for each in `ls -1`; do {
convname=`echo $each | sed "s/[.]/_thumbnail_/"`;
if [ ! -f "${target}_thumbnails/${convname}.jpg" ]; then
{
echo converting $each;
convert -geometry 128x128 ${each} ../${target}_thumbnails/${convname}.jpg;
}
fi
}
done;
Fixing up gift-config.mrml
gift always fails to generate this file correctly. specifically:
Lenny Defects
Out of Memory
PROGRESS: 99% Copying /home/gift/gift-config.mrml to /home/gift/gift-config.mrml-old Ran out of memory for input buffer at /usr/lib/perl5/XML/Parser/Expat.pm line 469, <LOCALELIST> line 270.
Run out of memory? create a 256 meg swap file, and use it:
dd if=/dev/zero of=/home/gift/swapfile bs=4k count=65536 sudo mkswap /home/gift/swapfile sudo swapon /home/gift/swapfile
now, re-run gift-add-collection.pl
Other
The packages in lenny commonly fail to create a config file, because there isn't one to move out of the way. touching the file before running gift-add-collection.pl (as we perform above) works around the problem. it also has the same defect as cvs, which we describe next.
CVS Defects
CVS seems to just fail to change the collection IDs in gift-config.mrml. To repair a file generated by CVS, meerly take the collection ID spit out as the last thing you see when running gift-add-collection.pl, and use it to replace the collection IDs in the 'adefault' algorithm, and in the collection id declaration.
When this breaks
on my machine running gift from debian's lenny packages, this broke creating the gift-config.mrml file.
Copying /home/gift/gift-config.mrml to /home/gift/gift-config.mrml-old Couldn't open /home/gift/gift-config.mrml: No such file or directory at /usr/bin/gift-add-collection.pl line 585
To fix it, I touched the file in question, and re-ran gift-add-collection.pl.
Setting up a Frontend
apt-get install libapache2-mod-php5 php-xml-parser
rm /var/www/index.html cd /var/www/ wget http://79.99.65.184/rainbowsock.tar.gz tar -xzf rainbowsock.tar.gz
