Jelajahi Sumber

AMBARI-5588. Ambari should not hardcode python 2.6, but support 2.6 and higher (aonishuk)

Andrew Onishuk 11 tahun lalu
induk
melakukan
1eab85a4b3

+ 17 - 1
ambari-client/groovy-client/pom.xml

@@ -108,6 +108,22 @@
           <skipAssembly>true</skipAssembly>
         </configuration>
       </plugin>
+      <plugin>
+        <groupId>org.vafer</groupId>
+        <artifactId>jdeb</artifactId>
+        <version>1.0.1</version>
+        <executions>
+          <execution>
+            <phase>none</phase>
+            <goals>
+              <goal>jdeb</goal>
+            </goals>
+          </execution>
+        </executions>
+        <configuration>
+          <controlDir>${basedir}/../../ambari-project/src/main/package/deb/control</controlDir>
+        </configuration>
+      </plugin>
     </plugins>
   </build>
-</project>
+</project>

+ 16 - 0
ambari-client/pom.xml

@@ -54,6 +54,22 @@
           </execution>
         </executions>
       </plugin>
+      <plugin>
+        <groupId>org.vafer</groupId>
+        <artifactId>jdeb</artifactId>
+        <version>1.0.1</version>
+        <executions>
+          <execution>
+            <phase>none</phase>
+            <goals>
+              <goal>jdeb</goal>
+            </goals>
+          </execution>
+        </executions>
+        <configuration>
+          <controlDir>${basedir}/../ambari-project/src/main/package/deb/control</controlDir>
+        </configuration>
+      </plugin>
     </plugins>
   </build>
 </project>

+ 17 - 5
ambari-client/python-client/pom.xml

@@ -40,6 +40,9 @@
     <install.dir>/usr/lib/python2.6/site-packages/ambari_client</install.dir>
     <lib.dir>/usr/lib/ambari-client/lib</lib.dir>
     <python.ver>python &gt;= 2.6</python.ver>
+    <deb.python.ver>python (&gt;= 2.6)</deb.python.ver>
+    <deb.architecture>amd64</deb.architecture>
+    <deb.dependency.list>openssl, zlibc, ${deb.python.ver}</deb.dependency.list>
   </properties>
   <build>
     <plugins>
@@ -72,7 +75,7 @@
         <executions>
           <execution>
             <configuration>
-              <executable>python2.6</executable>
+              <executable>${project.basedir}/../../ambari-common/src/main/unix/ambari-python-wrap</executable>
               <workingDirectory>src/test/python</workingDirectory>
               <arguments>
                 <argument>unitTests.py</argument>
@@ -90,7 +93,7 @@
           </execution>
           <execution>
             <configuration>
-              <executable>python2.6</executable>
+              <executable>${project.basedir}/../../ambari-common/src/main/unix/ambari-python-wrap</executable>
               <workingDirectory>target/python-client-${project.version}</workingDirectory>
               <arguments>
                 <argument>${project.basedir}/src/main/python/setup.py</argument>
@@ -141,7 +144,6 @@
                 </source>
               </sources>
             </mapping>
-            <!-- -->
           </mappings>
         </configuration>
       </plugin>
@@ -180,8 +182,18 @@
           </execution>
         </executions>
         <configuration>
-          <skip>true</skip>
-          <submodules>false</submodules>
+          <controlDir>${basedir}/src/main/package/deb/control</controlDir>
+          <deb>${basedir}/target/${artifactId}_${package-version}-${package-release}.deb</deb>
+          <dataSet>
+            <data>
+              <src>${project.build.directory}/${project.artifactId}-${project.version}/ambari_client</src>
+              <type>directory</type>
+              <mapper>
+                <type>perm</type>
+                <prefix>${install.dir}</prefix>
+              </mapper>
+            </data>
+          </dataSet>
         </configuration>
       </plugin>
     </plugins>

+ 22 - 0
ambari-client/python-client/src/main/package/deb/control/control

@@ -0,0 +1,22 @@
+# 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
+Package: [[artifactId]]
+Version: [[package-version]]-[[package-release]]
+Section: [[deb.section]]
+Priority: [[deb.priority]]
+Depends: [[deb.dependency.list]]
+Architecture: [[deb.architecture]]
+Description: [[description]]
+Maintainer: [[deb.publisher]]

+ 15 - 0
ambari-client/python-client/src/main/package/deb/control/postinst

@@ -0,0 +1,15 @@
+#!/bin/bash
+# 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

+ 15 - 0
ambari-client/python-client/src/main/package/deb/control/postrm

@@ -0,0 +1,15 @@
+#!/bin/bash
+# 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

+ 15 - 0
ambari-client/python-client/src/main/package/deb/control/posttrm

@@ -0,0 +1,15 @@
+#!/bin/bash
+# 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

+ 15 - 0
ambari-client/python-client/src/main/package/deb/control/preinst

@@ -0,0 +1,15 @@
+#!/bin/bash
+# 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

+ 15 - 0
ambari-client/python-client/src/main/package/deb/control/prerm

@@ -0,0 +1,15 @@
+#!/bin/bash
+# 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

+ 1 - 1
ambari-common/src/main/unix/ambari-python-wrap

@@ -37,4 +37,4 @@ if [[ -z "$PYTHON" ]]; then
 fi
 
 # execute script
-$PYTHON $@
+$PYTHON "$@"

+ 19 - 1
ambari-shell/pom.xml

