openEuler 20.03 LTS SP1 使用alien转换rpm和deb包


Debian的DEB与redhat的RPM,是linux下比较经典的两种软件二进制安装包格式.
使用alien可以实现这两种格式之间的互换.

一 os环境


# cat /etc/openEuler-release
openEuler release 20.03 (LTS-SP1)

# uname -r
4.19.90-2012.5.0.0054.oe1.x86_64

# cat /etc/yum.repos.d/openEuler.repo
[everything]
name=everything
baseurl=http://repo.openeuler.org/openEuler-20.03-LTS-SP1/everything/$basearch/
enabled=1
gpgcheck=1
gpgkey=http://repo.openeuler.org/openEuler-20.03-LTS-SP1/everything/$basearch/RPM-GPG-KEY-openEuler


[EPOL]
name=EPOL
baseurl=http://repo.openeuler.org/openEuler-20.03-LTS-SP1/EPOL/$basearch/
enabled=1
gpgcheck=0
gpgkey=http://repo.openeuler.org/openEuler-20.03-LTS-SP1/OS/$basearch/RPM-GPG-KEY-openEuler


二 创建alien相关repo仓库

# dnf install -y createrepo
# mkdir -p /root/alien
# cp dir/*.rpm /root/alien
# cd /root/alien
# ls  *.rpm
a2ps-4.14-48.oe1.x86_64.rpm
alien-8.95-15.oe1.noarch.rpm
cdbs-0.4.163-2.oe1.noarch.rpm
debconf-1.5.74-7.oe1.noarch.rpm
debconf-doc-1.5.74-7.oe1.noarch.rpm
debconf-gnome-1.5.74-7.oe1.noarch.rpm
debconf-i18n-1.5.74-7.oe1.noarch.rpm
debconf-LDAP-1.5.74-7.oe1.noarch.rpm
debconf-utils-1.5.74-7.oe1.noarch.rpm
debhelper-12.7.3-6.oe1.noarch.rpm
dh-autoreconf-19-10.oe1.noarch.rpm
dpkg-1.19.7-9.oe1.x86_64.rpm
dpkg-dev-1.19.7-9.oe1.noarch.rpm
dpkg-devel-1.19.7-9.oe1.x86_64.rpm
dpkg-perl-1.19.7-9.oe1.noarch.rpm
dselect-1.19.7-9.oe1.x86_64.rpm
html2ps-1.0-0.39.b7.oe1.noarch.rpm
perl-App-cpanminus-1.7044-11.oe1.noarch.rpm
perl-Cairo-1.109-2.oe1.x86_64.rpm
perl-Cairo-GObject-1.005-5.oe1.x86_64.rpm
perl-Class-Data-Inheritable-0.08-37.oe1.noarch.rpm
perl-Convert-ASN1-0.27-22.oe1.noarch.rpm
perl-Convert-ASN1-tests-0.27-22.oe1.noarch.rpm
perl-Convert-BinHex-1.125-17.oe1.noarch.rpm
perl-CPAN-DistnameInfo-0.12-21.oe1.noarch.rpm
perl-CPAN-Meta-Check-0.014-15.oe1.noarch.rpm
perl-Data-Dumper-Names-0.03-36.oe1.noarch.rpm
perl-Devel-StackTrace-2.04-8.oe1.noarch.rpm
perl-Email-Abstract-3.008-19.oe1.noarch.rpm
perl-Email-Address-1.912-9.oe1.noarch.rpm
perl-Email-Address-XS-1.04-10.oe1.x86_64.rpm
perl-Email-MessageID-1.406-18.oe1.noarch.rpm
perl-Email-MIME-1.949-4.oe1.noarch.rpm
perl-Email-MIME-ContentType-1.026-2.oe1.noarch.rpm
perl-Email-MIME-Encodings-1.315-21.oe1.noarch.rpm
perl-Email-Simple-2.216-10.oe1.noarch.rpm
perl-Exception-Class-1.44-11.oe1.noarch.rpm
perl-ExtUtils-Depends-0.8000-7.oe1.noarch.rpm
perl-ExtUtils-PkgConfig-1.16-14.oe1.noarch.rpm
perl-File-FcntlLock-0.22-20.oe1.x86_64.rpm
perl-Font-AFM-1.20-35.oe1.noarch.rpm
perl-Geography-Countries-2009041301-31.oe1.noarch.rpm
perl-Glib-1.3293-4.oe1.x86_64.rpm
perl-Glib-devel-1.3293-4.oe1.x86_64.rpm
perl-Glib-Object-Introspection-0.049-3.oe1.x86_64.rpm
perl-Gtk3-0.037-4.oe1.noarch.rpm
perl-HTML-Formatter-2.16-15.oe1.noarch.rpm
perl-HTML-Tree-5.07-14.oe1.noarch.rpm
perli11ndoc-0.049-3.oe1.noarch.rpm
perl-Image-ExifTool-12.16-2.oe1.noarch.rpm
perl-LDAP-0.68-2.oe1.noarch.rpm
perl-LDAP-tests-0.68-2.oe1.noarch.rpm
perl-Mail-Box-3.009-2.oe1.noarch.rpm
perl-Mail-Message-3.010-2.oe1.noarch.rpm
perl-Mail-Transport-3.005-2.oe1.noarch.rpm
perl-MIME-tools-5.509-14.oe1.noarch.rpm
perl-Module-CPANfile-1.1004-10.oe1.noarch.rpm
perl-Module-Pluggable-5.2-16.oe1.noarch.rpm
perl-Object-Realize-Later-0.21-11.oe1.noarch.rpm
perl-PadWalker-2.5-2.oe1.x86_64.rpm
perl-Parse-PMFile-0.43-2.oe1.noarch.rpm
perl-Regexp-Assemble-0.38-12.oe1.noarch.rpm
perl-Test-Differences-0.6700-7.oe1.noarch.rpm
perl-Test-File-Contents-0.23-15.oe1.noarch.rpm
perl-Test-Most-0.37-4.oe1.noarch.rpm
perl-Test-Number-Delta-1.06-19.oe1.noarch.rpm
perl-Test-Warn-0.36-11.oe1.noarch.rpm
perl-TeX-Hyphen-1.18-14.oe1.noarch.rpm
perl-Text-Autoformat-1.750000-5.oe1.noarch.rpm
perl-Text-Iconv-1.7-41.oe1.x86_64.rpm
perl-Text-Reform-1.20-29.oe1.noarch.rpm
perl-Text-Soundex-3.05-18.oe1.x86_64.rpm
perl-User-Identity-1.00-2.oe1.noarch.rpm
po-debconf-1.0.21-5.oe1.noarch.rpm
python3-pdfrw-0.4-13.oe1.noarch.rpm
python3-smartypants-2.0.1-9.oe1.noarch.rpm
python-smartypants-doc-2.0.1-9.oe1.noarch.rpm
rst2pdf-0.97-5.oe1.noarch.rpm
xhtml2ps-1.0-0.39.b7.oe1.noarch.rpm

