summaryrefslogtreecommitdiffstats
path: root/rescue/make_rescue_img
diff options
context:
space:
mode:
authorPascal Rigaux <pixel@mandriva.com>2007-05-30 11:11:18 +0000
committerPascal Rigaux <pixel@mandriva.com>2007-05-30 11:11:18 +0000
commitc1af4addb6f18c15b59fc270854a0fbb8d92dcb6 (patch)
tree5a6f717efc60087849f45827fcbf618d40e15d46 /rescue/make_rescue_img
downloaddrakx-c1af4addb6f18c15b59fc270854a0fbb8d92dcb6.tar
drakx-c1af4addb6f18c15b59fc270854a0fbb8d92dcb6.tar.gz
drakx-c1af4addb6f18c15b59fc270854a0fbb8d92dcb6.tar.bz2
drakx-c1af4addb6f18c15b59fc270854a0fbb8d92dcb6.tar.xz
drakx-c1af4addb6f18c15b59fc270854a0fbb8d92dcb6.zip
create branch 2007.1 from drakx-installer-* tarballs
(needed after the big svn loss)
Diffstat (limited to 'rescue/make_rescue_img')
-rwxr-xr-xrescue/make_rescue_img109
1 files changed, 109 insertions, 0 deletions
diff --git a/rescue/make_rescue_img b/rescue/make_rescue_img
new file mode 100755
index 000000000..996025373
--- /dev/null
+++ b/rescue/make_rescue_img
@@ -0,0 +1,109 @@
+#!/usr/bin/perl
+
+use MDK::Common;
+use lib "/usr/lib/libDrakX";
+use keyboard;
+
+my $lib = (arch() =~ /x86_64/ ? "lib64" : "lib");
+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 }
+
+sub installown($$) {
+ my ($own, $dir) = @_;
+ return if -e "$tmp$dir/" . basename($own);
+ mkdir_p("$tmp$dir");
+ _ "cp -rL $own $tmp$dir";
+}
+
+sub install_perl_script {
+ my ($script, $dir) = @_;
+ my @gi_modules;
+ foreach (`../tools/get-needed-drakx-modules /usr/lib/libDrakX /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");
+}
+
+_ "rm -rf $tmp" if -e $tmp;
+_ "mkdir $tmp";
+_ 'find . -name "*~" | xargs rm -f';
+mkdir_p($tmp . chomp_($_)) foreach cat_("dirs");
+_ "cp -a tree/* $tmp";
+_ "find $tmp -name .svn | xargs rm -rf";
+_ "perl devices.pl $tmp/dev";
+_ "mkfifo $tmp/dev/initctl";
+substInFile { s/DISTRIB_DESCR/$ENV{DISTRIB_DESCR}/ } "$tmp/etc/issue";
+
+_ "../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 ($dir, $fname) = (dirname($_), basename($_));
+ my ($name) = $fname =~ /(.*)\.kmap\.gz/ or next;
+ next if member($name, @less_important_keytables);
+ if (my ($short) = $name =~ m|(.+?)[\W_]|) {
+ $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");
+ }
+}
+
+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/etc/rc.sysinit";
+}
+
+if ($ENV{PARTIMAGE_RPM}) {
+
+ _ "rpm2cpio $ENV{PARTIMAGE_RPM} | (cd $tmp ; cpio -idu ./usr/sbin/partimage)";
+ my $server = 'partimaged';
+ $server = 'leia';
+
+ my $default_dir = '/data/box';
+
+ substInFile {
+ $_ = " server=$server\n" . " default_dir=$default_dir\n" . <<'EOF' if /^\s*rescue-gui/;
+
+ partimage_dir=`perl -lne 'print $1 if /BOX=(\S+)/' /proc/cmdline`
+ [ -z "$partimage_dir" ] && partimage_dir=$default_dir
+
+ if grep -q save_all /proc/cmdline; then
+ partimage_whole_disk -s $server save_all $default_dir
+ fi
+ if 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 $server rest_all $partimage_dir
+ fi
+ fi
+EOF
+ } "$tmp/etc/rc.sysinit";
+}
+
+exit 0 if $ARGV[0];
+
+_ "mksquashfs $tmp $rescue -all-root -noappend >/dev/null";
+_ "chmod 755 $rescue";
+_ "rm -rf $tmp";