[Reproducible-commits] [dpkg] 35/40: Also write control.tar.gz in deterministic order
Jérémy Bobbio
lunar at moszumanska.debian.org
Sat May 30 09:52:51 UTC 2015
This is an automated email from the git hooks/post-receive script.
lunar pushed a commit to branch pu/reproducible_builds
in repository dpkg.
commit 0ef0918aeefce34844c62790bbb82db8ece0e362
Author: Jérémy Bobbio <lunar at debian.org>
Date: Tue Aug 27 23:03:49 2013 +0200
Also write control.tar.gz in deterministic order
Closes: #719845
---
dpkg-deb/build.c | 62 +++++++++++++++++++++++++++++++++++++++++++++++++-------
1 file changed, 55 insertions(+), 7 deletions(-)
diff --git a/dpkg-deb/build.c b/dpkg-deb/build.c
index ba15007..264bf13 100644
--- a/dpkg-deb/build.c
+++ b/dpkg-deb/build.c
@@ -238,32 +238,80 @@ static void
create_control_tar(const char *dir, struct compress_params *control_compress_params,
int gzfd)
{
- int tar_pipefd[2];
- pid_t tar_pid, compressor_pid;
+ int tar_pipefd[2], compressor_pipefd[2], sort_pipefd[2];
+ pid_t tar_pid, compressor_pid, sort_pid, find_pid;
/* Fork a tar to package the control-section of the package. */
unsetenv("TAR_OPTIONS");
m_pipe(tar_pipefd);
+ m_pipe(compressor_pipefd);
tar_pid = subproc_fork();
if (!tar_pid) {
- m_dup2(tar_pipefd[1],1); close(tar_pipefd[0]); close(tar_pipefd[1]);
+ m_dup2(tar_pipefd[0], 0);
+ close(tar_pipefd[0]);
+ close(tar_pipefd[1]);
+ m_dup2(compressor_pipefd[1], 1);
+ close(compressor_pipefd[0]);
+ close(compressor_pipefd[1]);
if (chdir(dir))
ohshite(_("failed to chdir to '%.255s'"), dir);
if (chdir(BUILDCONTROLDIR))
ohshite(_("failed to chdir to '%.255s'"), ".../DEBIAN");
- execlp(TAR, "tar", "-cf", "-", "--format=gnu", ".", NULL);
+ execlp(TAR, "tar", "-cf", "-", "--format=gnu", "--null", "--no-unquote",
+ "-T", "-", "--no-recursion", NULL);
ohshite(_("unable to execute %s (%s)"), "tar -cf", TAR);
}
- close(tar_pipefd[1]);
+ close(tar_pipefd[0]);
+ close(compressor_pipefd[1]);
/* And run the compressor on our control archive. */
compressor_pid = subproc_fork();
if (!compressor_pid) {
- compress_filter(control_compress_params, tar_pipefd[0], gzfd, _("compressing control member"));
+ close(tar_pipefd[1]);
+ compress_filter(control_compress_params, compressor_pipefd[0], gzfd, _("compressing control member"));
exit(0);
}
- close(tar_pipefd[0]);
+ close(compressor_pipefd[0]);
+
+ /* We pipe the filename to sort between find and tar to get deterministic
+ * builds. */
+ m_pipe(sort_pipefd);
+ sort_pid = subproc_fork();
+ if (!sort_pid) {
+ m_dup2(sort_pipefd[0], 0);
+ close(sort_pipefd[0]);
+ close(sort_pipefd[1]);
+ m_dup2(tar_pipefd[1], 1);
+ close(tar_pipefd[0]);
+ close(tar_pipefd[1]);
+ if (setenv("LC_ALL", "C", 1 /* overwrite */))
+ ohshite(_("unable to setenv"));
+ execlp(SORT, "sort", "--zero-terminated", NULL);
+ ohshite(_("unable to execute %s (%s)"), "sort", SORT);
+ }
+ close(sort_pipefd[0]);
+ close(tar_pipefd[1]);
+
+ /* All the pipes are set, now lets run find, and start feeding
+ * filenames to tar. */
+ find_pid = subproc_fork();
+ if (!find_pid) {
+ m_dup2(sort_pipefd[1], 1);
+ close(sort_pipefd[0]);
+ close(sort_pipefd[1]);
+ if (chdir(dir))
+ ohshite(_("failed to chdir to `%.255s'"), dir);
+ if (chdir(BUILDCONTROLDIR))
+ ohshite(_("failed to chdir to `%.255s'"), ".../DEBIAN");
+ execlp(FIND, "find", ".", "-path", "./" BUILDCONTROLDIR, "-prune", "-o",
+ "-print0", NULL);
+ ohshite(_("unable to execute %s (%s)"), "find", FIND);
+ }
+ close(sort_pipefd[1]);
+
+ subproc_reap(find_pid, "find", 0);
+ subproc_reap(sort_pid, "sort", 0);
subproc_reap(compressor_pid, _("<compress> from tar -cf"), 0);
subproc_reap(tar_pid, "tar -cf", 0);
}
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/reproducible/dpkg.git
More information about the Reproducible-commits
mailing list