> Jonathan Nieder <jrnie...@gmail.com> wrote:
> > Wookey wrote:
(out of order for convenience)

> Attached is a slightly better version which is at least useful enough to
> work with.

Thanks.  What did you think of Raphaël's idea of the virtual
bootstrap-stage package?

Interesting. We did look at various ways of representing this info in
the normal fields, but it was difficult to think of something that
was both sufficient and not too intrusive.

Raphael's idea could possibly work. The main problem seems to be if
you want to use a different build-dep (e.g foo-minimal rather
than foo). That gets a bit long-winded  (foo | bootstrap-stage (<<
99), bootstrap-stage (!= 2) | foo-minimal). A simple alternative list
is clearer.

Also this makes it hard for a tool to divine which build-stages are
available to build. Having -stageN headers also makes this very obvious. 

I'll read up the original docs where this was discussed at length and
see, then post on -devel (I have actually started said mail now!).

In the maintime I want to post this update of the existing scheme now for 
feedback.

> Won't there be need for a Build-Conflicts-Stage1, too?

In theory I suppose so, but in practice we've seen no use for it. I am
inclined to add this if we find it's necessary in the future.


> Aside from that sort of question, the Dpkg::Control::Fields numbering
> still seems to be off.  Some people might think it is right to make
> the maintainer do penance for this kind of fussy code, but I think
> there are better ways to convince people to fix things. ;-)

Sorry - I had failed to understand what those fields actually did. I
thought that as the -stage1 were alternative they would have the same
priority. It worked for my purposes without getting those right. I've
included your correcting in the new patch.

> I also was surprised that the patch did not have to touch the code in
> "dpkg-source -b" that checks and normalizes Build-Depends so it could
> be applied to Build-Depends-Stage1, too.  (See bug#254449.)  Is that
> not needed?

Well it seemed to work OK without touching that, but I agree it seems
wrong. I guess we were putting them all on one line, or didn't notice
the lost lines...

Fixed in new patch (but not tested yet). I need to add tests, as
suggested.

> The patch below (untested) fixes a few whitespace nits and the
> Control::Fields numbering but not "dpkg-source -b".  Maybe it can save
> some time.

It did - thanks.

One remaining issue is that packages built with stage=n set should
have their headers marked accordingly so they can be rejected from
repos or detected by scans. The suggestion in
http://wiki.debian.org/DebianBootstrap (specifying stages) says:

"Any 'staged' package must be identified as such in the metadata so it
is not accidentally uploaded as a 'real' package. Is the 'UNRELEASED'
codename indicator sufficient or do we need something more explicit:
e.g. X-Staged-Build:N header?"

I think the latter is a good idea, but it's not been implemented yet.
A clue as to where in the code to do that would be helpful. Is
dpkg-gencontrol the right place?

I notice the only other place that build-depends gets a mention is
dpkg-shlibs. Again not touching this has worked fine for us so far,
but maybe that should be adjusted too. I'm really not sure if it
matters?

Wookey
diff -urN dpkg-1.16.3.original/man/deb-src-control.5 dpkg-1.16.3.bootstrap/man/deb-src-control.5
--- dpkg-1.16.3.original/man/deb-src-control.5	2012-04-27 05:32:53.000000000 +0100
+++ dpkg-1.16.3.bootstrap/man/deb-src-control.5	2012-05-11 03:31:26.879333306 +0100
@@ -135,6 +135,22 @@
 in this case.
 
 .TP
+.BI Build\-Depends\-Stage1: " package-list"
+.BI Build\-Depends\-Stage2: " package-list"
+Modfied \fBBuild\-Depends\fP list of packages needed to build the source
+package in 'bootstrap stage 1 (or 2)' mode. Staged builds are used to break
+build-dependency loops when bootstrapping an architecture.
+
+.TP
+.BI Build\-Depends\-Indep\-Stage1: " package-list"
+.BI Build\-Depends\-Indep\-Stage2: " package-list"
+Modified \fBBuild\-Depends\-Indep\fPA package list for building the source
+package in 'bootstrap stage 1 (or 2)' mode. Staged builds are used to break
+build-dependency loops when bootstrapping an architecture.
+
+
+
+.TP
 .BI Build\-Conflicts: " package-list"
 A list of packages that should not be installed when the package is build, for
 example because they interfere with the used build system.
@@ -146,8 +162,16 @@
 
 The syntax of the
 .B Build\-Depends
-and
+,
 .B Build\-Depends\-Indep
+,
+.B Build\-Depends\-Stage1
+,
+.B Build\-Depends\-Indep\-Stage1
+,
+.B Build\-Depends\-Stage2
+and
+.B Build\-Depends\-Indep\-Stage2
 fields is a list of groups of alternative packages. Each group is a list
 of packages separated by vertical bar (or "pipe") symbols, "|". The
 groups are separated by commas. Commas are to be read as "AND", and pipes
diff -urN dpkg-1.16.3.original/man/dpkg-buildpackage.1 dpkg-1.16.3.bootstrap/man/dpkg-buildpackage.1
--- dpkg-1.16.3.original/man/dpkg-buildpackage.1	2012-04-27 05:32:53.000000000 +0100
+++ dpkg-1.16.3.bootstrap/man/dpkg-buildpackage.1	2012-05-11 03:50:45.249077350 +0100
@@ -263,6 +263,11 @@
 \fBCPPFLAGS\fP and \fBLDFLAGS\fP) with values as returned
 by \fBdpkg\-buildflags\fP. This is no longer the case.
 .
