[debhelper-devel] [Git][debian/debhelper][master] dh: Rename optimize_sequence to unpack_sequence
Niels Thykier
gitlab at salsa.debian.org
Sun Jan 28 12:48:16 UTC 2018
Niels Thykier pushed to branch master at Debian / debhelper
Commits:
4d8d691b by Niels Thykier at 2018-01-28T12:31:15+00:00
dh: Rename optimize_sequence to unpack_sequence
It is not a super name, but "optimize" implies that dh will work if
you skip the call. By renaming it to unpack we avoid that implication.
Signed-off-by: Niels Thykier <niels at thykier.net>
- - - - -
3 changed files:
- dh
- lib/Debian/Debhelper/SequencerUtil.pm
- t/dh-sequencer.t
Changes:
=====================================
dh
=====================================
--- a/dh
+++ b/dh
@@ -690,7 +690,7 @@ if ( -f $build_stamp_file and not compat(9)) {
# In compat <= 8, the sequences are always inlined (those versions do not
# recurse into debian/rules anyway). In compat 9+, we never inline an
# existing rules target.
-my ($rules_targets, $full_sequence) = optimize_sequence(\%sequences,
+my ($rules_targets, $full_sequence) = unpack_sequence(\%sequences,
$sequence,
(!compat(8) ? 0 : 1),
\%completed_sequences
@@ -754,7 +754,7 @@ for my $rules_command (@{$rules_targets}) {
run("debian/rules", $rules_target);
my $override_packages = $sequence2packages{$rules_target} // \@packages;
for my $package (@{$override_packages}) {
- my (undef, $seq) = optimize_sequence(\%sequences, $rules_target, 1);
+ my (undef, $seq) = unpack_sequence(\%sequences, $rules_target, 1);
COMMAND: for my $c (reverse(@{$seq})) {
for my $j (0 .. $#{$full_sequence}) {
if ($c eq $full_sequence->[$j]) {
=====================================
lib/Debian/Debhelper/SequencerUtil.pm
=====================================
--- a/lib/Debian/Debhelper/SequencerUtil.pm
+++ b/lib/Debian/Debhelper/SequencerUtil.pm
@@ -12,7 +12,7 @@ use Exporter qw(import);
our @EXPORT = qw(
extract_rules_target_name
to_rules_target
- optimize_sequence
+ unpack_sequence
rules_explicit_target
DUMMY_TARGET
);
@@ -31,9 +31,11 @@ sub to_rules_target {
return 'debian/rules '.join(' ', @_);
}
-sub optimize_sequence {
+sub unpack_sequence {
my ($sequences, $sequence_name, $always_inline, $completed_sequences) = @_;
my (@sequence, @targets, %seen, %non_inlineable_targets, @stack);
+ # Walk through the sequence effectively doing a DFS of the rules targets
+ # (when we are allowed to inline them).
push(@stack, [@{$sequences->{$sequence_name}}]);
while (@stack) {
my $current_sequence = pop(@stack);
=====================================
t/dh-sequencer.t
=====================================
--- a/t/dh-sequencer.t
+++ b/t/dh-sequencer.t
@@ -55,33 +55,33 @@ $Debian::Debhelper::SequencerUtil::RULES_PARSED = 1;
is_deeply(
- [optimize_sequence(\%sequences, 'build')],
+ [unpack_sequence(\%sequences, 'build')],
[[], [@bd]],
'Inlined build sequence matches build-indep/build-arch');
is_deeply(
- [optimize_sequence(\%sequences, 'install')],
+ [unpack_sequence(\%sequences, 'install')],
[[], [@bd, @i]],
'Inlined install sequence matches build-indep/build-arch + install commands');
is_deeply(
- [optimize_sequence(\%sequences, 'binary-arch')],
+ [unpack_sequence(\%sequences, 'binary-arch')],
[[], [@bd, @i, @ba, @b]],
'Inlined binary-arch sequence has all the commands');
is_deeply(
- [optimize_sequence(\%sequences, 'binary-indep')],
+ [unpack_sequence(\%sequences, 'binary-indep')],
[[], [@bd, @i, @b]],
'Inlined binary-indep sequence has all the commands except @bd');
is_deeply(
- [optimize_sequence(\%sequences, 'binary')],
+ [unpack_sequence(\%sequences, 'binary')],
[[], [@bd, @i, @ba, @b]],
'Inlined binary sequence has all the commands');
is_deeply(
- [optimize_sequence(\%sequences, 'binary', 0, { 'build' => 1, 'build-arch' => 1, 'build-indep' => 1})],
+ [unpack_sequence(\%sequences, 'binary', 0, { 'build' => 1, 'build-arch' => 1, 'build-indep' => 1})],
[[], [@i, @ba, @b]],
'Inlined binary sequence with build-* done has @i, @ba and @b');
@@ -89,17 +89,17 @@ is_deeply(
local $Debian::Debhelper::SequencerUtil::EXPLICIT_TARGETS{'build'} = 1;
is_deeply(
- [optimize_sequence(\%sequences, 'binary')],
+ [unpack_sequence(\%sequences, 'binary')],
[[to_rules_target('build')], [@i, @ba, @b]],
'Inlined binary sequence has all the commands but build target is opaque');
is_deeply(
- [optimize_sequence(\%sequences, 'binary', 0, { 'build' => 1, 'build-arch' => 1, 'build-indep' => 1})],
+ [unpack_sequence(\%sequences, 'binary', 0, { 'build' => 1, 'build-arch' => 1, 'build-indep' => 1})],
[[], [@i, @ba, @b]],
'Inlined binary sequence has all the commands with build-* done and not build-target');
is_deeply(
- [optimize_sequence(\%sequences, 'build')],
+ [unpack_sequence(\%sequences, 'build')],
[[], [@bd]],
'build sequence is inlineable');
@@ -109,9 +109,9 @@ is_deeply(
local $Debian::Debhelper::SequencerUtil::EXPLICIT_TARGETS{'install-arch'} = 1;
is_deeply(
- [optimize_sequence(\%sequences, 'binary')],
+ [unpack_sequence(\%sequences, 'binary')],
# @bd_minimal, @bd and @i should be "-i"-only, @ba + @b should be both.
- # Unfortunately, optimize_sequence cannot show that.
+ # Unfortunately, unpack_sequence cannot show that.
[[to_rules_target('install-arch')], [@bd, @i, @ba, @b]],
'Inlined binary sequence has all the commands');
}
@@ -120,9 +120,9 @@ is_deeply(
local $Debian::Debhelper::SequencerUtil::EXPLICIT_TARGETS{'install-arch'} = 1;
local $Debian::Debhelper::SequencerUtil::EXPLICIT_TARGETS{'build'} = 1;
- my $actual = [optimize_sequence(\%sequences, 'binary')];
+ my $actual = [unpack_sequence(\%sequences, 'binary')];
# @i should be "-i"-only, @ba + @b should be both.
- # Unfortunately, optimize_sequence cannot show that.
+ # Unfortunately, unpack_sequence cannot show that.
my $expected = [[to_rules_target('build'), to_rules_target('install-arch')], [@i, @ba, @b]];
# Permit some fuzz on the order between build and install-arch
if ($actual->[0][0] eq to_rules_target('install-arch')) {
View it on GitLab: https://salsa.debian.org/debian/debhelper/commit/4d8d691b722075dc5a1a35ab900a6f059bb6d8f4
---
View it on GitLab: https://salsa.debian.org/debian/debhelper/commit/4d8d691b722075dc5a1a35ab900a6f059bb6d8f4
You're receiving this email because of your account on salsa.debian.org.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.alioth.debian.org/pipermail/debhelper-devel/attachments/20180128/d96b99eb/attachment-0001.html>
More information about the debhelper-devel
mailing list