aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--qarepo.pl224
1 files changed, 131 insertions, 93 deletions
diff --git a/qarepo.pl b/qarepo.pl
index c7d5947..cc6045e 100644
--- a/qarepo.pl
+++ b/qarepo.pl
@@ -25,7 +25,7 @@ use Gtk3 '-init';
use MDK::Common;
use URPM;
-my $release = 'v1.3';
+my $version = 'v1.4';
###############################################################################
# States and Status
@@ -64,25 +64,25 @@ if (open(my $f, '<', $config_file)) {
# Use sensible defaults for settings not in the config file.
my $mirror = $config{MIRROR} // 'rsync://mirrors.kernel.org/mirrors/mageia';
-my $version = $config{VERSION} // '6';
+my $release = $config{RELEASE} // '6';
my $arch = $config{ARCH} // 'x86_64';
my $nonfree = $config{NONFREE} // 1;
my $tainted = $config{TAINTED} // 1;
my $qa_repo = $config{QA_REPO} // "$home/qa-testing";
-my $qa_repo_name = 'QA Testing';
-
-my $repo_name_and_url = `urpmq --list-url | grep '$qa_repo_name '`;
-chomp($repo_name_and_url);
+my %qa_repo_names = (
+ i586 => 'QA Testing (32-bit)',
+ x86_64 => 'QA Testing (64-bit)'
+);
-my $active_qa_repo = $repo_name_and_url =~ s/$qa_repo_name +//r;
+my $qa_repo_name;
+my $active_qa_repo;
-if ($repo_name_and_url && $active_qa_repo ne $qa_repo) {
- disable_repo();
-}
+my $last_release = $release;
+my $last_arch = '';
-my $last_version = $version;
-my $last_arch = $arch;
+my $fatal_message = '*** application will terminate ***';
+my $fatal_error;
###############################################################################
# GUI Main Window
@@ -95,14 +95,14 @@ my $grid = Gtk3::Grid->new();
my $label1 = Gtk3::Label->new('Mirror:');
my $entry1 = Gtk3::Entry->new();
-my $label2 = Gtk3::Label->new('Version:');
+my $label2 = Gtk3::Label->new('Release:');
my $entry2 = Gtk3::Entry->new();
-my $label3 = Gtk3::Label->new('Arch:');
-my $entry3 = Gtk3::ComboBoxText->new();
+my $label3 = Gtk3::Label->new('QA Repo:');
+my $entry3 = Gtk3::Entry->new();
-my $label4 = Gtk3::Label->new('QA Repo:');
-my $entry4 = Gtk3::Entry->new();
+my $label4 = Gtk3::Label->new('Arch:');
+my $entry4 = Gtk3::ComboBoxText->new();
my $label5 = Gtk3::Label->new('RPMs:');
my $entry5 = Gtk3::TextView->new();
@@ -117,13 +117,14 @@ my $button2 = Gtk3::Button->new('Disable');
my $button3 = Gtk3::Button->new('Enable');
my $button4 = Gtk3::Button->new('Clear');
+my $check0 = Gtk3::CheckButton->new_with_label("core");
my $check1 = Gtk3::CheckButton->new_with_label("nonfree");
my $check2 = Gtk3::CheckButton->new_with_label("tainted");
my $check3 = Gtk3::CheckButton->new_with_label("fuzzy\nversion");
my $check4 = Gtk3::CheckButton->new_with_label("add\ndeps");
-$window->set_title("QA Repo $release");
+$window->set_title("QA Repo $version");
$window->set_default_size(600, 400);
$window->set_border_width(10);
$window->signal_connect(delete_event => \&quit);
@@ -139,32 +140,31 @@ $entry1->signal_connect(changed => \&changed);
$label2->set_halign('GTK_ALIGN_END');
-$entry2->set_text($version);
+$entry2->set_text($release);
$entry2->set_width_chars(2);
$entry2->set_hexpand(TRUE);
$entry2->signal_connect(changed => \&changed);
$label3->set_halign('GTK_ALIGN_END');
-$entry3->append_text('i586');
-$entry3->append_text('x86_64');
-if ($arch eq 'x86_64') {
- $entry3->set_active(1);
-} else {
- $entry3->set_active(0);
-}
+$entry3->set_text($qa_repo);
+$entry3->set_hexpand(TRUE);
$entry3->signal_connect(changed => \&changed);
$label4->set_halign('GTK_ALIGN_END');
-$entry4->set_text($qa_repo);
-$entry4->set_hexpand(TRUE);
+$entry4->append_text('i586');
+$entry4->append_text('x86_64');
+if ($arch eq 'x86_64') {
+ $entry4->set_active(1);
+} else {
+ $entry4->set_active(0);
+}
$entry4->signal_connect(changed => \&changed);
$label5->set_valign('GTK_ALIGN_START');
$label5->set_halign('GTK_ALIGN_END');
-$entry5->get_buffer->set_text(join("\n", get_existing_rpms()));
$entry5->get_buffer->signal_connect(changed => \&changed);
$scroll->set_hexpand(TRUE);
@@ -185,34 +185,37 @@ $button4->set_vexpand(TRUE);
$button4->set_valign('GTK_ALIGN_END');
$button4->signal_connect(clicked => \&clear);
-$check1->signal_connect(clicked => \&changed);
+$check0->set_active(TRUE);
+$check0->set_sensitive(FALSE);
+
$check1->set_active($nonfree);
+$check1->signal_connect(clicked => \&changed);
-$check2->signal_connect(clicked => \&changed);
$check2->set_active($tainted);
+$check2->signal_connect(clicked => \&changed);
-$check3->signal_connect(clicked => \&changed);
$check3->set_active(FALSE);
+$check3->signal_connect(clicked => \&changed);
-$check4->signal_connect(clicked => \&changed);
$check4->set_active(FALSE);
+$check4->signal_connect(clicked => \&changed);
$grid->attach($label1, 0, 0, 1, 1);
-$grid->attach($entry1, 1, 0, 6, 1);
+$grid->attach($entry1, 1, 0, 5, 1);
$grid->attach($label2, 1, 1, 1, 1);
$grid->attach($entry2, 2, 1, 1, 1);
-$grid->attach($label3, 3, 1, 1, 1);
-$grid->attach($entry3, 4, 1, 1, 1);
-$grid->attach($check1, 5, 1, 1, 1);
-$grid->attach($check2, 6, 1, 1, 1);
+$grid->attach($check0, 3, 1, 1, 1);
+$grid->attach($check1, 4, 1, 1, 1);
+$grid->attach($check2, 5, 1, 1, 1);
-$grid->attach($label4, 0, 2, 1, 1);
-$grid->attach($entry4, 1, 2, 6, 1);
+$grid->attach($label3, 0, 2, 1, 1);
+$grid->attach($entry3, 1, 2, 4, 1);
+$grid->attach($entry4, 5, 2, 1, 1);
$grid->attach($label5, 0, 3, 1, 1);
-$grid->attach($scroll, 1, 3, 6, 4);
+$grid->attach($scroll, 1, 3, 5, 4);
$grid->attach($label6, 0, 7, 1, 1);
-$grid->attach($status, 1, 7, 6, 1);
+$grid->attach($status, 1, 7, 5, 1);
$grid->attach($button1, 7, 0, 1, 1);
$grid->attach($button2, 7, 2, 1, 1);
@@ -223,12 +226,6 @@ $grid->attach($button4, 7, 6, 1, 1);
$window->add($grid);
-if ($active_qa_repo) {
- set_state('enabled');
-} else {
- set_state('disabled');
-}
-
###############################################################################
# GUI Error Dialogue
###############################################################################
@@ -249,7 +246,7 @@ $error_window->set_title("Error");
$error_window->set_default_size(600, 300);
$error_window->set_border_width(10);
$error_window->set_type_hint('dialog');
-$error_window->signal_connect(delete_event => sub { $error_window->hide_on_delete() });
+$error_window->signal_connect(delete_event => \&error_dismiss);
$error_grid->set_row_spacing(10);
$error_grid->set_column_spacing(10);
@@ -262,7 +259,7 @@ $error_scroll->set_hexpand(TRUE);
$error_scroll->set_vexpand(TRUE);
$error_scroll->add($error_text);
-$error_button->signal_connect(clicked => sub { $error_window->hide() });
+$error_button->signal_connect(clicked => \&error_dismiss);
$error_button->set_halign('GTK_ALIGN_CENTER');
$error_grid->attach($error_label, 0, 0, 1, 1);
@@ -275,6 +272,8 @@ $error_window->add($error_grid);
# GUI Start
###############################################################################
+changed();
+
$window->show_all();
Gtk3->main();
@@ -284,21 +283,32 @@ Gtk3->main();
###############################################################################
sub changed {
- set_state('changed');
+ $arch = trim($entry4->get_active_text());
+ if ($arch ne $last_arch) {
+ $last_arch = $arch;
+ set_qa_repo_info();
+ if ($active_qa_repo) {
+ set_state('enabled');
+ } else {
+ set_state('disabled');
+ }
+ } else {
+ set_state('changed');
+ }
}
sub quit {
get_settings();
if (open(my $f, '>', $config_file)) {
printf $f "MIRROR=%s\n", $mirror;
- printf $f "VERSION=%s\n", $version;
+ printf $f "RELEASE=%s\n", $release;
printf $f "ARCH=%s\n", $arch;
printf $f "NONFREE=%d\n", $nonfree;
printf $f "TAINTED=%d\n", $tainted;
printf $f "QA_REPO=%s\n", $qa_repo;
close($f);
}
- Gtk3->main_quit;
+ Gtk3->main_quit();
}
sub disable {
@@ -332,10 +342,33 @@ sub clear {
$entry5->get_buffer()->set_text('');
}
+sub error_dismiss {
+ if ($fatal_error) {
+ Gtk3->main_quit();
+ } else {
+ $error_window->hide_on_delete()
+ }
+}
+
###############################################################################
# Subsidiary Functions
###############################################################################
+sub set_qa_repo_info {
+ $qa_repo_name = $qa_repo_names{$arch};
+
+ my $repo_name_and_url = `urpmq --list-url | grep '$qa_repo_name '`;
+ chomp($repo_name_and_url);
+
+ $active_qa_repo = $repo_name_and_url =~ s/\Q$qa_repo_name\E\s+(\S+)\/$arch/$1/r;
+
+ if ($repo_name_and_url && $active_qa_repo ne $qa_repo) {
+ disable_repo();
+ }
+
+ $entry5->get_buffer->set_text(join("\n", get_existing_rpms()));
+}
+
sub set_state {
my ($new_state) = @_;
$state = $new_state;
@@ -361,11 +394,11 @@ sub disable_buttons {
sub get_settings {
$mirror = trim($entry1->get_text());
- $version = trim($entry2->get_text());
- $arch = trim($entry3->get_active_text());
+ $release = trim($entry2->get_text());
+ $arch = trim($entry4->get_active_text());
$nonfree = $check1->get_active();
$tainted = $check2->get_active();
- $qa_repo = trim($entry4->get_text());
+ $qa_repo = trim($entry3->get_text());
if ($active_qa_repo && $active_qa_repo ne $qa_repo) {
disable_repo();
}
@@ -381,7 +414,7 @@ sub get_requested_rpms {
my @lines = split("\n", $buffer->get_text($start, $end, FALSE));
if ($fuzzy_version) {
# replace version-release with wildcard
- s/-\d.*-.+(\.mga$version(?:(?:\.$arch|\.noarch)(?:\.rpm)?)?)$/-\\d*$1/ foreach @lines;
+ s/-\d.*-.+(\.mga$release(?:(?:\.$arch|\.noarch)(?:\.rpm)?)?)$/-\\d*$1/ foreach @lines;
}
s/^\s+// foreach @lines; # trim leading white space
s/\s+$// foreach @lines; # trim trailing white space
@@ -389,7 +422,7 @@ sub get_requested_rpms {
}
sub get_existing_rpms {
- map { basename($_) } glob("$qa_repo/*.rpm");
+ map { basename($_) } glob("$qa_repo/$arch/*.rpm");
}
sub disable_repo {
@@ -397,18 +430,18 @@ sub disable_repo {
$active_qa_repo = '';
} else {
my $message = "couldn't disable the $qa_repo_name media";
- show_error_dialogue($message);
- die "ERROR: $message.\n";
+ show_error_dialogue($message, $fatal_message);
+ print_error($message, 'fatal');
}
}
sub enable_repo {
- if (system("$sudo urpmi.addmedia --update '$qa_repo_name' $qa_repo") == 0) {
+ if (system("$sudo urpmi.addmedia --update '$qa_repo_name' $qa_repo/$arch") == 0) {
$active_qa_repo = $qa_repo;
} else {
my $message = "couldn't enable the $qa_repo_name media";
show_error_dialogue($message);
- print "ERROR: $message.\n";
+ print_error($message);
$active_qa_repo = '';
}
}
@@ -417,7 +450,7 @@ sub update_repo {
if (system("$sudo urpmi.update '$qa_repo_name'") != 0) {
my $message = "couldn't update the $qa_repo_name media";
show_error_dialogue($message);
- print "ERROR: $message.\n";
+ print_error($message);
disable_repo();
}
}
@@ -426,10 +459,10 @@ sub clear_repo {
my ($type) = @_;
my @existing_rpms = grep { $_ =~ /$type/ } get_existing_rpms();
if (@existing_rpms) {
- if (!unlink(map { "$qa_repo/$_" } @existing_rpms)) {
+ if (!unlink(map { "$qa_repo/$arch/$_" } @existing_rpms)) {
my $message = "couldn't delete existing RPMs in the QA repo";
- show_error_dialogue($message);
- die "ERROR: $message.\n";
+ show_error_dialogue($message, $fatal_message);
+ print_error($message, 'fatal');
}
}
}
@@ -443,28 +476,27 @@ sub sync_repo {
my $sync_file;
if ($mirror =~ /^rsync:/) {
$sync_file = \&sync_file_rsync;
- } elsif ($mirror =~ /^ftp:/
- || $mirror =~ /^http:/) {
+ } elsif ($mirror =~ /^ftp:/ || $mirror =~ /^http:/) {
$sync_file = \&sync_file_aria2;
} elsif ($mirror !~ /^\w+:/) {
$sync_file = \&sync_file_link;
} else {
my $message = "unsupported mirror URL type";
show_error_dialogue($message);
- print "ERROR: $message.\n";
+ print_error($message);
return 0;
}
- if ($version ne $last_version || $arch ne $last_arch) {
- $last_version = $version;
- $last_arch = $arch;
+ if ($release ne $last_release) {
+ $last_release = $release;
clear_repo();
gtk_update();
}
my $add_dependencies = $check4->get_active();
- my $remote_repo = "$mirror/distrib/$version/$arch/media";
+ my $remote_repo = "$mirror/distrib/$release/$arch/media";
+ my $local_repo = "$qa_repo/$arch";
my @mediatypes = ( 'core' );
push @mediatypes, 'nonfree' if $nonfree;
@@ -498,9 +530,9 @@ sub sync_repo {
});
if (!unlink("$download_dir/$synthesis")) {
- my $message = "couldn't delete $download_dir/$synthesis in the QA repo.\n";
- show_error_dialogue($message);
- die "ERROR: $message.\n";
+ my $message = "couldn't delete $download_dir/$synthesis in the QA repo";
+ show_error_dialogue($message, $fatal_message);
+ print_error($message, 'fatal');
}
gtk_update();
}
@@ -531,26 +563,26 @@ sub sync_repo {
return 0;
}
- my @required_rpms = keys %selection;
+ my @required_rpms = sort keys %selection;
my @existing_rpms = get_existing_rpms();
my @unwanted_rpms = difference2(\@existing_rpms, \@required_rpms);
if (@unwanted_rpms) {
- if (!unlink(map { "$qa_repo/$_" } @unwanted_rpms)) {
- my $message = "couldn't delete unwanted RPMs in the QA repo.\n";
- show_error_dialogue($message);
- die "ERROR: $message.\n";
+ if (!unlink(map { "$local_repo/$_" } @unwanted_rpms)) {
+ my $message = "couldn't delete unwanted RPMs in the QA repo";
+ show_error_dialogue($message, $fatal_message);
+ print_error($message, 'fatal');
}
}
- my $old_pubkey = "$qa_repo/media_info/pubkey";
+ my $old_pubkey = "$local_repo/media_info/pubkey";
if (-e $old_pubkey) {
if (!unlink($old_pubkey)) {
- my $message = "couldn't delete old pubkey in the QA repo.\n";
- show_error_dialogue($message);
- die "ERROR: $message.\n";
+ my $message = "couldn't delete old pubkey in the QA repo";
+ show_error_dialogue($message, $fatal_message);
+ print_error($message, 'fatal');
}
}
- mkdir_p("$qa_repo/media_info");
+ mkdir_p("$local_repo/media_info");
gtk_update();
foreach my $rpm (difference2(\@required_rpms, \@existing_rpms)) {
@@ -562,17 +594,17 @@ sub sync_repo {
} else {
$remote_url .= "/core/updates_testing/$rpm";
}
- &$sync_file($remote_url, $qa_repo);
+ &$sync_file($remote_url, $local_repo);
gtk_update();
}
- &$sync_file("$remote_repo/core/updates_testing/media_info/pubkey", "$qa_repo/media_info");
+ &$sync_file("$remote_repo/core/updates_testing/media_info/pubkey", "$local_repo/media_info");
gtk_update();
- if (@sync_errors == 0) {
- system("genhdlist2 --allow-empty-media $qa_repo") == 0
- or sync_error("failed to update hdlist");
+ if (@sync_errors) {
+ print_error('failed to download all the files');
} else {
- print "ERROR: failed to download all the files.\n";
+ system("genhdlist2 --allow-empty-media $local_repo") == 0
+ or sync_error("failed to update hdlist");
}
if (@sync_errors) {
@@ -612,7 +644,7 @@ sub sync_file_link {
sub sync_error {
my ($message) = @_;
push @sync_errors, $message;
- print "ERROR: $message.\n";
+ print_error($message);
0;
}
@@ -636,6 +668,12 @@ sub show_error_dialogue {
$error_window->show_all();
}
+sub print_error {
+ my ($message, $o_fatal) = @_;
+ print "ERROR: $message.\n";
+ $fatal_error = $o_fatal;
+}
+
sub gtk_update {
while (Gtk3::events_pending()) {
Gtk3::main_iteration();