-
Notifications
You must be signed in to change notification settings - Fork 34
/
inst_do_net_test.ycp
877 lines (721 loc) · 24.1 KB
/
inst_do_net_test.ycp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
/*
* File: clients/inst_do_net_test.ycp
* Package: Network configuration
* Summary: Configuration dialogs for installation
* Authors: Michal Svec <msvec@suse.cz>
* Arvin Schnell <arvin@suse.de>
*
*/
{
textdomain "network";
import "Directory";
import "Internet";
import "Label";
import "Mode";
import "Popup";
import "Product";
import "Wizard";
import "PackageCallbacks";
import "Proxy";
import "GetInstArgs";
import "Report";
import "String";
include "network/routines.ycp";
include "network/installation/dialogs.ycp";
/* Called backwards */
if(GetInstArgs::going_back())
return `auto;
if(!Internet::do_test)
{
// no internet test - no suse register
// suse register then only informs about its existence
Internet::suse_register = false;
return `auto;
}
Internet::suse_register = true;
boolean we_have_patches = false;
// do we have a connection already?
// then don't open or close it, don't show respective steps
boolean already_up = false;
// curl return code of downloading release notes
// useful to tell apart misconfigured network
// from server side error (#236371)
integer curl_ret_code = 0;
//subset of curl return codes, indicating misconfigured network
list <integer> curl_ret_codes_bad =
[ 5, //couldn't resolve proxy
6, //couldn't resolve host
7 //couldn't connect()
];
// Stage transitions in handle_stage:
// open: wait (test), copy, finish (failure), wait
// wait: copy (test), finish (failure), copy
// copy: relnotes
// relnotes: patches
// patches: close
// close: finish
// finish
symbol test_stage = `open;
symbol test_result = `success;
// list of all log files to show
list<map> logs = [];
// dir of log files
// Formerly it was under tmpdir and thus got erased automatically.
// Now we want to keep it (#46285), so let's put it under logdir.
string logdir = Directory::logdir + "/internet-test";
if(!Mode::test ())
already_up = Internet::Status();
/* Progress step 1/3 */
string l1 = _("Connecting to Internet...");
/* Progress step 2/3 */
string l2 = _("Downloading the latest release notes...");
/* Progress step 3/3 */
string l4 = _("Closing connection...");
/**
* Return current language with .UTF-8 appended.
* FIXME: there must be a better way!
*/
define string GetLanguageUTF8 ()
{
string tmp = WFM::GetLanguage ();
integer pos = findfirstof (tmp, "@.");
if (pos != nil)
tmp = substring (tmp, 0, pos);
return tmp + ".UTF-8";
};
/* fix checkycp complaints */
string dash = "- ";
string excl = "! ";
/**
* Create the dialog contents
*/
define void make_dialog ()
{
/* Test dialog caption */
string caption = _("Running Internet Connection Test");
/* help for dialog "Running Internet Connection Test" */
string help = _("<p>Here, view the progress of the
Internet connection test.</p>
") +
/* help for dialog "Running Internet Connection Test" */
_("<p>The test can be aborted by pressing
<b>Abort Test</b>.</p>
");
// In update mode there's no network setup, #50381
// Actually it depends on the control file, but it's only a help text
if (!Mode::update ())
{
help = help +
/* help for dialog "Running Internet Connection Test" */
_("<p>If the test fails, return to the network configuration
and correct the settings.</p>
");
}
/* Progress labels */
term progress = `VBox();
// do not connect to internet when already connected
if(!already_up)
progress = add(progress, `Left(`HBox(`Heading(`id(`s1), dash), `Label(l1))));
if(true)
progress = add(progress, `Left(`HBox(`Heading(`id(`s2), dash), `Label(l2))));
// do not shutdown the connection when already connected
if(!already_up)
progress = add(progress, `Left(`HBox(`Heading(`id(`s3), dash), `Label(l4))));
progress = add(progress, `VStretch());
progress = add(progress, `HBox(
/* Label for result of internet test */
`Label(_("Test Result:")),
`HSpacing(2),
`Label(`id(`res), `opt(`outputField, `hstretch), "")
));
progress = add(progress, `VSpacing(1));
/* Push Button to abort internet test */
progress = add(progress, `PushButton(`id(`abort_test), _("&Abort Test")));
/* Frame label: status of internet test */
progress = `Frame (_("Test Status"),
`VBox (
`VSpacing (1),
`HBox (
`HSpacing (1),
progress,
`HSpacing (1)
),
`VSpacing (1)
)
);
/* Test dialog contents */
term contents = `VBox(
`VStretch(),
`VBox(`HVCenter(`HSquash(progress))),
`VStretch(),
/* Push Button to see logs of internet test */
`PushButton(`id(`view_log), `opt(`disabled), _("&View Logs...")),
`VStretch()
);
Wizard::SetContents(caption, contents, help, true, true);
Wizard::SetTitleIcon ("yast-network");
}
/**
* @param i step number 1..4
* @param s bullet: `arrow: current, `check: done, `dash: not done or failed
*/
define void mark_label (integer i, symbol s)
{
list<symbol> widgets = [nil, `s1, `s2, `s3, `s4];
map<symbol, string> bullets = $[
`arrow : UI::Glyph (`BulletArrowRight),
`check : UI::Glyph (`CheckMark),
`dash : excl,
];
if (UI::WidgetExists(`id(widgets[i]:nil))) {
UI::ChangeWidget (`id (widgets[i]:nil), `Value, bullets[s]:"?");
} else {
y2error("No such widget with ID: %1", widgets[i]:nil);
}
}
define void show_result ()
{
if(test_result == `success) {
Internet::test = true;
/* result of internet test */
UI::ChangeWidget(`id(`res), `Value, _("Success"));
} else {
Internet::test = false;
/* result of internet test */
UI::ChangeWidget(`id(`res), `Value, _("Failure"));
}
}
define void copy_logs1 ()
{
integer ret_command = nil;
string run_command = nil;
// label of combobox where the log is selected
logs = add (logs, $[ `menuname : _("Kernel Network Interfaces"),
`filename : "ip_addr.log" ]);
run_command = "/sbin/ip addr show > '" + String::Quote (logdir) + "/ip_addr.log'";
ret_command = (integer) SCR::Execute (.target.bash, run_command,
$["LANG" : GetLanguageUTF8 ()]);
if (ret_command != 0) y2error("Command '%1' failed -> %2", run_command, ret_command);
// label of combobox where the log is selected
logs = add (logs, $[ `menuname : _("Kernel Routing Table"),
`filename : "ip_route.log" ]);
run_command = "/sbin/ip route show > '" + String::Quote (logdir) + "/ip_route.log'";
ret_command = (integer) SCR::Execute (.target.bash, run_command,
$["LANG" : GetLanguageUTF8 ()]);
if (ret_command != 0) y2error("Command '%1' failed -> %2", run_command, ret_command);
// label of combobox where the log is selected
logs = add (logs, $[ `menuname : _("Hostname Lookup"),
`filename : "resolv.conf" ]);
run_command = "/bin/cp /etc/resolv.conf '" + String::Quote (logdir) + "/resolv.conf'";
ret_command = (integer) SCR::Execute (.target.bash, run_command);
if (ret_command != 0) y2error("Command '%1' failed -> %2", run_command, ret_command);
}
define void copy_logs2 ()
{
integer ret_command = nil;
string run_command = nil;
// label of combobox where the log is selected
logs = add (logs, $[ `menuname : _("Kernel Messages"),
`filename : "messages" ]);
run_command = Directory::ybindir + "/cut-messages > '" + String::Quote (logdir) + "/messages'";
ret_command = (integer) SCR::Execute (.target.bash, run_command);
if (ret_command != 0) y2error("Command '%1' failed -> %2", run_command, ret_command);
if (Internet::logfile != "") {
// label of combobox where the log is selected
logs = add (logs, $[ `menuname : _("PPP Daemon"),
`filename : "smpppd.log",
`prio : 20 ]);
run_command = "/bin/cp '" + String::Quote (Internet::logfile) + "' '" + String::Quote (logdir) + "/smpppd.log'";
ret_command = (integer) SCR::Execute (.target.bash, run_command);
if (ret_command != 0) y2error("Command '%1' failed -> %2", run_command, ret_command);
}
}
define integer wait_for_test ()
{
while ( (boolean)SCR::Read(.background.output_open) || (boolean)SCR::Read(.background.isrunning) )
{
sleep (100);
any ret = UI::PollInput ();
if (ret == `abort || ret == `abort_test)
{
// Abort pressed by the user
y2milestone ("Test aborted by user");
SCR::Execute (.background.kill);
return -1;
}
}
// check the exit code of the test
integer res = (integer)SCR::Read(.background.status);
y2milestone ("Command returned: %1", res);
return res;
}
// File names of downloaded release notes
list <string> release_notes_filenames = [];
// RPM names of downloaded release notes
map <string, string> release_notes_rpms = $[];
/**
* Download all release notes mentioned in Product::relnotesurl_all
*
* @return true when successful
*/
define boolean download_release_notes () {
// At least one release notes downloaded means success
// but the default is false in case of some release-notes
// available for download
// @see Bug #181094
boolean test_ret = false;
integer relnotes_counter = 0;
Product::relnotesurl_all = toset(Product::relnotesurl_all);
//#390738: only one URL now
//works well with the list of all products
// string url = Product::relnotesurl;
foreach (string url, Product::relnotesurl_all, {
// protect from wrong urls
if (url == nil || url == "") {
y2warning("Skipping relnotesurl '%1'", url);
return false;
}
integer pos = findlastof (url, "/") + 1;
if (pos == nil) {
y2error ("broken url for release notes: %1", url);
return false;
}
//relnotes_counter = relnotes_counter + 1;
// Where we want to store the downloaded release notes
string filename = sformat("%1/%2-%3",
(string) SCR::Read (.target.tmpdir),
relnotes_counter,
substring (url, pos)
);
// Package name
release_notes_rpms[filename] = substring (url, pos);
release_notes_rpms[filename] = regexpsub(release_notes_rpms[filename]:"\.rpm", "(.*)\.rpm", "\\1");
// Where to store the curl log
string log_filename = sformat("curl_%1.log", relnotes_counter);
// Get proxy settings (if any)
string proxy = "";
Proxy::Read();
// Test if proxy works
if (Proxy::enabled) {
//it is enough to test http proxy, release notes are downloaded via http
map <string, map <string, any> > proxy_ret = Proxy::RunTestProxy(Proxy::http, "", "", Proxy::user, Proxy::pass);
if ( (proxy_ret["HTTP", "tested"]:true == true) && ((integer) proxy_ret["HTTP", "exit"]:1 == 0 ) ) {
string user_pass = (Proxy::user != "") ? (Proxy::user + ":" + Proxy::pass) : "";
proxy = "--proxy " + Proxy::http + ((user_pass != "") ? (" --proxy-user '" + user_pass + "'") : "");
}
}
//Include also proxy option (if applicable) - #162800, #260407
string cmd = "/usr/bin/curl --location --verbose --fail --max-time 300 " +
sformat ("%1 %2 --output '%3' > '%4/%5' 2>&1",
proxy, url, String::Quote (filename), String::Quote (logdir), String::Quote (log_filename));
// env["LANG"] = GetLanguageUTF8 ();
y2milestone ("Downloading release notes: %1", cmd);
// SCR::Execute(.background.run, cmd);
// integer ret = wait_for_test ();
integer ret = (integer)SCR::Execute(.target.bash, cmd);
if (ret == 0) {
release_notes_filenames = add (release_notes_filenames, filename);
y2milestone("Successful");
// At least one successfully installed -> internet test succeeded
test_ret = true;
} else {
y2error("Downloading failed");
curl_ret_code = ret;
}
// label of combobox where the log is selected
string menu_name = _("Download of Release Notes");
// identify release notes by name of the product, bug 180581
if (Product::product_of_relnotes[url]:"" != "") {
menu_name = menu_name + sformat(" (%1)", Product::product_of_relnotes[url]:"");
}
logs = add (logs, $[ `menuname : menu_name, `filename : log_filename ]);
});
return test_ret;
}
/**
* Function checks two versions of installed rpm and decides whether the second one is
* newer than the first one. This function ignores non-numerical values in versions
*
* @param string first version
* @param string second version
* @return boolean true if the second one is newer than the first one
*/
boolean IsDownloadedVersionNewer (string installed_rpm_version, string downloaded_rpm_version) {
list <string> installed_rpm_version_l = filter(string one_item, splitstring(installed_rpm_version, "-\."), {
return regexpmatch(one_item, "^[0123456789]+$");
});
list <string> downloaded_rpm_version_l = filter(string one_item, splitstring(downloaded_rpm_version, "-\."), {
return regexpmatch(one_item, "^[0123456789]+$");
});
y2milestone("Evaluating installed %1 and downloaded %2 versions", installed_rpm_version_l, downloaded_rpm_version_l);
integer installed_version_item = nil;
integer downloaded_version_item = nil;
boolean downloaded_version_is_newer = false;
integer loop_counter = 0;
foreach (string i_item, installed_rpm_version_l, {
installed_version_item = tointeger(i_item);
downloaded_version_item = tointeger(downloaded_rpm_version_l[loop_counter]:"0");
if (downloaded_version_item != installed_version_item) {
downloaded_version_is_newer = (downloaded_version_item > installed_version_item);
break;
}
loop_counter = loop_counter + 1;
});
y2milestone("%1 > %2 -> %3", downloaded_rpm_version, installed_rpm_version, downloaded_version_is_newer);
return downloaded_version_is_newer;
}
/**
* Function checks whether the downloaded and installed versions are different
*/
boolean IsDownloadedRPMInstallable(string rpm_name, string disk_file) {
string query_format = "%{NAME}-%{VERSION}";
// Checking the installed version of RPM
map cmd_installed_rpm_version = (map) SCR::Execute(.target.bash_output,
sformat("/bin/rpm -q --queryformat \"%1\" %2", query_format, rpm_name)
);
if (cmd_installed_rpm_version["exit"]:-1 != 0) {
y2warning("Cannot check the installed RPM version: %1 -> %2", disk_file, cmd_installed_rpm_version);
return true;
}
string installed_rpm_version = cmd_installed_rpm_version["stdout"]:"undefined-i";
y2milestone("Installed version: '%1'", installed_rpm_version);
// Checking the downloaded version of RPM
map cmd_downloaded_rpm_version = (map) SCR::Execute(.target.bash_output,
sformat("/bin/rpm -qp --queryformat \"%1\" %2", query_format, disk_file)
);
if (cmd_downloaded_rpm_version["exit"]:-1 != 0) {
y2warning("Cannot check the downloaded RPM version: %1 -> %2", disk_file, cmd_downloaded_rpm_version);
return true;
}
string downloaded_rpm_version = cmd_downloaded_rpm_version["stdout"]:"undefined-d";
y2milestone("Downloaded version: '%1'", downloaded_rpm_version);
// The same or older versions -> false
return IsDownloadedVersionNewer(installed_rpm_version, downloaded_rpm_version);
}
define boolean install_release_notes () {
boolean test_ret = true;
foreach (string filename, release_notes_filenames, {
boolean ret1 = Pkg::RpmChecksig (filename);
if (!ret1) {
y2error ("checksig of release notes failed");
// popup error message
Report::Error(_("Cannot install downloaded release notes.
RPM signature check failed."));
test_ret = false;
// next loop
return;
}
// Checking whether installed/new rpm versions are different (#164388)
// Checking whether the downloaded one is newer (#167985)
string rpm_name = release_notes_rpms[filename]:"";
if (IsDownloadedRPMInstallable(rpm_name, filename)) {
y2milestone("Downloaded version is newer, let's install it...");
} else {
y2milestone("Downloaded version is the same or older, skipping...");
return;
}
boolean old2 = PackageCallbacks::EnableAsterixPackage (false);
boolean ret2 = Pkg::TargetInstall (filename);
PackageCallbacks::EnableAsterixPackage (old2);
if (!ret2) {
y2error ("installation release notes failed.");
// popup error message
Report::Error(_("Installation of downloaded release notes failed."));
test_ret = false;
// next loop
return;
}
});
return test_ret;
}
define void handle_stage ()
{
if (test_stage == `open) // open connection
{
if(Mode::test ()) {
mark_label(1, `arrow);
test_stage = `wait;
return;
}
if(already_up)
{
test_stage = `wait; // not `copy. NM takes its time. #145153
}
else
{
mark_label(1, `arrow);
if(!AskForPassword()) {
y2error("Password required");
test_stage = `finish;
test_result = `failure;
mark_label (1, `dash);
return;
}
// start the connection
y2milestone("called Start");
// label of combobox where the log is selected
logs = add (logs, $[ `menuname : _("Opening of Connection"),
`filename : "ifup.log",
`prio : 16 ]);
if(!Internet::Start(logdir + "/ifup.log")) {
// popup to inform user about the failure
Report::Error(_("Connecting to the Internet failed. View
the logs for details.
"));
test_stage = `finish;
test_result = `failure;
mark_label (1, `dash);
return;
}
test_stage = `wait;
}
return;
}
if (test_stage == `wait) // wait until really connected
{
if(Mode::test ()) {
test_stage = `copy;
mark_label(1, `check);
return;
}
// status must be up
if(!Internet::Status()) {
// popup to inform user about the failure
Report::Error(_("Connecting to the Internet failed. View
the logs for details.
"));
test_stage = `finish;
test_result = `failure;
if (!already_up) mark_label (1, `dash);
return;
}
// and we must be connected
if(Internet::Connected())
{
y2milestone("Connected ok");
// even after we get an address, the test can fail. #145153
// so before we have the dbus event filter, let's try this
SCR::Execute (.target.bash, "ip route list >&2");
y2milestone("Waiting 5000 to get initialized...");
sleep (5000);
SCR::Execute (.target.bash, "ip route list >&2");
test_stage = `copy;
if (!already_up) mark_label(1, `check);
return;
}
// ping anything (www.suse.com) to trigger dod connections
SCR::Execute(.target.bash_background,
"/bin/ping -c 1 -w 1 213.95.15.200");
return;
}
if (test_stage == `copy) // copy some status
{
copy_logs1 ();
test_stage = `relnotes;
}
if (test_stage == `relnotes) // download release notes
{
mark_label(2, `arrow);
boolean ret = true;
//Product::relnotesurl_all=[ "http://www.suse.com/relnotes/i386/openSUSE/10.3/release-notes.rpm" ];
//y2error("FAKE RELNOTES!");
//#390738: need to read available products here (hopefully only one)
//but need to switch off package callbacks first
PackageCallbacks::RegisterEmptyProgressCallbacks();
Product::ReadProducts();
PackageCallbacks::RestorePreviousProgressCallbacks();
y2milestone("Product::relnotesurl = %1", Product::relnotesurl);
// Fallback for situation that mustn't exist
if (size (Product::relnotesurl_all) == 0 && (Product::relnotesurl == nil || Product::relnotesurl == "")) {
Popup::Warning(_("No URL for the release notes defined. Internet test cannot be performed."));
ret = false;
} else
{
if (!download_release_notes ())
{
// return code is not on the blacklist (meaning misconfigured network)
// return true if user wants to continue despite the failure, false otherwise
if ( !contains(curl_ret_codes_bad, curl_ret_code) )
{
//popup informing user about the failure to retrieve release notes
//most likely due to server-side error
ret = Popup::ContinueCancel(_("Download of latest release notes failed due to server-side error.
This does not necessarily imply a faulty network configuration.
Click 'Continue' to proceed to the next installation step. To skip any steps
requiring an internet connection or to get back to your network configuration,
click 'Cancel'.
"));
}
// return code shows misconfigured network
// return false
else
{
// popup to inform user about the failure
Report::Error(_("Download of latest release notes failed. View
the logs for details."));
ret = false;
}
test_stage = `close;
}
}
if (ret)
{
install_release_notes ();
mark_label(2, `check);
}
else
{
test_result = `failure;
mark_label(2, `dash);
}
// we don't check for patches anymore
test_stage = `close;
return;
}
if (test_stage == `patches) // check for updates
{
if(!Product::run_you)
{
test_stage = `close;
return;
}
mark_label(3, `arrow);
string cmd = "/usr/bin/online_update -q -V";
// ugly hack (see bug #42177)
// string cmd = "/bin/false";
cmd = cmd + "> " + logdir + "/you.log 2>&1";
y2milestone ("online_update command: %1", cmd);
SCR::Execute(.background.run, cmd,
$["LANG" : GetLanguageUTF8 ()]);
integer ret = wait_for_test ();
// label of combobox where the log is selected
logs = add (logs, $[ `menuname : _("Check for Patches"),
`filename : "you.log" ]);
if(ret == 0 || ret == 1 || ret == 2) // success
{
we_have_patches = ret != 0;
mark_label(3, `check);
}
else
{
// popup to inform user about the failure
Report::Error(_("Check for latest updates failed. View
the logs for details.
"));
test_result = `failure;
mark_label(3, `dash);
}
test_stage = `close;
return;
}
if (test_stage == `close) // close connection
{
if(Mode::test ()) {
mark_label(4, `arrow);
test_stage = `finish;
mark_label(4, `check);
return;
}
if(!already_up) {
mark_label(4, `arrow);
/* Stop connection */
y2milestone("Connection: stop");
// label of combobox where the log is selected
logs = add (logs, $[ `menuname : _("Closing of Connection"),
`filename : "ifdown.log",
`prio : 14 ]);
if(Internet::Stop(logdir + "/ifdown.log"))
{
mark_label (4, `check);
}
else
{
test_result = `failure;
mark_label (4, `dash);
}
}
test_stage = `finish;
return;
}
}
/* --- internet test starts here --- */
// Create logdir
if (!(boolean)SCR::Execute (.target.mkdir, logdir))
y2error ("can't create logdir");
any ret = nil;
make_dialog();
Wizard::DisableBackButton();
Wizard::DisableAbortButton();
Wizard::DisableNextButton();
UI::ChangeWidget(`id(`abort_test), `Enabled, true);
UI::ChangeWidget(`id(`view_log), `Enabled, false);
UI::BusyCursor ();
// loop during internet test
SCR::Execute (.target.bash, "/bin/logger BEGIN OF YAST2 INTERNET TEST");
while (true)
{
handle_stage ();
if (test_stage == `finish)
break;
ret = UI::TimeoutUserInput (250);
if (ret == `timeout)
continue;
if (ret == `abort_test)
{
if (!already_up)
Internet::Stop ("");
test_result = `failure;
break;
}
y2error ("Unexpected return code: %1", ret);
}
SCR::Execute (.target.bash, "/bin/logger END OF YAST2 INTERNET TEST");
show_result ();
copy_logs2 ();
Wizard::EnableBackButton();
Wizard::DisableAbortButton();
Wizard::EnableNextButton();
// #105811, it lost focus when it was disabled
Wizard::SetFocusToNextButton();
UI::ChangeWidget(`id(`abort_test), `Enabled, false);
UI::ChangeWidget(`id(`view_log), `Enabled, true);
UI::NormalCursor();
/* --- internet test ends here --- */
// loop after internet test
while (true)
{
ret = UI::UserInput();
if (ret == `view_log)
{
ShowLogs (logs, logdir);
continue;
}
if (ret == `abort || ret == `cancel)
{
if (Popup::ConfirmAbort (`incomplete))
break;
continue;
}
if (ret == `back || ret == `next)
{
break;
}
y2error ("Unexpected return code: %1", ret);
}
// set internal data according the test result
if (ret == `next)
{
Internet::suse_register = test_result == `success;
// we don't check for patches here anymore
// if (we_have_patches)
// {
// Internet::do_you = true;
// // Removed due to integration of suse_register
// // AskYOUDialog ();
// }
// else
// Internet::do_you = false;
}
return (symbol) ret;
/* EOF */
}