source: trunk/dports/java/hadoop/Portfile @ 84040

Last change on this file since 84040 was 84040, checked in by hum@…, 8 years ago

hadoop: change maintainers.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 6.2 KB
Line 
1# -*- coding: utf-8; mode: tcl; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- vim:fenc=utf-8:ft=tcl:et:sw=4:ts=4:sts=4
2# $Id: Portfile 84040 2011-09-15 16:32:03Z hum@macports.org $
3
4PortSystem          1.0
5
6name                hadoop
7version             0.20.203.0
8categories          java science
9platforms           darwin
10maintainers         hum openmaintainer
11license             Apache-2.0
12
13description         Open-source software for reliable, scalable, distributed computing
14
15long_description    Hadoop is a distributed computing platform written in Java. \
16                    It incorporates features similar to those of the Google File System \
17                    and of MapReduce.
18
19homepage            http://hadoop.apache.org/
20master_sites        apache:hadoop/common/stable
21
22distfiles           ${name}-${version}rc1${extract.suffix}
23
24checksums           sha1    18684bf8b8f72ef9a00a0034ad7167d6b16ce7c8 \
25                    rmd160  79bbcc8ad71f01d8179c2e6ce2ae60b371c4ed5d
26
27patchfiles          patch-hadoop-env.sh.diff
28
29use_configure       no
30supported_archs     noarch
31
32build {}
33
34set hadoopuser      hadoop
35
36set java_home       /System/Library/Frameworks/JavaVM.framework/Versions/1.6/Home
37
38pre-configure {
39    if {![file exists ${java_home}]} {
40        ui_error "Java 1.6 is required, but not located at ${java_home}"
41        return -code error "Java 1.6 missing"
42    }
43}
44
45# Hadoop home and conf directories.
46set hadoop_basedir  ${prefix}/share/java
47set hadoop_home     ${hadoop_basedir}/${distname}
48set hadoop_conf_dir ${hadoop_home}/conf
49
50# Working directories.
51set hadoop_var_dir  ${prefix}/var/${name}
52set hadoop_log_dir  ${hadoop_var_dir}/log
53set hadoop_pid_dir  ${hadoop_var_dir}/run
54
55destroot {
56    # Copy the distribution to Hadoop home directory.
57    xinstall -m 755 -${destroot}${hadoop_basedir}
58    copy ${worksrcpath} ${destroot}${hadoop_basedir}
59
60    # Patch for Mahout 0.4 to suppress warnings.
61    xinstall -m 755 -d \
62        ${destroot}${hadoop_home}/webapps/secondary/WEB-INF
63
64    # Install an extra script for this port.
65    set hadoop_bin ${destroot}${prefix}/bin/hadoop-bin
66    xinstall -m 755 ${filespath}/hadoop-bin      ${hadoop_bin}
67    reinplace "s|@hadoop_home@|${hadoop_home}|g" ${hadoop_bin}
68    reinplace "s|@java_home@|${java_home}|g"     ${hadoop_bin}
69    reinplace "s|@hadoopuser@|${hadoopuser}|g"   ${hadoop_bin}
70
71    # Setup 'hadoop-env.sh' in conf.
72    set env_sh ${destroot}${hadoop_conf_dir}/hadoop-env.sh
73    reinplace "s|@java_home@|${java_home}|g"           ${env_sh}
74    reinplace "s|@hadoop_log_dir@|${hadoop_log_dir}|g" ${env_sh}
75    reinplace "s|@hadoop_pid_dir@|${hadoop_pid_dir}|g" ${env_sh}
76
77    # Add Hadoop user and group.
78    addgroup ${hadoopuser}
79    set gid [existsgroup ${hadoopuser}]
80    adduser ${hadoopuser} \
81        gid=${gid} \
82        realname=Hadoop\ Server \
83        home=${hadoop_var_dir} \
84        shell=/bin/bash
85
86    # Create working directories.
87    xinstall -m 755 -o ${hadoopuser} -g ${hadoopuser} -d \
88        ${destroot}${hadoop_var_dir} \
89        ${destroot}${hadoop_log_dir} \
90        ${destroot}${hadoop_pid_dir}
91    destroot.keepdirs-append \
92        ${destroot}${hadoop_var_dir} \
93        ${destroot}${hadoop_log_dir} \
94        ${destroot}${hadoop_pid_dir}
95}
96
97post-deactivate {
98    ui_msg "********************************************************"
99    ui_msg "* To revert the system after uninstalling the port:"
100    ui_msg "* 1) Delete Hadoop working directory:"
101    ui_msg "*  $ sudo rm -rf ${hadoop_var_dir}"
102    ui_msg "* 2) Delete Hadoop user and group:"
103    ui_msg "*  $ sudo dscl . -delete /Users/${hadoopuser}"
104    ui_msg "*  $ sudo dscl . -delete /Groups/${hadoopuser}"
105    ui_msg "********************************************************"
106}
107
108default_variants    +pseudo
109
110set hadoop_tmp_dir  ${hadoop_var_dir}/cache
111
112variant pseudo description {Run on a single-node in a pseudo-distributed mode} {
113    patchfiles-append  patch-conf.diff
114
115    post-destroot {
116        # Set conf directory for a pseudo-distributed mode.
117        copy ${destroot}${hadoop_conf_dir} ${destroot}${hadoop_conf_dir}.pseudo
118        move ${destroot}${hadoop_conf_dir} ${destroot}${hadoop_conf_dir}.local
119        system "cd ${destroot}${hadoop_home} && ln -s conf.pseudo conf"
120
121        # Set the maximum number of tasks based on the number of the CPUs (cores).
122        regexp {\d+} [exec sysctl hw.ncpu] ncpu
123        set tasks_max [expr $ncpu + 2]
124
125        # Setup configuration files.
126        reinplace "s|@tasks_max@|${tasks_max}|g" \
127            ${destroot}${hadoop_conf_dir}.pseudo/mapred-site.xml
128        reinplace "s|@hadoop_tmp_dir@|${hadoop_tmp_dir}|" \
129            ${destroot}${hadoop_conf_dir}.pseudo/core-site.xml
130
131        # Create a temporary directory.
132        xinstall -m 755 -o ${hadoopuser} -g ${hadoopuser} -d \
133            ${destroot}${hadoop_tmp_dir}
134        destroot.keepdirs-append \
135            ${destroot}${hadoop_tmp_dir}
136    }
137
138    post-activate {
139        # Setup passphraseless ssh.
140        set ssh_dir ${hadoop_var_dir}/.ssh
141        if {![file exists ${ssh_dir}]} {
142            xinstall -m 700 -o ${hadoopuser} -g ${hadoopuser} -d ${ssh_dir}
143            system "sudo -u ${hadoopuser} ssh-keygen -t rsa -P '' -f ${ssh_dir}/id_rsa"
144            xinstall -m 644 -o ${hadoopuser} -g ${hadoopuser} \
145                ${ssh_dir}/id_rsa.pub \
146                ${ssh_dir}/authorized_keys
147        }
148
149        ui_msg "********************************************************"
150        ui_msg "* To run on a single-node in a pseudo-distributed mode:"
151        ui_msg "* 1) Turn on Remote Login (sshd):"
152        ui_msg "*  check 'System Preferences > Sharing > Remote Login'"
153        ui_msg "* 2) Format a new distributed-filesystem:"
154        ui_msg "*  $ hadoop-bin hadoop namenode -format"
155        ui_msg "* 3) Start the hadoop daemons:"
156        ui_msg "*  $ hadoop-bin start-all.sh"
157        ui_msg "* 4) Perform operations you like. To see examples:"
158        ui_msg "*  $ open file://${hadoop_home}/docs/single_node_setup.html"
159        ui_msg "* 5) When you're done, stop the daemons with:"
160        ui_msg "*  $ hadoop-bin stop-all.sh"
161        ui_msg "********************************************************"
162    }
163}
164
165livecheck.type      regex
166livecheck.url       http://www.eu.apache.org/dist/hadoop/common/stable/
167livecheck.regex     ${name}-(\[0-9.\]+)
Note: See TracBrowser for help on using the repository browser.