将任何单个(或多个)可执行文件转换为.deb包

ELF2deb的Python项目详细描述


elf2deb

logo

将任何单个(或多个)可执行文件转换为DEB包。

也就是说,这是一个将AppImage | ELF |可执行脚本转换为.deb的脚本

脚本将把二进制文件放在/usr/bin/中。

设置

您需要为deb工具设置DEBEMAILDEBFULLNAME以正常工作:

$ cat >>~/.bashrc <<EOFDEBEMAIL="email@example.org"DEBFULLNAME="John Doe"export DEBEMAIL DEBFULLNAMEEOF
$ . ~/.bashrc

然后从releases下载elf2deb.pyz,或者从pypi下载pip3 install elf2debelf2deb --help

示例

在本例中,我首先下载skaffold二进制文件并将其打包为.deb文件:

# Download ./skaffold binary to empty folder:
$ curl -Lo ./skaffold https://storage.googleapis.com/skaffold/releases/latest/skaffold-linux-amd64

# Run the tool:
$ ./elf2deb.pyz --license apache-2.0 --license_year 2018 --license_holder "The Skaffold Authors"\
> --package_name skaffold --package_version 0.28.0 --homepage "https://skaffold.dev/" ./skaffold

# Fix description and use debuild:
$ cd skaffold-0.28.0/
$ vim debian/control  # add description
$ debuild -us -uc
[... lots of debuild output ...]
$ cd ../

# Finally the .deb file is ready to be uploaded, or installed:
$ sudo dpkg -i skaffold_0.28.0_amd64.deb

参数

usage: elf2deb [-h] [--version]
               --package_name PACKAGE_NAME
               --package_version PACKAGE_VERSION
               [--homepage HOMEPAGE]
               [--dependencies DEPENDENCIES]
               [--license {MIT,LGPL-3.0,MPL-2.0,AGPL-3.0,unlicense,apache-2.0,GPL-3.0} | --license_file LICENSE_FILE]
               [--license_year LICENSE_YEAR]
               [--license_holder LICENSE_HOLDER]
               binary_files [binary_files ...]

positional arguments:
  binary_files          The binaries you want to package.

optional arguments:
  -h, --help            show this help message and exit
  --version             show program's version number and exit

package info:
  --package_name PACKAGE_NAME
                        The name of the deb package
  --package_version PACKAGE_VERSION
                        The version of the package
  --homepage HOMEPAGE   The webpage of the package
  --dependencies DEPENDENCIES
                        Dependencies specified in the deb package

license info:
  --license {MIT,LGPL-3.0,MPL-2.0,AGPL-3.0,unlicense,apache-2.0,GPL-3.0}
                        Select a standard license.
  --license_file LICENSE_FILE
                        ... or use a LICENSE text file.
  --license_year LICENSE_YEAR
                        If using a standard license: year
  --license_holder LICENSE_HOLDER
                        If using a standard license: owner

常见警告

如果你运行的是ubuntu,你可能会得到E: bad-distribution-in-changes-file unstable。 在本例中,编辑debian/changelog,并将unstable更改为您的发行版代码名(通过运行lsb_release -c找到它)。 然后从源目录运行debuild -us -uc,重新编译.deb

如果缺少dch-工具,请运行:sudo apt install --no-install-recommends devscripts libdistro-info-perl

您可以放心地忽略林寻的以下警告:

  • source-is-missing

  • binary-without-manpage

(您可能会得到更长的错误和警告列表,无需担心)

其他/更多格式的包装

如果你想以更多的格式发布你的软件——或者你的源代码不是二进制文件的列表——那么考虑使用一个类似“Effing package management”的工具fpm是一个更成熟的工具,允许先进的包装。

elf2deb的优点是;

  • 可以使用pip install elf2deb安装,也可以将用作独立的可执行文件./elf2deb.pyz

  • 简单、小(<;10 KB),并且依赖关系很少:>= python3.5(如果需要下载许可证文件,+requests

更多示例(交互式!)

在1.2.0版中,elf2deb:

$ git clone https://github.com/NicolaiSoeborg/ELF2deb.git &&cd ELF2deb/
$ make  # to make 'elf2deb.pyz' (or use pip to install globally, or carry/copy elf2deb.pyz around)
$ ./elf2deb.pyz elf2deb.pyz  # package 'elf2deb.pyz' using elf2deb (very meta!)
Package info:
author_mail: git@xn--sb-lka.org
author_name: Nicolai Søborg
binary_files: ['elf2deb.pyz']
dependencies: 
homepage: None
license: None
license_file: <_io.TextIOWrapper name='/.../ELF2deb/LICENSE'mode='r'encoding='UTF-8'>
license_holder: None
license_year: None
package_name: ELF2deb
package_version: 0.0.1
==> Does this look correct? (y/n/q): n

Properties:
[1] author_mail
[2] author_name
[3] binary_files
[4] dependencies
[5] homepage
[6] license
[7] license_file
[8] license_holder
[9] license_year
[10] package_name
[11]package_version==> Which property to change? (1..11): 4==> Which value should dependencies be changed to? python3, python3-requests

Package info:
author_mail: git@xn--sb-lka.org
author_name: Nicolai Søborg
binary_files: ['elf2deb.pyz']
dependencies: python3, python3-requests
homepage: None
license: None
license_file: <_io.TextIOWrapper name='/home/nsq/pakker/test/ELF2deb/LICENSE'mode='r'encoding='UTF-8'>
license_holder: None
license_year: None
package_name: ELF2deb
package_version: 0.0.1
==> Does this look correct? (y/n/q): n
[...]==> Which value should package_version be changed to? 1.2.0
[...]==> Does this look correct? (y/n/q): y
Copying templates... done!
Copying files... done!
Run:
 * cd elf2deb-1.2.0
 * vim debian/control  # change description, dont add empty lines
 * debuild -us -uc  # remove -us -uc if you want to sign the deb file

$ cd elf2deb-1.2.0
$ vim debian/control
$ debuild -us -uc
[...]
dpkg-deb: building package 'elf2deb' in '../elf2deb_1.2.0_amd64.deb'.

$ dpkg-deb --info ../elf2deb_1.2.0_amd64.deb
 new Debian package, version 2.0.
 size 5100 bytes: control archive=624 bytes.
     383 bytes,    12 lines      control
     189 bytes,     3 lines      md5sums
 Package: elf2deb
 Version: 1.2.0
 Architecture: amd64
 Maintainer: Nicolai Søborg <git@xn--sb-lka.org>
 Installed-Size: 20
 Depends: python3, python3-requests
 Section: misc
 Priority: optional
 Multi-Arch: foreign
 Description: tool to easily package any binary to a deb file
  ELF2deb makes it easy to package simple binaries to a deb file
  to help deploy files across debian environments.

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
主类中的java访问方法   Javalog4j不读取它的log4j。属性文件   雅加达ee通过Java(web应用程序)使用iText/任何其他使用现成数据的库生成PDF报告   lua使用java阅读TeamSpeak 3消息   将日期转换为BST java   java Spring引用ProxyFactoryBean中带有ref的protoyype bean   如何使java只打印一条带有if语句的消息   java如何通过JavaMail从雅虎服务器发送电子邮件?   使用百分比和BigDecimal的java测试   java如何对字符串数组排序   java验证器+MVC+REST::更新问题   java如何阻止eclipse如此频繁地挂起?   java从AsyncTask(片段内)访问TextView   IDEJava:制作可调整大小和拖动的组件