Browse Source

HDFS-4163. HDFS distribution build fails on Windows. Contributed by Chris Nauroth.

git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/branches/branch-trunk-win@1408997 13f79535-47bb-0310-9956-ffa450edef68
Suresh Srinivas 12 năm trước cách đây
mục cha
commit
a600a18040

+ 25 - 24
hadoop-hdfs-project/hadoop-hdfs-httpfs/pom.xml

@@ -535,20 +535,20 @@
                     <delete dir="${project.build.directory}/tomcat.exp"/>
                     <mkdir dir="${project.build.directory}/tomcat.exp"/>
 
-                    <!-- Using Unix script to preserve file permissions -->
-                    <echo file="${project.build.directory}/tomcat-untar.sh">
+                    <!-- This script preserves permissions and symlinks. -->
+                    <!-- Python requires resetting indentation to far left. -->
+                    <echo file="${project.build.directory}/tomcat-untar.py">
+from os.path import abspath
+import tarfile
 
-                      which cygpath 2&gt; /dev/null
-                      if [ $? = 1 ]; then
-                      BUILD_DIR="${project.build.directory}"
-                      else
-                      BUILD_DIR=`cygpath --unix '${project.build.directory}'`
-                      fi
-                      cd $BUILD_DIR/tomcat.exp
-                      tar xzf ${basedir}/downloads/tomcat.tar.gz
+src = abspath(r"${basedir}/downloads/tomcat.tar.gz")
+dest = abspath(r"${project.build.directory}/tomcat.exp")
+
+with tarfile.open(src, "r:gz") as tar:
+  tar.extractall(path=dest)
                     </echo>
-                    <exec executable="sh" dir="${project.build.directory}" failonerror="true">
-                      <arg line="./tomcat-untar.sh"/>
+                    <exec executable="python" dir="${project.build.directory}" failonerror="true">
+                      <arg line="tomcat-untar.py"/>
                     </exec>
 
                     <move file="${project.build.directory}/tomcat.exp/apache-tomcat-${tomcat.version}"
@@ -578,20 +578,21 @@
                 </goals>
                 <configuration>
                   <target if="tar">
-                    <!-- Using Unix script to preserve symlinks -->
-                    <echo file="${project.build.directory}/dist-maketar.sh">
+                    <!-- This script preserves permissions and symlinks. -->
+                    <!-- Python requires resetting indentation to far left. -->
+                    <echo file="${project.build.directory}/dist-maketar.py">
+from os.path import abspath, join
+import tarfile
+
+base_name = "${project.artifactId}" + "-" + "${project.version}"
+dir_name = abspath(join(r"${project.build.directory}", base_name))
+tar_name = dir_name + ".tar.gz"
 
-                      which cygpath 2&gt; /dev/null
-                      if [ $? = 1 ]; then
-                      BUILD_DIR="${project.build.directory}"
-                      else
-                      BUILD_DIR=`cygpath --unix '${project.build.directory}'`
-                      fi
-                      cd $BUILD_DIR
-                      tar czf ${project.artifactId}-${project.version}.tar.gz ${project.artifactId}-${project.version}
+with tarfile.open(tar_name, "w:gz") as tar:
+  tar.add(dir_name, arcname=base_name)
                     </echo>
-                    <exec executable="sh" dir="${project.build.directory}" failonerror="true">
-                      <arg line="./dist-maketar.sh"/>
+                    <exec executable="python" dir="${project.build.directory}" failonerror="true">
+                      <arg value="dist-maketar.py" />
                     </exec>
                   </target>
                 </configuration>

+ 3 - 0
hadoop-hdfs-project/hadoop-hdfs/CHANGES.branch-trunk-win.txt

@@ -3,3 +3,6 @@ branch-trunk-win changes - unreleased
   HDFS-4145. Merge hdfs cmd line scripts from branch-1-win. (David Lao,
   Bikas Saha, Lauren Yang, Chuan Liu, Thejas M Nair and Ivan Mitic via suresh)
 
+  HDFS-4163. HDFS distribution build fails on Windows. (Chris Nauroth via
+  suresh)
+

+ 3 - 0
hadoop-yarn-project/CHANGES.branch-trunk-win.txt

@@ -9,3 +9,6 @@ branch-trunk-win changes - unreleased
   suresh)
 
   YARN-199. Yarn cmd line scripts for windows. (Ivan Mitic via suresh)
+
+  YARN-213. YARN build script would be more readable using abspath.
+  (Chris Nauroth via suresh)