当前位置:   article > 正文

Linux软件包转换-deb与rpm互转_deb2rpm

deb2rpm

前言:
Linux二进制软件包分为几大派系,其中deb与rpm为主流派。各个派系之间资源各有差异

1、工具安装

1.1、apt安装

apt系默认收录该软件,所以直接执行下面的安装命令即可

apt install -y alien
  • 1

1.2、yum安装

由于yum系官方未收录该软件,所以需要先添加源再进行安装,命令步骤如下:

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

然后更新源(可选)

yum update
  • 1

最后是安装

yum install  -y alien
  • 1

1.3、安装完成

执行下面的命令进行验证是否安装成功

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

2、实践操作

2.1、语法解析

直接执行下面的命令即可调出帮助命令

alien
  • 1

结果如下:

[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 scripts 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.
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33

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

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

2.2、rpm转deb

首先使用下面的命令下载一个rpm包

yum install  --downloadonly vsftpd  --downloaddir=/opt/
 cd /opt;ls
  • 1
  • 2

执行过程:

[root@localhost ~]# yum install  --downloadonly vsftpd  --downloaddir=/opt/
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
 * base: mirrors.aliyun.com
 * epel: mirrors.tuna.tsinghua.edu.cn
 * extras: mirrors.aliyun.com
 * nux-dextop: li.nux.ro
 * updates: mirrors.ustc.edu.cn
Resolving Dependencies
--> Running transaction check
---> Package vsftpd.x86_64 0:3.0.2-27.el7 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

===================================================================================
 Package           Arch              Version                 Repository       Size
===================================================================================
Installing:
 vsftpd            x86_64            3.0.2-27.el7            base            172 k

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

Total download size: 172 k
Installed size: 353 k
Background downloading packages, then exiting:
vsftpd-3.0.2-27.el7.x86_64.rpm                              | 172 kB  00:00:00     
exiting because "Download Only" specified
[root@localhost ~]# cd /opt;ls
vsftpd-3.0.2-27.el7.x86_64.rpm
[root@localhost opt]# 
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33

然后使用下面的命令进行转换

alien -d vsftpd-3.0.2-27.el7.x86_64.rpm
  • 1

执行结果如下:

[root@localhost opt]# alien -d vsftpd-3.0.2-27.el7.x86_64.rpm 
Warning: Skipping conversion of scripts in package vsftpd: postinst postrm prerm
Warning: Use the --scripts parameter to include the scripts.
Can't exec "gcc": No such file or directory at /usr/share/perl5/vendor_perl/Dpkg/Arch.pm line 165.
dpkg-architecture: warning: cannot determine CC system type, falling back to default (native compilation)
vsftpd_3.0.2-28_amd64.deb generated
[root@localhost opt]# ls
vsftpd-3.0.2-27.el7.x86_64.rpm  vsftpd_3.0.2-28_amd64.deb
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8

2.3、deb转rpm

使用下面的命令进行转换

[root@localhost opt]# rm -f vsftpd-3.0.2-27.el7.x86_64.rpm 
[root@localhost opt]# alien -r vsftpd_3.0.2-28_amd64.deb 
vsftpd-3.0.2-29.x86_64.rpm generated
[root@localhost opt]# ls
vsftpd_3.0.2-28_amd64.deb  vsftpd-3.0.2-29.x86_64.rpm
  • 1
  • 2
  • 3
  • 4
  • 5

教程结束!!

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/从前慢现在也慢/article/detail/176918
推荐阅读
相关标签
  

闽ICP备14008679号