View | Details | Raw Unified | Return to bug 332663
Collapse All | Expand All

(-)src/functions.ycp (-4 / +7 lines)
Lines 722-743 Link Here
722
	return [];
722
	return [];
723
    }
723
    }
724
724
725
    string cmd = sformat("%1 backup_get_packages %2", yastbin, temporary_file);
725
    string cmd = sformat("%1 backup_get_packages %2 1>/dev/null 2>/dev/null", yastbin, temporary_file);
726
    y2milestone ("Running command: '%1'", cmd);
726
    y2milestone ("Running command: '%1'", cmd);
727
    map command = (map) SCR::Execute(.target.bash_output, cmd);
727
    map command = (map) SCR::Execute(.target.bash_output, cmd);
728
728
729
    list <string> ret = nil;
729
    list <string> ret = [];
730
730
731
    if (command["exit"]:nil != 0) {
731
    if (command["exit"]:nil != 0) {
732
	y2error ("Unexpected error: %1", command);
732
	y2error ("Unexpected error: %1", command);
733
	return [];
733
	ret = [];
734
    } else {
734
    } else {
735
	if (FileUtils::Exists (temporary_file)) {
735
	if (FileUtils::Exists (temporary_file)) {
736
	    ret = (list <string>) SCR::Read (.target.ycp, temporary_file);
736
	    ret = (list <string>) SCR::Read (.target.ycp, temporary_file);
737
	    SCR::Execute (.target.remove, temporary_file);
737
	    SCR::Execute (.target.remove, temporary_file);
738
738
	    if (ret == nil) {
739
	    if (ret == nil) {
739
		return [];
740
		ret = [];
740
		y2error ("Error while reading %1", temporary_file);
741
		y2error ("Error while reading %1", temporary_file);
742
	    } else {
743
		y2milestone ("backup_get_packages found %1 packages", ret);
741
	    }
744
	    }
742
	}
745
	}
743
    }
746
    }
(-)src/scripts/backup_archive.pl (-29 / +50 lines)
Lines 23-28 Link Here
23
use File::Temp qw( tempdir );
23
use File::Temp qw( tempdir );
24
use POSIX qw( strftime );
24
use POSIX qw( strftime );
25
25
26
# command line options
27
my $archive_name = '';
28
my $archive_type = '';
29
my $help = '0';
30
my $store_pt = '0';
31
my @ext2_parts = ();
32
my $verbose = '0';
33
my $files_info = '';
34
my $comment_file = '';
35
my $complete_backup = '';
36
my $multi_volume = undef;
37
my $temp_dir = '/tmp';
38
26
# return all harddisks present in system
39
# return all harddisks present in system
27
sub harddisks($)
40
sub harddisks($)
28
{
41
{
Lines 61-66 Link Here
61
    if ($ix > 0)
74
    if ($ix > 0)
62
    {
75
    {
63
	my $dirs = substr($f, 0, $ix);
76
	my $dirs = substr($f, 0, $ix);
77
	if ($verbose) {
78
	    print "Running: /bin/mkdir -p $dirs 2> /dev/null\n";
79
	}
64
	system("/bin/mkdir -p $dirs 2> /dev/null");		# create directory with parents
80
	system("/bin/mkdir -p $dirs 2> /dev/null");		# create directory with parents
65
    }
81
    }
66
}
82
}
Lines 115-134 Link Here
115
    return $result;
131
    return $result;
