[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#377520: debbugs: New SOAP infrastructure with first function for usertags



On Mon, 10 Jul 2006, Don Armstrong wrote:
> Not really, because it requires hard coding the configuration file
> location and loading that first; far better to use PERL_LIB or similar
> to set it. [Or just install into the appropriate location if you're
> using suexec or something.]

FWIW, PERLLIB or PERL5LIB is incompatible with the '-T' switch of perl.
So the SetEnv in the apache.conf file is only working if you remove -T.

So what I suggest is to put the "require '/etc/debbugs/config'" in a BEGIN block
and to let the user add his "use lib '/my/own/copy/of/debbugs'" there in
the config file.

Please find an updated patch and here's the comment of the patch:

> === added directory 'Debbugs/SOAP'
> === added file 'Debbugs/SOAP/Usertag.pm'
> --- /dev/null	
> +++ Debbugs/SOAP/Usertag.pm	
> @@ -0,0 +1,18 @@
> +package Debbugs::SOAP::Usertag;
[...]
> === added file 'cgi/soap.cgi'
> --- /dev/null	
> +++ cgi/soap.cgi	
> @@ -0,0 +1,18 @@
> +#!/usr/bin/perl -wT
> +
> +package debbugs;
> +
> +use SOAP::Transport::HTTP;
> +
> +BEGIN {
> +    # Needed so that other modules have access to the variables
> +    # when included with use
> +    require '/etc/debbugs/config';
> +}
> +
> +use Debbugs::SOAP::Usertag;
> +
> +SOAP::Transport::HTTP::CGI
> +    -> dispatch_to('Debbugs::SOAP::Usertag', 'Debbugs::SOAP::Hello')
> +    -> handle;
> +

This is the core of the patch. You can apply that without changing anthing
else and it should just work.

However I wanted to get rid of an hardcoded value so I also the rest:

> === modified file 'Debbugs/User.pm'
> --- Debbugs/User.pm	
> +++ Debbugs/User.pm	
> @@ -53,7 +53,10 @@
>      $EXPORT_TAGS{all} = [@EXPORT_OK];
>  }
>  
> -my $gSpoolPath = "/org/bugs.debian.org/spool";
> +my $gSpoolDir = "/org/bugs.debian.org/spool";
> +if (defined($debbugs::gSpoolDir)) {
> +    $gSpoolDir = $debbugs::gSpoolDir;
> +}

I use the global variable if it's defined. For this to work, the variable
needs to exist when the module is loaded via "use". Thus the "require
'/etc/debbugs/config';" calls have been moved into BEGIN block (see
below).

> === modified file 'cgi/bugreport.cgi'
> --- cgi/bugreport.cgi	
> +++ cgi/bugreport.cgi	
 
> === modified file 'cgi/pkgindex.cgi'
> --- cgi/pkgindex.cgi	
> +++ cgi/pkgindex.cgi	
 
> === modified file 'cgi/pkgreport.cgi'
> --- cgi/pkgreport.cgi	
> +++ cgi/pkgreport.cgi	
> @@ -5,11 +5,15 @@

This is only the require moved to a BEGIN block.

> === modified file 'debian/control'
> --- debian/control	
> +++ debian/control	
> @@ -8,7 +8,7 @@
>  
>  Package: debbugs
>  Architecture: all
> -Depends: perl5 | perl, exim4 | mail-transport-agent, libmailtools-perl, ed, libmime-perl, libio-stringy-perl, libmldbm-perl, liburi-perl
> +Depends: perl5 | perl, exim4 | mail-transport-agent, libmailtools-perl, ed, libmime-perl, libio-stringy-perl, libmldbm-perl, liburi-perl, libsoap-lite-perl
>  Recommends: httpd, links | lynx
>  Suggests: spamassassin (>= 3.0)
>  Description: The bug tracking system based on the active Debian BTS

New package is needed... BTW, shall I ask debian-admin to install it on
spohr ?

> === modified file 'scripts/config.debian'
> --- scripts/config.debian	
> +++ scripts/config.debian	
> @@ -4,6 +4,7 @@
>  # Domains
>  $gEmailDomain = "bugs.debian.org";
>  $gListDomain = "lists.debian.org";
> +$gWebHostBugDir = "";
>  $gWebDomain = "www.debian.org/Bugs";
>  $gHTMLSuffix = "";
>  $gPackagePages = "packages.debian.org";
> 
> === modified file 'scripts/config.in.default'
> --- scripts/config.in.default	
> +++ scripts/config.in.default	
> @@ -2,6 +2,7 @@
>  #domains
>  $gEmailDomain = "bugs.top.domain";		#bugs.debian.org
>  $gListDomain = "lists.top.domain";		#lists.debian.org
> +$gWebHostBugDir = "";
>  $gWebDomain = "www.top.domain";			#www.debian.org/Bugs
>  $gCGIDomain = "cgi.top.domain";			#cgi.debian.org
 
This is only a little bugfix. This variable is used by bugreport.cgi and
it generated a warning about use of uninitialized value so I added it (it
already exists in scripts/config.in but has a different default value).

Cheers,
-- 
Raphaël Hertzog

Premier livre français sur Debian GNU/Linux :
http://www.ouaza.com/livre/admin-debian/
=== added directory 'Debbugs/SOAP'
=== added file 'Debbugs/SOAP/Usertag.pm'
--- /dev/null	
+++ Debbugs/SOAP/Usertag.pm	
@@ -0,0 +1,18 @@
+package Debbugs::SOAP::Usertag;
+
+use Debbugs::User;
+
+sub get_usertag {
+    my ($class, $email, $tag) = @_;
+    my %ut = ();
+    Debbugs::User::read_usertags(\%ut, $email);
+    if (defined($tag) and $tag ne "") {
+	# Remove unwanted tags
+	foreach (keys %ut) {
+	    delete $ut{$_} unless $_ eq $tag;
+	}
+    }
+    return \%ut;
+}
+
+1;

