diff options
Diffstat (limited to 'draklive-install')
-rwxr-xr-x | draklive-install | 70 |
1 files changed, 65 insertions, 5 deletions
diff --git a/draklive-install b/draklive-install index b3212c3..996d6e3 100755 --- a/draklive-install +++ b/draklive-install @@ -37,6 +37,21 @@ my $logfile = '/tmp/draklive-install.log'; } } +my $child_pid; +END { + run_program::terminate($child_pid) if $child_pid; +} + +sub wait_loop_callback { + my ($pid) = @_; + $child_pid = $pid; + while (Gtk3::events_pending()) { + Gtk3::main_iteration(); + } + $child_pid = undef; +} +run_program::set_wait_loop_callback(\&wait_loop_callback, 50); + ($::rootwidth, $::rootheight) = (Gtk3::Gdk::Screen::width, Gtk3::Gdk::Screen::height); $::real_windowwidth = $::rootwidth > 800 ? 750 : 600; $::real_windowheight = $::rootheight > 600 ? 500 : 400; @@ -91,13 +106,20 @@ sub install_live() { my $persistent = -e '/run/mgalive/persistent'; + # Don't remove packages from a persistent live system, as they will no + # longer be available for future installs. Don't remove packages from + # a non-persistent live system with insufficient RAM to accomodate the + # changes that will be stored in the upper layer of the overlay file + # system (mga#27872). + my $remove_after_install = $persistent || ram_size_in_MB() < 750; + display_start_message(); init_hds($in, $all_hds, $fstab); ask_partitions_loop($in, $all_hds, $fstab, $copy_source); - remove_unused_packages($in, $copy_source) if !$persistent; + remove_unused_packages($in, $copy_source) if !$remove_after_install; prepare_root($in); copy_root($in, $copy_source); - remove_unused_packages($in, $::prefix) if $persistent; + remove_unused_packages($in, $::prefix) if $remove_after_install; complete_install($in, $all_hds); setup_bootloader($in, $all_hds, $fstab); install_updates($in); @@ -106,6 +128,11 @@ sub install_live() { $in->exit(0); } +sub ram_size_in_MB() { + my @mem_total = map { /(\d+)/ } grep { /^MemTotal:/ } cat_("/proc/meminfo"); + $mem_total[0] / 1024; +} + sub umount_all { my ($fstab, $o_except_swap) = @_; #- make sure nothing is mounted in the new root @@ -262,6 +289,8 @@ sub prepare_root { fs::any::prepare_minimal_root(); #- /media isn't included in the minimal root, and we don't copy it to avoid copying stale mount points mkdir_p("$::prefix/media"); + #- under GNOME/Xwayland, running gurpmi inside the chroot requires connection to the X11 socket in /tmp + run_program::run('mount', '--bind', '/tmp', "$::prefix/tmp"); } sub build_copy_command { @@ -278,7 +307,7 @@ sub get_total_size { state %total; return $total{$source} if $total{$source}; my $_wait = $in->wait_message('', N("Computing total size")); - $total{$source} = first(split(/\s+/, `du -sbx /run/mgalive/ovlsize 2>/dev/null`)); + $total{$source} = first(split(/\s+/, run_program::get_stdout('du', '2>', '/dev/null', '-sbx', '/run/mgalive/ovlsize'))); } sub sync_logs() { @@ -301,6 +330,8 @@ sub copy_root { if ($current <= $total && $current/$total > $previous/$total + 0.001) { $update_progress->('', $current, $total); $previous = $current; + } else { + mygtk3::flush(); } } } @@ -444,12 +475,41 @@ Do you want to setup the update media?")), return 0; }; + require urpm; + require urpm::media; + + my $urpm = urpm->new(); + $urpm->{log} = \&log::l; + urpm::set_files($urpm, $::prefix); + urpm::media::read_config($urpm); + + $in->{packages} = $urpm; + $in->{product_id} = mageia_release_info(); + + require mirror; + require urpm::download; + + my $downloader = sub { + my ($url) = @_; + urpm::download::get_content($urpm, $url); + }; + mirror::register_downloader($downloader); + + my $urpmi_options = { mirror_url => '$MIRRORLIST' }; + try_again: enable_network_connection($in); + any::ask_mirror_and_downloader($in, $urpmi_options); + any::urpmi_set_downloader($in, $urpm, $urpmi_options->{downloader}) || die("Failed to set downloader\n"); + + if ($urpmi_options->{mirror_url} ne '$MIRRORLIST') { + $urpmi_options->{mirror_url} = any::ask_mirror($in, 'distrib', $urpmi_options->{mirror_url}); + } + clean_rpmdb_shared_regions(); - if (any::urpmi_add_all_media($in)) { + if (any::urpmi_add_all_media($in, undef, $urpmi_options->{mirror_url})) { log::l("successfully added update media"); return 1; } @@ -486,7 +546,7 @@ Do you want to install the updates?")), }; my $log_file = '/root/drakx/updates.log'; - run_program::rooted($::prefix, 'gurpmi2', '>>', $log_file, '2>>', $log_file, '--auto-select'); + run_program::raw({ root => $::prefix, timeout => 'never' }, 'gurpmi2', '>>', $log_file, '2>>', $log_file, '--auto-select'); clean_rpmdb_shared_regions(); } |