116
}
132
}
117
133
118
119
# command line options
120
my $archive_name = '';
121
my $archive_type = '';
122
my $help = '0';
123
my $store_pt = '0';
124
my @ext2_parts = ();
125
my $verbose = '0';
126
my $files_info = '';
127
my $comment_file = '';
128
my $complete_backup = '';
129
my $multi_volume = undef;
130
my $temp_dir = '/tmp';
131
132
# parse command line options
134
# parse command line options
133
GetOptions('archive-name=s' => \$archive_name, 
135
GetOptions('archive-name=s' => \$archive_name, 
134
    'archive-type=s' => \$archive_type, 'help' => \$help,
136
    'archive-type=s' => \$archive_type, 'help' => \$help,
Lines 210-218 Link Here
210
}
212
}
211
213
212
# create parent temporary directory
214
# create parent temporary directory
213
system("/bin/mkdir -p $temp_dir");
215
system("/bin/mkdir -p '$temp_dir'");
216
if (! -d $temp_dir) {
217
    die "Cannot create directory $temp_dir: ".$!;
218
}
214
219
215
my $tmp_dir_root = tempdir($temp_dir."/backup_tmp_XXXXXXXX", CLEANUP => 1);	# remove directory content at exit
220
my $tmp_dir_root = tempdir($temp_dir."/backup_tmp_XXXXXXXX", CLEANUP => 1);	# remove directory content at exit
221
system("/bin/mkdir -p '$tmp_dir_root'");
222
if (! -d $tmp_dir_root) {
223
    die "Cannot create directory $tmp_dir_root: ".$!;
224
}
216
225
217
my $tmp_dir = $tmp_dir_root."/tmp";
226
my $tmp_dir = $tmp_dir_root."/tmp";
218
if (!mkdir($tmp_dir))
227
if (!mkdir($tmp_dir))
Lines 244-250 Link Here
244
print OUT "info/packages_info.gz\n";
253
print OUT "info/packages_info.gz\n";
245
$files_num++;
254
$files_num++;
246
255
247
248
# store host name
256
# store host name
249
use Sys::Hostname;
257
use Sys::Hostname;
250
my $host = hostname();
258
my $host = hostname();
Lines 490-498 Link Here
490
	
498
	
491
	if ($line =~ /^\/.+/)
499
	if ($line =~ /^\/.+/)
492
	{
500
	{
493
	    if (-r remove_escape($line) or -l remove_escape($line))	# output only readable files from files-info
501
	    my $esc_line = remove_escape($line);
494
						# symlinked files need not to be readable
502
495
	    {
503
#	    if (-r $esc_line or -l $esc_line)	# output only readable files from files-info
504
#						# symlinked files need not to be readable
505
#	    {
496
    		print FILES_INFO $line."\n";
506
    		print FILES_INFO $line."\n";
497
507
498
		if (defined $opened)
508
		if (defined $opened)
Lines 504-517 Link Here
504
		    else
514
		    else
505
		    {
515
		    {
506
			# star doesn't use escape sequences
516
			# star doesn't use escape sequences
507
			print PKGLIST remove_escape($line)."\n";
517
			print PKGLIST $esc_line."\n";
508
		    }
518
		    }
509
		}
519
		}
510
	    }
520
#	    }
511
	    else
521
#	    else
512
	    {
522
#	    {
513
    		print "/File not readable: $line\n";
523
#    		print "/File not readable: $line\n";
514
	    }
524
#	    }
515
	}
525
	}
516
	else
526
	else
