Java环境下编译支持Debian/Centos系统安装镜像

项目需要编译镜像安装,现在梳理下在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

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值