# Description:  Pack, ship and run any application as a lightweight container
# URL:          http://www.docker.com/
# Maintainer:   James Mills, prologic at shortcircuit dot net dot au
#
# Depends on:   go sqlite3 cgroupfs-mount start-stop-daemon

name=docker
version=1.8.1
revision=d12ea79
release=1
source=(
    https://raw.githubusercontent.com/docker/docker/v${version}/contrib/check-config.sh
    https://github.com/docker/docker/archive/v$version.tar.gz
    $name
    $name.conf
)

build() {
    cd $name-$version

    # Build
    export AUTO_GOPATH=1
    export DOCKER_GITCOMMIT=$revision
    unset CC   # The build fails with a customer C compiler (e.g: ccache)
    unset CXX  # The build fails with a customer C++ compiler (e.g: ccache)
    ./hack/make.sh dynbinary

    # Package
    install -D -m 755 $SRC/check-config.sh $PKG/usr/share/docker/check-config.sh

    install -D -m 755 "bundles/$version/dynbinary/docker-$version" \
        "$PKG/usr/bin/docker"
    install -D -m 755 "bundles/$version/dynbinary/dockerinit-$version" \
        "$PKG/usr/lib/docker/dockerinit"
    install -D -m 644 "contrib/udev/80-docker.rules" \
        "$PKG/etc/udev/rules.d/80-docker.rules"

    install -D -m 755 $SRC/$name $PKG/etc/rc.d/$name
    install -D -m 644 $SRC/$name.conf $PKG/etc/$name.conf
}
