资讯详情

ubuntu | centos 找不到软件包

前言

Linux二进制软件包分为几个派系,其中deb与rpm主流派。每个派系的资源都不一样。


一、rpm与deb的区别

有些系统只支持使用rpm有的只支持包装安装deb混乱的安装会导致系统问题。

RPM(Red Hat Package Manager),是基于Red hat的Linux Distribution包管理系统也指rpm包本身,RPM用于rpm包管理(如安装、卸载、升级等。Mandrake和SuSE这些基于RPM发行版通常有自己的特定版本rpm包。 第三方发行的混合安装可能不正常工作rpm一般来说,基于RPM正常安装在系统上。

对于基于Debian的系统使用deb格式包可用于安装和升级dpkg,然而,它不能很容易地处理包的依赖关系,这更容易dselect和apt-get, Ubunut是debian的变种, 其软件以deb以包或源文件的形式出现。

rpm包主要用于redhat及分支如redhat,centos,Fedora等。 deb包主要用于debian及分支如debian,ubuntu等。

rpm相对而言,版本不是最新的,但相对稳定;和deb包则的版本相对较新。一般来说,一个新软件可能会出来deb但在使用过程中很容易造成包bugs。


二、工具安装

2.1 apt端(ubuntu/debian)

apt该软件默认包含,直接执行以下安装命令。

apt install -y alien 

2.2 yum端(redhat/centos)

由于yum该软件不包括在官方内,因此安装前需要添加源,命令步骤如下:

yum install -y epel-release rpm --import http://li.nux.ro/download/nux/RPM-GPG-KEY-nux.ro rpm -Uvh http://li.nux.ro/download/nux/dextop/el7/x86_64/nux-dextop-release-0-5.el7.nux.noarch.rpm 

然后更新源(可选)

yum update 

最后是安装

yum install  -y alien 

2.3 安装完成

执行下列命令,验证安装是否成功

[root@localhost ~]# alien -V alien version 8.95 

三、包转换

[root@localhost ~]# alien You must specify a file to convert.  Usage: alien [options] file [...]   file [...]                Package file or files to convert.   -d, --to-deb              Generate a Debian deb package (default).      Enables these options:        --patch=<patch>      Specify patch file to use instead of automatically                             looking for patch in /var/lib/alien.        --nopatch     Do not use patches.        --anypatch           Use even old version os patches.        -s, --single         Like --generate, but do not create .orig                             directory.        --fixperms           Munge/fix permissions and owners.        --test               Test generated packages with lintian.   -r, --to-rpm              Generate a Red Hat rpm package.       --to-slp              Generate a Stampede slp package.   -l, --to-lsb              Generate a LSB package.   -t, --to-tgz              Generate a Slackware tgz package.      Enables these options:        --description=<desc> Specify package description.        --version=<version>  Specify package version.   -p, --to-pkg              Generate a Solaris pkg package.   -i, --install             Install generated package.   -g, --generate            Generate build tree, but do not build package.   -c, --scripts             Include scrits in package.
      --target=<arch>       Set architecture of the generated package.
  -v, --verbose             Display each command alien runs.
      --veryverbose         Be verbose, and also display output of run commands.
  -k, --keep-version        Do not change version of generated package.
      --bump=number         Increment package version by this number.
  -h, --help                Display this help message.
  -V, --version		    Display alien's version number.

从上面的信息可以看出,常用的两个参数为:

-d #转为deb
-r #转为rpm

3.1 rpm转deb

首先使用下载一个rpm包,以下载 mce-inject 工具为例:

[root@localhost ~]# yum search mce-inject # 查找 mce-inject 程序所在的包名
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
 * base: mirrors.aliyun.com
 * epel: hkg.mirror.rackspace.com
 * extras: mirrors.aliyun.com
 * nux-dextop: li.nux.ro
 * updates: mirrors.aliyun.com
=================================================================================== Matched: mce-inject ====================================================================================
ras-utils.x86_64 : RAS Utilities        # mce-inject 程序所在的包名为:ras-utils.x86_64
[root@localhost ~]# 
[root@localhost ~]# yum install --downloadonly ras-utils # 只下载,不安装;因为后续要将下载的rpm包转换为deb包
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
 * base: mirrors.aliyun.com
 * epel: hkg.mirror.rackspace.com
 * extras: mirrors.aliyun.com
 * nux-dextop: li.nux.ro
 * updates: mirrors.aliyun.com
Resolving Dependencies
--> Running transaction check
---> Package ras-utils.x86_64 0:7.0-6.el7 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

============================================================================================================================================================================================
 Package                                        Arch                                        Version                                         Repository                                 Size
============================================================================================================================================================================================
Installing:
 ras-utils                                      x86_64                                      7.0-6.el7                                       base                                      156 k

Transaction Summary
============================================================================================================================================================================================
Install  1 Package

Total download size: 156 k
Installed size: 453 k
Background downloading packages, then exiting:
ras-utils-7.0-6.el7.x86_64.rpm                                                                                                                                       | 156 kB  00:00:05     
exiting because "Download Only" specified
[root@localhost ~]# 
[root@localhost ~]# find / -name "ras-utils-7.0-6.el7.x86_64.rpm" 
/var/cache/yum/x86_64/7/base/packages/ras-utils-7.0-6.el7.x86_64.rpm
[root@localhost ~]#
[root@localhost ~]# cp /var/cache/yum/x86_64/7/base/packages/ras-utils-7.0-6.el7.x86_64.rpm . # 拷贝到当前路径
[root@localhost ~]#
[root@localhost ~]# alien -d ras-utils-7.0-6.el7.x86_64.rpm # 将 rpm 包转换为 deb 包
ras-utils_7.0-7_amd64.deb generated
[root@localhost ~]#
[root@localhost ~]# ls ras-utils
ras-utils-7.0-6.el7.x86_64.rpm  ras-utils_7.0-7_amd64.deb        # 转换完成

将deb包发送到 ubuntu/debian,进行安装:

root@:/home/admin# dpkg -i ras-utils_7.0-7_amd64.deb 
Selecting previously unselected package ras-utils.
(Reading database ... 41122 files and directories currently installed.)
Preparing to unpack ras-utils_7.0-7_amd64.deb ...
Unpacking ras-utils (7.0-7) ...
Setting up ras-utils (7.0-7) ...
root@:/home/admin# 
root@:/home/admin# mc # mce-inject 即为安装的程序
mce-inject  mcelog      mcookie     

3.2 deb转rpm

使用下面的命令进行转换

root@sonic:/home/admin# alien -r ras-utils_7.0-7_amd64.deb # 开始转换
ras-utils-7.0-8.x86_64.rpm generated
root@sonic:/home/admin# 
root@sonic:/home/admin# ls ras-utils
ras-utils_7.0-7_amd64.deb   ras-utils-7.0-8.x86_64.rpm          # 转换完成
root@sonic:/home/admin# 

将 rpm 包发送到 redhat/centos,进行安装:

[root@localhost ~]# rpm -i ras-utils-7.0-6.el7.x86_64.rpm # 安装完成
[root@localhost ~]# mc # mce-inject 即为安装的程序
mcat              mce-inject        mcheck            mcomp             mcopy             mc-wait-for-name  
mcd               mcelog            mclasserase       mcookie           mc-tool           
[root@localhost ~]# 

链接地址 mcelog 链接地址1 mcelog 链接地址2

标签: nux光电传感器pnnux光电传感器ps

锐单商城拥有海量元器件数据手册IC替代型号,打造 电子元器件IC百科大全!

锐单商城 - 一站式电子元器件采购平台