summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMartin Whitaker <mageia@martin-whitaker.me.uk>2020-06-07 22:16:39 +0100
committerMartin Whitaker <mageia@martin-whitaker.me.uk>2020-06-07 22:40:46 +0100
commitc5b94c2661331c361c24407624469fa0d5f951af (patch)
tree4bac2a658b3dfa76963bb7259523b7b76210e0fd
parent7c976d6789541402a4a6ec5fcd74187e4e9eb2b7 (diff)
downloaddraklive-install-c5b94c2661331c361c24407624469fa0d5f951af.tar
draklive-install-c5b94c2661331c361c24407624469fa0d5f951af.tar.gz
draklive-install-c5b94c2661331c361c24407624469fa0d5f951af.tar.bz2
draklive-install-c5b94c2661331c361c24407624469fa0d5f951af.tar.xz
draklive-install-c5b94c2661331c361c24407624469fa0d5f951af.zip
Add option to install updates.
Based on code from classical installer and finish-install.
-rw-r--r--NEWS2
-rwxr-xr-xdraklive-install94
2 files changed, 96 insertions, 0 deletions
diff --git a/NEWS b/NEWS
index ebed9a1..7351f27 100644
--- a/NEWS
+++ b/NEWS
@@ -1,3 +1,5 @@
+- add option to install updates
+
2.24
- record installer log messages and store in /root/drakx
diff --git a/draklive-install b/draklive-install
index 10b1190..b3212c3 100755
--- a/draklive-install
+++ b/draklive-install
@@ -100,6 +100,7 @@ sub install_live() {
remove_unused_packages($in, $::prefix) if $persistent;
complete_install($in, $all_hds);
setup_bootloader($in, $all_hds, $fstab);
+ install_updates($in);
finish_installation($fstab);
display_end_message($in);
$in->exit(0);
@@ -397,6 +398,99 @@ sub setup_bootloader {
sync_logs();
}
+sub enable_network_connection {
+ my ($in) = @_;
+
+ #- The network service is running in the live system
+ local $::prefix = undef;
+
+ require network::tools;
+ return if network::tools::has_network_connection();
+
+ require network::netconnect;
+ my $modules_conf = modules::any_conf->read;
+ network::netconnect::real_main($net, $in, $modules_conf);
+ $modules_conf->write;
+
+ #- Enable network access when running in the chroot
+ cp_f('/etc/resolv.conf', '/mnt/install/etc/resolv.conf');
+}
+
+sub clean_rpmdb_shared_regions {
+ unlink glob("$::prefix/var/lib/rpm/__db.*");
+}
+
+sub add_online_media {
+ my ($in) = @_;
+
+ my @media_url = map { top(split(' ', $_)) } run_program::get_stdout('urpmq', '--list-url');
+ my @online_media = grep { !m,^(?:file://)?/, } @media_url;
+ @online_media and return 1;
+
+ $in->ask_yesorno_(
+ {
+ title => N("Updates"),
+ messages => formatAlaTeX(
+N("You now have the opportunity to setup online media.") . "\n\n" .
+N("This allows to install security updates.") . "\n\n" .
+N("To setup those media, you will need to have a working Internet
+connection.
+
+Do you want to setup the update media?")),
+ },
+ 1
+ ) or do {
+ log::l("user said no to media setup");
+ return 0;
+ };
+
+try_again:
+ enable_network_connection($in);
+
+ clean_rpmdb_shared_regions();
+
+ if (any::urpmi_add_all_media($in)) {
+ log::l("successfully added update media");
+ return 1;
+ }
+
+ log::l("failed to add update media");
+ if ($in->ask_okcancel(N("Warning"), N("Failure when adding medium") . "\n" . N("Retry?"))) {
+ goto try_again;
+ }
+ 0;
+}
+
+sub install_updates {
+ my ($in) = @_;
+
+ add_online_media($in) or return;
+
+ $in->ask_yesorno_(
+ {
+ title => N("Updates"),
+ messages => formatAlaTeX(
+N("You now have the opportunity to download updated packages. These packages
+have been updated after the distribution was released. They may
+contain security or bug fixes.
+
+To download these packages, you will need to have a working Internet
+connection.
+
+Do you want to install the updates?")),
+ },
+ 1
+ ) or do {
+ log::l("user said no to installing updates");
+ return;
+ };
+
+ my $log_file = '/root/drakx/updates.log';
+ run_program::rooted($::prefix, 'gurpmi2', '>>', $log_file, '2>>', $log_file, '--auto-select');
+
+ clean_rpmdb_shared_regions();
+}
+
sub clean_live_system_hds() {
#- clean fstab and harddrake config in the live system
#- since partitions UUIDs of the installed system have been modified