mojohaus / rpm-maven-plugin

http://www.mojohaus.org/rpm-maven-plugin/
Other
56 stars 48 forks source link

Can not uninstall the rpm software through “rpm -e” #123

Open xiaocw opened 3 years ago

xiaocw commented 3 years ago

I used rpm-maven-plugin to package a springboot applicaiton to rpm, and I use 'rpm -ivh xxxx.rpm' successfully installed it. but I can not uninstall it by using 'rpm -e ', after I completed execute uninstall command, it also exsisted by using rpm -qa |grep xxx below is my config:

<?xml version="1.0" encoding="UTF-8"?> <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 https://maven.apache.org/xsd/maven-4.0.0.xsd">

4.0.0
<parent>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-parent</artifactId>
    <version>2.2.4.RELEASE</version>
    <relativePath/>
</parent>
<groupId>com.example</groupId>
<artifactId>cx03</artifactId>
<version>1.0.0</version>
<description>Demo project for Spring Boot, package by rpm</description>

<properties>
    <java.version>1.8</java.version>
    <rpm.install.path>/opt/westone/${artifactId}</rpm.install.path>
    <rpm.prefix>${rpm.install.path}</rpm.prefix>
</properties>

<dependencies>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-web</artifactId>
    </dependency>
</dependencies>

<build>
    <plugins>
        <plugin>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-maven-plugin</artifactId>
        </plugin>
    </plugins>
</build>

<!--rpm打包: mvn clean package -Dmaven.test.skip -Prpm-->
<profiles>
    <profile>
        <id>rpm</id>
        <build>
            <finalName>${project.artifactId}</finalName>
            <plugins>
                <plugin>
                    <groupId>org.springframework.boot</groupId>
                    <artifactId>spring-boot-maven-plugin</artifactId>
                </plugin>
                <plugin>
                    <groupId>org.codehaus.mojo</groupId>
                    <artifactId>rpm-maven-plugin</artifactId>
                    <version>2.2.0</version>
                    <extensions>true</extensions>
                    <executions>
                        <execution>
                            <goals>
                                <goal>rpm</goal>
                            </goals>
                        </execution>
                    </executions>
                    <configuration>
                        <prefix>${rpm.prefix}</prefix>
                        <distribution>westone</distribution>
                        <group>westone.com</group>
                        <packager>xiao.changwei</packager>
                        <version>${project.version}</version>
                        <autoRequires>true</autoRequires>
                        <release>1</release>
                        <requires>
                        </requires>
                        <mappings>
                            <mapping>
                                <directory>${rpm.install.path}/${project.artifactId}</directory>
                                <filemode>755</filemode>
                                <username>root</username>
                                <groupname>root</groupname>
                                <sources>
                                    <source>
                                        <location>target/${project.artifactId}.jar</location>
                                    </source>
                                </sources>
                            </mapping>
                            <mapping>
                                <directory>${rpm.install.path}/${project.artifactId}/bin</directory>
                                <filemode>750</filemode>
                                <username>root</username>
                                <groupname>root</groupname>
                                <sources>
                                    <source>
                                        <location>src/bin</location>
                                    </source>
                                </sources>
                            </mapping>
                        </mappings>
                        <preinstallScriptlet>
                            <script>echo "installing ${project.name} now"</script>
                        </preinstallScriptlet>
                        <postinstallScriptlet>
                            <script>
                                sed -i 's$XXX$${rpm.install.path}/${project.artifactId}/${project.artifactId}.jar$g' ${rpm.install.path}/${project.artifactId}/bin/startup.sh;
                                ${rpm.install.path}/${project.artifactId}/bin/startup.sh
                            </script>
                        </postinstallScriptlet>
                        <preremoveScriptlet>
                            <script>
                                ps -ef |grep ${project.artifactId} |grep -v grep|awk '{print "kill -9 " $2}'| sh;
                            </script>
                        </preremoveScriptlet>
                    </configuration>
                </plugin>
            </plugins>
        </build>
    </profile>
</profiles>