当“dpkg-buildpackage -rfakeroot -d -us -uc -S”成功时,是什么导致“debuild -S”失败并显示“找不到命令”?

当“dpkg-buildpackage -rfakeroot -d -us -uc -S”成功时,是什么导致“debuild -S”失败并显示“找不到命令”?

考虑以下脚本:

#!/usr/bin/env bash

set -ex

wget -N http://archive.ubuntu.com/ubuntu/pool/universe/o/ocaml-re/ocaml-re_1.7.3-2.dsc
wget -N http://archive.ubuntu.com/ubuntu/pool/universe/o/ocaml-re/ocaml-re_1.7.3.orig.tar.gz
wget -N http://archive.ubuntu.com/ubuntu/pool/universe/o/ocaml-re/ocaml-re_1.7.3-2.debian.tar.xz
dpkg-source -x ocaml-re_1.7.3-2.dsc
cd ocaml-re-1.7.3
dpkg-buildpackage -rfakeroot -d -us -uc -S || exit $?
debuild -S || exit $?

当我运行它时,我看到

+ wget -N http://archive.ubuntu.com/ubuntu/pool/universe/o/ocaml-re/ocaml-re_1.7.3-2.dsc
--2018-10-28 20:29:03--  http://archive.ubuntu.com/ubuntu/pool/universe/o/ocaml-re/ocaml-re_1.7.3-2.dsc
Resolving archive.ubuntu.com (archive.ubuntu.com)... 91.189.88.162, 91.189.88.149, 91.189.91.23, ...
Connecting to archive.ubuntu.com (archive.ubuntu.com)|91.189.88.162|:80... connected.
HTTP request sent, awaiting response... 304 Not Modified
File ‘ocaml-re_1.7.3-2.dsc’ not modified on server. Omitting download.

+ wget -N http://archive.ubuntu.com/ubuntu/pool/universe/o/ocaml-re/ocaml-re_1.7.3.orig.tar.gz
--2018-10-28 20:29:03--  http://archive.ubuntu.com/ubuntu/pool/universe/o/ocaml-re/ocaml-re_1.7.3.orig.tar.gz
Resolving archive.ubuntu.com (archive.ubuntu.com)... 91.189.88.152, 91.189.88.162, 91.189.88.149, ...
Connecting to archive.ubuntu.com (archive.ubuntu.com)|91.189.88.152|:80... connected.
HTTP request sent, awaiting response... 304 Not Modified
File ‘ocaml-re_1.7.3.orig.tar.gz’ not modified on server. Omitting download.

+ wget -N http://archive.ubuntu.com/ubuntu/pool/universe/o/ocaml-re/ocaml-re_1.7.3-2.debian.tar.xz
--2018-10-28 20:29:03--  http://archive.ubuntu.com/ubuntu/pool/universe/o/ocaml-re/ocaml-re_1.7.3-2.debian.tar.xz
Resolving archive.ubuntu.com (archive.ubuntu.com)... 91.189.88.152, 91.189.88.162, 91.189.88.149, ...
Connecting to archive.ubuntu.com (archive.ubuntu.com)|91.189.88.152|:80... connected.
HTTP request sent, awaiting response... 304 Not Modified
File ‘ocaml-re_1.7.3-2.debian.tar.xz’ not modified on server. Omitting download.

+ dpkg-source -x ocaml-re_1.7.3-2.dsc
dpkg-source: warning: extracting unsigned source package (ocaml-re_1.7.3-2.dsc)
dpkg-source: info: extracting ocaml-re in ocaml-re-1.7.3
dpkg-source: info: unpacking ocaml-re_1.7.3.orig.tar.gz
dpkg-source: info: unpacking ocaml-re_1.7.3-2.debian.tar.xz
+ cd ocaml-re-1.7.3
+ dpkg-buildpackage -rfakeroot -d -us -uc -S
dpkg-buildpackage: source package ocaml-re
dpkg-buildpackage: source version 1.7.3-2
dpkg-buildpackage: source distribution unstable
dpkg-buildpackage: source changed by Mehdi Dogguy <[email protected]>
 dpkg-source --before-build ocaml-re-1.7.3
 fakeroot debian/rules clean
dh clean --with ocaml
   dh_testdir
   dh_auto_clean
        make -j1 clean
make[1]: Entering directory '/home/jgross/Documents/repos/coq-debian-build-scripts/ocaml-stuff/debian-sources/foo/ocaml-re-1.7.3'
make[1]: Leaving directory '/home/jgross/Documents/repos/coq-debian-build-scripts/ocaml-stuff/debian-sources/foo/ocaml-re-1.7.3'
   dh_ocamlclean
   dh_clean
 dpkg-source -b ocaml-re-1.7.3
dpkg-source: info: using source format '3.0 (quilt)'
dpkg-source: info: building ocaml-re using existing ./ocaml-re_1.7.3.orig.tar.gz
dpkg-source: info: building ocaml-re in ocaml-re_1.7.3-2.debian.tar.xz
dpkg-source: info: building ocaml-re in ocaml-re_1.7.3-2.dsc
 dpkg-genchanges -S >../ocaml-re_1.7.3-2_source.changes
dpkg-genchanges: not including original source code in upload
 dpkg-source --after-build ocaml-re-1.7.3
dpkg-buildpackage: binary and diff upload (original source NOT included)
+ debuild -S
 dpkg-buildpackage -rfakeroot -d -us -uc -S
dpkg-buildpackage: source package ocaml-re
dpkg-buildpackage: source version 1.7.3-2
dpkg-buildpackage: source distribution unstable
dpkg-buildpackage: source changed by Mehdi Dogguy <[email protected]>
 dpkg-source --before-build ocaml-re-1.7.3
 fakeroot debian/rules clean
dh clean --with ocaml
   dh_testdir
   dh_auto_clean
        make -j1 clean
make[1]: Entering directory '/home/jgross/Documents/repos/coq-debian-build-scripts/ocaml-stuff/debian-sources/foo/ocaml-re-1.7.3'
make[1]: jbuilder: Command not found
Makefile:12: recipe for target 'clean' failed
make[1]: *** [clean] Error 127
make[1]: Leaving directory '/home/jgross/Documents/repos/coq-debian-build-scripts/ocaml-stuff/debian-sources/foo/ocaml-re-1.7.3'
dh_auto_clean: make -j1 clean returned exit code 2
debian/rules:13: recipe for target 'clean' failed
make: *** [clean] Error 2

我感到困惑的是,尽管我安装了 jbuilder(通过 opam),但debuild -S找不到它,即使它似乎正在运行dpkg-buildpackage -rfakeroot -d -us -uc -S并且成功得很好。这里发生了什么?

答案1

阅读手册页后,我发现关于环境变量的部分,其中说:

由于环境变量可能会影响包的构建,因此 debuild 通常会无意中通过删除除TERMHOMELOGNAMEGNUPGHOMEPGPPATHGPG_AGENT_INFOFAKEROOTKEYDEB_*、 ( CCPPCXX和 )变量及其对应项以及区域设置变量和 之外 的所有环境变量来清理环境。 如果未设置则 设置为 ,如果未设置则 设置为 。LDFFLAGS_APPENDLANGLC_*TERMdumbPATH"/usr/sbin:/usr/bin:/sbin:/bin:/usr/bin/X11"

[...]

请注意,可以使用 选项将目录添加到清理后的 PATH 的开头 --prepend-path 。当人们希望使用诸如ccache或 之 类的工具distcc进行构建时,这非常有用。

所以问题是 opam 二进制文件存在PATH,因此在这里找不到。

相关内容