summaryrefslogtreecommitdiffstats
path: root/rescue/make_rescue_img
diff options
context:
space:
mode:
Diffstat (limited to 'rescue/make_rescue_img')
-rwxr-xr-xrescue/make_rescue_img121
1 files changed, 48 insertions, 73 deletions
diff --git a/rescue/make_rescue_img b/rescue/make_rescue_img
index 0ecd835a7..8e3f64334 100755
--- a/rescue/make_rescue_img
+++ b/rescue/make_rescue_img
@@ -1,92 +1,67 @@
#!/usr/bin/perl
-use lib "../perl-install";
+use MDK::Common;
+use lib "/usr/lib/libDrakX";
use keyboard;
-use common qw(:file);
-use Config;
-Config->import;
-my ($arch) = $Config{archname} =~ /(.*)-/;
-
-$tmp = "/tmp/rescue_tmp";
-$mnt = "/tmp/rescue_stage2_img";
-$mke2fs = "/sbin/mke2fs -q -m 0 -F -s 1";
-$rescue = "rescue_stage2";
+my $tmp = "/tmp/rescue_tmp";
+my $rescue = "rescue.sqfs";
if ($>) {
- $sudo = "sudo";
$ENV{PATH} = "/sbin:/usr/sbin:$ENV{PATH}";
}
-BEGIN { undef *_; }
-sub __ { print @_, "\n"; system(@_); }
-sub _ { __ @_; $? and die; }
-
-sub install_ {
- return if -e "$tmp$_[0]";
- my $d = dirname($_[0]);
- commands::mkdir_("-p", "$tmp$d") unless -d "$tmp$d";
- _ "$sudo cp $_[1] $_[0] $tmp$d";
-}
-sub install_lib { install_($_[0], "") }
-sub install { grep {/lib\w+.so/} @_ and install_lib(@_) or install_($_[0], "-a") }
-
-sub installown($$) {
- my ($own, $dir) = @_;
- return if -e "$tmp$dir$own";
- commands::mkdir_("-p", "$tmp$dir") unless -d "$tmp$dir";
- _ "$sudo cp -a $own $tmp$dir";
-}
+BEGIN { undef *_ }
+sub __ { print @_, "\n"; system(@_) }
+sub _ { __ @_; $? and die }
-_ "$sudo rm -rf $tmp" if -e $tmp;
-_ "mkdir $tmp";
-_ 'find . -name "*~" | xargs rm -f';
-foreach (cat_("dirs")) {
- chomp;
- commands::mkdir_("-p", "$tmp$_");
-}
+my $arch = arch() =~ /i.86/ ? $MDK::Common::System::compat_arch{arch()} : arch();
+_ "rm -rf $tmp" if -e $tmp;
+_ "mkdir -p $tmp";
_ "cp -a tree/* $tmp";
-_ "find $tmp -name 'CVS*' | xargs rm -rf";
-
-foreach (keyboard::loadkeys_files) {
- install($_);
- symlink "$2.kmap.gz", "$tmp$1/$3.kmap.gz" if m|(.*)/((..).+)\.kmap\.gz|;
-}
-unlink "$tmp/usr/lib/kbd/keymaps/i386/qwertz/fr.kmap.gz";
-
-foreach (cat_("list"), cat_(`../tools/specific_arch list`)) {
- chomp;
- install($_);
- chomp, install_lib($_) foreach `ldd $_ 2>/dev/null | grep "=>" | sed -e 's/.*=> //' -e 's/ .*//'`;
-}
+_ "find $tmp -name '*~' -delete";
+mkdir_p($tmp . chomp_($_)) foreach cat_("dirs");
foreach (cat_("aliases")) {
chomp; my ($f, $dest) = split;
symlink $dest, "$tmp$f";
}
-_ "cp ../modules/modules.{cz*,dep} $tmp/modules";
-
-installown("drvinst", "/usr/bin");
+if ($arch eq "x86_64") {
+ _ "mkdir $tmp/usr/lib64";
+ _ "ln -s usr/lib64 $tmp/lib64";
+}
+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";
+# Loading the floppy module causes this service to fail so lets mask this to
+# prevent a red "FAILED" briefly showing on the screen
+_ "sed -i s/ExecStart=/ExecStart=-/ $tmp/usr/lib/systemd/system/systemd-modules-load.service";
+
+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");
+ }
+}
-#_ "install -s kernel_read_part $tmp/sbin" if $arch =~ /i.86/;
-__ "$sudo strip $tmp/{lib,bin,sbin}/* $tmp/usr/{bin,sbin}/* 2>/dev/null";
+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];
-$size = `du -s $tmp | cut -f1` + 2048; #- add 2MB of free space
-
-commands::mkdir_("-p", $mnt) if !-e $mnt;
-__ "$sudo umount $rescue 2>/dev/null";
-
-_ "dd if=/dev/zero of=$rescue bs=1k count=$size";
-_ "$mke2fs $rescue";
-_ "$sudo mount -t ext2 $rescue $mnt -o loop";
-_ "rmdir $mnt/lost+found";
-
-_ "$sudo chown -R root.root $tmp";
-_ "$sudo cp -a $tmp/* $mnt";
-_ "$sudo rm -rf $tmp";
-
-_ "$sudo umount $rescue";
-_ "rmdir $mnt";
-
-_ "bzip2 -f -9 $rescue";
+_ "mksquashfs $tmp $rescue -all-root -noappend >/dev/null";
+_ "chmod 755 $rescue";
+#_ "rm -rf $tmp";