从脚本或二进制文件创建一个 .deb 包

Tho*_*sch 74 packaging apt deb

我寻找一种简单的方法来为没有要编译的源代码的东西(配置、shellscripts、专有软件)创建 .deb 包。这是一个相当大的问题,因为大多数软件包教程都假设您有一个要编译的源 tarball。然后我找到了这个简短的教程(德语)。

之后,我创建了一个小脚本来创建一个简单的存储库。像这样:

rm /export/my-repository/repository/*
cd /home/tdeutsch/deb-pkg
for i in $(ls | grep my); do dpkg -b ./$i /export/my-repository/repository/$i.deb; done
cd /export/avanon-repository/repository
gpg --armor --export "My Package Signing Key" > PublicKey
apt-ftparchive packages ./ | gzip > Packages.gz
apt-ftparchive packages ./ > Packages
apt-ftparchive release ./ > /tmp/Release.tmp; mv /tmp/Release.tmp Release
gpg --output Release.gpg -ba Release
Run Code Online (Sandbox Code Playgroud)

我将密钥添加到 apt 密钥环并包含如下来源:

deb http://my.default.com/my-repository/ ./
Run Code Online (Sandbox Code Playgroud)

看起来 repo 本身运行良好(我遇到了一些问题,为了解决这些问题,我需要添加两次 Packages 并为 Release 文件制作临时文件解决方法)。我还将一些下载的 .deb 放入 repo 中,看起来它们也可以正常工作。但是我自己创建的包没有……我做的sudo apt-get update,它们导致了这样的错误:

E: Problem parsing dependency Depends
E: Error occurred while processing my-printerconf (NewVersion2)
E: Problem with MergeList /var/lib/apt/lists/my.default.com_my-repository_._Packages
E: The package lists or status file could not be parsed or opened.
Run Code Online (Sandbox Code Playgroud)

有谁知道我做错了什么?

2012 年 3 月 6 日更新:只是给另一个正在寻找创建 DEB 的简单方法的人的提示:看看FPM

Joã*_*nto 74

您链接的教程使用低级方法来构建包。通常不推荐这种方法,如果不小心执行,可能会导致各种问题。

一旦您了解了打包基础知识,为脚本创建 .deb 就非常简单了。简而言之:

# Configure your paths and filenames
SOURCEBINPATH=~
SOURCEBIN=myscript.sh
DEBFOLDER=~/somescripts
DEBVERSION=0.1

DEBFOLDERNAME=$DEBFOLDER-$DEBVERSION

# Create your scripts source dir
mkdir $DEBFOLDERNAME

# Copy your script to the source dir
cp $SOURCEBINPATH/$SOURCEBIN $DEBFOLDERNAME 
cd $DEBFOLDERNAME

# Create the packaging skeleton (debian/*)
dh_make -s --indep --createorig 

# Remove make calls
grep -v makefile debian/rules > debian/rules.new 
mv debian/rules.new debian/rules 

# debian/install must contain the list of scripts to install 
# as well as the target directory
echo $SOURCEBIN usr/bin > debian/install 

# Remove the example files
rm debian/*.ex

# Build the package.
# You  will get a lot of warnings and ../somescripts_0.1-1_i386.deb
debuild
Run Code Online (Sandbox Code Playgroud)

添加更多脚本需要将它们复制到目录并添加到 debian/install 文件中——然后只需重新运行 debuild。您还应该根据需要检查和更新 debian/* 文件。

您应该阅读以下手册页:dh_make, dh_install, 和debuild

  • 编辑 debian/control,必须将“架构:任何”更改为“架构:所有”。不要忘记将问题设置为已回答;) (4认同)
  • 除了重命名目录和更新 debian/changelog 之外,您必须创建与新版本相对应的 .orig 存档,这是源目录内容的存档(不包括 debian/)。 (3认同)
  • `dh_make:错误:参数 -i/--indep:不允许与参数 -s/--single` (2认同)