+If DEB_BUILD_OPTIONS contains \fBstage=1\fP or \fBstage=2\fP then
+'staged build' mode is selected and checkbuilddeps is called with the
+--stage=N option so that the alternate Build-Depends-StageN
+build-dependencies are checked.
+.
 .SH BACKWARD COMPATIBILITY
 \fBdpkg\-buildpackage\fP is using the \fBbuild\-arch\fP and
 \fBbuild\-indep\fP targets since version 1.16.2. Those targets are thus
diff -urN dpkg-1.16.3.original/man/dpkg-checkbuilddeps.1 dpkg-1.16.3.bootstrap/man/dpkg-checkbuilddeps.1
--- dpkg-1.16.3.original/man/dpkg-checkbuilddeps.1	2012-04-27 05:32:53.000000000 +0100
+++ dpkg-1.16.3.bootstrap/man/dpkg-checkbuilddeps.1	2012-05-11 03:44:47.455303129 +0100
@@ -55,6 +55,11 @@
 the control file is to be built for the given host architecture instead of
 the architecture of the current system.
 .TP
+.BI \-\-stage= stage
+Specify that the Build-Depends-StageN dependency requirements should 
+be checked (if present) instead of the normal fields, for use in
+bootstrapping. Values of 1 and 2 are supported.
+.TP
 .BR \-h ", " \-\-help
 Show the usage message and exit.
 .TP
diff -urN dpkg-1.16.3.original/scripts/Dpkg/BuildOptions.pm dpkg-1.16.3.bootstrap/scripts/Dpkg/BuildOptions.pm
--- dpkg-1.16.3.original/scripts/Dpkg/BuildOptions.pm	2012-04-27 03:49:02.000000000 +0100
+++ dpkg-1.16.3.bootstrap/scripts/Dpkg/BuildOptions.pm	2012-05-11 02:59:12.273740130 +0100
@@ -121,6 +121,9 @@
     } elsif ($key eq 'parallel')  {
 	$value = "" if not defined($value);
 	return 0 if $value !~ /^\d*$/;
+    } elsif ($key eq 'stage')  {
+	$value = "" if not defined($value);
+	return 1 if $value !~ /^\d*$/;
     }
 
     $self->{'options'}{$key} = $value;
diff -urN dpkg-1.16.3.original/scripts/Dpkg/Control/Fields.pm dpkg-1.16.3.bootstrap/scripts/Dpkg/Control/Fields.pm
--- dpkg-1.16.3.original/scripts/Dpkg/Control/Fields.pm	2012-04-27 03:49:02.000000000 +0100
+++ dpkg-1.16.3.bootstrap/scripts/Dpkg/Control/Fields.pm	2012-05-11 03:14:20.482243689 +0100
@@ -61,12 +61,12 @@
     'Build-Conflicts' => {
         allowed => ALL_SRC,
         dependency => 'union',
-        dep_order => 3,
+        dep_order => 5,
     },
     'Build-Conflicts-Indep' => {
         allowed => ALL_SRC,
         dependency => 'union',
-        dep_order => 4,
+        dep_order => 6,
     },
     'Build-Depends' => {
         allowed => ALL_SRC,
@@ -78,6 +78,26 @@
         dependency => 'normal',
         dep_order => 2,
     },
+    'Build-Depends-Stage1' => {
+        allowed => ALL_SRC,
+        dependency => 'normal',
+        dep_order => 3,
+    },
+    'Build-Depends-Indep-Stage1' => {
+        allowed => ALL_SRC,
+        dependency => 'normal',
+        dep_order => 4,
+    },
+    'Build-Depends-Stage2' => {
+        allowed => ALL_SRC,
+        dependency => 'normal',
+        dep_order => 5,
+    },
+    'Build-Depends-Indep-Stage2' => {
+        allowed => ALL_SRC,
+        dependency => 'normal',
+        dep_order => 6,
+    },
     'Built-Using' => {
         allowed => ALL_PKG,
         dependency => 'union',
diff -urN dpkg-1.16.3.original/scripts/dpkg-buildpackage.pl dpkg-1.16.3.bootstrap/scripts/dpkg-buildpackage.pl
--- dpkg-1.16.3.original/scripts/dpkg-buildpackage.pl	2012-04-27 03:49:03.000000000 +0100
+++ dpkg-1.16.3.bootstrap/scripts/dpkg-buildpackage.pl	2012-05-11 02:59:12.273740130 +0100
@@ -123,6 +123,7 @@
 my $targetarch = my $targetgnusystem = '';
 my $call_target = '';
 my $call_target_as_root = 0;
+my $buildstage = 0;
 my (@checkbuilddep_opts, @changes_opts, @source_opts);
 
 use constant BUILD_DEFAULT    => 1;
@@ -299,6 +300,9 @@
     $build_opts->export();
 }
 
