打包时更改 debhelper 的默认目录 (.deb)

Mar*_*ski 5 packaging dpkg debian deb autotools

我正在尝试将 Spamdyke 4.3.1(下载链接)转换为 Debian 软件包(.deb)。这是一个非常容易构建的软件,没有疯狂的依赖项,只是libssl-dev这样:

apt-get install build-essential devscripts \
                debhelper dh-make libssl-dev
Run Code Online (Sandbox Code Playgroud)

然后一旦你解压源:

cd spamdyke-4.3.1/spamdyke
./configure --exec_prefix=/usr 
make
Run Code Online (Sandbox Code Playgroud)

和平常一样

make install
Run Code Online (Sandbox Code Playgroud)

因为我愿意用这个软件制作 Debian 软件包,所以我在debian/文件夹中创建了所有必需的文件,并通过添加以下内容install来修改其目标:spamdyke/Makefile.in${DESTDIR}

install: spamdyke
        cp spamdyke ${DESTDIR}/usr/local/bin/spamdyke-@PACKAGE_VERSION@
        rm -f ${DESTDIR}/usr/local/bin/spamdyke
        ln -s ${DESTDIR}/usr/local/bin/spamdyke-@PACKAGE_VERSION@ ${DESTDIR}/usr/local/bin/spamdyke
Run Code Online (Sandbox Code Playgroud)

但我当前的问题是,分发存档将所有源代码保存在spamdyke/文件夹而不是根文件夹中,这不是dh_*工具期望自动完成所有繁重工作的:

drwxr-xr-x   4 vagrant vagrant  4096 Feb  3 10:57 debian
drwxr-xr-x   3 vagrant vagrant  4096 Jan 30 19:43 documentation
drwxr-xr-x   2 vagrant vagrant  4096 Feb  5 21:00 spamdyke
drwxr-xr-x 997 vagrant vagrant 77824 Jan 30 19:43 tests
drwxr-xr-x   2 vagrant vagrant  4096 Jan 20  2012 utils
Run Code Online (Sandbox Code Playgroud)

不幸的是,我无法创建正确的方法debian/rules来使所有包装工作。我希望保持debian/rules尽可能简单,坦率地说,我希望将其指向带有选项spamdyke的源文件夹--builddirectory至少对于配置和构建步骤来说就足够了。我debian/rules现在的样子是这样的:

#!/usr/bin/make -f
export DH_VERBOSE = 1

%:
        dh $@  --builddirectory=spamdyke

override_dh_auto_configure:
        dh_auto_configure --builddirectory=spamdyke -- --exec_prefix=/usr

override_dh_auto_build:
        dh_auto_make --builddirectory=spamdyke
Run Code Online (Sandbox Code Playgroud)

然而,结果debuild -b -us -uc产生了相当空的.deb包,lintian 抱怨empty-binary-package

dpkg-genchanges: binary-only upload (no source code included)
 dpkg-source --after-build spamdyke-4.3.1
dpkg-buildpackage: binary-only upload (no source included)
Now running lintian...
W: spamdyke: new-package-should-close-itp-bug
E: spamdyke: copyright-should-refer-to-common-license-file-for-gpl
W: spamdyke: empty-binary-package
Finished running lintian.
Run Code Online (Sandbox Code Playgroud)

我希望这里一定遗漏了一些明显的东西,但目前我无法找出要搜索的内容。任何提示表示赞赏。提前致谢。

use*_*.dz 5

你需要设置--sourcedirectory而不是--builddirectory随叫随到dh $@,它会影响所有dh_auto_*。所以你可以删除这些覆盖。

BUILD SYSTEM OPTIONS
       The following command line options are supported by all of the 
       dh_auto_* debhelper programs. These programs support a variety 
       of build systems, and normally
       heuristically determine which to use, and how to use them. You
       can use these command line options to override the default 
       behavior.  Typically these are passed to
       dh(1), which then passes them to all the dh_auto_* programs.


   -Ddirectory, --sourcedirectory=directory
       Assume that the original package source tree is at the 
       specified directory rather than the top level directory of 
       the Debian source package tree.

   -B[directory], --builddirectory=[directory]
       Enable out of source building and use the specified directory
       as the build directory. If directory parameter is omitted, a 
       default build directory will be chosen.
Run Code Online (Sandbox Code Playgroud)

来源: man debhelper

笔记:

  • 避免使用硬编码路径

    例如/usr/local,使用$prefix变量代替。autotools/usr/local默认情况下,debhelper 重置为/usr(无需手动设置)

    建议修复:

    spamdyke/Makefile.in定义prefix和更改符号链接目标。

    prefix := @prefix@
    ...
    install: spamdyke
            mkdir -p ${DESTDIR}$(prefix)/bin/
            cp spamdyke ${DESTDIR}$(prefix)/bin/spamdyke-@PACKAGE_VERSION@
            rm -f ${DESTDIR}$(prefix)/bin/spamdyke
            ln -s $(prefix)/bin/spamdyke-@PACKAGE_VERSION@ ${DESTDIR}$(prefix)/bin/spamdyke
    
    Run Code Online (Sandbox Code Playgroud)

    debian/rules删除覆盖

    #!/usr/bin/make -f
    export DH_VERBOSE=1
    
    %:
            dh $@ --sourcedirectory=spamdyke
    
    Run Code Online (Sandbox Code Playgroud)

    参考: GNU 编码标准