2021-05-12 14:32:11
rpm包指定安裝路徑
rpm包一般都有預設的安裝路徑,如何你要更改預設路徑,有沒有辦法呢?當然有。我們來看下面的例子。
比如在安裝JDK (Java Development Kit)或JRE (Java Runtime Environment)時,這個RedHat package檔案的預設安裝路徑是/usr/java。如果你要安裝在其它路徑下,例如要放到/home/java目錄下,該如何做呢?
一、首先檢視rpm包的詳細資訊
[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 <jre-comments@java.sun.com>
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.
這個JDK是預設要裝在/usr/java 下的。
下面我們這樣來設定引數,就可以把JDK裝在你指定的目錄下。
[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
引數釋義:
badreloc是強制把檔案安裝到你想要的地方。
relocate就是只把應該裝到oldpath下的檔案安裝到newpath,實現將一部分檔案安裝到其它的路徑,而不是把所有的這個包的檔案都替換。
但是無論是prefix還是relocate都不見得可以真正可以用,因為有的包或者檔案不允許裝到其他路徑,比如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 <joel.becker@oracle.com>
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不能重定位,是無法修改安裝目錄的,只有去掉 --prefix引數了。
[root@linuxidc ~]# java -version
-bash: /usr/bin/java: No such file or directory
這時沒有顯示JAVA版本號,是因為環境變數還沒修改。
下面修改一下JAVA的環境變數
[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
使環境變數生效。
再檢視,就有JAVA版本號顯示了。
[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)
補充一下:
在安裝JDK時,需要檢視一下原系統是否有其他的JAVA版本號,如果跟你要裝的不一致,請解除安裝後再裝。
[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)
進行查詢
[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
強制解除安裝
[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
再檢查,發現已解除安裝乾淨。
[root@linuxidc ~]# java -version
-bash: /usr/bin/java: No such file or directory
RPM包建立入門 http://www.linuxidc.com/Linux/2015-02/113559.htm
如何在Linux中建立RPM包? http://www.linuxidc.com/Linux/2012-05/60278.htm
製作自己的rpm包 http://www.linuxidc.com/Linux/2013-06/86435.htm
Linux 下rpm安裝後的目錄結構和一些設定 http://www.linuxidc.com/Linux/2013-06/85761.htm
rpm與yum的綜合性介紹與範例演示 http://www.linuxidc.com/Linux/2013-05/84480.htm
Redhat Linux---rpm 命令詳解 http://www.linuxidc.com/Linux/2013-03/81971.htm
使用FPM輕鬆製作RPM包 http://www.linuxidc.com/linux/2014-06/103019.htm
本文永久更新連結地址:http://www.linuxidc.com/Linux/2015-05/117967.htm
相關文章