Bug#630982: Automatic build-time dependency generation for jquery.js

2013-02-23 Thread Helmut Grohne
Control: severity -1 important

Raising the severity due to the number of packages affected and the
number of workarounds deployed already.

On Sun, Jun 19, 2011 at 02:25:44PM +0100, Marcin Owsiany wrote:
 Here's my proposal:
 
 whenever doxygen is used during libgadu-doc build, it should:
 
 1) install symlinks to /usr/share/javascript/jquery/jquery*.js rather
than outputing the file contents
 
 2) add misc:Depends=libjs-jquery to debian/libgadu-doc.substvars

I am attaching a preliminary version of dh_doxygen (bluntly copied from
Jakub Wilk's dh_sphinxdoc). In addition to the above it will also clean
*.md5 and *.map files used to speed up incremental regeneration (which
is useless in binary packages). Note that the substvar is called
${doxygen:Depends} instead. Also ${doxygen:Built-Using} is provided to
meet recent policy changes.

Open issues:

 * Maybe the libjs-jquery dependency should be versioned?
 * Would it be possible for doxygen to ship a doxygen-common package
   shipping files like doxygen.css doxygen.png tabs.css dynsections.js?
   That way we might be able to get rid of the Built-Using field.

Helmut
#!/usr/bin/perl

# Copyright © 2011 Jakub Wilk jw...@debian.org
# Copyright © 2013 Helmut Grohne hel...@subdivi.de
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are
# met:
#
# * Redistributions of source code must retain the above copyright
#   notice, this list of conditions and the following disclaimer.
#
# * Redistributions in binary form must reproduce the above copyright
#   notice, this list of conditions and the following disclaimer in the
#   documentation and/or other materials provided with the distribution.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
# AS IS AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

=head1 NAME

dh_doxygen - helps with packaging doxygen-generated documentation

=head1 SYNOPSIS

dh_doxygen [SIdebhelper options] [B-XIitem] [Idirectory...]

=head1 DESCRIPTION

Bdh_doxygen is a debhelper program that prepares doxygen-generated
documentation for inclusion in a Debian package. More specifically:

=over 4

=item *

It replaces known F*.js files with symlinks to F/usr/share/javascript/
and generates B${doxygen:Depends} substitution variable.

=item *

It removes F*.md5 and F*.map files. These are created by doxygen to speed
up incremental runs.

=item *

It generates a B${doxygen:Built-Using} substitution variable.

=back

=head1 OPTIONS

=over 4

=item Idirectory

By default, Bdh_doxygen scans your package looking for directories looking
like they contain doxygen-generated documentation. However, if you explicitly
provide one or more directories, only they will be processed.

=item B-XIitem, B--exclude=Iitem

Exclude files that contain Iitem anywhere in their filename from
being symlinked, removed or checked for existence.

=back

=head1 BUGS

Probably.

=cut

use strict;
use warnings;

use File::Find;
use Debian::Debhelper::Dh_Lib;

sub looks_like_doxygen_doc($)
{
my ($path) = @_;
return 0 unless -f $path/doxygen.css;
return 0 unless -f $path/doxygen.png;
return 0 unless -f $path/index.html;
return 1;
}

sub ln_sf($$)
{
my ($orig_target, $orig_source) = my ($target, $source) = @_;
$source =~ s{^debian/[^/]++/+}{} or die;
$target =~ s{^/++}{} or die;
my @source = split(m{/++}, $source);
my @target = split(m{/++}, $target);
@source  0 and @target  0 or die;
if ($source[0] eq $target[0])
{
# Make the symlink relative, as per Policy 10.5.
while (@source  0 and @target  0 and $source[0] eq $target[0])
{
shift @source;
shift @target;
}
$target = ('../' x $#source) . join('/', @target);
}
else
{
# Keep the symlink absolute, as per Policy 10.5.
$target = $orig_target;
}
doit('ln', '-sf', $target, $orig_source);
}

sub fix_symlinks($)
{
my %deps = ();
my ($path) = @_;
if(-f $path/jquery.js) {
ln_sf(/usr/share/javascript/jquery/jquery.js, $path/jquery.js);
$deps{libjs-jquery} = 1;
}
return keys %deps;
}

sub drop_cruft($)
{
my ($path) = @_;
my $find_options = ;
if(defined($dh{EXCLUDE_FIND})  $dh{EXCLUDE_FIND} ne '')
  

Bug#630982: Automatic build-time dependency generation for jquery.js

2011-06-19 Thread Marcin Owsiany
Package: doxygen
Version: 1.7.4-2

I maintain libgadu, which is one of many packages that use doxygen for
generating its API documentation (in this case in libgadu-doc). I'm
writing because of the new lintian check for embedded JavaScript
libraries which also affects libgadu-doc. While this problem affects
more than libgadu-doc, let's focus on this case for sake of simplicity.

I've seen #622147 and #625956, however I feel they do not address the
core of the problem, which is the fact that calling doxygen when
building src:libgadu embeds a copy of jquery.js inside the libgadu-doc
binary package.

It seems that in order to rid of the embedded copy, the libgadu-doc
maintainer would need to hunt down such jquery.js file and replace it
with a symlink to the file provided by libjs-jquery. 

However from libgadu's POV that's not the right approach:
 - libgadu-doc treats doxygen as a service - it points it at some source
   files, and expects a bunch of HTML files in the output directory. The
   exact names or paths of these files are not generally its concern
   (maybe apart from the main index.html). In particular which
   JavaScript libriaries doxygen decides to use for the documentation it
   generates is an implementation detail.
 - It might change between doxygen versions in various ways: the name or
   exact path of the embedded file could change, or it might decide to
   use a completely different jquery implementation altogether. Or might
   even stop using jquery at all! And that's all completely fine, and it
   must not require any action on part of libgadu-doc maintainer.
   Otherwise simple rebuilds against a new doxygen would be unsafe!

I think instead we should use the technology we already have in Debian
for dynamically generating binary package dependencies at build time.

Here's my proposal:

whenever doxygen is used during libgadu-doc build, it should:

1) install symlinks to /usr/share/javascript/jquery/jquery*.js rather
   than outputing the file contents

2) add misc:Depends=libjs-jquery to debian/libgadu-doc.substvars

How this should be implemented is an open question. I don't think the
doxygen binary should be modified to edit Debian build-specific files,
but I could imagine:

 - doxygen emitting a list of jquery.js file paths it created during a
   run,

 - a wrapper for doxygen, which would accept a path to the debian
   directory, and the name of the package being built (libgadu-doc in
   this case). This wrapper would parse the list emitted by doxygen,
   replace files with symlinks, and edit the appropriate .substvars
   file.


Implementing this proposal will obviously require some work, but I think
it will be an overall win given the number of packages which use doxygen
and currently end up with embedded copies of jquery. Moreover, when such
mechanism is implemented, it can probably be used in other packages
whose role is similar to doxygen.

-- 
Marcin Owsiany porri...@debian.org http://marcin.owsiany.pl/
GnuPG: 1024D/60F41216  FE67 DA2D 0ACA FC5E 3F75  D6F6 3A0D 8AA0 60F4 1216



-- 
To UNSUBSCRIBE, email to debian-bugs-dist-requ...@lists.debian.org
with a subject of unsubscribe. Trouble? Contact listmas...@lists.debian.org