@@ -115,6 +115,24 @@
           <mainClass>${start-class}</mainClass>
         </configuration>
       </plugin>
+      <plugin>
+        <groupId>org.vafer</groupId>
+        <artifactId>jdeb</artifactId>
+        <version>1.0.1</version>
+        <executions>
+          <execution>
+            <phase>none</phase>
+            <goals>
+              <goal>jdeb</goal>
+            </goals>
+          </execution>
+        </executions>
+        <configuration>
+          <controlDir>${basedir}/../../ambari-project/src/main/package/deb/control</controlDir>
+          <skip>true</skip>
+          <submodules>false</submodules>
+        </configuration>
+      </plugin>
     </plugins>
   </build>
-</project>
+</project>

+ 1 - 1
ambari-web/pom.xml

@@ -117,7 +117,7 @@
             <configuration>
               <target name="ambari-web-compile">
                 <exec dir="${basedir}" executable="npm" failonerror="false">
-                  <env key="PYTHON" value="python2.6" />
+                  <env key="PYTHON" value="${project.basedir}/../ambari-common/src/main/unix/ambari-python-wrap" />
                   <arg value="install"/>
                 </exec>
                 <exec dir="${basedir}" executable="brunch" failonerror="false">

+ 3 - 3
contrib/views/files/pom.xml

@@ -21,13 +21,13 @@
     <artifactId>files</artifactId>
     <version>0.1.0-SNAPSHOT</version>
     <name>Files</name>
-    
+
     <parent>
         <groupId>org.apache.ambari.views</groupId>
         <artifactId>ambari-contrib-views</artifactId>
         <version>0.1.0-SNAPSHOT</version>
     </parent>
-    
+
     <dependencies>
     <dependency>
         <groupId>org.apache.hadoop</groupId>
@@ -155,7 +155,7 @@
                 <!-- optional: The default argument is actually "install", so unless
                  you need to run some other npm command, you can remove this whole <configuration>
                  section. -->
-              <arguments>install --python=python2.6 --unsafe-perm --registry=http://registry.npmjs.eu</arguments>
+              <arguments>install --python="${project.basedir}/../src/main/unix/ambari-python-wrap" --unsafe-perm --registry=http://registry.npmjs.eu</arguments>
             </configuration>
             </execution>
         </executions>

+ 1 - 1
contrib/views/pig/pom.xml

@@ -147,7 +147,7 @@
               <goal>npm</goal>
             </goals>
             <configuration>
-              <arguments>install --python=python2.6 --unsafe-perm</arguments>
+              <arguments>install --python="${project.basedir}/../src/main/unix/ambari-python-wrap" --unsafe-perm</arguments>
             </configuration>
           </execution>
         </executions>

+ 13 - 13
contrib/views/slider/pom.xml

@@ -1,12 +1,12 @@
-<!-- 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 
+<!-- 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. -->
 <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
 	xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
@@ -415,7 +415,7 @@
 						<configuration>
 							<target name="slider-ui-compile">
 								<exec dir="${ui.directory}" executable="npm" failonerror="false">
-									<env key="PYTHON" value="python2.6" />
+									<env key="PYTHON" value="${project.basedir}/../src/main/unix/ambari-python-wrap" />
 									<arg value="install" />
 								</exec>
 								<exec dir="${ui.directory}" executable="brunch"
@@ -438,7 +438,7 @@
 						</goals>
 						<configuration>
 							<target name="slider-ui-test">
-								<!-- <exec dir="${ui.directory}" executable="brunch" failonerror="false"> 
+								<!-- <exec dir="${ui.directory}" executable="brunch" failonerror="false">
 									<arg value="test"/> </exec> -->
 							</target>
 						</configuration>
@@ -451,7 +451,7 @@
 						</goals>
 						<configuration>
 							<target name="slider-ui-package">
-								<!-- <copy toDir="${project.build.directory}/ambari-server-${project.version}-dist/ambari-server-${project.version}/web/"> 
+								<!-- <copy toDir="${project.build.directory}/ambari-server-${project.version}-dist/ambari-server-${project.version}/web/">
 									<fileset dir="${ui.directory}/../ambari-web/public"/> </copy> -->
 							</target>
 						</configuration>
@@ -510,7 +510,7 @@
 		</resources>
 		<pluginManagement>
 			<plugins>
-				<!--This plugin's configuration is used to store Eclipse m2e settings 
+				<!--This plugin's configuration is used to store Eclipse m2e settings
 					only. It has no influence on the Maven build itself. -->
 				<plugin>
 					<groupId>org.eclipse.m2e</groupId>

+ 38 - 0
contrib/views/src/main/unix/ambari-python-wrap

@@ -0,0 +1,38 @@
+#!/usr/bin/env bash
+# Copyright 2011 The Apache Software Foundation
+#
+# 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.
+
+# reset settings
+unset PYTHON
+
+# checking for preferable python versions
+if [ -a /usr/bin/python2.7 ] && [ -z "$PYTHON" ]; then
+  PYTHON=/usr/bin/python2.7
+fi
+
+if [ -a /usr/bin/python2.6 ] && [ -z "$PYTHON" ]; then
+  PYTHON=/usr/bin/python2.6
+fi
+
+# if no preferable python versions found, try to use system one
+if [[ -z "$PYTHON" ]]; then
+  PYTHON=/usr/bin/python
+fi
+
+# execute script
+$PYTHON "$@"