diff options
Diffstat (limited to 'qarepo')
-rw-r--r-- | qarepo | 107 |
1 files changed, 56 insertions, 51 deletions
@@ -1,7 +1,7 @@ #!/usr/bin/perl -# Copyright (C) 2018 Mageia -# Martin Whitaker <mageia@martin-whitaker.me.uk> +# Copyright (C) 2018-2023 Mageia +# Martin Whitaker <mageia@martin-whitaker.me.uk> # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -22,20 +22,25 @@ use warnings; use Glib qw(TRUE FALSE); use Gtk3 '-init'; +use Locale::Messages qw(LC_MESSAGES); +use Locale::TextDomain qw(qarepo); use MDK::Common; +use POSIX qw(setlocale); use URPM; my $version = '(devel)'; +setlocale(LC_MESSAGES, ''); + ############################################################################### # States and Status ############################################################################### my %status_text = ( - disabled => 'Disabled', - enabled => 'Enabled', - changed => 'Needs update', - failed => 'Update failed' + disabled => __"Disabled", + enabled => __"Enabled", + changed => __"Needs update", + failed => __"Update failed" ); my $state; @@ -81,7 +86,7 @@ my $active_qa_repo; my $last_release = $release; my $last_arch = ''; -my $fatal_message = '*** application will terminate ***'; +my $fatal_message = __"*** application will terminate ***"; my $fatal_error; ############################################################################### @@ -92,38 +97,38 @@ my $window = Gtk3::Window->new('toplevel'); my $grid = Gtk3::Grid->new(); -my $label1 = Gtk3::Label->new('Mirror:'); +my $label1 = Gtk3::Label->new(__"Mirror:"); my $entry1 = Gtk3::Entry->new(); -my $label2 = Gtk3::Label->new('Release:'); +my $label2 = Gtk3::Label->new(__"Release:"); my $entry2 = Gtk3::Entry->new(); -my $label3 = Gtk3::Label->new('QA Repo:'); +my $label3 = Gtk3::Label->new(__"QA Repo:"); my $entry3 = Gtk3::Entry->new(); -my $label4 = Gtk3::Label->new('Arch:'); +my $label4 = Gtk3::Label->new(__"Arch:"); my $entry4 = Gtk3::ComboBoxText->new(); -my $label5 = Gtk3::Label->new('RPMs:'); +my $label5 = Gtk3::Label->new(__"RPMs:"); my $entry5 = Gtk3::TextView->new(); my $scroll = Gtk3::ScrolledWindow->new(); -my $label6 = Gtk3::Label->new('Status:'); +my $label6 = Gtk3::Label->new(__"Status:"); my $status = Gtk3::Label->new(''); -my $button1 = Gtk3::Button->new('Quit'); -my $button2 = Gtk3::Button->new('Disable'); -my $button3 = Gtk3::Button->new('Enable'); -my $button4 = Gtk3::Button->new('Clear'); -my $button5 = Gtk3::Button->new('Downgrade'); +my $button1 = Gtk3::Button->new(__"Quit"); +my $button2 = Gtk3::Button->new(__"Disable"); +my $button3 = Gtk3::Button->new(__"Enable"); +my $button4 = Gtk3::Button->new(__"Clear"); +my $button5 = Gtk3::Button->new(__"Downgrade"); 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"); +my $check3 = Gtk3::CheckButton->new_with_label(__"fuzzy\nversion"); +my $check4 = Gtk3::CheckButton->new_with_label(__"add\ndeps"); $window->set_title("QA Repo $version"); $window->set_default_size(600, 400); @@ -244,7 +249,7 @@ my $dialogue_text = Gtk3::TextView->new(); my $dialogue_scroll = Gtk3::ScrolledWindow->new(); -my $dialogue_button = Gtk3::Button->new('Dismiss'); +my $dialogue_button = Gtk3::Button->new(__"Dismiss"); $dialogue_window->set_default_size(600, 300); $dialogue_window->set_border_width(10); @@ -321,7 +326,7 @@ sub disable { } sub enable { - check_no_testing_media("This may enable unwanted packages to be installed.") + check_no_testing_media(__"This may enable unwanted packages to be installed.") or return; disable_buttons(); get_settings(); @@ -348,7 +353,7 @@ sub clear { } sub downgrade { - check_no_testing_media("This may stop some packages from being downgraded.") + check_no_testing_media(__"This may stop some packages from being downgraded.") or return; disable_buttons(); if ($active_qa_repo) { @@ -373,8 +378,8 @@ sub dialogue_dismiss { sub check_no_testing_media { my ($message2) = @_; if (system("urpmq --list-media active --list-url | grep -q updates_testing") == 0) { - my $message1 = "Some updates_testing media are enabled."; - my $message3 = "Please disable these media and try again."; + my $message1 = __"Some updates_testing media are enabled."; + my $message3 = __"Please disable these media and try again."; show_error_dialogue(($message1, $message2, $message3)); return 0; } @@ -407,9 +412,9 @@ sub set_state { $button4->set_sensitive(TRUE); $button5->set_sensitive($state ne 'changed'); if ($state eq 'changed' || $state eq 'failed') { - $button3->set_label('Update'); + $button3->set_label(__"Update"); } else { - $button3->set_label('Enable'); + $button3->set_label(__"Enable"); } } @@ -460,7 +465,7 @@ sub disable_repo { if (system("$pkexec /usr/libexec/qarepo-helper disable $arch_type") == 0) { $active_qa_repo = ''; } else { - my $message = "couldn't disable the $qa_repo_name media"; + my $message = __"couldn't disable the local repository ['" . $qa_repo_name . "']"; show_error_dialogue($message, $fatal_message); print_error($message, 'fatal'); } @@ -471,7 +476,7 @@ sub enable_repo { if (system("$pkexec /usr/libexec/qarepo-helper enable $arch_type $qa_repo/$arch") == 0) { $active_qa_repo = $qa_repo; } else { - my $message = "couldn't enable the $qa_repo_name media"; + my $message = __"couldn't enable the local repository ['" . $qa_repo_name . "']"; show_error_dialogue($message); print_error($message); $active_qa_repo = ''; @@ -481,7 +486,7 @@ sub enable_repo { sub update_repo { my $arch_type = $arch eq 'x86_64' ? '64' : '32'; if (system("$pkexec /usr/libexec/qarepo-helper update $arch_type") != 0) { - my $message = "couldn't update the $qa_repo_name media"; + my $message = __"couldn't update the local repository ['" . $qa_repo_name . "']"; show_error_dialogue($message); print_error($message); disable_repo(); @@ -493,7 +498,7 @@ sub clear_repo { my @existing_rpms = grep { $_ =~ /$type/ } get_existing_rpms(); if (@existing_rpms) { if (!unlink(map { "$qa_repo/$arch/$_" } @existing_rpms)) { - my $message = "couldn't delete existing RPMs in the QA repo"; + my $message = __"couldn't delete existing RPMs in the local repository"; show_error_dialogue($message, $fatal_message); print_error($message, 'fatal'); } @@ -503,7 +508,7 @@ sub clear_repo { my @sync_errors; sub sync_repo { - $status->set_label('Updating'); + $status->set_label(__"Updating"); @sync_errors = (); my $sync_file; @@ -514,7 +519,7 @@ sub sync_repo { } elsif ($mirror !~ /^\w+:/) { $sync_file = \&sync_file_link; } else { - my $message = "unsupported mirror URL type"; + my $message = __"unsupported mirror URL type"; show_error_dialogue($message); print_error($message); return 0; @@ -563,7 +568,7 @@ sub sync_repo { }); if (!unlink("$download_dir/$synthesis")) { - my $message = "couldn't delete $download_dir/$synthesis in the QA repo"; + my $message = __"couldn't delete the downloaded synthesis file [" . $download_dir . '/' . $synthesis . "]"; show_error_dialogue($message, $fatal_message); print_error($message, 'fatal'); } @@ -583,7 +588,7 @@ sub sync_repo { $matched = 1; } } - $matched or sync_error("$request not found in the remote repository"); + $matched or sync_error($request . __" was not found in the remote repository"); } # avoid infinite loop if we haven't found a match last if @sync_errors; @@ -601,7 +606,7 @@ sub sync_repo { my @unwanted_rpms = difference2(\@existing_rpms, \@required_rpms); if (@unwanted_rpms) { if (!unlink(map { "$local_repo/$_" } @unwanted_rpms)) { - my $message = "couldn't delete unwanted RPMs in the QA repo"; + my $message = "couldn't delete unwanted RPMs in the local repository"; show_error_dialogue($message, $fatal_message); print_error($message, 'fatal'); } @@ -609,7 +614,7 @@ sub sync_repo { 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"; + my $message = __"couldn't delete the old pubkey in the local repository"; show_error_dialogue($message, $fatal_message); print_error($message, 'fatal'); } @@ -634,10 +639,10 @@ sub sync_repo { gtk_update(); if (@sync_errors) { - print_error('failed to download all the files'); + print_error(__"failed to download all the files"); } else { system("genhdlist2 --allow-empty-media $local_repo") == 0 - or sync_error("failed to update hdlist"); + or sync_error(__"failed to update hdlist"); } if (@sync_errors) { @@ -650,14 +655,14 @@ sub sync_repo { sub sync_file_rsync { my ($src_url, $dst_dir) = @_; - print "fetching $src_url\n"; + print __"fetching " . $src_url . "\n"; system("rsync -q $src_url $dst_dir") == 0 - or sync_error("failed to download $src_url"); + or sync_error(__"failed to download file [" . $src_url . "]"); } sub sync_file_aria2 { my ($src_url, $dst_dir) = @_; - print "fetching $src_url\n"; + print __"fetching " . $src_url . "\n"; system("aria2c -q -d $dst_dir $src_url") == 0 and return 1; @@ -665,13 +670,13 @@ sub sync_file_aria2 { my $dst_file = $dst_dir . '/' . basename($src_url); unlink($dst_file) if -e $dst_file; - sync_error("failed to download $src_url"); + sync_error(__"failed to download file [" . $src_url . "]"); } sub sync_file_link { my ($src_file, $dst_dir) = @_; -e $src_file && symlink($src_file, $dst_dir . '/' . basename($src_file)) - or sync_error("failed to link $src_file"); + or sync_error(__"failed to link to file [" . $src_file . "]"); } sub sync_error { @@ -684,7 +689,7 @@ sub sync_error { sub downgrade_packages { my $synthesis = "$qa_repo/$arch/media_info/synthesis.hdlist.cz"; if (! -e $synthesis) { - my $message = "no synthesis file found in local repository"; + my $message = __"no synthesis file found in the local repository"; show_error_dialogue($message); print_error($message); return 0; @@ -705,7 +710,7 @@ sub downgrade_packages { @packages = sort @packages; show_downgrade_dialogue("urpmi --downgrade @packages"); } else { - show_error_dialogue("none of the listed packages are installed"); + show_error_dialogue(__"none of the listed packages are installed"); } } @@ -726,16 +731,16 @@ sub wildcard_to_regexp { } sub show_downgrade_dialogue { - $dialogue_window->set_title('Downgrade'); - $dialogue_label->set_text('The following command may be used to downgrade the listed packages:'); + $dialogue_window->set_title(__"Downgrade"); + $dialogue_label->set_text(__"The following command may be used to downgrade the listed packages:"); $dialogue_text->get_buffer()->set_text(join("\n", @_)); $dialogue_text->set_wrap_mode('GTK_WRAP_WORD_CHAR'); $dialogue_window->show_all(); } sub show_error_dialogue { - $dialogue_window->set_title('Error'); - $dialogue_label->set_text('The following error(s) occurred:'); + $dialogue_window->set_title(__"Error"); + $dialogue_label->set_text(__"The following error(s) occurred:"); $dialogue_text->get_buffer()->set_text(join("\n", @_)); $dialogue_text->set_wrap_mode('GTK_WRAP_NONE'); $dialogue_window->show_all(); @@ -743,7 +748,7 @@ sub show_error_dialogue { sub print_error { my ($message, $o_fatal) = @_; - print "ERROR: $message.\n"; + print __"ERROR: " . $message . ".\n"; $fatal_error = $o_fatal; } |