rpm package specifies the installation path

The rpm package generally has a default installation path, how do you want to change the default path, is there any way? Of course there is. Let's look at the following example.
For example, when installing JDK (Java Development Kit) or JRE (Java Runtime Environment), the default installation path of this RedHat package file is /usr/java. What if you want to install it in another path, for example, in the /home/java directory?
1. First check the details of the rpm package
[root@ Oracle ~]# rpm -qpi jdk-6u43-linux-amd64.rpm
Name : jdk Relocations: /usr/java
Version : 1.6.0_43 Vendor: Oracle and/or its affiliates .
Release : fcs Build Date: Fri 01 Mar 2013 09:03:27 PM CST
Install Date: (not installed) Build Host: jb6-lin-amd64.sfbay.sun.com
Group : Development/Tools Source RPM: jdk-1.6 .0_43-fcs.src.rpm
Size        : 127075557                        License: Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved. Also under other license(s) as shown at the Description field.
Signature  : (none)
Packager    : Java Software <[email protected]>
URL        : http://www.oracle.com/technetwork/java/javase/overview/index.html
Summary    : Java(TM) Platform Standard Edition Development Kit
Description :
The Java Platform Standard Edition Development Kit (JDK) includes both
the runtime environment (Java virtual machine, the Java platform classes
and supporting files) and development tools (compilers, debuggers,
tool libraries and other tools).


The JDK is a development environment for building applications, applets
and components that can be deployed with the Java Platform Standard
Edition Runtime Environment.


The JDK is installed under /usr/java by default.

 

Let's set the parameters in this way, you can install the JDK in the directory you specify.
[root@linuxidc ~]# rpm -i --badreloc --relocate /usr/java=/home/java jdk-6u43-linux-amd64.rpm
Unpacking JAR files...
        rt.jar...
        jsse.jar. ..
        charsets.jar...
        tools.jar...
        localedata.jar...
        plugin.jar...
        javaws.jar...
        deploy.jar...
ln: creating symbolic link `/usr/java/jdk1 .6.0_43': No such file or directory
Parameter definition:
badreloc is to force the file to be installed where you want it.
Relocate is to install only the files that should be installed in the oldpath to the newpath, so as to install some files to other paths, instead of replacing all the files of this package.
But neither prefix nor relocate can really be used, because some packages or files are not allowed to be installed in other paths, such as oracleasm-support-2.1.8-1.el6.x86_64.rpm


[root@oracle ~]# rpm -qpi oracleasm-support-2.1.8-1.el6.x86_64.rpm
warning: oracleasm-support-2.1.8-1.el6.x86_64.rpm: Header V3 RSA/SHA256 Signature, key ID ec551f03: NOKEY
Name        : oracleasm-support            Relocations: (not relocatable)
Version    : 2.1.8                            Vendor: Oracle Corporation
Release    : 1.el6                        Build Date: Sat 09 Feb 2013 06:46:49 AM CST
Install Date: (not installed)              Build Host: ca-build44.us.oracle.com
Group      : System Environment/Kernel    Source RPM: oracleasm-support-2.1.8-1.el6.src.rpm
Size        : 221696                          License: GPL
Signature  : RSA/8, Sat 09 Feb 2013 06:50:30 AM CST, Key ID 72f97b74ec551f03
Packager    : Joel Becker <[email protected]>
URL        : http://oss.oracle.com/projects/oracleasm/
Summary    : The Oracle Automatic Storage Management support programs.
Description :
Tools to manage the Oracle Automatic Storage Management library driver


not relocatable can not be relocated, it is impossible to modify the installation directory, only remove the --prefix parameter.


[root@linuxidc ~]# java -version
-bash: /usr/bin/java: No such file or directory
The JAVA version number is not displayed at this time because the environment variables have not been modified.
Modify the JAVA environment variables below
[root@linuxidc jdk1.6.0_43]# vi /etc/profile
JAVA_HOME=/home/java/jdk1.6.0_43
PATH=$JAVA_HOME/bin:$PATH
CLASSPATH=.:$JAVA_HOME/lib /dt.jar:$JAVA_HOME/lib/tools.jar
export JAVA_HOME
export PATH
export CLASSPATH
"/etc/profile" 85L, 1961C written


[root@linuxidc jdk1.6.0_43]# source /etc/profile
to make environment variables take effect.
Check again, there is a JAVA version number displayed.
[root@linuxidc jdk1.6.0_43]# java -version
java version "1.6.0_43"
Java(TM) SE Runtime Environment (build 1.6.0_43-b01)
Java HotSpot(TM) 64-Bit Server VM (build 20.14-b01 , mixed mode)

 


Supplement:
When installing JDK, you need to check whether the original system has other JAVA version numbers. If it is inconsistent with the one you want to install, please uninstall it and then install it.
[root@linuxidc ~]# java -version
java version "1.7.0_45"
OpenJDK Runtime Environment (rhel-2.4.3.3.el6-x86_64 u45-b15)
OpenJDK 64-Bit Server VM (build 24.45-b08, mixed mode
) Find
[root@linuxidc ~]# rpm -aq |grep java
java-1.7.0-openjdk-1.7.0.45-2.4.3.3.el6.x86_64
tzdata-java-2013g-1.el6.noarch
java-1.6.0- openjdk-1.6.0.0-1.66.1.13.0.el6.x86_64
force uninstall
[root@linuxidc ~]# rpm -e --nodeps java-1.7.0-openjdk-1.7.0.45-2.4.3.3.el6.x86_64
[ root@linuxidc ~]# rpm -aq |grep java
tzdata-java-2013g-1.el6.noarch
java-1.6.0-openjdk-1.6.0.0-1.66.1.13.0.el6.x86_64
[root@linuxidc ~]# rpm -e --nodeps java-1.6.0-openjdk-1.6.0.0-1.66.1.13.0.el6.x86_64
Check again and find that it has been uninstalled cleanly.
[root@linuxidc ~]# java -version
-bash: /usr/bin/java: No such file or directory

 

Getting Started with RPM Package Creationhttp  ://www.linuxidc.com/Linux/2015-02/113559.htm

How to create an RPM package in Linux?  http://www.linuxidc.com/Linux/2012-05/60278.htm

Make your own rpm package http://www.linuxidc.com/Linux/2013-06/86435.htm

The directory structure and some configurations after rpm installation under Linuxhttp ://www.linuxidc.com/Linux/2013-06/85761.htm

Comprehensive introduction and example demonstration of rpm and yum http://www.linuxidc.com/Linux/2013-05/84480.htm

Redhat Linux---rpm command detailed explanationhttp ://www.linuxidc.com/Linux/2013-03/81971.htm

Use FPM to easily make RPM packages http://www.linuxidc.com/linux/2014-06/103019.htm

 

Reference to: http://www.linuxidc.com/Linux/2015-05/117967.htm

If there are mistakes, welcome to make

Email: [email protected]

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326530641&siteId=291194637