summaryrefslogtreecommitdiffstats
path: root/rescue/make_rescue_img
blob: 50083d0b06d5fb21ef825ceb5f45e09eb304a70c (plain)
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
#!/usr/bin/perl

use MDK::Common;
use lib "/usr/lib/libDrakX";
use keyboard;

my $tmp = "/tmp/rescue_tmp";
my $rescue = "rescue.sqfs";

if ($>) {
    $ENV{PATH} = "/sbin:/usr/sbin:$ENV{PATH}";
}

BEGIN { undef *_ }
sub __ { print @_, "\n"; system(@_) }
sub _ { __ @_; $? and die }

my $arch = arch() =~ /i.86/ ? $MDK::Common::System::compat_arch{arch()} : arch();
_ "rm -rf $tmp" if -e $tmp;
_ "mkdir -p $tmp";
_ "ln -s usr/bin $tmp/bin";
_ "ln -s usr/sbin $tmp/sbin";
_ "ln -s usr/lib $tmp/lib";
if ($arch eq "x86_64") {
    _ "mkdir $tmp/usr/lib64";
    _ "ln -s usr/lib64 $tmp/lib64";
}
_ "cp -a tree/* $tmp";
_ "find $tmp -name '*~' -delete";
mkdir_p($tmp . chomp_($_)) foreach cat_("dirs");
substInFile { s/DISTRIB_DESCR/$ENV{DISTRIB_DESCR}/ } "$tmp/etc/issue";

_ "../tools/install-xml-file-list list.xml $tmp";

_ "sed 's/Mageia \\([0-9]*\\)/Mageia Rescue \\1/' /etc/os-release >$tmp/etc/os-release";
_ "ls -1 $tmp/etc | sed 's,\\(.*\\),/etc/\\1,' >>$tmp/usr/share/symlinks";

my %keytable_conflicts;
my @less_important_keytables = qw(am_old am_phonetic no-dvorak de-latin1);
foreach (keyboard::loadkeys_files(sub { warn @_ })) {
    my ($dir, $fname) = (dirname($_), basename($_));
    my ($name) = $fname =~ /(.*)\.map\.gz/ or next;
    next if member($name, @less_important_keytables);
    if (my ($short2, $short) = $name =~ m|((.+?)[\W_][^\W_]*)|) {
	$keytable_conflicts{$short} && $short2 ne $name and $short = $short2;
	$keytable_conflicts{$short} and warn("conflict between $keytable_conflicts{$short} and $name for short name $short (choosing the first)\n"), next;
	$keytable_conflicts{$short} = $name;
	# create the short name based on the long one
	symlinkf($fname, "$tmp$dir/$short.map.gz");
    }
}

foreach (cat_("aliases")) {
    chomp; my ($f, $dest) = split;
    symlink $dest, "$tmp$f";
}


if (my ($LANGUAGE) = map { if_(/LANGUAGE_(.*)/, $1) } keys %ENV) {
    substInFile {
	$_ = "export LANGUAGE=$LANGUAGE\n" . "export LC_ALL=$LANGUAGE\n" if /^#LANGUAGE/;	
    } "$tmp/usr/bin/mageia-rescue";
}

exit 0 if $ARGV[0];

_ "mksquashfs $tmp $rescue -all-root -noappend >/dev/null";
_ "chmod 755 $rescue";
#_ "rm -rf $tmp";