aboutsummaryrefslogtreecommitdiffstats
path: root/bin
diff options
context:
space:
mode:
Diffstat (limited to 'bin')
-rwxr-xr-xbin/fillbugzilla81
1 files changed, 81 insertions, 0 deletions
diff --git a/bin/fillbugzilla b/bin/fillbugzilla
new file mode 100755
index 0000000..8895c09
--- /dev/null
+++ b/bin/fillbugzilla
@@ -0,0 +1,81 @@
+#!/usr/bin/perl
+# fillbugzilla
+# copyright (c) 2002 Guillaume Rousse <guillomovitch@zarb.org>
+# $Id: fillbugzilla 1179 2006-08-05 08:30:57Z warly $
+
+use strict;
+use warnings;
+use Getopt::Long;
+use Bugzilla;
+use Mail::Sendmail;
+
+# constants
+my $name = "fillbugzilla";
+my $version = "1.0";
+
+# command-line parameters
+my ($base, $user, $pass, $project, $mode, $help);
+GetOptions(
+ "base=s" => \$base,
+ "user=s" => \$user,
+ "pass=s" => \$pass,
+ "mode=s" => \$mode,
+ "help" => \$help,
+);
+
+# mandatory argument
+die usage() unless ($base && $user && $pass);
+die usage() unless ($mode eq 'package' || $mode eq 'packager');
+
+usage() && exit 0 if $help;
+
+my $bugzilla = Bugzilla->new('localhost', $base, $user, $pass);
+
+if ($mode eq 'packager') {
+ while (my $packager = <>) {
+ chomp $packager;
+ my ($name, $login) = split(/\t/, $packager);
+
+ # random passwd
+ my @chars = (0..9, 'A'..'Z', 'a'..'z', '-', '_', '!', '@', '#', '$', '%', '^', '&', '*');
+ my $password = join('', map { $chars[rand(scalar @chars)] } 1 .. 8);
+
+ # insert into database
+ $bugzilla->add_packager($name, $login, $password);
+
+ # mail user
+ my %mail = (
+ smtp => 'localhost',
+ To => $login,
+ From => 'bugmaster@zarb.org',
+ Subject => 'bugzilla password',
+ 'X-Mailer' => "$name $version",
+ );
+ $mail{Message} .= "login: $login\n";
+ $mail{Message} .= "password: $password\n";
+ sendmail(%mail) or warn $Mail::Sendmail::error;
+ }
+}
+
+if ($mode eq 'package') {
+ while (my $line = <>) {
+ chomp $line;
+ my ($name, $summary, $version, $maintainer) = split(/\t/, $line);
+ $bugzilla->add_package($name, $summary, $version, $maintainer);
+ }
+}
+
+sub usage {
+ print <<EOF;
+$name $version
+
+Usage:
+$name --base <base> --user <user> --pass <pass> --mode <mode> < $file
+
+Options:
+--base <base> bugzilla base name
+--user <user> bugzilla base user
+--pass <pass> bugzilla base password
+--mode <mode> package or packager
+EOF
+}