You are viewing a plain text version of this content. The canonical link for it is here.
Posted to common-commits@hadoop.apache.org by su...@apache.org on 2012/11/14 18:38:02 UTC

svn commit: r1409269 - in /hadoop/common/branches/branch-1-win: build.xml src/contrib/hod/build.xml src/fixFontsPath.py src/fixFontsPath.sh src/native/packageNativeHadoop.py src/native/packageNativeHadoop.sh src/saveVersion.sh

Author: suresh
Date: Wed Nov 14 17:38:01 2012
New Revision: 1409269

URL: http://svn.apache.org/viewvc?rev=1409269&view=rev
Log:
HADOOP-9027. Build fails on Windows without sh/sed/echo in the path. Contributed by Ivan.

Added:
    hadoop/common/branches/branch-1-win/src/fixFontsPath.py
    hadoop/common/branches/branch-1-win/src/native/packageNativeHadoop.py
Removed:
    hadoop/common/branches/branch-1-win/src/fixFontsPath.sh
    hadoop/common/branches/branch-1-win/src/native/packageNativeHadoop.sh
    hadoop/common/branches/branch-1-win/src/saveVersion.sh
Modified:
    hadoop/common/branches/branch-1-win/build.xml
    hadoop/common/branches/branch-1-win/src/contrib/hod/build.xml

Modified: hadoop/common/branches/branch-1-win/build.xml
URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-1-win/build.xml?rev=1409269&r1=1409268&r2=1409269&view=diff
==============================================================================
--- hadoop/common/branches/branch-1-win/build.xml (original)
+++ hadoop/common/branches/branch-1-win/build.xml Wed Nov 14 17:38:01 2012
@@ -82,10 +82,10 @@
   <property name="build.anttasks" value="${build.dir}/ant"/>
   <property name="build.librecordio" value="${build.dir}/librecordio"/>
   <!-- convert spaces to _ so that mac os doesn't break things -->
-  <exec executable="sed" inputstring="${os.name}" 
-        outputproperty="nonspace.os">
-     <arg value="s/ /_/g"/>
-  </exec>
+  <script language="javascript">
+    var before = project.getProperty("os.name");
+    project.setProperty("nonspace.os", before.replaceAll(" ", "_"));
+  </script>
   <condition property="build.platform"
     value="${env.OS}-${os.arch}-${sun.arch.data.model}"
     else="${nonspace.os}-${os.arch}-${sun.arch.data.model}">
@@ -446,9 +446,9 @@
     <exec executable="python">
        <arg line="src/saveVersion.py ${version} ${build.dir}"/>
     </exec>
-	
-   <exec executable="sh">
-       <arg line="src/fixFontsPath.sh ${src.docs.cn}"/>
+
+   <exec executable="python">
+       <arg line="src/fixFontsPath.py ${src.docs.cn}"/>
    </exec>
   </target>
 
@@ -1530,12 +1530,10 @@
        </classpath>
     </javadoc>
   </target>
-	
+
   <target name="write-null">
-	<exec executable="touch">
-	   <arg value="${jdiff.home}/Null.java"/>
-        </exec>
-  </target> 
+    <touch file="${jdiff.home}/Null.java"/>
+  </target>
 
   <target name="api-report" depends="ivy-retrieve-jdiff,api-xml">
     <mkdir dir="${jdiff.build.dir}"/>
@@ -1606,13 +1604,13 @@
       </fileset>
     </copy>
 
-  	<exec dir="${dist.dir}" executable="sh" failonerror="true">
-	  <env key="BASE_NATIVE_LIB_DIR" value="${lib.dir}/native"/>
-	  <env key="BUILD_NATIVE_DIR" value="${build.dir}/native"/>
-	  <env key="DIST_LIB_DIR" value="${dist.dir}/lib/native"/>
+    <exec dir="${dist.dir}" executable="python" failonerror="true">
+    <env key="BASE_NATIVE_LIB_DIR" value="${lib.dir}/native"/>
+      <env key="BUILD_NATIVE_DIR" value="${build.dir}/native"/>
+      <env key="DIST_LIB_DIR" value="${dist.dir}/lib/native"/>
       <env key="BUNDLE_SNAPPY_LIB" value="${bundle.snappy}"/>
       <env key="SNAPPY_LIB_DIR" value="${snappy.prefix}/lib"/>
-	  <arg line="${native.src.dir}/packageNativeHadoop.sh"/>
+      <arg line="${native.src.dir}/packageNativeHadoop.py"/>
     </exec>
 
     <subant target="package">
@@ -1733,11 +1731,11 @@
       </fileset>
     </copy>
 
-    <exec dir="${dist.dir}" executable="sh" failonerror="true">
+    <exec dir="${dist.dir}" executable="python" failonerror="true">
           <env key="BASE_NATIVE_LIB_DIR" value="${lib.dir}/native"/>
           <env key="BUILD_NATIVE_DIR" value="${build.dir}/native"/>
           <env key="DIST_LIB_DIR" value="${dist.dir}/lib/native"/>
-          <arg line="${native.src.dir}/packageNativeHadoop.sh"/>
+          <arg line="${native.src.dir}/packageNativeHadoop.py"/>
     </exec>
 
     <subant target="package">

Modified: hadoop/common/branches/branch-1-win/src/contrib/hod/build.xml
URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-1-win/src/contrib/hod/build.xml?rev=1409269&r1=1409268&r2=1409269&view=diff
==============================================================================
--- hadoop/common/branches/branch-1-win/src/contrib/hod/build.xml (original)
+++ hadoop/common/branches/branch-1-win/src/contrib/hod/build.xml Wed Nov 14 17:38:01 2012
@@ -26,9 +26,7 @@
                 <exclude name="**/VERSION"/>
             </fileset>
         </copy>
-        <exec executable="echo" output="${build.dir}/bin/VERSION">
-            <arg line="${version}" />
-        </exec>
+        <echo file="${build.dir}/bin/VERSION" append="false">${version}</echo>
     </target>
     <target name="package" depends="compile">
         <mkdir dir="${dist.dir}/contrib/${name}"/>

Added: hadoop/common/branches/branch-1-win/src/fixFontsPath.py
URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-1-win/src/fixFontsPath.py?rev=1409269&view=auto
==============================================================================
--- hadoop/common/branches/branch-1-win/src/fixFontsPath.py (added)
+++ hadoop/common/branches/branch-1-win/src/fixFontsPath.py Wed Nov 14 17:38:01 2012
@@ -0,0 +1,108 @@
+#! /usr/bin/python
+
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License.  You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+
+# This file is used to fix the paths in CNDOCS_SRC/uming.conf and
+# CNDOCS_SRC/src/documentation/sitemap.xmap 
+
+import os
+import sys
+
+template_uming = \
+'''<?xml version="1.0"?>
+<configuration>
+  <fonts>
+    <font metrics-file="%s/uming.xml" kerning="yes" embed-file="%s/uming.ttc">
+      <font-triplet name="AR PL UMing" style="normal" weight="normal"/>
+      <font-triplet name="AR PL UMing" style="italic" weight="normal"/>
+      <font-triplet name="AR PL UMing" style="normal" weight="bold"/>
+      <font-triplet name="AR PL UMing" style="italic" weight="bold"/>
+    </font>
+  </fonts>
+</configuration>
+'''
+
+template_sitemap = \
+'''<?xml version="1.0"?>
+<!--
+  Licensed to the Apache Software Foundation (ASF) under one or more
+  contributor license agreements.  See the NOTICE file distributed with
+  this work for additional information regarding copyright ownership.
+  The ASF licenses this file to You under the Apache License, Version 2.0
+  (the "License"); you may not use this file except in compliance with
+  the License.  You may obtain a copy of the License at
+
+      http://www.apache.org/licenses/LICENSE-2.0
+
+  Unless required by applicable law or agreed to in writing, software
+  distributed under the License is distributed on an "AS IS" BASIS,
+  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  See the License for the specific language governing permissions and
+  limitations under the License.
+-->
+<map:sitemap xmlns:map="http://apache.org/cocoon/sitemap/1.0">
+  <map:components>
+    <map:serializers default="fo2pdf">
+      <map:serializer name="fo2pdf"
+                src="org.apache.cocoon.serialization.FOPSerializer"
+                mime-type="application/pdf">
+        <user-config src="%s/uming.conf"/>
+        </map:serializer>
+    </map:serializers>
+  </map:components>
+  <map:pipelines>
+    <map:pipeline>
+<!-- generate .pdf files from .fo -->
+      <map:match type="regexp" pattern="^(.*?)([^/]*).pdf$">
+        <map:select type="exists">
+          <map:when test="{lm:project.{1}{2}.pdf}">
+            <map:read src="{lm:project.{1}{2}.pdf}"/>
+          </map:when>
+          <map:when test="{lm:project.{1}{2}.fo}">
+            <map:generate src="{lm:project.{1}{2}.fo}"/>
+            <map:serialize type="fo2pdf"/>
+          </map:when>
+          <map:otherwise>
+            <map:generate src="cocoon://{1}{2}.fo"/>
+            <map:serialize type="fo2pdf"/>
+          </map:otherwise>
+        </map:select>
+      </map:match>
+    </map:pipeline>
+  </map:pipelines>
+</map:sitemap>
+'''
+
+def main(argv=None):
+  if argv is None:
+    argv = sys.argv[1:3]
+  cndocs_src = argv[0]
+
+  uming_file = 'src/docs/cn/uming.conf'
+  fout = open(uming_file, "w")
+  fout.write(template_uming % (cndocs_src, cndocs_src))
+  fout.close()
+  
+  site_map_file = 'src/docs/cn/src/documentation/sitemap.xmap'
+  fout = open(site_map_file, "w")
+  fout.write(template_sitemap % (cndocs_src))
+  fout.close()
+  return 0
+
+##########################
+if __name__ == "__main__":
+  sys.exit(main())

Added: hadoop/common/branches/branch-1-win/src/native/packageNativeHadoop.py
URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-1-win/src/native/packageNativeHadoop.py?rev=1409269&view=auto
==============================================================================
--- hadoop/common/branches/branch-1-win/src/native/packageNativeHadoop.py (added)
+++ hadoop/common/branches/branch-1-win/src/native/packageNativeHadoop.py Wed Nov 14 17:38:01 2012
@@ -0,0 +1,97 @@
+#! /usr/bin/python
+
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License.  You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+
+# packageNativeHadoop.py - A simple script to help package native-hadoop libraries
+
+#
+# Note: 
+# This script relies on the following environment variables to function correctly:
+#  * BASE_NATIVE_LIB_DIR
+#  * BUILD_NATIVE_DIR
+#  * DIST_LIB_DIR
+# All these are setup by build.xml.
+#
+
+import os
+import sys
+import re
+from glob import iglob
+from shutil import copy2
+from shutil import copytree
+from os.path import join
+from os.path import basename
+
+# Convert Windows paths with back-slashes into canonical Unix paths
+# with forward slashes.  Unix paths are unchanged.  Mixed formats
+# just naively have back-slashes converted to forward slashes.
+def canonicalpath(path):
+  return re.sub('\\\\','/',path)
+
+def copy_files(src_glob, dst_folder):
+  for fname in iglob(src_glob):
+    src_file = canonicalpath(fname)
+    dst_file = canonicalpath(join(dst_folder, basename(fname)))
+    if (os.path.isdir(src_file)):
+      copytree(src_file, dst_file)
+    else:
+      copy2(src_file, dst_file)
+
+def main(argv=None):
+  dist_lib_dir = os.environ["DIST_LIB_DIR"]
+  if not os.path.isdir(dist_lib_dir):
+    os.makedirs(dist_lib_dir)
+
+  # Copy the pre-built libraries in BASE_NATIVE_LIB_DIR
+  if os.path.isdir(os.environ["BASE_NATIVE_LIB_DIR"]):
+    for platform in os.listdir(os.environ["BASE_NATIVE_LIB_DIR"]):
+      base_path = canonicalpath(os.path.join(os.environ["BASE_NATIVE_LIB_DIR"], platform))
+      dist_path = canonicalpath(os.path.join(dist_lib_dir, platform))
+      if not os.path.isdir(dist_path):
+        os.makedirs(dist_path)
+        print "Created %s" % dist_path
+      print "Copying libraries from %s to %s" % (base_path+ "/*hadoop*", dist_path)
+      copy_files(base_path + "/*hadoop*", dist_path)
+
+  # Copy the custom-built libraries in BUILD_NATIVE_DIR
+  if os.path.isdir(os.environ["BUILD_NATIVE_DIR"]):
+    for platform in os.listdir(os.environ["BUILD_NATIVE_DIR"]):
+      base_path = canonicalpath(os.path.join(os.environ["BUILD_NATIVE_DIR"], platform))
+      dist_path = canonicalpath(os.path.join(dist_lib_dir, platform))
+      if not os.path.isdir(dist_path):
+        os.makedirs(dist_path)
+        print "Created %s" % dist_path
+      print "Copying libraries from %s to %s" % (base_path+ "/lib/*hadoop*", dist_path)
+      copy_files(base_path + "/lib/*hadoop*", dist_path)
+
+  if "BUNDLE_SNAPPY_LIB" in os.environ and os.environ["BUNDLE_SNAPPY_LIB"] == "true":
+    if "SNAPPY_LIB_DIR" in os.environ:
+      if os.path.isdir(os.environ["SNAPPY_LIB_DIR"]):
+        print "Copying Snappy library in %s to %s/" % (os.environ["SNAPPY_LIB_DIR"], dist_lib_dir)
+        copy_files(os.environ["SNAPPY_LIB_DIR"] + "/*", dist_lib_dir)
+      else:
+        print "Snappy lib directory '%s' does not exist" % os.environ["SNAPPY_LIB_DIR"]
+        return 1
+    else:
+      print "Snappy SNAPPY_LIB_DIR environment variable undefined"
+      return 1
+
+  return 0
+
+##########################
+if __name__ == "__main__":
+  sys.exit(main())