创建repo仓库
# createrepo alien

三 安装alien

通过三个仓库安装alien包()
# dnf --repofrompath=repo1,/root/alien --enablerepo=repo1 --nogpgcheck install -y alien

四 使用alien

# which alien
/usr/bin/alien

# alien -V
alien version 8.95

# alien -h
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.


示例:

-k 保持version版本信息,否则自动+1
-v 详细信息输出
-r 转换为rpm格式

转换RPM为DEB

# alien -kv hello-1-1.oe1.noarch.rpm
    LANG=C rpm -qp --queryformat %{NAME} 'hello-1-1.oe1.noarch.rpm'
    LANG=C rpm -qp --queryformat %{VERSION} 'hello-1-1.oe1.noarch.rpm'
    LANG=C rpm -qp --queryformat %{RELEASE} 'hello-1-1.oe1.noarch.rpm'
    LANG=C rpm -qp --queryformat %{ARCH} 'hello-1-1.oe1.noarch.rpm'
    LANG=C rpm -qp --queryformat %{CHANGELOGTEXT} 'hello-1-1.oe1.noarch.rpm'
    LANG=C rpm -qp --queryformat %{SUMMARY} 'hello-1-1.oe1.noarch.rpm'
    LANG=C rpm -qp --queryformat %{DESCRIPTION} 'hello-1-1.oe1.noarch.rpm'
    LANG=C rpm -qp --queryformat %{PREFIXES} 'hello-1-1.oe1.noarch.rpm'
    LANG=C rpm -qp --queryformat %{POSTUN} 'hello-1-1.oe1.noarch.rpm'
    LANG=C rpm -qp --queryformat %{LICENSE} 'hello-1-1.oe1.noarch.rpm'
    LANG=C rpm -qp --queryformat %{POSTIN} 'hello-1-1.oe1.noarch.rpm'
    LANG=C rpm -qp --queryformat %{PREUN} 'hello-1-1.oe1.noarch.rpm'
    LANG=C rpm -qp --queryformat %{PREIN} 'hello-1-1.oe1.noarch.rpm'
    LANG=C rpm -qcp 'hello-1-1.oe1.noarch.rpm'
    rpm -qpi 'hello-1-1.oe1.noarch.rpm'
    LANG=C rpm -qpl 'hello-1-1.oe1.noarch.rpm'
    mkdir hello-1
    chmod 755 hello-1
    rpm2cpio 'hello-1-1.oe1.noarch.rpm' | lzma -t -q > /dev/null 2>&1
    rpm2cpio 'hello-1-1.oe1.noarch.rpm' | (cd hello-1;  cpio --extract --make-directories --no-absolute-filenames --preserve-modification-time) 2>&1
    chmod 755 'hello-1/./'
    chmod 755 'hello-1/./tmp'
    chown 0:0 hello-1//tmp/aaa.txt
    chmod 644 hello-1//tmp/aaa.txt
    mkdir hello-1/debian
    hostname
    date -R
    hostname
    date -R
    chmod 755 hello-1/debian/rules
    debian/rules binary 2>&1
