Browse Source

AMBARI-8648. Fix hadoop-sink rpm build to create symlink in postinstall scriptlet. (mpapirkovskyy)

Myroslav Papirkovskyy 10 years ago
parent
commit
391a53b40a

+ 20 - 4
ambari-metrics/ambari-metrics-hadoop-sink/pom.xml

@@ -28,6 +28,12 @@ limitations under the License.
   <artifactId>ambari-metrics-hadoop-sink</artifactId>
   <version>0.1.0-SNAPSHOT</version>
   <packaging>jar</packaging>
+  <properties>
+    <sinkJarName>${project.artifactId}-with-common-${project.version}.jar</sinkJarName>
+  </properties>
+
+
+
   <build>
     <plugins>
       <plugin>
@@ -123,6 +129,12 @@ limitations under the License.
           <copyright>2012, Apache Software Foundation</copyright>
           <group>Development</group>
           <description>Maven Recipe: RPM Package.</description>
+
+          <postinstallScriptlet>
+            <scriptFile>${project.build.outputDirectory}/rpm/postinstall.sh</scriptFile>
+            <fileEncoding>utf-8</fileEncoding>
+          </postinstallScriptlet>
+
           <mappings>
             <mapping>
               <directory>/usr/lib/ambari-metrics-hadoop-sink</directory>
@@ -133,10 +145,6 @@ limitations under the License.
                 <source>
                   <location>target/${project.artifactId}-with-common-${project.version}.jar</location>
                 </source>
-                <softlinkSource>
-                  <destination>ambari-metrics-hadoop-sink.jar</destination>
-                  <location>/usr/lib/ambari-metrics-hadoop-sink/${project.artifactId}-with-common-${project.version}.jar</location>
-                </softlinkSource>
               </sources>
 
             </mapping>
@@ -145,6 +153,14 @@ limitations under the License.
         </configuration>
       </plugin>
     </plugins>
+
+    <resources>
+      <resource>
+        <directory>src/main/package</directory>
+        <filtering>true</filtering>
+      </resource>
+    </resources>
+
   </build>
 
   <dependencies>

+ 24 - 0
ambari-metrics/ambari-metrics-hadoop-sink/src/main/package/rpm/postinstall.sh

@@ -0,0 +1,24 @@
+#!/bin/sh
+# 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
+
+LINK_NAME="/usr/lib/ambari-metrics-hadoop-sink/ambari-metrics-hadoop-sink.jar"
+JAR_NAME="/usr/lib/ambari-metrics-hadoop-sink/${sinkJarName}"
+
+if [ -e "$LINK_NAME" ]; then
+  rm -f $LINK_NAME
+fi
+
+ln -s $JAR_NAME $LINK_NAME