aboutsummaryrefslogtreecommitdiffstats
path: root/bin/fillbugzilla
diff options
context:
space:
mode:
authorNicolas Vigier <boklm@mageia.org>2011-01-06 01:07:55 +0000
committerNicolas Vigier <boklm@mageia.org>2011-01-06 01:07:55 +0000
commita4f149873af1e9cff9ab0829adfcd3eca1a3780d (patch)
treec1345b951f4c67e3e9c5bf57f984c3e9f901f17f /bin/fillbugzilla
downloadmga-youri-core-a4f149873af1e9cff9ab0829adfcd3eca1a3780d.tar
mga-youri-core-a4f149873af1e9cff9ab0829adfcd3eca1a3780d.tar.gz
mga-youri-core-a4f149873af1e9cff9ab0829adfcd3eca1a3780d.tar.bz2
mga-youri-core-a4f149873af1e9cff9ab0829adfcd3eca1a3780d.tar.xz
mga-youri-core-a4f149873af1e9cff9ab0829adfcd3eca1a3780d.zip
search in core, nonfree, tainted instead of main, contrib
Diffstat (limited to 'bin/fillbugzilla')
-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
+}