# Recipe for version 1.4.18 by Nathan Middleton, on Sun Nov 25 12:52:35 CST 2007
# Recipe (MakeRecipe) for LightTPD by Harald Klimach, on Mon Feb 6 19:51:39 CET 2006
compile_version=1.9.0
url="http://www.lighttpd.net/download/lighttpd-1.4.18.tar.bz2"
file_size=600227
file_md5=26f98dddf9d8c0775221b800986003ee
recipe_type=configure
configure_options=(
    "--sbindir=${target}/bin"
    "--libdir=${target}/lib/lighttpd"
)
docs=(
    'doc/*.txt'
)

pre_build() {
    if test ! "$(grep httpd /etc/group)"
    then
        gid=100
        for ngid in `egrep '^.*:[0-9]{3}:.*$' /etc/group | cut -d':' -f3 | sort | xargs`; do
            if [ $gid -eq $ngid ]; then gid=$(($gid+1)); else break; fi
        done
        groupadd -g $gid httpd
    fi
    
    if test ! "$(grep httpd /etc/passwd)"
    then
        uid=-1
        while [ $uid -eq -1 ]; do
            if [ "$(grep ":$gid:" /etc/passwd)" ]; then
                gid=$(($gid+1)); else uid=$gid
            fi
        done
        useradd -s /bin/false -d /Files/WWW -g httpd -u $uid httpd
    fi
}

pre_link() {
    mkdir -p ${target}/doc/tests
    cp -r tests/* ${target}/doc/tests
}
 
post_install() {
    chown -R httpd.httpd /Files/WWW
    chown -R httpd.httpd ${goboVariable}/run/lighttpd
    chown -R httpd.httpd ${goboVariable}/log/lighttpd
}