+$buildstage = $build_opts->get("stage") if $build_opts->has("stage");
+
+
 my $cwd = cwd();
 my $dir = basename($cwd);
 
@@ -362,6 +366,9 @@
     if ($admindir) {
 	push @checkbuilddep_opts, "--admindir=$admindir";
     }
+    if ($buildstage) {
+	push @checkbuilddep_opts, "--stage=$buildstage";
+    }
 
     system('dpkg-checkbuilddeps', @checkbuilddep_opts);
     if (not WIFEXITED($?)) {
diff -urN dpkg-1.16.3.original/scripts/dpkg-checkbuilddeps.pl dpkg-1.16.3.bootstrap/scripts/dpkg-checkbuilddeps.pl
--- dpkg-1.16.3.original/scripts/dpkg-checkbuilddeps.pl	2012-04-27 03:49:03.000000000 +0100
+++ dpkg-1.16.3.bootstrap/scripts/dpkg-checkbuilddeps.pl	2012-05-11 03:34:47.584328546 +0100
@@ -51,6 +51,8 @@
   -a arch        assume given host architecture
   --admindir=<directory>
                  change the administrative directory.
+  --stage=<level>
+                 use build-depends-stage level specified
   -h, --help     show this help message.
       --version  show the version.")
 	. "\n\n" . _g(
@@ -61,13 +63,15 @@
 my $binary_only=0;
 my ($bd_value, $bc_value);
 my $host_arch = get_host_arch();
+my $buildstage=0;
 if (!GetOptions('B' => \$binary_only,
                 'help|h' => sub { usage(); exit(0); },
                 'version' => \&version,
                 'd=s' => \$bd_value,
                 'c=s' => \$bc_value,
                 'a=s' => \$host_arch,
-                'admindir=s' => \$admindir)) {
+                'admindir=s' => \$admindir,
+                'stage=s' => \$buildstage)) {
 	usage();
 	exit(2);
 }
@@ -80,10 +84,16 @@
 my $facts = parse_status("$admindir/status");
 
 unless (defined($bd_value) or defined($bc_value)) {
+    my $BD_key="Build-Depends";
+    my $BDI_key="Build-Depends-Indep";
+    if ($buildstage and defined $fields->{"Build-Depends-Stage".$buildstage}) {
+       $BD_key="Build-Depends-Stage".$buildstage;
+       $BDI_key="Build-Depends-Indep-Stage".$buildstage;
+    }
     $bd_value = 'build-essential';
-    $bd_value .= ", " . $fields->{"Build-Depends"} if defined $fields->{"Build-Depends"};
-    if (not $binary_only and defined $fields->{"Build-Depends-Indep"}) {
-	$bd_value .= ", " . $fields->{"Build-Depends-Indep"};
+    $bd_value .= ", " . $fields->{$BD_key} if defined $fields->{$BD_key};
+    if (not $binary_only and defined $fields->{$BDI_key}) {
+       $bd_value .= ", " . $fields->{$BDI_key};
     }
     $bc_value = $fields->{"Build-Conflicts"} if defined $fields->{"Build-Conflicts"};
     if (not $binary_only and defined $fields->{"Build-Conflicts-Indep"}) {
diff -urN dpkg-1.16.3.original/scripts/dpkg-source.pl dpkg-1.16.3.bootstrap/scripts/dpkg-source.pl
--- dpkg-1.16.3.original/scripts/dpkg-source.pl	2012-04-27 03:49:03.000000000 +0100
+++ dpkg-1.16.3.bootstrap/scripts/dpkg-source.pl	2012-05-11 04:02:14.224493804 +0100
@@ -246,7 +246,7 @@
 	    $fields->{$_} = $v;
 	} elsif (m/^Uploaders$/i) {
 	    ($fields->{$_} = $v) =~ s/\s*[\r\n]\s*/ /g; # Merge in a single-line
-	} elsif (m/^Build-(Depends|Conflicts)(-Indep)?$/i) {
+	} elsif (m/^Build-(Depends|Conflicts)(-Indep)?(-Stage\d)?$/i) {
 	    my $dep;
 	    my $type = field_get_dep_type($_);
 	    $dep = deps_parse($v, union => $type eq 'union');

Reply via email to