# Recipe for version 1.4.19 by Antony Male <atom14x7@gmail.com>, on Tue May 20 12:06:15 BST 2008
# 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.19.tar.bz2"
file_size=610347
file_md5=d787374e4e4aaa09d5cfa9ab9d23ad40
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
}
