summaryrefslogtreecommitdiffstats
path: root/rescue
diff options
context:
space:
mode:
Diffstat (limited to 'rescue')
-rw-r--r--rescue/.cvsignore1
-rw-r--r--rescue/.perl_checker74
-rw-r--r--rescue/Makefile39
-rw-r--r--rescue/NEWS213
-rw-r--r--rescue/aliases4
-rw-r--r--rescue/devices.pl54
-rw-r--r--rescue/dirs2
-rwxr-xr-xrescue/diskdrake-resize29
-rwxr-xr-xrescue/drvinst19
-rwxr-xr-xrescue/genpasswd13
-rwxr-xr-xrescue/guessmounts171
-rwxr-xr-xrescue/install_bootloader97
-rw-r--r--rescue/list157
-rw-r--r--rescue/list.alpha1
-rw-r--r--rescue/list.i38615
-rw-r--r--rescue/list.ia647
-rw-r--r--rescue/list.ppc13
-rw-r--r--rescue/list.sparc2
-rw-r--r--rescue/list.x86_6418
-rw-r--r--rescue/list.xml372
-rwxr-xr-xrescue/lsparts8
-rwxr-xr-xrescue/make_flash_rescuebin0 -> 2504 bytes
-rwxr-xr-xrescue/make_partimage_save_rest_all46
-rwxr-xr-xrescue/make_rescue_img141
-rwxr-xr-xrescue/partimage_whole_disk242
-rwxr-xr-xrescue/rescue-doc17
-rwxr-xr-xrescue/restore-image-lib.sh80
-rwxr-xr-xrescue/restore-image.sh413
-rwxr-xr-xrescue/restore_ms_boot102
-rwxr-xr-xrescue/startssh27
-rw-r--r--rescue/tree/etc/hosts2
-rw-r--r--rescue/tree/etc/inittab16
-rw-r--r--rescue/tree/etc/issue3
-rw-r--r--rescue/tree/etc/passwd2
-rw-r--r--rescue/tree/etc/profile4
-rwxr-xr-xrescue/tree/etc/rc.sysinit66
-rwxr-xr-xrescue/tree/sbin/fakeshutdown6
-rwxr-xr-xrescue/tree/sbin/modprobe66
-rw-r--r--rescue/tree/usr/share/symlinks2
39 files changed, 1755 insertions, 789 deletions
diff --git a/rescue/.cvsignore b/rescue/.cvsignore
deleted file mode 100644
index c660273e8..000000000
--- a/rescue/.cvsignore
+++ /dev/null
@@ -1 +0,0 @@
-rescue.clp
diff --git a/rescue/.perl_checker b/rescue/.perl_checker
new file mode 100644
index 000000000..b0e673b0a
--- /dev/null
+++ b/rescue/.perl_checker
@@ -0,0 +1,74 @@
+AutoLoader
+Carp
+Carp::Heavy
+Compress::Zlib
+Config::IniFiles
+Cwd
+Data::DumpXML
+Data::DumpXML::Parser
+Date::Manip
+Digest::MD5
+Encode
+File::Copy::Recursive
+File::Find
+File::FnMatch
+File::Glob
+File::Path
+File::Sync
+File::Temp
+Filesys::Df
+Gtk2::Gdk::Keysyms
+Gtk2::Helper
+Gtk2::Pango
+Gtk2::SimpleList
+I18N::Langinfo
+IO::Handle
+IO::Select
+IO::Socket::INET
+IPC::Open2
+Image::Magick
+Libconf
+Libconf::Glueconf::NUT::Ups_conf
+Libconf::Glueconf::Samba::Smb_conf
+Libconf::Templates::Generic::KeyValueSections
+Libconf::Templates::Samba
+Locale::gettext
+Net::DBus
+Net::DBus::Binding::Watch
+Net::LDAP
+RS::Handy
+Scalar::Util
+Sys::Syslog
+Term::ReadKey
+Time::HiRes
+Time::ZoneInfo
+URI::Escape
+XML::LibXML
+XML::LibXML::Boolean
+XML::LibXML::Common
+XML::LibXML::Literal
+XML::LibXML::NodeList
+XML::LibXML::Number
+XML::Parser
+base
+constant
+encoding
+feature
+handle_configs
+move
+open
+overload
+printer::cups
+printer::hpoj
+printer::main
+printer::printerdrake
+scanner
+urpm::dudf
+urpm::ldap
+urpm::parallel_ka_run
+urpm::parallel_ssh
+URPM::Resolve
+utf8
+warnings
+warnings::register
+bytes
diff --git a/rescue/Makefile b/rescue/Makefile
index bbcf73e5b..b50ab8f8e 100644
--- a/rescue/Makefile
+++ b/rescue/Makefile
@@ -1,12 +1,43 @@
include ../Makefile.config
-all: rescue.clp
+VERSION=1.39
+PRODUCT=drakx-installer-rescue
-install: rescue.clp
+RESCUE = rescue.sqfs
+
+all: $(RESCUE)
+
+install: $(RESCUE)
cp -f $< $(STAGE2_DEST)
-rescue.clp: list list.$(ARCH) drvinst guessmounts lsparts rescue-doc make_rescue_img
+$(RESCUE): list.xml drvinst guessmounts lsparts rescue-doc make_rescue_img
DISTRIB_DESCR=$(DISTRIB_DESCR) ./make_rescue_img
+dist-svn:
+ rm -rf $(PRODUCT)*.tar* $(PRODUCT)-$(VERSION)
+ mkdir -p $(PRODUCT)-$(VERSION)/tools
+ svn export -q -rBASE . $(PRODUCT)-$(VERSION)/rescue
+ cp ../Makefile.config $(PRODUCT)-$(VERSION)/
+ cp ../tools/install-xml-file-list $(PRODUCT)-$(VERSION)/tools
+ tar cfa $(PRODUCT)-$(VERSION).tar.xz $(PRODUCT)-$(VERSION)
+ rm -rf $(PRODUCT)-$(VERSION)
+
+dist-git:
+ @cd ..; git archive --prefix=$(PRODUCT)-$(VERSION)/ HEAD rescue tools/install-xml-file-list Makefile.config | xz >$(PRODUCT)-$(VERSION).tar.xz;
+
+dist: tar
+
+tar:
+ rm -rf $(PRODUCT)*.tar* $(PRODUCT)-$(VERSION)
+ @if [ -e "../.svn" ]; then \
+ $(MAKE) dist-svn; \
+ elif [ -e "../.git" ]; then \
+ $(MAKE) dist-git; \
+ else \
+ echo "Unknown SCM (not SVN nor GIT)";\
+ exit 1; \
+ fi;
+ $(info $(PRODUCT)-$(VERSION).tar.xz is ready)
+
clean:
- rm -f rescue.clp kernel_read_part
+ rm -f $(RESCUE) kernel_read_part
diff --git a/rescue/NEWS b/rescue/NEWS
new file mode 100644
index 000000000..151ada7f1
--- /dev/null
+++ b/rescue/NEWS
@@ -0,0 +1,213 @@
+Version 1.39 - 3 September 2012 by Thierry Vignaud
+
+- adapt to latest systemd/udevd
+- adapt to perl-5.16.0
+- adapt to /usr move
+- default to the higher version when there're several mga roots (mga#6003)
+- drop KA support
+- fix detecting USB devices with kernel-3.5+ (mga#7248)
+- preload load btrfs and nilfs2 too
+- rely on stage1 for mounting /dev
+- revert to "linux" terminfo
+- simplify bringing up local loop interface (pok, mdv)
+- stop fixing the raid udev rule now that it has been fixed
+
+Version 1.38 - 11 May 2012, by Thierry Vignaud
+
+- include missing modules when SMB appears in fstab (mga#5850)
+
+Version 1.37 - 18 April 2012, by Thierry Vignaud
+
+- fix detecting RAID (mga#5048)
+- include more udev rules for RAID (mga#5048)
+
+Version 1.36 - 8 April 2012, by Pascal Terjan
+
+- fix modprobe to support being called by kernel (mga#5274)
+
+Version 1.35 - 5 April 2012, by Thierry Vignaud
+
+- add chrooted rescue system in PATH
+- 32bit grub needs 32 bit loader (mga#5191)
+- default to "screen" instead of "linux" terminfo (mga#4894)
+- include "screen" terminfo (mga#4894)
+
+Version 1.34 - 26 February 2012, by Maarten Vanraes (AL13N)
+
+- escape / in generated passwords in startssh
+- add trailing ; in command lists in startssh
+
+Version 1.33 - 26 February 2012, by Thierry Vignaud
+
+- do not symlink /dev (mga#1023)
+
+Version 1.32 - 25 February 2012, by Thierry Vignaud & Maarten Vanraes (AL13N)
+
+- don't overwrite /dev after udev handles it
+- add some tests and error handling in startssh
+- really fix mounting /dev/pts & /dev/shm (mga#1023)
+
+Version 1.31 - 25 February 2012, by Thierry Vignaud & Maarten Vanraes (AL13N)
+
+- add logging to dropbear
+- fix mounting /dev/pts & /dev/shm (mga#1023)
+- make root user homedir /root
+- add agetty (mga#2052)
+
+Version 1.30 - 26 January 2012, by Thierry Vignaud
+
+- enable autologin on all consoles
+- include mkfs.nilfs2 & nilfs-tune
+
+Version 1.29 - 25 January 2012, by Thierry Vignaud
+
+- drop support for squashfs3
+- enable rescue through serial line (mga#2052)
+- fix mounting / (mga#3327)
+- fix mounting / on LV
+- fix mounting / on soft RAID or crypted LV (mga#3778 & mga#448)
+- include xz for xz modules
+- mount /proc in chroot
+- only consider fstab from the selected fs
+- switch to udev
+
+Version 1.28 - 15 January 2012, by Thierry Vignaud
+
+- use init from drakx-installer-sysvinit instead of system one
+
+Version 1.27 - 28 October 2011, by Thomas "tmb" Backlund
+
+- clean up genpasswd (AL13N)
+- add gdisk for GPT partitioning support (#1023)
+
+Version 1.26 - 24 October 2011, by Thomas "tmb" Backlund
+
+- add dropbear ssh support to rescue mode (AL13N, mga #1023)
+ * add screen, dropbear, dropbearkey, genpasswd and startssh
+ * add /etc/shells
+- add partprobe tool from parted (9k)
+
+Version 1.25.1 - 05 August 2011, by Thierry Vignaud
+
+- fix build with perl-5.14
+
+Version 1.25 - 05 August 2011, by Thierry Vignaud
+
+- add missing libfuse.so.2 for mount.ntfs-3g (#1189)
+- prefer Mageia root partitions over Mdv ones (#1320)
+
+Version 1.24 - 20 May 2011, by tmb
+
+- devices.pl: call mknod directly
+- list.xml: add btrfs tools to the image
+- list.xml: fix XSLoader path
+
+Version 1.23 - 06 April 2011, by Dmorgan
+
+- Fix function names ( Bug #651 )
+
+Version 1.22 - 24 February 2011, by Pascal "pterjan" Terjan
+
+- cleaning for Mageia import
+- include /etc/netconfig (needed by mount.nfs)
+
+Version 1.18 - 13 April 2010, by Olivier "blino" Blin
+
+- image restore script: use blkid instead of deprecated vol_id
+
+Version 1.17 - 12 April 2010, by Olivier "blino" Blin
+
+- Handle LVM (#44723)
+- image restore script: handle hybrid images (by matching main device)
+
+Version 1.16 - 9 October 2009, by Olivier "blino" Blin
+
+- work both with squashfs 3 and 4
+- image restore script (from Paulo Ricardo Zanoni):
+ o re-read partition table after writing image
+ o do not extend / to the end of the disk, it overlaps with swap
+ partition
+- do not make de-latin1 keymap a symlink/include loop (#45109)
+- use extipl from /usr/lib/extipl on x86_64 too
+ (to fix restore_ms_boot, hardcoding this path)
+
+Version 1.15 - 3 September 2009, by Thierry Vignaud
+
+- add back dumpe2fs
+- run /oem-rescue.sh if oem option is present on cmdline
+- allow to specify main partition in the restore config file
+ (MAIN_PART_NUMBER), if there is a restore partition at beginning of
+ disk
+- load ext4 module (#48816)
+- use blkid instead of vol_id which we no longer ship
+
+Version 1.14 - 27 May 2009, by Olivier "blino" Blin
+
+- adapt to new extipl location in x86_64
+- adapt to new magic.mgc location
+
+Version 1.13 - 27 May 2009, by Olivier "blino" Blin
+
+- include various commands
+- image restore script:
+ o better estimate of image dump progression
+ o fix detecting multiple partitions to avoid win32 detection
+ o fix guessing extension when filename contains a dot
+
+Version 1.12 - 20 February 2009, by Olivier "blino" Blin
+
+- image restore script:
+ o add swap partition
+ o use a minimum size for disks to be detected (Caio)
+ o resize Windows partitions if needed (Caio)
+- Flash rescue:
+ o add support for Flash 2009
+ o try to load squashfs-lzma too
+ o handle path to lzma distrib loopbacks
+- fix build:
+ o do not include dead parsehdlist
+ o do not include dead rpm helpers
+
+Version 1.11 - 25 September 2008, by Olivier "blino" Blin
+
+- add image restoration scripts ("restore" command line parameter)
+
+Version 1.10 - 25 April 2008, by Olivier "blino" Blin
+
+- fix "Mounting other partitions from fstab" which use UUID=xxx
+- fix build with latest file package, which only includes the
+ precompiled magic file
+
+Version 1.9 - 10 March 2008, by Olivier "blino" Blin
+
+- handle ntfs-3g in fstab
+- add missing modalias files (#38690)
+
+Version 1.8 - 28 February 2008, by Olivier "blino" Blin
+
+- support new modules location (#38207)
+- adapt to perl 5.10
+- fix build (fix a workaround in partimage_whole_disk)
+
+Version 1.7 - 25 September 2007, by Pascal "Pixel" Rigaux
+
+- add mount.nfs binary (since mount doesn't handle nfs fs anymore)
+
+Version 1.6 - 8 August 2007, by Pascal "Pixel" Rigaux
+
+- adapt to new libldetect together with drakx-installer-images 1.13
+- loadkeys file:
+ o handle new "kbd" rpm which have .map files instead of .kmap
+ o don't skip fr_CH-latin1
+ o handle "fr_CH"-like short names
+- remove rescuept (use testdisk instead, which is much nicer)
+
+Version 1.5 - 9 July 2007, by Pascal "Pixel" Rigaux
+
+- add /etc/mke2fs.conf in order to format ext3fs with 4k blocks (#27377)
+- add "mkfs.ext3" which is no more equivalent to "mkfs.ext2 -J"
+ (eg: dir_index & resize_inode features)
+
+Version 1.4 - 4 April 2007, by Pascal "Pixel" Rigaux
+
+- zcat and gunzip can't be symlinks anymore, they are scripts
diff --git a/rescue/aliases b/rescue/aliases
index eae42f0ce..59c96a124 100644
--- a/rescue/aliases
+++ b/rescue/aliases
@@ -1,4 +1,2 @@
-/bin/zcat gzip
-/bin/gunzip gzip
-/bin/rpm /usr/bin/rpm-dynamic
/bin/vi vim-minimal
+/lib/modules /modules
diff --git a/rescue/devices.pl b/rescue/devices.pl
deleted file mode 100644
index 79308508a..000000000
--- a/rescue/devices.pl
+++ /dev/null
@@ -1,54 +0,0 @@
-#!/usr/bin/perl
-
-@ARGV == 1 && chdir $ARGV[0] or die "usage: devices.pl <dir>\n";
-
-if ($>) { $sudo = "sudo"; $ENV{PATH} = "/sbin:/usr/sbin:$ENV{PATH}"; }
-
-foreach (<DATA>) {
- chomp;
- my ($typ, $maj, $min, @l) = split;
- foreach (@l) {
- my @l2 = do {
- if (my ($prefix, $ini, $end) = /(.*)(\d+)-(\d+)$/) {
- map { "$prefix$_" } $ini .. $end;
- } else {
- $_;
- }
- };
- system("$sudo mknod $_ $typ $maj " . $min++) foreach @l2;
- }
-}
-
-__DATA__
-c 5 1 console
-b 2 0 fd0-1
-c 1 2 kmem
-b 7 0 loop0-15
-c 1 1 mem
-c 1 3 null
-c 1 4 port
-b 1 1 ram
-b 1 0 ram0-19
-b 1 0 ramdisk
-c 1 8 random
-b 11 0 scd0-7
-c 0 0 stderr
-c 0 0 stdin
-c 0 0 stdout
-c 5 0 tty
-c 4 0 tty0-9
-c 4 64 ttyS0-3
-c 1 9 urandom
-c 1 5 zero
-b 3 0 hda hda1-16
-b 3 64 hdb hdb1-16
-b 22 0 hdc hdc1-16
-b 22 64 hdd hdd1-16
-b 33 0 hde hde1-16
-b 33 64 hdf hdf1-16
-b 34 0 hdg hdg1-16
-b 34 64 hdh hdh1-16
-b 8 0 sda sda1-15 sdb sdb1-15 sdc sdc1-15 sdd sdd1-15 sde sde1-15 sdf sdf1-15 sdg sdg1-15 sdh sdh1-15
-b 9 0 md0-15
-c 10 144 nvram
-c 9 0 st0-15
diff --git a/rescue/dirs b/rescue/dirs
index e6d5a5d47..6b6d88a6f 100644
--- a/rescue/dirs
+++ b/rescue/dirs
@@ -2,5 +2,3 @@
/tmp
/modules
/proc
-/dev
-/dev/pts
diff --git a/rescue/diskdrake-resize b/rescue/diskdrake-resize
new file mode 100755
index 000000000..88372aac7
--- /dev/null
+++ b/rescue/diskdrake-resize
@@ -0,0 +1,29 @@
+#!/usr/bin/perl
+
+use lib qw(/usr/lib/libDrakX);
+
+use devices;
+use log;
+use resize_fat::main;
+use diskdrake::resize_ntfs;
+use diskdrake::resize_ext2;
+
+my ($device, $fs_type, $size) = @ARGV
+ or die "usage: $0 <device> <fs type> <size>\n";
+
+my %fs_pkgs = (
+ vfat => 'resize_fat::main',
+ ntfs => 'diskdrake::resize_ntfs',
+ ext2 => 'diskdrake::resize_ext2',
+ ext3 => 'diskdrake::resize_ext2',
+ ext4 => 'diskdrake::resize_ext2',
+);
+
+my $resize_pkg = $fs_pkgs{$fs_type}
+ or die "no support for $fs_type type\n";
+
+log::l("resizing $device to $size");
+
+my $resize = $resize_pkg->new($device, devices::make($device))
+ or die "unable to initialize resize\n";
+$resize->resize($size);
diff --git a/rescue/drvinst b/rescue/drvinst
index 78c6f5c74..4868b42e0 100755
--- a/rescue/drvinst
+++ b/rescue/drvinst
@@ -12,35 +12,26 @@
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
#
-use lib qw(../perl-install /usr/lib/libDrakX);
+use lib qw(/usr/lib/libDrakX);
use common;
use detect_devices;
$ARGV[0] =~ /^--?h/ and die "usage: drivers_install [drivertype1 [drivertype2 ...]]\n";
my @types = @ARGV;
-sub install_module_raw {
- my ($driver, $o_descr) = @_;
- print STDERR "Installing driver $driver", $o_descr ? " (for \"$o_descr\")" : '', "\n";
- system("/sbin/modprobe", $driver) and print "\tfailed\n";
-}
-
-my $already_usb;
sub install_module {
my ($driver, $descr) = @_;
- install_module_raw($driver, $descr);
- if (!$already_usb && $driver =~ /usb/) {
- $already_usb = 1;
- install_module_raw('usbkbd');
- install_module_raw('keybdev');
- }
+ print STDERR qq(Installing driver $driver (for "$descr")\n);
+ system("/sbin/modprobe", $driver) and print "\tfailed\n";
}
#- start
foreach my $card (detect_devices::pci_probe()) {
+ # ignoring "unknown", "Card:foobar" and the like as well as video cards:
$card->{driver} eq 'unknown' || $card->{driver} =~ /:/ and next;
$card->{media_type} eq "DISPLAY_VGA" and next;
+ # load drivers for selected categories or for everything if no args:
if (!@ARGV || find { $card->{media_type} =~ /$_/i } @types) {
install_module($card->{driver}, $card->{description});
}
diff --git a/rescue/genpasswd b/rescue/genpasswd
new file mode 100755
index 000000000..2f129673d
--- /dev/null
+++ b/rescue/genpasswd
@@ -0,0 +1,13 @@
+#!/usr/bin/perl
+
+use strict;
+
+system "stty -echo";
+print STDERR "Give a password for ssh access: ";
+chomp(my $word = <STDIN>);
+print STDERR "\n";
+system "stty echo";
+
+my @salt = ('.', '/', 0..9, 'A'..'Z', 'a'..'z')[rand 64, rand 64];
+print crypt($word, join('', @salt));
+print "\n";
diff --git a/rescue/guessmounts b/rescue/guessmounts
index 5220d0815..14d7cd804 100755
--- a/rescue/guessmounts
+++ b/rescue/guessmounts
@@ -12,102 +12,109 @@
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
#
+use lib qw(/usr/lib/libDrakX);
+use common;
+use devices;
+use fs;
+use fs::dmcrypt;
+use fs::proc_partitions;
+use fs::type;
+use lvm;
+use run_program;
+
+my @proc_mounts = fs::read_fstab('', '/proc/mounts');
-sub cat_ { local *F; open F, $_[0] or return; my @l = <F>; wantarray() ? @l : join '', @l }
-sub chomp_ { my @l = map { my $l = $_; chomp $l; $l } @_; wantarray() ? @l : $l[0] }
+my $target = '/mnt';
+if (fs::get::mntpoint2part($target, \@proc_mounts)) {
+ print STDERR "$target is already mounted (according to /proc/mounts)\n";
+ exit 0;
+}
-my @mounts = cat_('/proc/mounts');
-grep { (split)[1] =~ m|^/mnt$| } @mounts and print("/mnt is already mounted (according to /proc/mounts)\n"), exit 0;
+system('drvinst', 'STORAGE');
+print STDERR "\nPlease wait, trying to find your root device...\n";
-system('drvinst'); #- class2text seems broken, I can't detect easily only modules for SCSI storage :-(
+mkdir_p($target);
-print "\nPlease wait, trying to find your root device...\n";
+{
+ local $::isInstall = 1; # so that detect_during_install() got called by init:
+ lvm::init();
+}
+fs::dmcrypt::init;
+
+my @parts = map {
+ $_->{device} = delete $_->{dev};
+ put_in_hash($_, fs::type::type_subpart_from_magic($_));
+} fs::proc_partitions::read_raw();
+my ($raid_parts, $normal_parts) = partition { isRawRAID($_) } @parts;
+
+if (@$raid_parts) {
+ require raid;
+ raid::detect_during_install(@$raid_parts);
+ my $raids = raid::get_existing(@$raid_parts);
+ push @$normal_parts, @$raids;
+}
-my $target = '/mnt';
--d $target || mkdir($target) or die "couldn't create $target\n";
-
-
-my (undef, undef, @parts) = cat_('/proc/partitions');
-
-my @fstab;
-my $root;
-
-M: foreach (@parts) {
- my $dev = (split)[3] or next;
- $dev = "/dev/$dev";
-
- foreach my $fs ('ext3', 'ext2', 'reiserfs', 'xfs', 'jfs') {
- my $where = $target;
- if (!system("mount -t $fs $dev $where 2>/dev/null")) {
- if (-r "$where/etc/fstab" && -r "$where/etc/mandrake-release") {
- print "=> found a Mandriva Linux root partition on $dev\n=> type $fs, version `",
- chomp_(cat_ "$where/etc/mandrake-release"),
- "'\n";
- @fstab = cat_("$where/etc/fstab");
- $root = $dev;
- last M;
- } else {
- system('umount', $where) and die "error unmounting $where\n";
- }
- last;
- }
+my @roots;
+
+foreach (@$normal_parts) {
+ my $dev = devices::make($_->{device});
+
+ my $fs = find {
+ system("mount -t $_ $dev $target 2>/dev/null") == 0;
+ } fs::type::true_local_fs_types() or next;
+
+ if (my $release_file = common::release_file($target)) {
+ my $release = chomp_(cat_("$target$release_file"));
+ print STDERR "=> found a $release root partition on $dev\n=> type $fs, version `\n";
+ my @fstab = fs::read_fstab($target, '/etc/fstab');
+ push @roots, { dev => $dev, release => $release, fs => $fs, fstab => \@fstab };
}
+ system('umount', $target) == 0 or die "error unmounting $target\n";
+}
+
+my ($root, $fs, @fstab);
+
+# Try Mageia first:
+if (@roots) {
+ # Order by release number:
+ @roots = sort { $b->{release} cmp $a->{release} } @roots;
+ # Then pick mga over mdv:
+ @roots = map { @$_ } partition { $_->{release} =~ /Mageia/ } @roots;
+ my $selected = first(@roots);
+ $root = $selected->{dev};
+ $fs = $selected->{fs};
+ @fstab = @{$selected->{fstab}};
+ print STDERR "=> Selecting $root as root fs\n";
}
if ($root) {
- print "\nMounting other partitions from fstab on $target...\n";
+ system("mount -t $fs $root $target 2>/dev/null");
+
+ print STDERR "\nMounting other partitions from fstab on $target...\n";
foreach (@fstab) {
- next if /^\s*#/;
- my ($dev, $where, $type, $opts) = split;
- next if (!$type || $dev eq 'none' || $opts =~ /noauto/ ||
- $type =~ /^(supermount|swap|nfs)$/ ||
- $where eq '/' ||
- $where =~ m,proc|cdrom|floppy|/mnt/zip,
- );
- $opts = join(',', grep { !/codepage=/ && !/iocharset/ } split(',', $opts)); #- vfat opts, we don't have the modules in rescue
- $where = "$target$where";
- -d $where || mkdir($where) or die "couldn't create $where\n";
- print "\t$dev on $where type $type\n";
- system("mount -t $type $dev $where -o $opts");
- system("cp -f /etc/mtab $target/etc/mtab"); #- to allow a nice chrooted "mount" or "df"
+ my ($valued_options, $options) = fs::mount_options::unpack($_);
+
+ next if
+ !$_->{fs_type} || $_->{device} eq 'none'
+ || $valued_options->{noauto}
+ || $_->{mntpoint} eq '/'
+ || member($_->{fs_type}, 'swap', 'nfs', 'ntfs', 'ntfs-3g');
+
+ delete $valued_options->{'iocharset='};
+ delete $valued_options->{'codepage='};
+ fs::mount_options::pack($_, $valued_options, $options); #- vfat opts, we don't have the modules in rescue
+
+ my $where = "$target$_->{mntpoint}";
+ my $dev = fs::wild_device::from_part('', $_);
+ mkdir_p($where);
+ print STDERR "\t$dev on $where type $_->{fs_type} options $_->{options}\n";
+ system("mount -t $_->{fs_type} $dev $where -o $_->{options}");
}
- print "\nYour system is ready on $target.\n\n";
+ system("mount -t proc proc $target/proc");
+ print STDERR "\nYour system is ready on $target.\n\n";
} else {
die "Could not find your root device :-(.\n";
}
-
-
-#-------------------------------------------------
-#- $Log$
-#- Revision 1.8 2005/04/19 13:10:25 prigaux
-#- mandriva switch
-#-
-#- Revision 1.7 2004/07/20 02:42:12 prigaux
-#- MandrakeSoft -> Mandrakesoft
-#-
-#- Revision 1.6 2003/08/03 21:50:06 prigaux
-#- - copy /etc/mtab to /mnt/etc/mtab to have a nice chrooted "mount" or "df"
-#- - some perl_checker compliance
-#-
-#- Revision 1.5 2001/11/05 17:03:54 gc
-#- honours hash in /etc/fstab to disable lines
-#-
-#- Revision 1.4 2001/10/24 22:34:01 gc
-#- - add a GUI to the rescue
-#- - provide guessmounts with better efficiency and output, go to console, and reboot
-#- - provide install_bootloader which runs lilo from /mnt if it seems safe
-#- - add lsparts to rescue, which prints partitions with detected types
-#-
-#- Revision 1.3 2001/09/07 18:22:54 gc
-#- ext3, xfs, jfs
-#-
-#- Revision 1.2 2001/06/10 22:41:21 prigaux
-#- pixelization (tested!)
-#-
-#- Revision 1.1 2001/06/10 21:08:33 gc
-#- - add 'guessmounts' that mimics RH's detecting of partitions when rescue starts
-#-
-#-
diff --git a/rescue/install_bootloader b/rescue/install_bootloader
index 10812d41f..117b217e2 100755
--- a/rescue/install_bootloader
+++ b/rescue/install_bootloader
@@ -12,46 +12,59 @@
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
#
+use lib qw(/usr/lib/libDrakX);
+use common;
+use bootloader;
+use fs;
-sub cat_ { local *F; open F, $_[0] or $_[1] ? die "cat of file $_[0] failed: $!\n" : return; my @l = <F>; wantarray ? @l : join '', @l }
-sub chomp_ { my @l = map { my $l = $_; chomp $l; $l } @_; wantarray ? @l : $l[0] }
-
-system('guessmounts') and die;
-
-#- this is dangerous, try to take care
-my @mounts = cat_('/proc/mounts');
-grep { (split)[1] =~ m|^/mnt$| } @mounts or die "Your root device isn't mounted on /mnt (according to /proc/mounts)\n";
--x '/mnt/sbin/lilo' or die "/mnt/sbin/lilo isn't executable, exiting.\n";
--r '/mnt/etc/lilo.conf' or die "/mnt/etc/lilo.conf isn't readable, exiting.\n";
-my ($f) = grep { -f $_ } map { "/mnt/etc/$_" } 'mandrakelinux-release', 'mandrake-release';
-$f && cat_($f) =~ /Mandrake/ or die "$f doesn't contain 'Mandrake', exiting.\n";
-
-print "About to re-install Boot Loader of following Mandriva Linux distribution:\n\t",
- chomp_(cat_ "/mnt/etc/mandrake-release"),
- "\n=> ok? <press Enter to continue, 'n' and Enter to cancel> ";
-<STDIN> =~ /^n/i and exit 0;
-
-exec '/mnt/sbin/lilo', '-r', '/mnt';
-
-die "error: couldn't exec /mnt/sbin/lilo.\n";
-
-
-#-------------------------------------------------
-#- $Log$
-#- Revision 1.4 2005/04/19 13:10:25 prigaux
-#- mandriva switch
-#-
-#- Revision 1.3 2004/09/28 06:24:30 prigaux
-#- handle /etc/mandrakelinux-release
-#-
-#- Revision 1.2 2004/07/20 02:42:12 prigaux
-#- MandrakeSoft -> Mandrakesoft
-#-
-#- Revision 1.1 2001/10/24 22:34:01 gc
-#- - add a GUI to the rescue
-#- - provide guessmounts with better efficiency and output, go to console, and reboot
-#- - provide install_bootloader which runs lilo from /mnt if it seems safe
-#- - add lsparts to rescue, which prints partitions with detected types
-#-
-#-
-#-
+my $auto;
+if ($ARGV[0] eq '--auto') {
+ $auto = shift @ARGV;
+}
+
+$::prefix = '/mnt';
+
+my $release = common::mageia_release($::prefix) ||
+ do {
+ system('guessmounts') == 0 or die 'guessmounts failed';
+ common::mageia_release($::prefix);
+ };
+
+if ($release) {
+ $release =~ /Mageia|Mandriva/ or die "release file doesn't contain '%s', exiting.\n";
+} elsif (fs::get::mntpoint2part($::prefix, [ fs::read_fstab('', '/proc/mounts') ])) {
+ die "unknown distribution mounted in $::prefix\n";
+} else {
+ die "Your root device isn't mounted on $::prefix\n";
+}
+
+my @main_methods = bootloader::configured_main_methods();
+
+my $main_method;
+if (@main_methods == 0) {
+ die "Cannot find a configured boot loader\n";
+} elsif (@main_methods == 1) {
+ ($main_method) = @main_methods;
+} else {
+ while (1) {
+ print "Configuration files for Boot Loaders ", join(' and ', @main_methods), " were found.\n";
+ print "Which one one should be installed? ";
+ chomp($main_method = <STDIN>);
+ if (member($main_method, @main_methods)) {
+ last;
+ } else {
+ print "bad choice\n";
+ }
+ }
+}
+
+my $install = $bootloader::{'install_raw_' . $main_method} or die "unknown bootloader method install_raw_$main_method\n";
+
+print "About to re-install Boot Loader $main_method of following %s distribution:\n\t",
+ $release, "\n";
+if (!$auto) {
+ print "=> ok? <press Enter to continue, 'n' and Enter to cancel> ";
+ <STDIN> =~ /^n/i and exit 0;
+}
+
+$install->();
diff --git a/rescue/list b/rescue/list
deleted file mode 100644
index d817c7288..000000000
--- a/rescue/list
+++ /dev/null
@@ -1,157 +0,0 @@
-/bin/bash
-/bin/cat
-/bin/chmod
-/bin/chown
-/bin/cp
-/bin/date
-/bin/dd
-/bin/df
-/bin/dmesg
-/bin/false
-/bin/grep
-/bin/gzip
-/usr/bin/bzip2
-/usr/bin/bunzip2
-/usr/bin/bzcat
-/usr/bin/packdrake
-/usr/bin/parsehdlist
-/bin/hostname
-/bin/kill
-/bin/ln
-/usr/bin/du
-/usr/lib/kbd
-/bin/ls
-/bin/mkdir
-/bin/mknod
-/bin/mount
-/bin/mount
-/bin/mv
-/bin/ping
-/bin/ps
-/bin/pwd
-/bin/rm
-/bin/rmdir
-/bin/setserial
-/sbin/lsmod
-/sbin/lsmod.old
-/bin/cpio
-/usr/bin/diff
-/bin/sh
-/bin/sleep
-/bin/sync
-/bin/touch
-/bin/tar
-/bin/true
-/bin/umount
-/etc/inputrc
-/etc/termcap
-/LIB/libnss_files-*
-/LIB/libnss_files.so.2
-/sbin/badblocks
-/sbin/debugfs
-/sbin/e2fsck
-/sbin/fdisk
-/sbin/fsck.ext2
-/sbin/fsck.ext3
-/sbin/halt
-/sbin/ifconfig
-/sbin/init
-/sbin/insmod
-/sbin/insmod.old
-/sbin/ldconfig
-/sbin/mingetty
-/sbin/mkdosfs
-/sbin/mkfs.ext2
-/sbin/xfs_repair
-/sbin/reboot
-/sbin/rmmod
-/sbin/rmmod.old
-/sbin/shutdown
-/usr/bin/strace
-/sbin/route
-/sbin/mkswap
-/sbin/swapoff
-/sbin/swapon
-/sbin/tune2fs
-/sbin/update
-/usr/bin/cmp
-/usr/bin/cut
-/usr/bin/eject
-/usr/bin/fdformat
-/usr/bin/file
-/usr/bin/find
-/usr/bin/ftp
-/usr/bin/head
-/usr/bin/hexedit
-/usr/bin/less
-/usr/bin/less.bin
-/usr/bin/loadkeys
-/usr/bin/reset
-/usr/bin/split
-/usr/bin/tail
-/usr/bin/tee
-/usr/bin/telnet
-/usr/bin/tset
-/usr/sbin/chroot
-/usr/sbin/parted
-/usr/sbin/partimage
-/usr/share/misc/file/magic
-/usr/share/terminfo/l/linux
-/var/run/utmp
-/sbin/killall5
-/usr/bin/perl
-/usr/bin/perl5
-/usr/bin/perlPERL_VERSION
-/bin/sort
-/usr/bin/md5sum
-/etc/protocols
-/etc/services
-/bin/rpm
-/sbin/mdadm
-/sbin/lvm2
-/usr/lib/rpm/rpmrc
-/usr/lib/rpm/macros
-/usr/lib/rpm/rpmpopt-*
-/usr/bin/rpm2cpio
-/usr/bin/rpmdb
-/usr/lib/rpm/rpmd
-/usr/bin/rpme
-/usr/lib/rpm/rpme
-/usr/bin/rpmi
-/usr/lib/rpm/rpmi
-/usr/bin/rpmu
-/usr/lib/rpm/rpmu
-/usr/bin/rpmquery
-/usr/lib/rpm/rpmq
-/usr/bin/rpmverify
-/usr/lib/rpm/rpmv
-/usr/lib/perl5/PERL_VERSION/AutoLoader.pm
-/usr/lib/perl5/PERL_VERSION/strict.pm
-/usr/lib/perl5/PERL_VERSION/vars.pm
-/usr/lib/perl5/PERL_VERSION/warnings/register.pm
-/usr/lib/perl5/PERL_VERSION/warnings.pm
-/usr/lib/perl5/PERL_VERSION/Carp.pm
-/usr/lib/perl5/PERL_VERSION/Exporter.pm
-/usr/lib/perl5/PERL_VERSION/*-linux/CORE/libperl.so
-/usr/lib/perl5/PERL_VERSION/*-linux/auto/POSIX/autosplit.ix
-/usr/lib/perl5/PERL_VERSION/*-linux/auto/POSIX/load_imports.al
-/usr/lib/perl5/PERL_VERSION/*-linux/auto/POSIX/POSIX.so
-/usr/lib/perl5/PERL_VERSION/*-linux/POSIX.pm
-/usr/lib/perl5/PERL_VERSION/*-linux/XSLoader.pm
-/usr/lib/perl5/vendor_perl/*/packdrake.pm
-/usr/lib/perl5/vendor_perl/*/Packdrakeng.pm
-/usr/bin/lspci
-/usr/share/pci.ids
-/usr/bin/lspcidrake
-/usr/share/ldetect-lst/pcitable
-/usr/share/ldetect-lst/usbtable
-/bin/vim-minimal
-/LIB/libnss_dns.so.2
-/LIB/libresolv.so.2
-/LIB/ld-linux*.so.2
-/bin/mt
-/sbin/stinit
-/usr/bin/rsync
-/usr/bin/ssh
-/usr/bin/scp
-/etc/ssh/ssh_config
diff --git a/rescue/list.alpha b/rescue/list.alpha
deleted file mode 100644
index af48e87a9..000000000
--- a/rescue/list.alpha
+++ /dev/null
@@ -1 +0,0 @@
-/sbin/sfdisk
diff --git a/rescue/list.i386 b/rescue/list.i386
deleted file mode 100644
index 2ede95622..000000000
--- a/rescue/list.i386
+++ /dev/null
@@ -1,15 +0,0 @@
-/usr/bin/gpart
-/sbin/resize2fs
-/sbin/resize_reiserfs
-/sbin/rescuept
-/usr/sbin/grub
-/usr/sbin/grub-install
-/usr/sbin/dmidecode
-/sbin/reiserfsck
-/sbin/fsck.jfs
-/sbin/fsck.xfs
-/sbin/xfs_repair
-/sbin/sfdisk
-/boot/grub/stage[12]
-/usr/lib/extipl/aldebaran.bin
-/usr/sbin/ntfsresize
diff --git a/rescue/list.ia64 b/rescue/list.ia64
deleted file mode 100644
index 42bb9b75b..000000000
--- a/rescue/list.ia64
+++ /dev/null
@@ -1,7 +0,0 @@
-/sbin/resize2fs
-/sbin/mkreiserfs
-/sbin/reiserfsck
-/usr/sbin/fsck.xfs
-/usr/sbin/xfs_repair
-/sbin/sfdisk
-/usr/sbin/efibootmgr
diff --git a/rescue/list.ppc b/rescue/list.ppc
deleted file mode 100644
index f5709ca64..000000000
--- a/rescue/list.ppc
+++ /dev/null
@@ -1,13 +0,0 @@
-/sbin/resize2fs
-/sbin/resize_reiserfs
-/sbin/mkreiserfs
-/sbin/reiserfsck
-/sbin/xfs_repair
-/sbin/pdisk
-/usr/sbin/ybin
-/usr/sbin/mkofboot
-/usr/lib/yaboot/ofboot
-/usr/lib/yaboot/yaboot
-/usr/sbin/ofpath
-/sbin/nvsetenv
-/usr/bin/hformat
diff --git a/rescue/list.sparc b/rescue/list.sparc
deleted file mode 100644
index 2eff55cec..000000000
--- a/rescue/list.sparc
+++ /dev/null
@@ -1,2 +0,0 @@
-/sbin/silo
-/sbin/sfdisk
diff --git a/rescue/list.x86_64 b/rescue/list.x86_64
deleted file mode 100644
index 33e1153dd..000000000
--- a/rescue/list.x86_64
+++ /dev/null
@@ -1,18 +0,0 @@
-/usr/bin/gpart
-/sbin/resize2fs
-/sbin/resize_reiserfs
-/sbin/rescuept
-/usr/sbin/grub
-/usr/sbin/grub-install
-/sbin/mkreiserfs
-/sbin/reiserfsck
-/sbin/fsck.xfs
-/sbin/xfs_repair
-/sbin/sfdisk
-/boot/grub/stage[12]
-/lib/libnss_files-*
-/lib/libnss_files.so.2
-/lib/libnss_dns.so.2
-/lib/libresolv.so.2
-/lib/ld-linux*.so.2
-/lib/libdevmapper.so.*
diff --git a/rescue/list.xml b/rescue/list.xml
new file mode 100644
index 000000000..3bf73d1fa
--- /dev/null
+++ b/rescue/list.xml
@@ -0,0 +1,372 @@
+<list no-arch-libraries="on">
+
+<from expand="binary">
+ bash sh
+
+ false true
+ pwd reset
+
+ ls
+ cp ln mkdir mknod mv rm rmdir
+ chmod chown
+ dd touch
+
+ cat less
+ tail head tee
+ sort split cut
+ grep
+
+ cmp diff
+ find
+ file md5sum
+
+ gzip zcat gunzip xz
+ bzip2 bunzip2 bzcat
+
+ df du
+
+ packdrake
+ cpio ftp tar
+ rsync
+ ssh scp
+ telnet
+ host
+
+ date
+ dmesg
+ chroot
+ sleep
+ sync
+
+ eject
+ mount mount.nfs umount
+ losetup
+
+ ldconfig
+ mingetty agetty
+ reboot halt shutdown
+ kill killall5 ps strace
+ sed tr
+ strings
+
+ loadkeys tset stty
+
+ ping hostname ifconfig route
+
+ fdformat badblocks
+ mkswap swapoff swapon
+ e2fsck fsck.ext2 fsck.ext3 fsck.ext4
+ mke2fs mkfs.ext2 mkfs.ext3 mkfs.ext4
+ dumpe2fs tune2fs resize2fs debugfs
+
+ mkfs.reiserfs resize_reiserfs reiserfstune reiserfsck
+ mkfs.xfs xfs_admin xfs_repair fsck.xfs
+ mkfs.ntfs mkdosfs dosfslabel mkntfs ntfsresize ntfslabel
+ mkfs.nilfs2 nilfs-tune
+
+ btrfs btrfsck btrfs-convert btrfsctl btrfs-debug-tree
+ btrfs-map-logical btrfs-show btrfs-vol mkfs.btrfs fsck.btrfs
+
+ dropbear dropbearkey
+ screen
+
+ gdisk
+
+ <if ARCH="i.86|x86_64">
+ mkfs.jfs fsck.jfs jfs_tune
+ </if>
+ quotacheck
+ cryptsetup dmsetup
+
+ <if ARCH="ppc">
+ hformat
+ </if>
+
+ <if-not ARCH="ppc">
+ fdisk gpart
+ testdisk photorec
+ </if-not>
+
+ <if-not ARCH="ppc|sparc">
+ sfdisk
+ </if-not>
+
+ <if ARCH="ppc">
+ pdisk
+ </if>
+ dump dump.ext2 restore restore.ext2 dump.ext3 restore.ext3 dump.xfs restore.xfs
+ parted partimage partprobe
+
+ udevadm
+
+ mdadm lvm2
+ mdmon kpartx
+ dmevent_tool
+ dmeventd
+ <if ARCH="i.86|x86_64|ia64">
+ dmraid
+ </if>
+
+ lsmod
+ insmod
+ rmmod
+
+ setserial
+ mt stinit
+
+ lspci lspcidrake
+
+ rpm
+ rpm2cpio rpmdb
+ rpmquery rpmverify
+
+ vim-minimal hexedit
+
+ perl
+ uniq
+ wget
+
+ awk clear dialog wc
+ setterm
+
+ <if ARCH="i.86|x86_64|ia64">
+ dmidecode
+ </if>
+
+ <if ARCH="i.86|x86_64">
+ grub grub-install
+ </if>
+ <if ARCH="ia64">
+ efibootmgr
+ </if>
+ <if ARCH="ppc">
+ ybin
+ mkofboot ofpath
+ nvsetenv
+ </if>
+ <if ARCH="sparc">
+ silo
+ </if>
+</from>
+
+<from dir="/usr/LIB/drakx-installer-sysvinit/" expand="glob">
+ <to dir="/sbin">
+ init
+ </to>
+</from>
+
+<from>
+ /usr/lib/kbd/keymaps/include
+ <if ARCH="i.86|x86_64">
+ /usr/lib/kbd/keymaps/i386/include
+ /usr/lib/kbd/keymaps/i386/azerty/be-latin1.map.gz <!-- this one is needed by be2-latin1 -->
+ </if>
+ /usr/share/misc/magic.mgc
+ /usr/share/terminfo/l/linux
+ /usr/share/terminfo/s/screen
+ /usr/share/pci.ids
+ /var/run/utmp
+
+ <if ARCH="i.86|x86_64">
+ <from dir="/lib/grub/ARCH-mageia" expand="glob">
+ stage1
+ stage2
+ *_stage1_5
+ </from>
+ /usr/lib/extipl/aldebaran.bin
+ </if>
+
+ <if ARCH="ppc">
+ /usr/lib/yaboot/ofboot
+ /usr/lib/yaboot/yaboot
+ </if>
+
+ <from expand="command">
+ perl -Mkeyboard -I/usr/lib/libDrakX -le 'print foreach keyboard::loadkeys_files()'
+ </from>
+
+ <if set="LANGUAGE_fr_FR">
+ /usr/lib/gconv/gconv-modules
+ /usr/lib/gconv/ISO8859-15.so
+ /usr/share/locale/ISO-8859-15
+ /usr/share/locale/fr_FR
+ /usr/share/locale/fr/LC_MESSAGES/partimage.mo
+ </if>
+ <if set="LANGUAGE_pt_BR">
+ /usr/lib/gconv/gconv-modules
+ /usr/lib/gconv/ISO8859-15.so
+ /usr/share/locale/ISO-8859-15
+ /usr/share/locale/pt_BR
+ /usr/share/locale/pt/LC_MESSAGES/partimage.mo
+ </if>
+ <!-- needed by mlabel used during Flash upgrades -->
+ /usr/lib/gconv/IBM850.so
+
+
+ /sbin/mount.ntfs-3g <!-- can not be expanded as binary, not executable for all users -->
+ /sbin/blkid
+</from>
+
+<from dir="/usr/lib/rpm" expand="glob">
+ <mode copy="keep-links">
+ rpmrc
+ macros
+ rpmpopt-*
+ </mode>
+</from>
+
+<filter subst="/^__END__/ and $_ = '', close ARGV">
+<from expand="main-perl">
+ AutoLoader.pm
+ strict.pm
+ vars.pm
+ warnings/register.pm
+ warnings.pm
+ Carp.pm
+ Exporter.pm
+ File/Path.pm
+ File/Basename.pm
+ ARCH-linux-thread-multi/re.pm
+ ARCH-linux-thread-multi/Cwd.pm
+ ARCH-linux-thread-multi/auto/Cwd/Cwd.so
+ ARCH-linux-thread-multi/CORE/libperl.so
+ ARCH-linux-thread-multi/auto/POSIX/POSIX.so
+ ARCH-linux-thread-multi/POSIX.pm
+ XSLoader.pm
+ ARCH-linux-thread-multi/lib.pm
+ ARCH-linux-thread-multi/Socket.pm
+ ARCH-linux-thread-multi/IO/Socket.pm
+ ARCH-linux-thread-multi/IO.pm
+ ARCH-linux-thread-multi/IO/Handle.pm
+ ARCH-linux-thread-multi/Encode/Symbol.pm
+ Symbol.pm
+ SelectSaver.pm
+ ARCH-linux-thread-multi/DynaLoader.pm
+ ARCH-linux-thread-multi/auto/IO/IO.so
+ ARCH-linux-thread-multi/auto/Socket/Socket.so
+ ARCH-linux-thread-multi/Errno.pm
+ ARCH-linux-thread-multi/IO/Socket/INET.pm
+ ARCH-linux-thread-multi/IO/Socket/UNIX.pm
+</from>
+<from expand="perl">
+ packdrake.pm
+ MDV/Packdrakeng.pm
+</from>
+</filter>
+
+<from dir="/etc">
+ mke2fs.conf
+ netconfig
+ inputrc
+ termcap
+ protocols
+ services
+ shells
+ ssh/ssh_config
+</from>
+
+<from dir="/usr/lib/systemd">
+ systemd-udevd
+</from>
+
+<from dir="/lib/udev/rules.d">
+ 10-dm.rules
+ 11-dm-lvm.rules
+ 13-dm-disk.rules
+ 64-md-raid.rules
+ 65-md-incremental.rules
+ 95-dm-notify.rules
+</from>
+
+
+<filter command="strip">
+ <!-- 32bit grub needs 32 bit loader -->
+ <if ARCH="x86_64">
+ <from dir="/lib">
+ ld-linux*.so.2
+ </from>
+ </if>
+<from dir="/LIB">
+ libnss_files.so.2
+ libnss_dns.so.2
+ libresolv.so.2
+ ld-linux*.so.2
+ <!-- needed for mount.ntfs-3g -->
+ libfuse.so.2
+
+ <!-- needed by dmraid -->
+ libdmraid-events-isw.so
+</from>
+</filter>
+
+<from dir="/usr/share/ldetect-lst" expand="glob">
+ *table.gz
+ dkms-modules.alias fallback-modules.alias
+</from>
+
+<from dir="/lib/module-init-tools">
+ ldetect-lst-modules.alias
+</from>
+
+<filter command="../tools/simplify-drakx-modules">
+ <from dir="." expand="collect-perl-files /usr/lib/libDrakX /usr/lib/libDrakX">
+ <to dir="/usr/bin">
+ rescue-doc drvinst lsparts
+ guessmounts install_bootloader
+ <if ARCH="i.86|x86_64">
+ restore_ms_boot
+ </if>
+ </to>
+ <to dir="/usr/sbin">
+ partimage_whole_disk
+ </to>
+ </from>
+ <from dir="/usr/lib/libDrakX" expand="glob">
+ raid.pm <!-- required when needed in guessmounts -->
+ fs/remote.pm <!-- required by fs::remote::* -->
+ fs/remote/davfs.pm <!-- required by fs -->
+ fs/remote/smb.pm <!-- required by fs -->
+ fs/dmraid.pm <!-- required by fsedit -->
+ partition_table/*.pm <!-- required by partimage_whole_disk -->
+ </from>
+</filter>
+
+<from dir="/usr/LIB/drakx-installer-binaries">
+ <to dir="/usr/bin">
+ rescue-gui
+ </to>
+ <to dir="/usr/sbin">
+ dhcp-client
+ </to>
+</from>
+<from dir=".">
+ <to dir="/usr/sbin">
+ diskdrake-resize
+ genpasswd
+ startssh
+ </to>
+ <to dir="/usr/sbin">
+ restore-image.sh
+ </to>
+ <to dir="/usr/lib">
+ restore-image-lib.sh
+ </to>
+</from>
+<if set="RESCUE_FLASH">
+ <from expand="binary">
+ dirname
+ losetup
+ mlabel
+ nash
+ pv
+ sed
+ usleep
+ </from>
+ <from dir="Flash/scripts" expand="glob">
+ <to dir="/usr/bin">
+ *
+ </to>
+ </from>
+</if>
+
+</list>
diff --git a/rescue/lsparts b/rescue/lsparts
index 8dff460d2..8d36a02f4 100755
--- a/rescue/lsparts
+++ b/rescue/lsparts
@@ -1,6 +1,6 @@
#!/usr/bin/perl
#
-# Main author Pascal Rigaux (pixel@mandriva.com)
+# Main author Pascal Rigaux (pixel)
# Put together by Guillaume Cottenceau
#
# Copyright 1999-2005 Mandriva
@@ -16,10 +16,10 @@
# Detects partition types using signatures
#
-use lib qw(../perl-install /usr/lib/libDrakX);
+use lib qw(/usr/lib/libDrakX);
use common;
-use devices;
use fs::type;
+use fs::proc_partitions;
my $params = join '', @ARGV;
my $verbose = $params =~ /-v/;
@@ -27,7 +27,7 @@ my $verbose = $params =~ /-v/;
$params =~ /-h/ and die "usage: lsparts [-v]\n";
-foreach (devices::read_proc_partitions_raw()) {
+foreach (fs::proc_partitions::read_raw()) {
if (my $err = $_->{size} <= 1 ?
"Skipping <$_->{dev}> because too little blocks ($_->{size})" :
$_->{dev} !~ /\d$/ ?
diff --git a/rescue/make_flash_rescue b/rescue/make_flash_rescue
new file mode 100755
index 000000000..b439b9adc
--- /dev/null
+++ b/rescue/make_flash_rescue
Binary files differ
diff --git a/rescue/make_partimage_save_rest_all b/rescue/make_partimage_save_rest_all
index d91bfd3ec..929ffd2c1 100755
--- a/rescue/make_partimage_save_rest_all
+++ b/rescue/make_partimage_save_rest_all
@@ -1,38 +1,37 @@
#!/bin/sh
-[ $# != 1 -a $# != 2 -a $# != 3 ] && {
- echo "usage: make_partimage_save_rest_all <partimage special rpm> [<partimage dir> [</data/box>]]" ;
+[ $# -lt 1 ] && {
+ echo "usage: make_partimage_save_rest_all <partimage server> [<partimage dir> <data dirs>]" ;
exit 1
}
-rpm=$1
-partimage_dir=$2
-local_where=$3
-
-where=/data/box
-[ -z "$local_where" ] && local_where=$where
+server=$1 ; shift
+partimage_dir=$1 ; shift
+data_dir=$1 ; shift
if [ -n "$partimage_dir" ]; then
- [ -d "$partimage_dir$local_where" ] || {
- echo "can't find $partimage_dir$local_where"
+ first_data_dir="$partimage_dir$data_dir"
+
+ [ -d "$first_data_dir" ] || {
+ echo "can't find $first_data_dir"
exit 1
}
- [ -r "$partimage_dir$local_where/lst" ] || {
- echo "can't read $partimage_dir$local_where/*"
+ [ -r "$first_data_dir/lst" ] || {
+ echo "can't read $first_data_dir/*"
exit 1
}
fi
rm -rf .tmp
mkdir -p .tmp/isolinux
-cp -f /usr/lib/syslinux/isolinux.bin ../isolinux/alt0/* .tmp/isolinux
+cp -f /usr/lib/syslinux/isolinux.bin ../images/isolinux/alt0/* .tmp/isolinux
-PARTIMAGE_DIR="$where" PARTIMAGE_RPM=$rpm DISTRIB_DESCR="partimage save/restore all" ./make_rescue_img
+DISTRIB_DESCR="partimage save/restore all" ./make_rescue_img || exit 1
mkdir -p .tmp/install/stage2
-mv -f rescue.clp .tmp/install/stage2
+mv -f rescue.sqfs .tmp/install/stage2
-common_para="rescue acpi=ht automatic=method:cdrom"
-# hda=4864,255,63
+common_para="rescue automatic=method:cdrom"
+# hda=4864,255,63 acpi=ht
for action in save_all rest_all; do
@@ -43,21 +42,22 @@ timeout 150
label save_all
kernel vmlinuz
- append initrd=all.rdz $common_para save_all
+ append initrd=all.rdz $common_para save_all pserver=$server
label rest_all
kernel vmlinuz
- append initrd=all.rdz $common_para rest_all keepmounted
+ append initrd=all.rdz $common_para rest_all keepmounted BOX=$data_dir pserver=$server
label rescue
kernel vmlinuz
append initrd=all.rdz $common_para
EOF
- if [ $action = rest_all ]; then
- mkdir -p .tmp$where
- ln -s $partimage_dir$local_where/* .tmp$where
+ if [ $action = rest_all -a -n "$partimage_dir" ]; then
+ dir=`dirname $data_dir`
+ mkdir -p .tmp$dir
+ ln -s $partimage_dir$data_dir .tmp$dir
fi
- mkisofs -f -o part_$action.iso -r -J -hide-rr-moved -nobak -cache-inodes -publisher Mandrakesoft -V 'mdk part save/rest' -b isolinux/isolinux.bin -c isolinux/boot.cat -no-emul-boot -boot-load-size 4 -boot-info-table .tmp
+ genisoimage -f -o part_$action.iso -r -J -hide-rr-moved -nobak -cache-inodes -publisher Mageia -V 'part save/rest' -b isolinux/isolinux.bin -c isolinux/boot.cat -no-emul-boot -boot-load-size 4 -boot-info-table .tmp
mkcd --addmd5 part_$action.iso
done
diff --git a/rescue/make_rescue_img b/rescue/make_rescue_img
index db046625b..fa5342f1f 100755
--- a/rescue/make_rescue_img
+++ b/rescue/make_rescue_img
@@ -1,16 +1,13 @@
#!/usr/bin/perl
use MDK::Common;
-use lib "../perl-install";
+use lib "/usr/lib/libDrakX";
use keyboard;
-my $lib = (arch() =~ /x86_64/ ? "lib64" : "lib");
my $tmp = "/tmp/rescue_tmp";
-my $rescue = "rescue.clp";
+my $rescue = "rescue.sqfs";
-my $sudo = '';
if ($>) {
- $sudo = "sudo";
$ENV{PATH} = "/sbin:/usr/sbin:$ENV{PATH}";
}
@@ -18,142 +15,50 @@ BEGIN { undef *_ }
sub __ { print @_, "\n"; system(@_) }
sub _ { __ @_; $? and die }
-sub install_raw {
- s|^/|| foreach @_;
- _ "tar c -C / @_ | tar x -C $tmp" if @_;
-}
-sub install_deref {
- s|^/|| foreach @_;
- _ "tar c -C / --dereference @_ | tar x -C $tmp" if @_;
-}
-
-sub install_l {
- my @l = @_;
-
- @l = uniq(map { chomp_($_) } @l);
- push @l,
- `ldd @l 2>/dev/null | grep "=>" | perl -pe 's/.*=> //; s/ .*//; s,^/(lib|lib64)/.*?/,/\\1/,'`;
-
- my ($deref, $raw) = partition { /lib.*\.so/ || readlink("/$_") =~ m|/etc/alternatives| } uniq(map { chomp_($_) } @l);
- install_raw(@$raw);
- install_deref(@$deref);
-}
-
-sub installown($$) {
- my ($own, $dir) = @_;
- return if -e "$tmp$dir/" . basename($own);
- mkdir_p("$tmp$dir");
- _ "cp $own $tmp$dir";
-}
-
-sub install_perl_script {
- my ($script, $dir) = @_;
- my @gi_modules;
- foreach (`../tools/get-needed-drakx-modules ../perl-install /usr/lib/libDrakX $script`) {
- chomp;
- my ($local, $dest) = split "\t";
- installown($local, dirname($dest || $local));
- push @gi_modules, "$tmp$dest" if $dest;
- }
- installown($script, $dir);
- system('../tools/simplify-drakx-modules', @gi_modules, "$tmp$dir/$script");
-}
-
-_ "$sudo rm -rf $tmp" if -e $tmp;
+_ "rm -rf $tmp" if -e $tmp;
_ "mkdir $tmp";
_ 'find . -name "*~" | xargs rm -f';
-foreach (cat_("dirs")) {
- chomp;
- mkdir_p("$tmp$_");
-}
+mkdir_p($tmp . chomp_($_)) foreach cat_("dirs");
_ "cp -a tree/* $tmp";
-_ "find $tmp -name 'CVS*' | xargs rm -rf";
-_ "perl devices.pl $tmp/dev";
+# / -> /usr move
+foreach (qw(bin sbin)) {
+ rename("$tmp/$_", "$tmp/usr/$_");
+ symlinkf("usr/$_", "$tmp/$_");
+}
+_ "find $tmp -name .svn | xargs rm -rf";
substInFile { s/DISTRIB_DESCR/$ENV{DISTRIB_DESCR}/ } "$tmp/etc/issue";
-install_raw(keyboard::loadkeys_files());
+_ "../tools/install-xml-file-list list.xml $tmp";
+
my %keytable_conflicts;
-my @less_important_keytables = qw(am_old am_phonetic no-dvorak fr_CH-latin1);
-foreach (keyboard::loadkeys_files()) {
+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 =~ /(.*)\.kmap\.gz/ or next;
+ my ($name) = $fname =~ /(.*)\.map\.gz/ or next;
next if member($name, @less_important_keytables);
- if (my ($short) = $name =~ m|(.+?)[\W_]|) {
+ 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.kmap.gz");
+ symlinkf($fname, "$tmp$dir/$short.map.gz");
}
}
-my $perl_version = join ".", unpack "C3", $^V;
-my @bad;
-my @files = map {
- chomp;
- s/PERL_VERSION/$perl_version/g;
- s|/LIB/|/$lib/|g;
- my @l = glob($_) or push @bad, $_;
- m|\*.*/| && @l != 1 and die "multiple match for $_\n";
- @l;
-} (cat_("list"), cat_(`../tools/specific_arch list`));
-@bad and die "files missing\n" . join("\n", @bad) . "\n";
-install_l(@files);
-
foreach (cat_("aliases")) {
chomp; my ($f, $dest) = split;
symlink $dest, "$tmp$f";
}
--e "../kernel/all.kernels" or die "use ./update_kernel in gi/kernel first\n";
-
-my $main = chomp_(`cat ../kernel/all.kernels/.main`);
-
-_ "cp ../kernel/all.kernels/$main/modules.{cz,dep} $tmp/modules";
-
-installown("drvinst", "/usr/bin");
-install_perl_script("guessmounts", "/usr/bin");
-install_perl_script("install_bootloader", "/usr/bin");
-if (arch() =~ /^i.86|x86_64/) {
- install_perl_script("restore_ms_boot", "/usr/bin");
-}
-install_perl_script("lsparts", "/usr/bin");
-installown("rescue-doc", "/usr/bin");
-_ "cd ../mdk-stage1 && make rescue-gui dhcp-client";
-installown("../mdk-stage1/rescue-gui", "/usr/bin");
-installown("../mdk-stage1/dhcp-client", "/usr/sbin");
-
-#- note that on biarch systems, we may need to have both /lib and /lib64
-__ "strip $tmp/{lib,$lib,bin,sbin}/* $tmp/usr/{bin,sbin}/* 2>/dev/null";
-
-if ($ENV{PARTIMAGE_DIR}) {
-
- install_perl_script('partimage_whole_disk', '/usr/sbin');
- _ "rpm2cpio $ENV{PARTIMAGE_RPM} | (cd $tmp ; cpio -idu ./usr/sbin/partimage)";
- my $server = 'partimaged';
- $server = 'leia';
+if (my ($LANGUAGE) = map { if_(/LANGUAGE_(.*)/, $1) } keys %ENV) {
substInFile {
- $_ = <<EOF if /^\s*rescue-gui/;
- if grep -q save_all /proc/cmdline; then
- drvinst NETWORK ; dhcp-client ; partimage_whole_disk save_all $ENV{PARTIMAGE_DIR} $server
- echo "Press enter"
- read
- fi
- if grep -q rest_all /proc/cmdline; then
- local=/tmp/image$ENV{PARTIMAGE_DIR}
- if [ -d \$local ]; then
- partimage_whole_disk rest_all \$local
- else
- drvinst NETWORK ; dhcp-client ; partimage_whole_disk rest_all $ENV{PARTIMAGE_DIR} $server
- fi
- echo "Press enter"
- read
- fi
-EOF
+ $_ = "export LANGUAGE=$LANGUAGE\n" . "export LC_ALL=$LANGUAGE\n" if /^#LANGUAGE/;
} "$tmp/etc/rc.sysinit";
}
exit 0 if $ARGV[0];
-_ "mkisofs -quiet -D -R $tmp | create_compressed_fs - 65536 $rescue 200 2>/dev/null";
-_ "$sudo rm -rf $tmp";
+_ "mksquashfs $tmp $rescue -all-root -noappend >/dev/null";
+_ "chmod 755 $rescue";
+_ "rm -rf $tmp";
diff --git a/rescue/partimage_whole_disk b/rescue/partimage_whole_disk
index 309883d36..ed0653a95 100755
--- a/rescue/partimage_whole_disk
+++ b/rescue/partimage_whole_disk
@@ -1,71 +1,136 @@
#!/usr/bin/perl
-use lib qw(/usr/lib/libDrakX ../perl-install);
+use lib qw(/usr/lib/libDrakX);
use standalone;
use fsedit;
use fs::format;
use fs::type;
use resize_fat::main;
use diskdrake::resize_ntfs;
+use diskdrake::resize_ext2;
use common;
use partition_table::empty;
use Carp::Heavy;
-#- help getting the file in make_rescue_img
-BEGIN { partition_table::raw::default_type() }
+my %options = (
+ save_home_directory => 1,
+ empty_space_at_end_of_disk => 0, # 300 * 1024 * 2, # 300MB
+ ask_before_modifying_home => 1,
+ bzip2 => 1,
+);
-my ($action, $dir, $server) = @ARGV;
+my ($server);
+if ($ARGV[0] eq '-s') {
+ (undef, $server, @ARGV) = @ARGV;
+}
+my $action = shift @ARGV;
-sub usage() { die "partimage_whole_disk <save_all | rest_all> <dir> [<server>]\n" }
-@ARGV == 2 || @ARGV == 3 or usage();
+sub usage() { die "partimage_whole_disk [-s <server>] (save_all <dir> | rest_all <dir>)\n" }
$ENV{PATH} = "/sbin:/usr/sbin:$ENV{PATH}";
+$ENV{HOME} = '/';
log::openLog("/var/log/partimage_whole_disk.log");
-my @partimage_cmd = ('partimage', if_($server, '-s', $server));
+my @partimage_cmd = ('partimage', if_($server, '-s', $server, '-n', '-L'));
+
+@ARGV == 1 or usage();
+
+if ($server && !is_network_configured()) {
+ run_program::run('drvinst', 'NETWORK');
+ run_program::run('dhcp-client');
+}
+
+run_program::run('drvinst', 'STORAGE_SCSI', 'STORAGE_IDE');
+
my $all_hds = fsedit::get_hds({});
if ($action eq 'save_all') {
- save_all();
+ save_all($ARGV[0]);
} elsif ($action eq 'rest_all') {
- rest_all();
-} else {
- usage();
+ rest_all($ARGV[0]);
}
-sub save_all() {
+sub save_all {
+ my ($dir) = @_;
+
+ my $base_dir = $dir;
+ for (my $i = 0; read_part_list($dir); $i++) {
+ #- find a free dir
+ $dir = sprintf("$base_dir.%03d", $i);
+ }
+
my $hd = $all_hds->{hds}[0] or die "no main hard drive\n";
log::l("save_all on $hd->{device}");
my $part_list = [ partition_table::get_normal_parts($hd) ];
foreach (@$part_list) {
- $_->{saved} = !member($_->{fs_type}, 'ntfs', 'vfat', 'swap');
- if ($_->{saved}) {
- run_or_die(@partimage_cmd,
- '-V', 0, '--nombr', '--nodesc', '--nocheck', '-b', '-o',
- 'save', devices::make($_->{device}), "$dir/$_->{device}");
- }
+ $_->{saved} = !member($_->{fs_type}, 'ntfs', 'ntfs-3g', 'vfat', 'swap');
}
- save_part_list($part_list);
+
+ if (!$options{save_home_directory}) {
+ #- shrink and don't save the last ext3 partition (which is the /home partition)
+ if (my $part = find { isTrueLocalFS($_) } reverse @$part_list) {
+ $part->{size} = min($part->{size}, 1024 * 1024 * 2); # not greater than 1GB
+ $part->{saved} = 0;
+ }
+ }
+
+ foreach (grep { $_->{saved} } @$part_list) {
+ run_or_die(@partimage_cmd,
+ if_($options{bzip2}, '-z', 2),
+ '-V', 0, '--nombr', '--nodesc', '--nocheck', '-b', '-o',
+ 'save', devices::make($_->{device}), "$dir/$_->{device}");
+ }
+ save_part_list($dir, $hd->{geom}, $part_list);
}
-sub rest_all() {
- my $part_list = read_part_list();
- fs::type::set_fs_type($_, $_->{fs_type}) foreach @$part_list;
-
- my @used_hds;
- foreach my $part (@$part_list) {
- if (my $hd = find { $part->{device} =~ /^\Q$_->{device}\E./ } fs::get::hds($all_hds)) {
- push @used_hds, $hd;
- put_in_hash($part, partition_table::hd2minimal_part($hd));
+sub rest_all {
+ my ($dir) = @_;
+
+ my ($forced_geom, $part_list) = read_part_list($dir) or error("read_part_list $dir failed");
+
+ (my $hd) = my @used_hds = uniq(map {
+ my $part = $_;
+ find { $part->{device} =~ /^\Q$_->{device}\E./ } fs::get::hds($all_hds)
+ or error("can't find hard drive for partition $part->{device}");
+ } @$part_list);
+
+ @used_hds >= 1 or error("no matching hd");
+ @used_hds <= 1 or error("multiple hds: " . join(' ', map { $_->{device} } @used_hds));
+
+ fs::type::set_fs_type($_, $_->{fs_type}) foreach @$part_list;
+ put_in_hash($_, partition_table::hd2minimal_part($hd)) foreach @$part_list;
+
+ my ($from_partimage, $other) = partition { $_->{saved} } @$part_list;
+ my ($from_resize, $created) = partition { member($_->{fs_type}, 'vfat', 'ntfs', 'ntfs-3g') } @$other;
+
+ my $total = sum(map { $_->{size} } @$part_list);
+ if ($total > $hd->{totalsectors}) {
+ error("$dir doesn't fit: $total > $hd->{totalsectors}");
}
- }
- my ($from_partimage, $other) = partition { $_->{saved} } @$part_list;
- my ($from_resize, $created) = partition { member($_->{fs_type}, 'vfat', 'ntfs') } @$other;
foreach (@$from_resize) {
#- resize first
- my $part = fs::get::device2part($_->{device}, [ fs::get::fstab($all_hds) ]) or log::l("partition to resize is missing ($_->{device})"), next;
- $_->{fs_type} eq $_->{fs_type} or log::l("partition $_->{device} doesn't have the right filesystem ($part->{fs_type} != $_->{fs_type})"), next;
+ my $part = fs::get::device2part($_->{device}, [ fs::get::fstab($all_hds) ]);
+ if (!$part) {
+ log::l("partition to resize is missing ($_->{device})");
+ $_->{missing} = 1;
+ next;
+ }
+ if ($part->{fs_type} ne $_->{fs_type}) {
+ log::l("partition $_->{device} doesn't have the right filesystem ($part->{fs_type} != $_->{fs_type})");
+ $_->{missing} = 1;
+ next;
+ }
+
+ if (@$from_resize == 1) {
+ my $half_size = int($hd->{totalsectors} / 2) - 2 * $hd->cylinder_size;
+ my $suggested_total = $total - $_->{size} + $half_size;
+ log::l("resizing bigger? (size $_->{size}, half_size $half_size, total $total, suggested_total $suggested_total)");
+ if ($half_size > $_->{size} && $suggested_total < $hd->{totalsectors}) {
+ log::l("prefering to resize $_->{device} to size $half_size instead of $_->{size}");
+ $_->{size} = $half_size;
+ }
+ }
$_->{start} = $part->{start};
if ($_->{size} < $part->{size}) {
@@ -74,65 +139,126 @@ sub rest_all() {
my $resize = $resize_pkg->new($_->{device}, devices::make($_->{device}));
$resize->resize($_->{size});
} else {
- log::l("no need to resize $_->{device} since $_->{size} >= $part->{size}");
+ log::l("no need to resize, instead setting $_->{device}'s size to $part->{size} instead of $_->{size}");
+ $_->{size} = $part->{size};
}
}
- foreach my $hd (uniq(@used_hds)) {
-# put_in_hash($hd->{geom}, { heads => 240, sectors => 63 });
+ put_in_hash($hd->{geom}, $forced_geom);
+ log::l("totalsectors $hd->{totalsectors} heads $hd->{geom}{heads} sectors $hd->{geom}{sectors}");
+ partition_table::raw::compute_nb_cylinders($hd->{geom}, $hd->{totalsectors});
+
+ #- grow the last ext3 partition
+ if (my $part = find { isTrueLocalFS($_) } reverse @$part_list) {
+ $part->{ratio} = 1;
+
+ if ($options{ask_before_modifying_home}) {
+ print "\nkeep existing /home? (Y/n) ";
+ if (<STDIN> !~ /n/i) {
+ my $l = @$from_partimage > 1 ? $from_partimage : $created;
+ #- it was meant to be restored or formatted
+ my $p = pop @$l;
+ log::l("keeping existing /home: removing $p->{device}");
+ }
+ }
+ }
- #- write the partition table
- partition_table::raw::zero_MBR($hd);
- foreach my $part (grep { $_->{rootDevice} eq $hd->{device} } @$part_list) {
+ #- write the partition table
+ partition_table::raw::zero_MBR($hd);
+ foreach my $part (grep { $_->{rootDevice} eq $hd->{device} } @$part_list) {
+ next if $part->{missing};
- my $hole = find { isEmpty($_) && $_->{size} >= $part->{size} } partition_table::get_normal_parts_and_holes($hd) or die "not enough room";
- $part->{start} = $hole->{start};
+ my $hole = find { isEmpty($_) && $_->{size} >= $part->{size} } partition_table::get_normal_parts_and_holes($hd) or die "not enough room for $part->{device}";
+ $part->{start} = $hole->{start};
- log::l("handling $part->{device}");
- my $extended = $part->{device} =~ /(\d+)$/ && $1 > 4 && $hd->hasExtended;
+ log::l("handling $part->{device}");
+ my $extended = $part->{device} =~ /(\d+)$/ && $1 > 4 && $hd->hasExtended;
- my %wanted_part = %$part;
- if ($extended || $part->{start} == 1) {
- $part->{size} += $hd->{geom}{sectors};
- }
- partition_table::add($hd, $part, $extended && 'Extended');
- foreach ('device', 'size') {
- $part->{$_} eq $wanted_part{$_} or log::l("bad $_ for $part->{device}: $part->{$_} != $wanted_part{$_}");
- }
+ my %wanted_part = %$part;
+ if ($part->{ratio}) {
+ $part->{size} = $hole->{size} - ($options{empty_space_at_end_of_disk} || 0);
+ } else {
+ $part->{size} += $hd->{geom}{sectors} if $extended;
+ $part->{size} += $hd->cylinder_size if $part->{start} == 1;
+ }
+ log::l("adding $part->{device} with size $part->{size}");
+ partition_table::add($hd, $part, $extended ? 'Extended' : 'Primary');
+ foreach ('device', if_(!$part->{ratio}, 'size')) {
+ $part->{$_} eq $wanted_part{$_} or log::l("bad $_ for $part->{device}: $part->{$_} != $wanted_part{$_}");
}
- partition_table::write($hd);
}
+ partition_table::write($hd);
#- restore from partimage
foreach (@$from_partimage) {
run_or_die(@partimage_cmd, 'restore', '-b', devices::make($_->{device}), "$dir/$_->{device}");
+
+ if ($_->{ratio}) {
+ my $resize = diskdrake::resize_ext2->new($_->{device}, devices::make($_->{device}));
+ $resize->resize($_->{size});
+ }
}
foreach (@$created) {
fs::format::part_raw($_, undef);
}
+
+ run_program::run('guessmounts');
+
+ if (my @missing = grep { $_->{missing} } @$part_list) {
+ my $missing = join('|', map { quotemeta($_->{device}) } @missing);
+ log::l("drop missing devices from fstab and lilo.conf: $missing");
+ $::prefix = '/mnt';
+ substInFile { $_ = '' if m!^/dev/($missing)\s! } "$::prefix/etc/fstab";
+
+ my $match;
+ substInFile {
+ /^\S/ and $match = m!^other=/dev/($missing)$!;
+ $_ = '' if $match;
+ } "$::prefix/etc/lilo.conf";
+ }
- run_program::run('install_bootloader');
+ run_or_die('install_bootloader', '--auto');
+
+ print "\n", "Your system is ready, press enter to reboot (Y/n) ";
+ if (<STDIN> !~ /n/i) {
+ run_program::run('reboot');
+ }
}
sub lst_fields() { qw(device size fs_type saved) }
sub save_part_list {
- my ($part_list) = @_;
+ my ($dir, $geom, $part_list) = @_;
my @l = map { join(' ', @$_{lst_fields()}) } @$part_list;
- log::l("save_part_list: $_") foreach @l;
+ log::l("save_part_list $dir: $_") foreach @l;
my $partimage = join(' ', @partimage_cmd);
open(my $F, "| $partimage -z0 -Bfoo=bar -o save_file $dir/lst");
+ print $F join("/", $geom->{heads}, $geom->{sectors}), "\n";
print $F "$_\n" foreach @l;
}
-sub read_part_list() {
+sub read_part_list {
+ my ($dir) = @_;
my $partimage = join(' ', @partimage_cmd);
open(my $F, "$partimage -z0 -Bfoo=bar rest_file $dir/lst |");
+ my $geom_string = <$F> or return;
+ my %geom; @geom{'heads', 'sectors'} = split('/', chomp_($geom_string));
my @l = chomp_(cat__($F));
- log::l("read_part_list: $_") foreach @l;
- [ map { my %l; @l{lst_fields()} = split; \%l } @l ];
+ log::l("read_part_list $dir: $_") foreach @l;
+ \%geom, [ map { my %l; @l{lst_fields()} = split; \%l } @l ];
}
sub run_or_die {
my (@l) = @_;
run_program::raw({ timeout => 4 * 60 * 60 }, @l) or die join(' ', @l) . " failed\n";
}
+
+sub error {
+ my ($msg) = @_;
+ log::l($msg);
+ die "$msg\n";
+}
+
+sub is_network_configured() {
+ my (undef, @l) = cat_('/proc/net/route');
+ find { /^(\S+)/ && $1 ne 'lo' } @l;
+}
diff --git a/rescue/rescue-doc b/rescue/rescue-doc
index fa03d1be3..e6514b462 100755
--- a/rescue/rescue-doc
+++ b/rescue/rescue-doc
@@ -1,6 +1,7 @@
#!/usr/bin/perl
-sub output { my $f = shift; local *F; open F, ">$f" or die "output in file $f failed: $!\n"; print F foreach @_; }
+# From MDK::Common:
+sub output { my $f = shift; open(my $F, ">$f") or die "output in file $f failed: $!\n"; print $F $_ foreach @_ }
output('/tmp/rescue-doc-contents', q(
Information regarding problems not directly addressed
@@ -13,15 +14,15 @@ problem?
The rescue system on this CD is a very basic text-based
environment for rescuing systems that no longer boot. You will
not find an easy-to-use graphical environment in this rescue
-system, nor the Mandriva detection/configuration libraries.
+system, nor the detection/configuration libraries.
The vast majority of problems that can affect a Linux system are
much easier to repair on a running system than by booting into
"rescue mode". In fact, there are very few problems which aren't
easier to resolve in the comfortable environment of a fully
-installed Mandriva Linux system than in this spartan "rescue
-system" shell. Some of the most common problems include:
+installed system than in this spartan "rescue system" shell.
+Some of the most common problems include:
- bad or missing X (video display) configuration
- adding/removing/reconfiguring hardware
@@ -45,13 +46,9 @@ system is the right tool. Some common examples include:
just modify what's necessary to boot into a running system,
then complete the fix from there.
-In case you have found a new problem which should be handled by
-"rescue mode" but currently isn't, please report it to
-<pixel@mandriva.com>.
-
-For more information on troubleshooting a Mandriva Linux system,
+For more information on troubleshooting your system,
please consult the official manuals, the documentation on
-MandrivaLinux.com, MandrivaClub.org, or the MandrivaExpert.com support forum.
+wiki.mageia.org or support forum at forum.mageia.org.
<press 'q' (qwerty keyboard) to continue>
));
diff --git a/rescue/restore-image-lib.sh b/rescue/restore-image-lib.sh
new file mode 100755
index 000000000..3451f7be5
--- /dev/null
+++ b/rescue/restore-image-lib.sh
@@ -0,0 +1,80 @@
+#!/bin/bash
+
+TITLE="%s Installer"
+BACKTITLE="%s"
+MIN_DISKSIZE=5000000
+
+debug="/dev/null"
+
+function _msgbox()
+{
+ dialog --timeout 60 --backtitle "$BACKTITLE" --title "$TITLE" --msgbox \
+ "$1" 0 0
+
+ return $?
+}
+
+function _infobox()
+{
+ dialog --backtitle "$BACKTITLE" --title "$TITLE" --sleep 2 \
+ --infobox "$1" 0 0
+
+ return $?
+}
+
+function _yesno()
+{
+ dialog --backtitle "$BACKTITLE" --title "$TITLE" \
+ --yes-label "Yes" --no-label "No" --yesno "$1" 0 0
+
+ return $?
+}
+
+function _mount()
+{
+ mount $1 $2 > $debug 2>&1
+
+ return $?
+}
+
+function _umount()
+{
+ umount $1 > $debug 2>&1
+
+ return $?
+}
+
+function _bind()
+{
+ mount --bind $1 $2 > $debug 2>&1
+
+ return $?
+}
+
+function _eject()
+{
+ eject $1 > $debug 2>&1
+
+ return $?
+}
+
+function _shutdown()
+{
+ [ -e /tmp/no-shutdown ] && exit
+ clear
+ sync
+ echo s > /proc/sysrq-trigger
+ echo o > /proc/sysrq-trigger
+ exit
+}
+
+function _reboot()
+{
+ [ -e /tmp/no-shutdown ] && exit
+ clear
+ sync
+ echo s > /proc/sysrq-trigger
+ echo b > /proc/sysrq-trigger
+ exit
+}
+
diff --git a/rescue/restore-image.sh b/rescue/restore-image.sh
new file mode 100755
index 000000000..32eec242d
--- /dev/null
+++ b/rescue/restore-image.sh
@@ -0,0 +1,413 @@
+#!/bin/bash
+
+setterm -powersave off
+setterm -blank 0
+
+if [ -r ./restore-image-lib.sh ]; then
+ . ./restore-image-lib.sh
+elif [ -r /usr/lib/restore-image-lib.sh ]; then
+ . /usr/lib/restore-image-lib.sh
+fi
+
+export PATH="/sbin:/bin:/usr/sbin:/usr/bin"
+
+mnt_dir="/tmp/mnt"
+restore_media="/tmp/media"
+images_dir="$restore_media/images"
+images="$images_dir/list"
+images_config="$images_dir/config"
+image=""
+win32_part_dev=
+win32_part_type=
+win32_part_new_size=
+
+function read_config()
+{
+ if [ -r "$images_config" ]; then
+ . $images_config
+ fi
+}
+
+function image_list()
+{
+ list=$(cat $images | awk -F',' \
+ '{ print $1 " " $2 " " $4 }')
+
+ echo $list
+}
+
+function image_file()
+{
+ country="$1"
+
+ file=$(grep ^$country $images | awk -F',' '{ print $3 }')
+
+ echo $file
+}
+
+function welcome()
+{
+ while true; do
+ clear
+ msg="\n Welcome to $TITLE\n\
+\nThe following images were found, select one:\n "
+ opcao=$(dialog --backtitle "$BACKTITLE" --title "$TITLE" \
+ --stdout --radiolist "$msg" 0 0 0 \
+ $(image_list))
+
+ if [ "$?" != "0" ]; then
+ _yesno "\nInterrupt installation?\n "
+ if [ "$?" = "0" ]; then
+ _shutdown
+ fi
+ else
+ if [ -z "$opcao" ]; then
+ continue
+ else
+ image=$(image_file $opcao)
+ break
+ fi
+ fi
+ done
+
+ # disable kernel messages in the console
+ echo "1 4 1 7" > /proc/sys/kernel/printk
+}
+
+function install_warning()
+{
+ if [ -n "${win32_part_dev}" ]; then
+ warn_msg="Windows installation detected.\nWe will set it up as dual boot. \
+You may lose some data.\nPlease backup before proceeding."
+ else
+ warn_msg="WARNING: This process will erase all data in this machine, \
+do you want to continue?"
+ fi
+
+ clear
+ _yesno "\n$warn_msg\n"
+ if [ "$?" != "0" ]; then
+ _shutdown
+ fi
+}
+
+function detect_root()
+{
+ inst_source_dev=$(awk "\$2 == \"$restore_media\" { print \$1 }" /proc/mounts | sed -e 's/[0-9]$//')
+ inst_source_dev=${inst_source_dev#/dev/}
+ devices=$(grep "^ .*[^0-9]$" < /proc/partitions | grep -v ${inst_source_dev} | awk '$3 > '$MIN_DISKSIZE' { print $4,$3 }')
+
+ if [ -z "${devices}" ]; then
+ exit 1
+ fi
+
+ devs_found=$(($(echo $devices | wc -w)/2))
+
+ root_data=$(detect_win32 ${inst_source_dev})
+
+ if [ -z "${root_data}" ]; then
+ if [ "$devs_found" -gt "1" ]; then
+ if [ -n "${inst_source_dev}" ]; then
+ opcao=$(dialog --backtitle "$BACKTITLE" --title "$TITLE" --stdout --menu 'Choose one of the detected devices to restore to (check the blocks size column first):' 8 50 0 $devices )
+ if [ "$?" != "0" ]; then
+ _yesno "\nInterrupt installation?\n "
+ if [ "$?" = "0" ]; then
+ _shutdown
+ fi
+ else
+ root_data=${opcao}
+ fi
+ fi
+ else
+ root_data=$(echo ${devices} | cut -d ' ' -f 1)
+ fi
+ fi
+
+ echo ${root_data}
+}
+
+function detect_win32()
+{
+ # from detect_root()
+ skip_dev=${1}
+
+ # win32 detection won't handle complex layouts
+ if [ $(fdisk -l | grep "^/dev/" | grep -v ${skip_dev} | wc -l) -gt 1 ]; then
+ exit
+ fi
+
+ # get the last created windows partition information
+ set -f
+ device=$(fdisk -l | grep "^/dev/" | grep -v ${skip_dev} | grep -e "FAT\|NTFS\|HPFS" | tail -1 | sed 's/ .*$//')
+ set +f
+
+ if [ -z "${device}" ]; then
+ exit
+ fi
+
+ # it might be needed, for safety
+ device_type=$(blkid -o value -s TYPE ${device})
+ modprobe ${device_type}
+
+ # df for that partition
+ mount ${device} /mnt
+ size=$(df ${device} | tail -1)
+ umount /mnt
+
+ # its diskspace
+ used=$(echo ${size} | awk '{ print $3 }')
+ left=$(echo ${size} | awk '{ print $4 }')
+ avail=$((${left}/2))
+
+ if [ ! ${avail} -lt ${MIN_DISKSIZE} ]; then
+ win32_part_dev=${device}
+ win32_part_type=${device_type}
+ # our install takes half of 'left'
+ win32_part_new_size=$((${used}+${avail}))
+
+ dev=${win32_part_dev#/dev/}
+ disk=${dev%[0-9]}
+ number=${dev#[a-w][a-w][a-w]}
+ let number++
+ echo ${disk}${number} ${win32_part_dev} ${win32_part_type} ${win32_part_new_size}
+ fi
+}
+
+function resize_win32()
+{
+ device=${1}
+ device_type=${2}
+ new_win32_size=${3}
+
+ dialog --backtitle "$BACKTITLE" --title "$TITLE" --infobox "\nResizing Windows partition...\n" 4 55
+
+ dev=${device#/dev/}
+ disk=${dev%[0-9]}
+ win32_number=${dev#[a-w][a-w][a-w]}
+
+ case ${device_type} in
+ vfat) device_id=b ;;
+ ntfs) device_id=7 ;;
+ hpfs) device_id=87 ;;
+ esac
+
+ # wrapper around libdrakx by blino
+ diskdrake-resize ${device} ${device_type} $((${new_win32_size}*2)) &>/dev/null
+
+ # we need some free sector here, rebuilding layout
+ fdisk /dev/${disk} &>/dev/null <<EOF
+d
+n
+p
+${win32_number}
+
++${new_win32_size}K
+t
+${device_id}
+a
+${win32_number}
+w
+EOF
+ # adds linux partition to the end of the working disk
+ fdisk /dev/${disk} &>/dev/null <<EOF
+n
+p
+$((${win32_number}+1))
+
++${MIN_DISKSIZE}K
+t
+$((${win32_number}+1))
+83
+w
+EOF
+}
+
+function detect_device()
+{
+ dialog --backtitle "$BACKTITLE" --title "$TITLE" --infobox "\nTrying to detect your root partition and disk...\n" 4 55
+
+ root_data=$(detect_root)
+ if [ -z "${root_data}" ]; then
+ _msgbox "\nError writing image: disk device not detected.\n"
+ # so that netbooks using USB sticks as disks can retry (like Gdium)
+ welcome
+ root_data=$(detect_root)
+ fi
+ set ${root_data}
+ root=$1
+ win32_part_dev=$2
+ win32_part_type=$3
+ win32_part_new_size=$4
+}
+
+function write_image()
+{
+ if [ -n "${win32_part_dev}" ]; then
+ resize_win32 ${win32_part_dev} ${win32_part_type} ${win32_part_new_size}
+ fi
+
+ image=$(cat $images_dir/list | cut -d ',' -f 3)
+ extension=${image/*./}
+ imagesize=$(ls -l $images_dir/$image | awk '{ print $5 }')
+ case $extension in
+ gz)
+ uncomp=zcat
+ total=$(gzip -l $images_dir/$image | tail -n 1 | awk '{ print $2 }')
+ ;;
+ bz2)
+ uncomp=bzcat
+ total=$((imagesize * 3))
+ ;;
+ *)
+ uncomp=cat
+ total=$imagesize
+ ;;
+ esac
+
+ skipstart=/bin/true
+ if [ -n "$win32_part_dev" ]; then
+ skipstart='dd of=/dev/null bs=1 count=32256'
+ fi
+
+ # the actual dumping command, from image to disk
+ ${uncomp} ${images_dir}/${image} | (${skipstart} &>/dev/null; dd bs=4M of=/dev/${root} >/tmp/backup.out 2>&1>>/tmp/log) &
+
+ sleep 3
+ pid=$(ps ax | grep 'dd bs=4M of' | grep -v grep | awk '{ print $1 }')
+
+ while [ true ]; do
+ ps | grep -q $pid
+ if [ $? -eq 0 ]; then
+ /bin/kill -SIGUSR1 $pid
+ complete=$(tail -n 1 /tmp/backup.out | awk '{ print $1 }')
+ echo $((complete*100/total))
+ sleep 1
+ else
+ break
+ fi
+ done | dialog --backtitle "$BACKTITLE" --title "$TITLE" --gauge "\nWriting image..." 8 45
+
+ in=$(tail -n 3 /tmp/backup.out | grep 'in$' | cut -d' ' -f1)
+ out=$(tail -n 3 /tmp/backup.out | grep 'out$' | cut -d' ' -f1)
+
+ if [ x"$in" != x"$out" ]; then
+ _msgbox "\nError writing image!\n"
+ sleep 24h
+ fi
+
+ # Now re-read the partition table because 'dd' might have changed it
+ sfdisk -R /dev/${root}
+}
+
+function grub_setup()
+{
+ root=${1}
+ grub_dir=${2}
+
+ # install the bootloader
+ grub <<EOF
+device (hd0) /dev/${root%[0-9]}
+root (hd0,1)
+setup (hd0)
+quit
+EOF
+ # change the partition order and boot timeout accordingly
+ sed -i 's/(hd0,0)/(hd0,1)/g;/^timeout/s/$/0/' ${grub_dir}/menu.lst
+
+ # dualboot configuration for grub
+ cat >> ${grub_dir}/menu.lst <<EOF
+title Microsoft Windows
+root (hd0,0)
+makeactive
+rootnoverify(hd0,0)
+chainloader +1
+EOF
+}
+
+function expand_fs()
+{
+ if [ -z "$win32_part_dev" ]; then
+ if [ -n "$MAIN_PART_NUMBER" ]; then
+ part_number=$MAIN_PART_NUMBER
+ else
+ part_number=1
+ fi
+ root=${root%[0-9]}$part_number
+ fi
+ filesystem_type=$(dumpe2fs -h /dev/${root} 2>/dev/null| grep "Filesystem OS type" | awk '{ print $4 }')
+ if [ "${filesystem_type}" = "Linux" ]; then
+ dialog --backtitle "$BACKTITLE" --title "$TITLE" --infobox "Finishing Install... Expanding ${root}" 3 40
+ disk=/dev/${root%[0-9]}
+ main_part=/dev/${root}
+
+ # FIXME: absurdly dirty hack
+ main_part_num=${root:3}
+ swap_part_num=$((main_part_num+1))
+ swap_part=${disk}${swap_part_num}
+
+ main_part_sectors=
+ if [ -n "$SWAP_BLOCKS" ]; then
+ if [ -n "$EXPAND_FS" ]; then
+ total_blocks=$(sfdisk -s $disk)
+ main_part_blocks=$((total_blocks-SWAP_BLOCKS))
+ main_part_sectors=$((main_part_blocks*2))
+ else
+ main_part_sectors=$(sfdisk -d $disk | perl -lne 'm|^'$main_part'\b.*,\s*size\s*=\s*(\d+)\b| and print($1), exit')
+ fi
+ fi
+ if [ -n "$SWAP_BLOCKS" ]; then
+ parted $disk -- mkpartfs primary linux-swap ${main_part_sectors}s -1s yes
+ mkswap -L swap $swap_part
+ fi
+ if [ -n "$EXPAND_FS" ]; then
+ e2fsck -fy $main_part
+ fdisk $disk << EOF
+d
+$main_part_num
+n
+p
+$main_part_num
+
+
+a
+$main_part_num
+w
+EOF
+ sfdisk -R $disk
+ e2fsck -fy $main_part
+ resize2fs $main_part
+ fi
+ mkdir -p $mnt_dir
+ mount $main_part $mnt_dir
+ grub_dir="$mnt_dir/boot/grub"
+ if [ -d "$grub_dir" ]; then
+ echo "(hd0) $disk" > "$grub_dir/device.map"
+ if [ -n "$win32_part_dev" ]; then
+ grub_setup ${root} ${grub_dir}
+ fi
+ fi
+ if [ -n "$MKINITRD" ]; then
+ mount -t sysfs none "$mnt_dir/sys"
+ mount -t proc none "$mnt_dir/proc"
+ echo > /proc/sys/kernel/modprobe # rescue's modprobe does not handle modprobe -q and aliases
+ chroot $mnt_dir bootloader-config --action rebuild-initrds
+ umount "$mnt_dir/sys"
+ umount "$mnt_dir/proc"
+ fi
+ umount $mnt_dir
+ fi
+}
+
+# installation steps
+welcome
+read_config
+detect_device
+install_warning
+write_image
+expand_fs
+
+# all done!
+_msgbox "\nInstallation process finished.\nPress ENTER to shutdown.\n "
+
+_shutdown
+
diff --git a/rescue/restore_ms_boot b/rescue/restore_ms_boot
index 86350d7bc..1f8cc2907 100755
--- a/rescue/restore_ms_boot
+++ b/rescue/restore_ms_boot
@@ -12,96 +12,56 @@
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
#
-sub arch() {
- my $t = `uname -m`;
- chomp $t;
- $t;
-}
-sub if_($@) {
- my $b = shift;
- $b or return ();
- wantarray || @_ <= 1 or die("if_ called in scalar context with more than one argument " . join(":", caller()));
- wantarray ? @_ : $_[0];
-}
-sub cat_ { local *F; open F, $_[0] or $_[1] ? die "cat of file $_[0] failed: $!\n" : return; my @l = <F>; wantarray ? @l : join '', @l }
-sub member { my $e = shift; foreach (@_) { $e eq $_ and return 1 } 0 }
-
-@known_boot_loaders = qw(lilo grub yaboot);
-
-# keep this in sync with DrakX
-@MBR_signatures = (
- [ 'empty', 0, "\0\0\0\0" ],
- [ 'grub', 0x6, "GRUB" ],
- [ 'grub', 0, "\xEBG", 0x17d, "stage1 \0" ],
- [ 'grub', 0, "\xEBH", 0x17e, "stage1 \0" ],
- [ 'grub', 0, "\xEBH", 0x18a, "stage1 \0" ],
- [ 'grub', 0, "\xEBH", 0x181, "GRUB \0" ],
- [ 'lilo', 0x2, "LILO" ],
- [ 'lilo', 0x6, "LILO" ],
-if_(arch() =~ /ppc/,
- map { [ 'yaboot', 0, "PM", 0x200 * $_ + 0x10, "bootstrap\0" ] } 0 .. 61
-),
-);
-
-sub typeFromMagic {
- my $f = shift;
- local *F; sysopen F, $f, 0 or return;
-
- my $tmp;
- M: foreach (@MBR_signatures) {
- my ($name, @l) = @$_;
- while (@l) {
- my ($offset, $signature) = splice(@l, 0, 2);
- sysseek(F, $offset, 0) or next M;
- sysread(F, $tmp, length $signature);
- $tmp eq $signature or next M;
- }
- return $name;
- }
- return 0;
-}
-
+use lib qw(/usr/lib/libDrakX);
+use common;
+use bootloader;
+use fs;
+use fs::proc_partitions;
+use partition_table::raw;
-my (undef, undef, @parts) = cat_('/proc/partitions');
-my @possibilities;
-
-P: foreach (@parts) {
- my (undef, undef, $blocks, $dev) = split or next;
- next if $blocks <= 1;
- my $type = typeFromMagic("/dev/$dev");
- $type && member($type, @known_boot_loaders) and push @possibilities, [ $dev, $type ];
-}
+my @choices = map {
+ my $type = partition_table::raw::typeOfMBR($_->{dev});
+ if_($type && member($type, bootloader::main_method_choices()) , [ $_->{dev}, $type ]);
+} fs::proc_partitions::read_raw();
my $choice;
-if (!@possibilities) {
+if (!@choices) {
print "No known Linux bootloader has been found, nothing to do.\n";
-} elsif (@possibilities == 1) {
- print "I've found a Linux bootloader only on </dev/$possibilities[0]->[0]>.\n\n";
- $choice = $possibilities[0];
+} elsif (@choices == 1) {
+ print "I've found a Linux bootloader only on <$choices[0][0]>.\n\n";
+ $choice = $choices[0];
} else {
- print "I've found the following Linux bootloaders:\n";
- my $i;
- print "\t", ++$i, ": <$_->[1]> \ton <$_->[0]>\n" foreach @possibilities;
- print "\n";
- print "Which disk/partition do you want to overwrite with the Windows bootloader?\n";
- print "\t<enter the number or press 'n' and Enter to cancel> ";
- <STDIN> !~ /^(\d+)$/i && $1 >= 1 and $choice = $possibilities[$1-1];
+ print "I've found the following Linux bootloaders:\n",
+ (map_index { "\t" . $::i . ": <$_->[1]> \ton <$_->[0]>\n" } @choices),
+ "\n",
+ "Which disk/partition do you want to overwrite with the Windows bootloader?\n",
+ "\t<enter the number or press 'n' and Enter to cancel> ";
+ if (<STDIN> =~ /^(\d+)$/i && $1 >= 1) {
+ $choice = $choices[$1 - 1];
+ }
}
if ($choice) {
- print "I'm going to overwrite bootloader on </dev/$choice->[0]> with
+ print "I'm going to overwrite bootloader on <$choice->[0]> with
Windows bootloader.
Ok? <press Enter to continue, 'n' and Enter to cancel> ";
<STDIN> =~ /^n/i and exit 0;
- system("/bin/dd if=/usr/lib/extipl/aldebaran.bin of=/dev/$choice->[0]\n") and print "\tFailed!\n";
+ system('dd', 'if=/usr/lib/extipl/aldebaran.bin', "of=/dev/$choice->[0]") == 0
+ or print "\tFailed!\n";
}
#-------------------------------------------------
#- $Log$
+#- Revision 1.5 2005/06/13 04:33:50 prigaux
+#- move functions using /proc/partitions out of fsedit to fs::proc_partitions
+#-
+#- Revision 1.4 2005/05/19 08:59:54 prigaux
+#- rewrite using DrakX modules
+#-
#- Revision 1.3 2005/04/19 12:49:39 prigaux
#- update copyright
#-
diff --git a/rescue/startssh b/rescue/startssh
new file mode 100755
index 000000000..e14bb10e8
--- /dev/null
+++ b/rescue/startssh
@@ -0,0 +1,27 @@
+#!/bin/bash
+
+# test for an up interface != lo
+if test "x"`ifconfig | cut -d ' ' -f 1 | grep -v '^$' | grep -v lo` = "x"; then
+ echo "There is no up interface, you can try to execute 'drvinst' to find drivers and 'dhcp-client' to configure your interface for DHCP." >&2
+ exit 5
+fi
+
+# generate host keys
+mkdir -p /etc/dropbear
+[[ -f /etc/dropbear/dropbear_dss_host_key ]] || dropbearkey -t dss -f /etc/dropbear/dropbear_dss_host_key >/dev/null || { echo "Can't generate dsa host key" >&2 ; exit 4; }
+[[ -f /etc/dropbear/dropbear_rsa_host_key ]] || dropbearkey -t rsa -f /etc/dropbear/dropbear_rsa_host_key >/dev/null || { echo "Can't generate rsa host key" >&2 ; exit 3; }
+
+# set a password
+passwd=`genpasswd`
+if (( $? != 0 )); then
+ reset
+ exit $?
+fi
+sed -E -i -e 's/^root:[^:]*:/root:'"${passwd//\//\\/}"':/' /etc/passwd || { echo "Can't set password" >&2 ; exit 2; }
+
+# test for /dev/pts
+grep '^devpts /dev/pts devpts ' /proc/mounts >/dev/null 2>/dev/null || mount -t devpts devpts /dev/pts
+
+echo ""
+echo -n "Starting ssh daemon... "
+dropbear -E 2>/var/log/dropbear.log && echo "OK" || { echo "Failed" ; exit 1; }
diff --git a/rescue/tree/etc/hosts b/rescue/tree/etc/hosts
index a9bbdee7f..d02c36416 100644
--- a/rescue/tree/etc/hosts
+++ b/rescue/tree/etc/hosts
@@ -1 +1 @@
-127.0.0.1 mandrake-rescue
+127.0.0.1 mageia-rescue
diff --git a/rescue/tree/etc/inittab b/rescue/tree/etc/inittab
index 771d7c0d4..6a30c0360 100644
--- a/rescue/tree/etc/inittab
+++ b/rescue/tree/etc/inittab
@@ -1,5 +1,5 @@
-#Inittab for Mandrake Rescue Disk
-#Author: Daouda Lo <daouda@mandrakesoft.com>
+#Inittab for Mageia Rescue Disk
+#Author: Daouda Lo
id:3:initdefault:
si::sysinit:/etc/rc.sysinit
@@ -7,8 +7,10 @@ re:6:wait:/etc/rc.reboot
ca:12345:ctrlaltdel:/sbin/fakeshutdown
1:12345:respawn:/sbin/mingetty --autologin root tty1
-2:23:respawn:/sbin/mingetty tty2
-3:23:respawn:/sbin/mingetty tty3
-4:23:respawn:/sbin/mingetty tty4
-5:23:respawn:/sbin/mingetty tty5
-6:23:respawn:/sbin/mingetty tty6
+2:23:respawn:/sbin/mingetty --autologin root tty2
+3:23:respawn:/sbin/mingetty --autologin root tty3
+4:23:respawn:/sbin/mingetty --autologin root tty4
+5:23:respawn:/sbin/mingetty --autologin root tty5
+6:23:respawn:/sbin/mingetty --autologin root tty6
+s0:2345:respawn:/sbin/agetty -h -t 60 ttyS0 9600 ansi
+#s1:2345:respawn:/sbin/agetty -h -t 60 ttyS1 115200,9600 linux
diff --git a/rescue/tree/etc/issue b/rescue/tree/etc/issue
index f4799bad2..c5a4c7fb8 100644
--- a/rescue/tree/etc/issue
+++ b/rescue/tree/etc/issue
@@ -11,7 +11,7 @@
     [2[1;37;4
     
    
-    Mandrakelinux Rescue Disk
+    Mageia Linux Rescue Disk
     
     
    
@@ -24,5 +24,6 @@ Use loadkeys to change your keyboard layout (eg: loadkeys fr)
Use modprobe to load modules (eg: modprobe snd-card-fm801)
Use drvinst to install drivers according to detected devices
Use lsparts to list your partitions with types
+Use startssh to start an ssh daemon
Use rescue-gui to go back to the rescue menu
diff --git a/rescue/tree/etc/passwd b/rescue/tree/etc/passwd
index 568451e4e..3a1254f77 100644
--- a/rescue/tree/etc/passwd
+++ b/rescue/tree/etc/passwd
@@ -1,3 +1,3 @@
-root::0:0::/:/bin/bash
+root::0:0::/root:/bin/bash
shutdown:*:6:0:shutdown:/sbin:/sbin/shutdown
halt:*:7:0:halt:/sbin:/sbin/halt
diff --git a/rescue/tree/etc/profile b/rescue/tree/etc/profile
index 3b5ac21cc..800ce85ae 100644
--- a/rescue/tree/etc/profile
+++ b/rescue/tree/etc/profile
@@ -1,12 +1,12 @@
# /etc/profile
-# (c) Mandrakesoft, Chmouel Boudjnah <chmouel@mandrakesoft.com>
+# (c) Mandrakesoft, Chmouel Boudjnah <chmouel>
# System wide environment and startup programs
# Functions and aliases go in /etc/bashrc
PROFILE_LOADED=1
-export PATH=/usr/bin:/bin:/sbin:/usr/sbin:/usr/X11R6/bin
+PATH=/usr/bin:/bin:/sbin:/usr/sbin:/usr/X11R6/bin:/mnt/sbin:/mnt/bin:/mnt/usr/sbin:/mnt/usr/bin
PS1="[root@rescue \w]\\$ "
ls () { /bin/ls --color=auto -F "$@";}
diff --git a/rescue/tree/etc/rc.sysinit b/rescue/tree/etc/rc.sysinit
index e228c91ba..e22696e78 100755
--- a/rescue/tree/etc/rc.sysinit
+++ b/rescue/tree/etc/rc.sysinit
@@ -1,34 +1,35 @@
#!/bin/sh
action() { echo $1; shift; $*; }
+DATE=`date +%Y%m%d-%Hh%M`
export PATH=/bin:/sbin:/usr/bin:/usr/sbin
-echo -e "\t\t\tWelcome to \\033[1;36mMandrake\\033[0;39m Linux"
+echo -e "\t\t\tWelcome to \\033[1;36mMageia\\033[0;39m Linux"
action "Remounting root filesystem in read-write mode" mount -n -o remount,rw /
-ln -s /tmp/stage2/etc/* /etc 2>/dev/null
-
-rm -f /dev ; cp -a /tmp/stage2/dev /dev
+echo "Starting udev"
+mkdir /run
+mount -t tmpfs -o mode=0755,nosuid,nodev tmpfs /run
+mkdir -p /run/udev/rules.d
+export UDEVRULESD=/run/udev/rules.d
-mkdir /mnt /var/log
+/usr/lib/systemd/systemd-udevd --daemon --resolve-names=never
+udevadm trigger --type=subsystems --action=add
+udevadm trigger --type=devices --action=add
-mkdir /proc
-action "Mounting proc filesystem" mount -n -t proc /proc /proc
+ln -s /tmp/stage2/etc/* /etc 2>/dev/null
+# make passwd changable
+rm -f /etc/passwd
+cp /tmp/stage2/etc/passwd /etc/
-if grep -q sysfs /proc/filesystems; then
- mkdir /sys
- action "Mounting sysfs on /sys" mount -t sysfs none /sys
-fi
+mkdir -p /mnt /var/log
>/etc/mtab
mount -f /
mount -f /proc
-#- free up stage1 memory
-umount /stage1/proc/bus/usb /stage1/proc /stage1
-
# Set the hostname.
action "Setting hostname rescue" hostname rescue
echo rescue > /etc/HOSTNAME
@@ -36,27 +37,50 @@ echo rescue > /etc/HOSTNAME
# Loads common modules ( no kerneld :( )
echo "Loading additional modules..."
load() { modprobe $* 2>/dev/null; }
-load ide-mod
-load ide-probe
-load ide-disk
-load ide-cd
+load ide-gd_mod
+load ide-cd_mod
load floppy
load af_packet
load isofs
load vfat
load ext3
+load ext4
load reiserfs
+load nilfs2
+load btrfs
load xfs
load jfs
load loop
load sd_mod
load sr_mod
-/sbin/ifconfig lo 127.0.0.1 netmask 255.0.0.0
-/sbin/route add 127.0.0.1 lo
+action "Bringing up local loop interface" ifconfig lo up
+
+# disable the weird echoprt in cooked mode for user interaction:
+stty sane
+
+#LANGUAGE (filled by make_rescue_img)
grep -q noauto /proc/cmdline || drvinst SERIAL_USB
-if ! grep -q expert /proc/cmdline; then
+partimage_default_dir=/data/box
+partimage_dir=`perl -lne 'print $1 if /BOX=(\S+)/' /proc/cmdline`
+[ -z "$partimage_dir" ] && partimage_dir=$partimage_default_dir
+partimage_server=`perl -lne 'print $1 if /\bpserver=(\S+)/' /proc/cmdline`
+
+if grep -q save_all /proc/cmdline; then
+ partimage_whole_disk -s $partimage_server save_all $partimage_default_dir
+elif grep -q rest_all /proc/cmdline; then
+ if [ -d /tmp/image$partimage_dir ]; then
+ partimage_whole_disk rest_all /tmp/image$partimage_dir
+ else
+ partimage_whole_disk -s $partimage_server rest_all $partimage_dir
+ fi
+elif grep -q oem /proc/cmdline; then
+ /tmp/image/oem-rescue.sh
+elif grep -q restore /proc/cmdline; then
+ /usr/sbin/restore-image.sh
+elif ! grep -q expert /proc/cmdline; then
+ echo "starting GUI"
rescue-gui
fi
diff --git a/rescue/tree/sbin/fakeshutdown b/rescue/tree/sbin/fakeshutdown
index 3511020ff..309f26c6c 100755
--- a/rescue/tree/sbin/fakeshutdown
+++ b/rescue/tree/sbin/fakeshutdown
@@ -1,7 +1,7 @@
#!/usr/bin/perl
#
-# Guillaume Cottenceau (gc@mandrakesoft.com)
+# Guillaume Cottenceau (gc)
#
# Copyright 2001 Mandrakesoft
#
@@ -13,8 +13,8 @@
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
#
-sub cat_ { local *F; open F, $_[0] or $_[1] ? die "cat of file $_[0] failed: $!\n" : return; my @l = <F>; wantarray ? @l : join '', @l }
-
+# From MDK::Common:
+sub cat_ { open(my $F, '<', $_[0]) or die "cat of file $_[0] failed: $!\n"; my @l = <$F>; wantarray() ? @l : join '', @l }
print "\n";
diff --git a/rescue/tree/sbin/modprobe b/rescue/tree/sbin/modprobe
index 774101d7c..704ee6b0f 100755
--- a/rescue/tree/sbin/modprobe
+++ b/rescue/tree/sbin/modprobe
@@ -1,56 +1,18 @@
#!/usr/bin/perl
-sub cat_ { local *F; open F, $_[0] or $_[1] ? die "cat of file $_[0] failed: $!\n" : return; my @l = <F>; wantarray ? @l : join '', @l }
-
-sub read_already_loaded() {
- foreach (cat_("/proc/modules")) {
- my ($name) = split;
- $conf{$name}{loaded} = 1;
- }
-}
-
-sub load_deps($) {
- my ($file) = @_;
-
- local *F;
- open F, $file or log::l("error opening $file: $!"), return 0;
- foreach (<F>) {
- my ($f, $deps) = split ':';
- push @{$deps{$f}}, split ' ', $deps;
- }
+use lib qw(/usr/lib/libDrakX);
+use list_modules;
+use modules;
+
+# based on install::commands
+sub modprobe {
+ !@_ || $_[0] =~ /^-?-h/ and die "usage: modprobe <module> [<options...>]\n";
+ my $name;
+ # kernel calls us with modprobe -q -- <module>, so ignore options
+ do { $name = shift } while substr($name, 0, 1) eq "-";
+ list_modules::load_default_moddeps();
+ modules::load_with_options([ $name ], { $name => join(' ', @_) });
}
-my $module_extension = cat_('/proc/version') =~ /^Linux version 2.4/ ? '.o' : '.ko';
-
-my %mappings = ("usb-ohci" => "ohci-hcd",
- "usb-uhci" => "uhci-hcd",
- "uhci" => "uhci-hcd",
- "printer" => "usblp",
- "bcm4400" => "b44",
- "3c559" => "3c359",
- "3c90x" => "3c59x",
- "dc395x_trm" => "dc395x",
- "audigy" => "snd-emu10k1");
-
-sub load {
- my ($name, @options) = @_;
- $name =~ s/\.k?o$//;
-
- $name = $mappings{$name} || $name; #- 2.4 -> 2.6 compat mappings
-
- $conf{$name}{loaded} and return;
- eval { load($_, 'prereq') } foreach @{$deps{$name}};
-
- system("packdrake -x /modules/modules.cz* /tmp $name$module_extension");
- -r "/tmp/$name$module_extension" or die "can't find module $name\n";
- system("/sbin/insmod /tmp/$name$module_extension");
- my $retval = $?;
- system("rm /tmp/$name$module_extension");
- $retval and die("insmod $name failed");
-}
-
-!@ARGV || $ARGV[0] =~ /-h/ and die "usage: modprobe <module> [<options...>]\n";
-
-read_already_loaded();
-load_deps("/modules/modules.dep");
-load(@ARGV);
+$::isInstall = 1;
+modprobe(@ARGV);
diff --git a/rescue/tree/usr/share/symlinks b/rescue/tree/usr/share/symlinks
index 1c34ff204..659a42c8c 100644
--- a/rescue/tree/usr/share/symlinks
+++ b/rescue/tree/usr/share/symlinks
@@ -1,11 +1,9 @@
/bin
/boot
-/dev
/etc/fstab
/etc/inittab
/etc/rc.sysinit
/lib
/lib64
-/modules
/sbin
/usr