项目需要编译镜像安装,现在梳理下在Debian/Centos系统下编译可安装镜像的方法。
在项目中配置pom.xml如下,支持deb/centos系统:
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<version>1.8</version>
<executions>
<execution>
<id>parse-package-version</id>
<goals>
<goal>regex-property</goal>
</goals>
<configuration>
<name>package-version</name>
<value>${project.version}</value>
<regex>^([0-9]+)\.([0-9]+)\.([0-9]+)\.([0-9]+)((\.|-).*)?</regex>
<replacement>$1.$2.$3.$4</replacement>
<failIfNoMatch>true</failIfNoMatch>
</configuration>
</execution>
<execution>
<id>parse-package-release</id>
<goals>
<goal>regex-property</goal>
</goals>
<configuration>
<name>package-release</name>
<value>${project.release.version}</value>
<regex>^([0-9]+)\.([0-9]+)\.([0-9]+)\.([0-9]+)((\.|-)(([0-9]+)|(NDP)|(SNAPSHOT)|(techwin)).*)?</regex>
<replacement>$7</replacement>
<failIfNoMatch>true</failIfNoMatch>
</configuration>
</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>
<skip>true</skip>
<attach>false</attach>
<controlDir>${basedir}/src/deb/control</controlDir>
<dataSet>
<data>
<src>src/hdpselect/hdp-select</src>
<type>file</type>
<mapper>
<prefix>/usr/bin</prefix>
<type>perm</type>
<user>root</user>
<group>root</group>
<filemode>755</filemode>
</mapper>
</data>
<data>
<src>src/hdpselect/conf-select</src>
<type>file</type>
<mapper>
<prefix>/usr/bin</prefix>
<type>perm</type>
<user>root</user>
<group>root</group>
<filemode>755</filemode>
</mapper>
</data>
</dataSet>
</configuration>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>rpm-maven-plugin</artifactId>
<version>2.1.4</version>
<executions>
<execution>
<id>generate-rpm</id>
<goals>
<goal>rpm</goal>
</goals>
</execution>
</executions>
<configuration>
<license>Apache</license>
<copyright>2012, Apache Software Foundation</copyright>
<distribution>RedHadoop Enterprise </distribution>
<group>NDP/Hadoop</group>
<packager>Hadoop</packager>
<needarch>noarch</needarch>
<!--<targetOS>el7</targetOS>-->
<prefix>/usr/ndp</prefix>
<release>${package-release}</release>
<version>${package-version}</version>
<mappings>
<mapping>
<directory>/usr/bin/hdpselect</directory>
<filemode>755</filemode>
<username>root</username>
<groupname>root</groupname>
<sources>
<source>
<location>src/hdpselect</location>
</source>
</sources>
</mapping>
<mapping>
<directory>/usr/bin</directory>
<username>root</username>
<groupname>root</groupname>
<sources>
<softlinkSource>
<location>/usr/bin/hdpselect/hdp-select</location>
<destination>hdp-select</destination>
</softlinkSource>
</sources>
</mapping>
<mapping>
<directory>/usr/bin</directory>
<username>root</username>
<groupname>root</groupname>
<sources>
<softlinkSource>
<location>/usr/bin/hdpselect/conf-select</location>
<destination>conf-select</destination>
</softlinkSource>
</sources>
</mapping>
</mappings>
<preinstallScriptlet>
<script>echo "NeteaseHadoop NDP Installing Now!"</script>
</preinstallScriptlet>
</configuration>
</plugin>
</plugins>
运行
编译Debian8 deb镜像命令:
cd ne-ambari/hdp-select
mvn -B clean install package jdeb:jdeb
编译Cenots rpm镜像命令:
cd ne-ambari/hdp-select
mvn -B clean install package rpm:rpm
参考
最近搞的项目
https://github.com/LiShuMing/hdp-select
。