517
	{
527
	{
Lines 639-650 Link Here
639
close(FILES_INFO);
649
close(FILES_INFO);
640
650
641
# compress file packages_info (avg. ratio is ~10:1)
651
# compress file packages_info (avg. ratio is ~10:1)
642
while (!-e $tmp_dir.'/packages_info.gz') {
652
my $wait_sec = 60;
653
if (-e "$tmp_dir/packages_info") {
654
    print "Gzipping $tmp_dir/packages_info\n";
643
    system("/usr/bin/gzip -9 $tmp_dir/packages_info");
655
    system("/usr/bin/gzip -9 $tmp_dir/packages_info");
644
    warn 'Cannot create '.$tmp_dir.'/packages_info.gz: '.$!."\n";
656
    while ($wait_sec > 0 && ! -e "$tmp_dir/packages_info.gz") {
645
    sleep(15);
657
	--$wait_sec;
658
	sleep(1);
659
    }
660
} elsif (! -e "$tmp_dir/packages_info.gz") {
661
    print ("No such file : $tmp_dir/packages_info");
646
}
662
}
647
663
664
if (! -e "$tmp_dir/packages_info.gz") {
665
    print 'Cannot create '.$tmp_dir.'/packages_info.gz: '.$!."\n";
666
}
667
648
close(OUT);
668
close(OUT);
649
669
650
670
Lines 671-677 Link Here
671
#  -L <size>		volume size in kiB
691
#  -L <size>		volume size in kiB
672
#  -V <str>		volume prefix label
692
#  -V <str>		volume prefix label
673
693
674
my $tar_command = "(export LC_ALL=C; tar -c --files-from $tmp_dir/files --ignore-failed-read -C $tmp_dir_root/tmp -S";
694
my $tar_command = "(export LC_ALL=C; cd $tmp_dir_root/tmp; tar -c --files-from $tmp_dir/files --ignore-failed-read -C $tmp_dir_root/tmp -S";
675
695
676
if ($verbose)
696
if ($verbose)
677
{
697
{
Lines 781-786 Link Here
781
    # create standard (no multi volume) archive 
801
    # create standard (no multi volume) archive 
782
    $tar_command .= " -f $archive_name 2> /dev/null)";
802
    $tar_command .= " -f $archive_name 2> /dev/null)";
783
803
804
    print "Tar command: $tar_command\n";
784
    system($tar_command);
805
    system($tar_command);
785
}
806
}
786
807
(-)src/scripts/backup_search.pl (-5 / +14 lines)
Lines 346-351 Link Here
346
# uses global variable exclude_reg_comp (precompiled regular expressions)
346
# uses global variable exclude_reg_comp (precompiled regular expressions)
347
sub PrintFoundFile($$$$$)
347
sub PrintFoundFile($$$$$)
348
{
348
{
349
    my ($package_name, $file_for_ycp);
349
    my ($file, $ref_package, $widget_file, $output_files, $start_directory) = @_;
350
    my ($file, $ref_package, $widget_file, $output_files, $start_directory) = @_;
350
351
351
    # $widget_index <-> using the global one
352
    # $widget_index <-> using the global one
Lines 394-403 Link Here
394
395
395
	# escaping newline characters is needed because each file
396
	# escaping newline characters is needed because each file
396
	# is reported on separate line
397
	# is reported on separate line
398
399
	$file_for_ycp = $file;
397
	
400
	
398
	$file =~ s/\\/\\\\/g;
401
	$file_for_ycp =~ s/\\/\\\\/g;
399
	$file =~ s/\n/\\n/g;
402
	$file_for_ycp =~ s/\n/\\n/g;
403
	$file_for_ycp =~ s/\"/\\"/g;
400
404
405
	$package_name = $$ref_package;
406
	$package_name =~ s/\\/\\\\/g;
407
	$package_name =~ s/\n/\\n/g;
408
	$package_name =~ s/\"/\\"/g;
409
401
	if (!$output_files) {
410
	if (!$output_files) {
402
	    my $size = 0;
411
	    my $size = 0;
403
	    if ((! -d $file) && (! -l $file)) {
412
	    if ((! -d $file) && (! -l $file)) {
Lines 410-421 Link Here
410
419
411
	if ($widget_file ne "")
420
	if ($widget_file ne "")
412
	{
421
	{
413
	    print WIDGETFILE '`item(`id('.$widget_index.'), "X", "'.$file.'", "'.$$ref_package.'"),'."\n";
422
	    print WIDGETFILE '`item(`id('.$widget_index.'), "X", "'.$file_for_ycp.'", "'.$package_name.'"),'."\n";
414
	    print WIDGETFILE2 '`item(`id('.$widget_index.'), " ", "'.$file.'", "'.$$ref_package.'"),'."\n";
423
	    print WIDGETFILE2 '`item(`id('.$widget_index.'), " ", "'.$file_for_ycp.'", "'.$package_name.'"),'."\n";
415
	}
424
	}
416
425
417
	if ($list_items_file ne "") {
426
	if ($list_items_file ne "") {
418
	    print LISTITEMSFILE '['.$widget_index.', "'.$file.'"],'."\n";
427
	    print LISTITEMSFILE '['.$widget_index.', "'.$file_for_ycp.'"],'."\n";
419
	}
428
	}
420
    }
429
    }
421
}
430
}
(-)src/ui.ycp (-5 / +23 lines)
Lines 2002-2008 Link Here
2002
2002
2003
		    string size_str = substring(line, 0, findfirstof(line, " "));
2003
		    string size_str = substring(line, 0, findfirstof(line, " "));
2004
		    integer size_line = nil;
2004
		    integer size_line = nil;
2005
		    if (size_str != nil) {
2005
		    if (size_str != nil && size_str != "") {
2006
			size_line = tointeger(size_str);
2006
			size_line = tointeger(size_str);
2007
			if (size_line != nil) nopkg_size = nopkg_size + size_line;
2007
			if (size_line != nil) nopkg_size = nopkg_size + size_line;
2008
		    }
2008
		    }
Lines 2171-2190 Link Here
2171
2171
2172
    integer t1 = time();
2172
    integer t1 = time();
2173
2173
2174
    list< list<any> > items = (list< list<any> >) SCR::Read(.target.ycp, (string) SCR::Read(.target.tmpdir) + "/items-list.ycp");
2174
    list< list<any> > items = [];
2175
    string items_filename = Directory::tmpdir + "/items-list.ycp";
2175
2176
2177
    if (FileUtils::Exists (items_filename)) {
2178
	y2milestone ("Reading %1", items_filename);
2179
	items = (list< list<any> >) SCR::Read(.target.ycp, items_filename);
2180
    } else {
2181
	y2error ("File %1 doesn't exist!", items_filename);
2182
    }
2183
2176
    // dialog header
2184
    // dialog header
2177
    Wizard::SetContents( _("File Selection"),
2185
    Wizard::SetContents( _("File Selection"),
2178
	`VBox(
2186
	`VBox(
2179
	    `VSpacing(0.5),
2187
	    `VSpacing(0.5),
2180
	    // label text
2188
	    // label text
2181
	    `Left(`Label(_("Files to Back Up"))),
2189
	    `Left(`Label(_("Files to Back Up"))),
2182
	    `Table(`id(`table),
2190
	    `Table (
2191
		`id(`table),
2183
		`opt(`notify),
2192
		`opt(`notify),
2184
		// table header
2193
		// table header
2185
		`header(" ", _("Filename"), _("Package")),
2194
		`header(" ", _("Filename"), _("Package")),
2186
		// Items are pre-defined in the file
2195
		[]
2187
		(list<term>) SCR::Read(.target.ycp, (string) SCR::Read(.target.tmpdir) + "/items.ycp")
2188
	    ),
2196
	    ),
2189
	    `HBox(
2197
	    `HBox(
2190
		// push button label
2198
		// push button label
Lines 2199-2204 Link Here
2199
	backup_help_file_selection(), true, true
2207
	backup_help_file_selection(), true, true
2200
    );
2208
    );
2201
2209
2210
    // Items are pre-defined in the file
2211
    string items_filename_show = Directory::tmpdir + "/items.ycp";
2212
    UI::ChangeWidget (`id (`table), `Items,
2213
	(FileUtils::Exists (items_filename_show) ?
2214
	    (list<term>) SCR::Read (.target.ycp, items_filename_show)
2215
	    :
2216
	    [`item (`id("none"), ["", _("Internal error"), ""])]
2217
	)
2218
    );
2219
2202
    integer t2 = time();
2220
    integer t2 = time();
2203
    y2milestone("UI finished after %1 seconds", t2 - t1);
2221
    y2milestone("UI finished after %1 seconds", t2 - t1);
2204
2222
(-)src/backup_get_packages.ycp (-2 / +2 lines)
Lines 30-36 Link Here
30
30
31
    string filename = nil;
31
    string filename = nil;
32
    if (is(WFM::Args(0), string)) {
32
    if (is(WFM::Args(0), string)) {
33
	string filename = (string) WFM::Args (0);
33
	filename = (string) WFM::Args (0);
34
    } else {
34
    } else {
35
	y2error ("Wrong parameter for script");
35
	y2error ("Wrong parameter for script");
36
	return false;
36
	return false;
Lines 67-73 Link Here
67
		y2debug("Source %1 description: %2", source_id, source_description);
67
		y2debug("Source %1 description: %2", source_id, source_description);
68
68
69
		// TODO: really compare whole maps? Have they same keys?
69
		// TODO: really compare whole maps? Have they same keys?
70
		if (contains(installed_products, source_description))
70
		if (source_description != nil && source_description != $[] && contains(installed_products, source_description))
71
		{
71
		{
72
		    product_sources = add(product_sources, source_id);
72
		    product_sources = add(product_sources, source_id);
73
		}
73
		}

Return to bug 332663