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

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

我正在尝试将 Spamdyke 4.3.1 (下载链接) 放入 Debian 软件包 ( .deb)。这是一个非常容易构建的软件,没有疯狂的依赖关系,只需libssl-dev

apt-get install build-essential devscripts \
                debhelper dh-make libssl-dev

然后一旦你解压源文件:

cd spamdyke-4.3.1/spamdyke
./configure --exec_prefix=/usr 
make

和平常一样

make install

因为我愿意用这个软件制作 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

但我当前的问题是,分发档案将所有源保存在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

不幸的是,我无法创建正确的文件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

然而,结果debuild -b -us -uc产生了一个相当空的包,lintian 抱怨道:.debempty-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.

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

答案1

您需要设置--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.

来源: 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
    

    debian/rules删除覆盖

    #!/usr/bin/make -f
    export DH_VERBOSE=1
    
    %:
            dh $@ --sourcedirectory=spamdyke
    

    参考: GNU 编码标准

相关内容