# -*- coding: utf-8; mode: tcl; tab-width: 8; truncate-lines: t; indent-tabs-mode: nil; c-basic-offset: 4
# $Id: Portfile 68773 2010-06-13 08:04:56Z krischik@macports.org $
# vim: set fileencoding=utf-8 tabstop=8 shiftwidth=4 softtabstop=4 noexpandtab filetype=tcl :

PortSystem 1.0

name		    android
version		    6
revision	    0
categories	    java devel emulators
maintainers	    krischik
platforms	    darwin
description	    Android SDK
long_description							\
    The Android SDK allows development for the Android mobile platform.

set patchversion    68759
set appbundles	    ${name}-appbundles-r${patchversion}.tar.gz
set prog	    ${name}-sdk_r0${version}-mac_86.zip

homepage	    http://developer.${name}.com/
master_sites	    http://dl.google.com/${name}::prog			\
		    macports:${name}:appbundles
distfiles	    ${prog}:prog										\
		    ${appbundles}:appbundles
distname	    ${name}-sdk_r0${version}-mac_86
worksrcdir	    ${name}-sdk-mac_86
extract.only	    ${appbundles}

checksums           ${prog}						\
                    md5     c92abf66a82c7a3f2b8493ebe025dd22		\
                    sha1    92c0974808a0cc340890dabc1fdff7b6459e8bba	\
                    rmd160  f4c9c2c3db8f405621196435f7c2c67e685e4cf4	\
                    ${appbundles}					\
                    md5     5aed877bfbd0777df0f9c5476897b2fb		\
                    sha1    ad5da2a7734e6ced420b3b395962bde8fb42036d	\
                    rmd160  e42eaf0cbbbc73717db7860823b6c7e4cd003289

use_configure	    no
build.cmd	    true

destroot.keepdirs						\
    ${destroot}${prefix}/share/java/${worksrcdir}/add-ons	\
    ${destroot}${prefix}/share/java/${worksrcdir}/docs		\
    ${destroot}${prefix}/share/java/${worksrcdir}/platforms	\
    ${destroot}${prefix}/share/java/${worksrcdir}/samples	\
    ${destroot}${prefix}/share/java/${worksrcdir}/temp

post-extract {
	system "unzip -q ${distpath}/${prog} -d ${workpath}"
}

    
destroot {
    xinstall -m 755 -d ${destroot}${prefix}/share/java

    file copy ${worksrcpath} ${destroot}${prefix}/share/java/

    xinstall -m 770 -d ${destroot}${prefix}/share/java/${worksrcdir}/docs
    xinstall -m 770 -d ${destroot}${prefix}/share/java/${worksrcdir}/samples
    xinstall -m 770 -d ${destroot}${prefix}/share/java/${worksrcdir}/temp

    system "
	chgrp -R _developer ${destroot}${prefix}/share/java/${worksrcdir};
	chmod -R g+w ${destroot}${prefix}/share/java/${worksrcdir}/add-ons;
	chmod -R g+w ${destroot}${prefix}/share/java/${worksrcdir}/platforms;
	chmod -R g-w ${destroot}${prefix}/share/java/${worksrcdir}/tools;
    "

    ui_info "####################################################################"
    ui_info "# add-ons, docs, platforms, samples and temp have been made        #"
    ui_info "# group _developer writable. You need to be member of the          #"
    ui_info "# _developer group to use the android tools. If you are not use:   #"
    ui_info "#                                                                  #"
    ui_info "# sudo dscl . append /Groups/_developer GroupMembership <username> #"
    ui_info "#                                                                  #"
    ui_info "####################################################################"
}

platform macosx {
    post-destroot {
	xinstall -m 755 -d ${destroot}/${applications_dir}/Developer

	system "touch ${destroot}${applications_dir}/Developer/.localized"

	foreach comp { Android-DDMS Android-Draw9Patch Android-Emulator Android-Hierarchyviewer Android-Manager } {
	copy											\
	    ${workpath}/appbundles-r${patchversion}/${comp}.app					\
	    ${destroot}${applications_dir}/Developer
	    reinplace s|@PREFIX@|${prefix}|g							\
		${destroot}${applications_dir}/Developer/${comp}.app/Contents/MacOS/Start.command
	}
    }
}