=== added file 'cgi/soap.cgi'
--- /dev/null	
+++ cgi/soap.cgi	
@@ -0,0 +1,18 @@
+#!/usr/bin/perl -wT
+
+package debbugs;
+
+use SOAP::Transport::HTTP;
+
+BEGIN {
+    # Needed so that other modules have access to the variables
+    # when included with use
+    require '/etc/debbugs/config';
+}
+
+use Debbugs::SOAP::Usertag;
+
+SOAP::Transport::HTTP::CGI
+    -> dispatch_to('Debbugs::SOAP::Usertag', 'Debbugs::SOAP::Hello')
+    -> handle;
+

=== modified file 'Debbugs/User.pm'
--- Debbugs/User.pm	
+++ Debbugs/User.pm	
@@ -53,7 +53,10 @@
     $EXPORT_TAGS{all} = [@EXPORT_OK];
 }
 
-my $gSpoolPath = "/org/bugs.debian.org/spool";
+my $gSpoolDir = "/org/bugs.debian.org/spool";
+if (defined($debbugs::gSpoolDir)) {
+    $gSpoolDir = $debbugs::gSpoolDir;
+}
 
 # Obsolete compatability functions
 
@@ -83,7 +86,7 @@
 sub filefromemail {
     my $e = shift;
     my $l = length($e) % 7;
-    return "$gSpoolPath/user/$l/" . join("", 
+    return "$gSpoolDir/user/$l/" . join("", 
         map { m/^[0-9a-zA-Z_+.-]$/ ? $_ : sprintf("%%%02X", ord($_)) }
             split //, $e);
 }

=== modified file 'cgi/bugreport.cgi'
--- cgi/bugreport.cgi	
+++ cgi/bugreport.cgi	
@@ -9,11 +9,15 @@
 use IO::Scalar;
 use IO::File;
 
+BEGIN {
+    # Needed so that other modules have access to the variables
+    # when included with use
+    require '/etc/debbugs/config';
+    require '/etc/debbugs/text';
+}
+
 #require '/usr/lib/debbugs/errorlib';
 require './common.pl';
-
-require '/etc/debbugs/config';
-require '/etc/debbugs/text';
 
 use vars(qw($gEmailDomain $gHTMLTail $gSpoolDir $gWebDomain));
 

=== modified file 'cgi/pkgindex.cgi'
--- cgi/pkgindex.cgi	
+++ cgi/pkgindex.cgi	
@@ -5,11 +5,15 @@
 use strict;
 use POSIX qw(strftime tzset nice);
 
+BEGIN {
+    # Needed so that other modules have access to the variables
+    # when included with use
+    require '/etc/debbugs/config';
+    require '/etc/debbugs/text';
+}
+
 #require '/usr/lib/debbugs/errorlib';
 require './common.pl';
-
-require '/etc/debbugs/config';
-require '/etc/debbugs/text';
 
 nice(5);
 

=== modified file 'cgi/pkgreport.cgi'
--- cgi/pkgreport.cgi	
+++ cgi/pkgreport.cgi	
@@ -5,11 +5,15 @@
 use strict;
 use POSIX qw(strftime tzset nice);
 
+BEGIN {
+    # Needed so that other modules have access to the variables
+    # when included with use
+    require '/etc/debbugs/config';
+    require '/etc/debbugs/text';
+}
+
 #require '/usr/lib/debbugs/errorlib';
 require './common.pl';
-
-require '/etc/debbugs/config';
-require '/etc/debbugs/text';
 
 use Debbugs::User;
 

=== modified file 'debian/control'
--- debian/control	
+++ debian/control	
@@ -8,7 +8,7 @@
 
 Package: debbugs
 Architecture: all
-Depends: perl5 | perl, exim4 | mail-transport-agent, libmailtools-perl, ed, libmime-perl, libio-stringy-perl, libmldbm-perl, liburi-perl
+Depends: perl5 | perl, exim4 | mail-transport-agent, libmailtools-perl, ed, libmime-perl, libio-stringy-perl, libmldbm-perl, liburi-perl, libsoap-lite-perl
 Recommends: httpd, links | lynx
 Suggests: spamassassin (>= 3.0)
 Description: The bug tracking system based on the active Debian BTS

=== modified file 'scripts/config.debian'
--- scripts/config.debian	
+++ scripts/config.debian	
@@ -4,6 +4,7 @@
 # Domains
 $gEmailDomain = "bugs.debian.org";
 $gListDomain = "lists.debian.org";
+$gWebHostBugDir = "";
 $gWebDomain = "www.debian.org/Bugs";
 $gHTMLSuffix = "";
 $gPackagePages = "packages.debian.org";

=== modified file 'scripts/config.in.default'
--- scripts/config.in.default	
+++ scripts/config.in.default	
@@ -2,6 +2,7 @@
 #domains
 $gEmailDomain = "bugs.top.domain";		#bugs.debian.org
 $gListDomain = "lists.top.domain";		#lists.debian.org
+$gWebHostBugDir = "";
 $gWebDomain = "www.top.domain";			#www.debian.org/Bugs
 $gCGIDomain = "cgi.top.domain";			#cgi.debian.org
 


Reply to: