diff --git a/0001-add-pre-realbuild-commands-and-post-realbuild-comman.patch b/0001-add-pre-realbuild-commands-and-post-realbuild-comman.patch new file mode 100644 index 0000000..cd700b1 --- /dev/null +++ b/0001-add-pre-realbuild-commands-and-post-realbuild-comman.patch @@ -0,0 +1,88 @@ +From df094f79a67c0835b0fddd73019b09951ed26987 Mon Sep 17 00:00:00 2001 +From: josch +Date: Wed, 4 Jun 2014 22:57:36 +0200 +Subject: [PATCH] add pre-realbuild-commands and post-realbuild-commands + +--- + lib/Sbuild/Build.pm | 15 +++++++++++++++ + lib/Sbuild/Conf.pm | 2 ++ + lib/Sbuild/Options.pm | 10 ++++++++++ + 3 files changed, 27 insertions(+) + +diff --git a/lib/Sbuild/Build.pm b/lib/Sbuild/Build.pm +index a24b575..c8552de 100644 +--- a/lib/Sbuild/Build.pm ++++ b/lib/Sbuild/Build.pm +@@ -1060,6 +1060,12 @@ sub run_external_commands { + } elsif ($stage eq "chroot-setup-commands") { + $self->log_subsection("Chroot Setup Commands"); + $chroot = 1; ++ } elsif ($stage eq "pre-realbuild-commands") { ++ $self->log_subsection("Pre RealBuild Commands"); ++ $chroot = 1; ++ } elsif ($stage eq "post-realbuild-commands") { ++ $self->log_subsection("Post RealBuild Commands"); ++ $chroot = 1; + } elsif ($stage eq "chroot-cleanup-commands") { + $self->log_subsection("Chroot Cleanup Commands"); + $chroot = 1; +@@ -1383,6 +1389,10 @@ sub build { + return 0; + } + ++ $self->run_external_commands("pre-realbuild-commands", ++ $self->get_conf('LOG_EXTERNAL_COMMAND_OUTPUT'), ++ $self->get_conf('LOG_EXTERNAL_COMMAND_ERROR')); ++ + $self->set('Build Start Time', time); + $self->set('Build End Time', $self->get('Build Start Time')); + +@@ -1564,6 +1574,11 @@ sub build { + $self->log_sep(); + $self->log("Build finished at $finish_date\n"); + ++ ++ $self->run_external_commands("post-realbuild-commands", ++ $self->get_conf('LOG_EXTERNAL_COMMAND_OUTPUT'), ++ $self->get_conf('LOG_EXTERNAL_COMMAND_ERROR')); ++ + my @space_files = ("$dscdir"); + + $self->log_subsubsection("Finished"); +diff --git a/lib/Sbuild/Conf.pm b/lib/Sbuild/Conf.pm +index 25ec66d..a396821 100644 +--- a/lib/Sbuild/Conf.pm ++++ b/lib/Sbuild/Conf.pm +@@ -975,6 +975,8 @@ sub setup ($) { + DEFAULT => { + "pre-build-commands" => [], + "chroot-setup-commands" => [], ++ "pre-realbuild-commands" => [], ++ "post-realbuild-commands" => [], + "chroot-cleanup-commands" => [], + "post-build-commands" => [], + }, +diff --git a/lib/Sbuild/Options.pm b/lib/Sbuild/Options.pm +index 4a232bf..fbca939 100644 +--- a/lib/Sbuild/Options.pm ++++ b/lib/Sbuild/Options.pm +@@ -267,6 +267,16 @@ sub set_options { + push(@{${$self->get_conf('EXTERNAL_COMMANDS')}{"chroot-setup-commands"}}, + \@command); + }, ++ "pre-realbuild-commands=s" => sub { ++ my @command = split(/\s+/, $_[1]); ++ push(@{${$self->get_conf('EXTERNAL_COMMANDS')}{"pre-realbuild-commands"}}, ++ \@command); ++ }, ++ "post-realbuild-commands=s" => sub { ++ my @command = split(/\s+/, $_[1]); ++ push(@{${$self->get_conf('EXTERNAL_COMMANDS')}{"post-realbuild-commands"}}, ++ \@command); ++ }, + "chroot-cleanup-commands=s" => sub { + my @command = split(/\s+/, $_[1]); + push(@{${$self->get_conf('EXTERNAL_COMMANDS')}{"chroot-cleanup-commands"}}, +-- +1.9.2 + diff --git a/README.md b/README.md new file mode 100644 index 0000000..ddaafff --- /dev/null +++ b/README.md @@ -0,0 +1,24 @@ +Use `fatrace` to record all file access during an `sbuild` run and find those +build dependencies which have their files never needed. You need superuser +privileges to run this script because of `fatrace`. + +Run it like follows. In one terminal execute: + + $ ./findunusedbd.sh + +In another run sbuild like this: + + $ sbuild \ + --chroot-setup-commands='/home/user/path/to/findunusedbd.sh chroot-setup' \ + --pre-realbuild-commands='/home/user/path/to/findunusedbd.sh pre-realbuild' \ + --post-realbuild-commands='/home/user/path/to/findunusedbd.sh post-realbuild' + +This needs the --pre-realbuild-commands and --post-realbuild-commands to exist +which can be added to sbuild by applying +`0001-add-pre-realbuild-commands-and-post-realbuild-comman.patch` to it. + +Any unused dependencies can then be found by investigating the file +`unneededdepends.list`. + +Bugs: when investigating which build dependencies are unused, virtual packages +are not taken into account.