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

1、工具安装

1.1、apt安装

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

apt install -y alien

1.2、yum安装

由于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

1.3、安装完成

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

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

2、实践操作

2.1、语法解析

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

alien

结果如下:

[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.

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

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

2.2、rpm转deb

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

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

执行过程:

[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]# 

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

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

执行结果如下:

[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

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

教程结束!!

GitHub 加速计划 / li / linux-dash
10.39 K
1.2 K
下载
A beautiful web dashboard for Linux
最近提交(Master分支:2 个月前 )
186a802e added ecosystem file for PM2 4 年前
5def40a3 Add host customization support for the NodeJS version 4 年前
Logo

旨在为数千万中国开发者提供一个无缝且高效的云端环境,以支持学习、使用和贡献开源项目。

更多推荐