Re: New Build-Options field and build-arch option, please review

2008-07-10 Thread Felipe Sateler
El 10/07/08 18:02 Raphael Hertzog escribió:
> Hello,
>
> in order to fix #229357 I decided to add a new Build-Options field.
> I modified Dpkg::BuildOptions to parse this field and DEB_BUILD_OPTIONS.
> And I added support for a build-arch option, that if present, will let
> dpkg-buildpackage call debian/rules build-arch and build-indep.
>
> It's not obvious that this was the right choice when you think of the
> currently existing build options but once you start thinking of possible
> additions (as requested in #489771), it becomes more evident that it makes
> sense. Even if some build options should really only be used in
> the field while others should only be used in the environment variable,
> the possibility to override the former with the latter is nice.

I'm not really sure this is right. There are two things that we want to do 
here: declare that a package supports something, and asking the package to do 
something. This difference is blurred now, and I think it is confusing.
OTOH, it gives the benefit of being able to ignore the package capabilities 
via the environment (ie, unset a given option).
I fear it will give rise to abuses such as setting parallel=n in the control 
file.


Saludos,
Felipe Sateler


signature.asc
Description: This is a digitally signed message part.


New Build-Options field and build-arch option, please review

2008-07-10 Thread Raphael Hertzog
Hello,

in order to fix #229357 I decided to add a new Build-Options field.
I modified Dpkg::BuildOptions to parse this field and DEB_BUILD_OPTIONS.
And I added support for a build-arch option, that if present, will let
dpkg-buildpackage call debian/rules build-arch and build-indep.

It's not obvious that this was the right choice when you think of the
currently existing build options but once you start thinking of possible
additions (as requested in #489771), it becomes more evident that it makes
sense. Even if some build options should really only be used in
the field while others should only be used in the environment variable,
the possibility to override the former with the latter is nice.

The current patchset is available in my public repository but I'll attach
it as well so that you can easily review it. I intend to merge it this
week-end after some tests but feel free to test and comment in the mean
time.

http://git.debian.org/?p=users/hertzog/dpkg.git;a=shortlog;h=refs/heads/pu/bug229357-build-options

The patchset only applies on top of master.

Cheers,
-- 
Raphaël Hertzog

Le best-seller français mis à jour pour Debian Etch :
http://www.ouaza.com/livre/admin-debian/
>From 1ebeff797bc36c91e50f02c6d32cba094e827add Mon Sep 17 00:00:00 2001
From: Raphael Hertzog <[EMAIL PROTECTED]>
Date: Sun, 6 Jul 2008 22:03:27 +0200
Subject: [PATCH] Refactor Dpkg::BuildOptions to handle Build-Options field

* scripts/Dpkg/BuildOptions.pm: complete rewrite of the module
to handle various sources of build options: some options are auto-set
based on the standards version, then the maintainer can define options
with the Build-Options field in debian/control and last the builder
can use DEB_BUILD_OPTIONS to override everything. Some options are
meant to be exported through DEB_BUILD_OPTIONS and some are not.
* scripts/t/300_Dpkg_BuildOptions.t: adjust test suite for the new module
* scripts/dpkg-buildpackage.pl: adjust to use the new Dpkg::BuildOptions
API.
* scripts/Dpkg/Fields.pm, scripts/Dpkg/Source/Package.pm: add the new
Build-Options field as a valid field in the source section of
debian/control (and in .dsc files).
---
 scripts/Dpkg/BuildOptions.pm  |  257 +
 scripts/Dpkg/Fields.pm|2 +-
 scripts/Dpkg/Source/Package.pm|5 +-
 scripts/dpkg-buildpackage.pl  |   10 +-
 scripts/t/300_Dpkg_BuildOptions.t |   61 +
 5 files changed, 273 insertions(+), 62 deletions(-)

diff --git a/scripts/Dpkg/BuildOptions.pm b/scripts/Dpkg/BuildOptions.pm
index 9d6741b..5b2acdd 100644
--- a/scripts/Dpkg/BuildOptions.pm
+++ b/scripts/Dpkg/BuildOptions.pm
@@ -5,51 +5,252 @@ use warnings;
 
 use Dpkg::Gettext;
 use Dpkg::ErrorHandling qw(warning);
+use Dpkg::Control;
+use Dpkg::Version qw(compare_versions);
 
-sub parse {
-my ($env) = @_;
+# Define behavior for known options:
+# export -> the option is meant to be exported in DEB_BUILD_OPTIONS
+# valued -> the option can have a value
+# check_value_rx -> if defined, a regex to check the value, invalid value
+#   will lead to the option being discarded
+# min_standards_version -> if the s-v field is >= to the version given,
+#  the option is auto-enabled
+our %OPTIONS = (
+noopt => {
+export => 1,
+valued => 0,
+},
+nostrip => {
+export => 1,
+valued => 0,
+},
+nocheck => {
+export => 1,
+valued => 0,
+},
+parallel => {
+export => 1,
+valued => 1,
+check_value_rx => qr/^-?\d+$/,
+},
+);
 
-$env ||= $ENV{DEB_BUILD_OPTIONS};
+=head1 NAME
 
-unless ($env) { return {}; }
+Dpkg::BuildOptions - handle build options from debian/control and environment
 
-my %opts;
+=head1 DESCRIPTION
 
-foreach (split(/\s+/, $env)) {
-	unless (/^([a-z][a-z0-9_-]*)(=(\S*))?$/) {
-warning(_g("invalid flag in DEB_BUILD_OPTIONS: %s"), $_);
-next;
+It provides an object to analyze and manipulate build options as defined
+by combining information provided by the debian/control file and by the
+DEB_BUILD_OPTIONS environment variable.
+
+=head1 FUNCTIONS
+
+=over 4
+
+=item $b = Dpkg::BuildOptions($file)
+
+Create a new Dpkg::BuildOptions object. The $file parameter is simply
+forwarded to Dpkg::Control->new($file). If undef, it will simply use
+debian/control by default.
+
+=cut
+sub new {
+my ($this, $ctl_file) = @_;
+my $class = ref($this) || $this;
+my $self = {
+'opts' => {},
+'control' => Dpkg::Control->new($ctl_file),
+};
+bless $self, $class;
+$self->parse_options();
+return $self;
+}
+
+=item $b->reset()
+
+Forget all options already parsed. Start afresh.
+
+=cut
+sub reset {
+my ($self) = @_;
+$self->{'opts'} = {};
+}
+
+=item $b->parse_options()
+
+Do a full parse of options, including the Build-Options field in
+debian/control and the DEB_BUILD_OPTIONS variable.
+
+=cut
+sub parse_options {
+my 

Re: RFC: Idea for improved diversions and alternatives handling

2008-07-10 Thread Goswin von Brederlow
Neil Williams <[EMAIL PROTECTED]> writes:

> Goswin von Brederlow wrote:
>> working on dpkg reminded me that I wanted to propose a better
>> diversion and alternatives handling for debian packages. Currently
>> they have to be manually added and removed in the maintainer
>> scripts. This method is prone to errors and can easily leave
>> diversions or alternatives behind. Instead I suggest creating two new
>> control files detailing the diversions and alternatives a package
>> should have.
>
> Can symlinks be supported in the declarative control file stanzas?

Don't symlinks work in diversions now?

Diverting should just move the file around so I see no reason why it
should even care about the file type.

MfG
Goswin


-- 
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]



Re: Multiarch and idea for improved diversions and alternatives handling

2008-07-10 Thread Goswin von Brederlow
Neil Williams <[EMAIL PROTECTED]> writes:

> On Fri, 2008-07-04 at 08:33 +0200, Tollef Fog Heen wrote:
>> * Neil Williams 
>> 
>> | Just a thought - why use /usr/lib/$ARCH and /usr/include/$ARCH at all
>> | when it would (IMHO) be simpler to use /usr/$TRIPLET/ and put the entire
>> | package under that, as we do with dpkg-cross currently:
>> 
>> How would you then handle libraries that go in /lib?  (Apart from the
>> fact that I think just using a subdirectory of /usr/lib is much neater
>> than random subdirectories in /usr.
>
> /lib/
> /arm-linux-gnu/lib/
>
> (did I miss that bit?)
>
> A single subdirectory of /usr is, IMHO, neater than a subdirectory
> of /usr/include and /usr/lib/. It would also mean less changes for those
> who are currently using multiple architectures on one system for the
> purposes of cross building. I wouldn't want to go the whole hog though
> and have /arm-linux-gnu/usr/lib /arm-linux-gnu/lib because that would be
> ugly, at least to me.
>
>> 
>> | /usr/include/
>> | /usr/arm-linux-gnu/include/
>> 
>> Please note that the initial goal of multiarch at least has been just
>> running of packages from foreign architectures.  Not building them.
>
> True but the current usage of these mechanisms is in cross-building so
> sometimes the results of having to do something without major changes
> elsewhere can be helpful in designing the subsequent mechanism.

The current mechanism is a total mess and needs to be thrown out and
done right in any case.

binutils on amd64 uses /usr/i386-linux-gnu/lib while i386 uses
/usr/i486-linux-gnu/lib. So cross-building will fail there anyway.  It
also misses /i486-linux-gnu/lib making several core libraries go
missing. Not to mention that multilib gcc does not provide the cross
compiler binaries for the other supported archs,
i.e. i486-linux-gnu-gcc on amd64.

Further those directories are totaly wrong when compiling code for
e.g. uclibc.


The binutils upstream has further decided that it is not binutils
place to support multiarch directories. That is a job of the
compiler. As such binutils should be stoped from blindly adding the
(wrong) cross-compile dir and gcc should add the right directories.


So no matter what actual path you pick there has to be exactly the
same change. Both binutils and gcc need adapting.

 
>> | multiarch could even add:
>> | /usr/share/
>> | /usr/arm-linux-gnu/share
>> 
>> Pardon my language, but this is crack.  The point of /usr/share is you
>> can share it between systems.  If you go down this route, just use a
>> chroot and some wrapper scripts to bounce between them instead.
>
> It was only a suggestion for /usr/share - it was an alternative to
> renaming the package to get a different directory in /usr/share/ as the
> current tools do. Until all suitable packages have things like
> translations separated out into TDebs and other things like images in a
> -data or -common package instead of being packaged along with the
> architecture-dependent binaries, conflicts will occur if /usr/share is
> used as intended.

Then you could not just share /usr/share via nfs but would have to
share all the multiarch share dirs. bad bad bad.

MfG
Goswin


-- 
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]