hello_1-1.oe1_all.deb generated
    find hello-1 -type d -exec chmod 755 {} ;
    rm -rf hello-1

# ls hello*
hello_1-1.oe1_all.deb  hello-1-1.oe1.noarch.rpm

转换DEB至RPM

# alien -kvr hello_1-1.oe1_all.deb
    dpkg-deb --info 'hello_1-1.oe1_all.deb' control 2>/dev/null
    dpkg-deb --info 'hello_1-1.oe1_all.deb' control 2>/dev/null
    dpkg-deb --info 'hello_1-1.oe1_all.deb' conffiles 2>/dev/null
    dpkg-deb --fsys-tarfile 'hello_1-1.oe1_all.deb' | tar tf -
    dpkg-deb --info 'hello_1-1.oe1_all.deb' postinst 2>/dev/null
    dpkg-deb --info 'hello_1-1.oe1_all.deb' postrm 2>/dev/null
    dpkg-deb --info 'hello_1-1.oe1_all.deb' preinst 2>/dev/null
    dpkg-deb --info 'hello_1-1.oe1_all.deb' prerm 2>/dev/null
    mkdir hello-1
    chmod 755 hello-1
    dpkg-deb -x hello_1-1.oe1_all.deb hello-1
    rpm --showrc
    cd hello-1; rpmbuild --buildroot='/root/hello-1' -bb --target noarch 'hello-1-1.oe1.spec' 2>&1
hello-1-1.oe1.noarch.rpm generated


# dnf install -y hello-1-1.oe1.noarch.rpm

# rpm -qa |grep hello
hello-1-1.oe1.noarch

 

  • 2
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 3
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值