summaryrefslogtreecommitdiffstats
path: root/lib/MGA/DrakISO/BuildRoot.pm
diff options
context:
space:
mode:
authorMartin Whitaker <mageia@martin-whitaker.me.uk>2017-12-19 16:01:31 +0000
committerMartin Whitaker <mageia@martin-whitaker.me.uk>2017-12-19 16:01:31 +0000
commit505bfb9a7ade6a916d7869605a4f7a292de22776 (patch)
tree9b64ce385e96bc069c8b83f5deda2d11ff05996d /lib/MGA/DrakISO/BuildRoot.pm
parent059b5c2a18e61cc7e4348e955025f9d77466647d (diff)
downloaddrakiso-505bfb9a7ade6a916d7869605a4f7a292de22776.tar
drakiso-505bfb9a7ade6a916d7869605a4f7a292de22776.tar.gz
drakiso-505bfb9a7ade6a916d7869605a4f7a292de22776.tar.bz2
drakiso-505bfb9a7ade6a916d7869605a4f7a292de22776.tar.xz
drakiso-505bfb9a7ade6a916d7869605a4f7a292de22776.zip
Replace $live by $build throughout,
Ready for adding support for classic installer builds.
Diffstat (limited to 'lib/MGA/DrakISO/BuildRoot.pm')
-rwxr-xr-xlib/MGA/DrakISO/BuildRoot.pm166
1 files changed, 83 insertions, 83 deletions
diff --git a/lib/MGA/DrakISO/BuildRoot.pm b/lib/MGA/DrakISO/BuildRoot.pm
index a81bf0d..1924fa8 100755
--- a/lib/MGA/DrakISO/BuildRoot.pm
+++ b/lib/MGA/DrakISO/BuildRoot.pm
@@ -33,14 +33,14 @@ our @ISA = qw(Exporter);
our @EXPORT = qw(install_live_system customise_live_system);
sub install_live_system {
- my ($live) = @_;
+ my ($build) = @_;
- my $repository = $live->{settings}{repository} . '/' . $live->{settings}{arch};
+ my $repository = $build->{settings}{repository} . '/' . $build->{settings}{arch};
my $drakx_in_chroot = $repository . '/misc/drakx-in-chroot';
my $remote_repository = $repository =~ m!^(ftp|http)://! && $1;
if ($remote_repository) {
- my $local_drakx_in_chroot = $live->get_builddir('scripts') . '/drakx-in-chroot';
+ my $local_drakx_in_chroot = $build->get_builddir('scripts') . '/drakx-in-chroot';
mkdir_p(dirname($local_drakx_in_chroot));
run_('curl', '--silent', '-o', $local_drakx_in_chroot, $drakx_in_chroot)
or die "unable to get drakx-in-chroot from remote repository\n";
@@ -49,144 +49,144 @@ sub install_live_system {
local %ENV = (
%ENV,
- (map { "DRAKLIVE_" . uc($_->[0]) => $_->[1] } group_by2(%{$live->{settings}})),
- %{$live->{system}{install_env}},
+ (map { "DRAKLIVE_" . uc($_->[0]) => $_->[1] } group_by2(%{$build->{settings}})),
+ %{$build->{system}{install_env}},
);
- $ENV{DRAKLIVE_LANGS} = join(':', $live->get_langs);
- run_({ targetarch => $live->{settings}{arch} },
+ $ENV{DRAKLIVE_LANGS} = join(':', $build->get_langs);
+ run_({ targetarch => $build->{settings}{arch} },
'perl', $drakx_in_chroot,
$repository,
- $live->get_system_root,
- if_($live->{system}{auto_install}, '--auto_install', $live->{settings}{config_root} . '/' . $live->{system}{auto_install}),
- if_($live->{system}{patch_install}, '--defcfg', $live->{settings}{config_root} . '/' . $live->{system}{patch_install}),
- if_($live->{system}{rpmsrate}, '--rpmsrate', $live->{settings}{config_root} . '/' . $live->{system}{rpmsrate}),
- ($live->{system}{stage2_updates} ? (map { ('--stage2-update', $live->{settings}{config_root} . '/' . $_->[0], $_->[1]) } @{$live->{system}{stage2_updates}}) : ()),
+ $build->get_system_root,
+ if_($build->{system}{auto_install}, '--auto_install', $build->{settings}{config_root} . '/' . $build->{system}{auto_install}),
+ if_($build->{system}{patch_install}, '--defcfg', $build->{settings}{config_root} . '/' . $build->{system}{patch_install}),
+ if_($build->{system}{rpmsrate}, '--rpmsrate', $build->{settings}{config_root} . '/' . $build->{system}{rpmsrate}),
+ ($build->{system}{stage2_updates} ? (map { ('--stage2-update', $build->{settings}{config_root} . '/' . $_->[0], $_->[1]) } @{$build->{system}{stage2_updates}}) : ()),
) or die "unable to install system chroot\n";
}
sub customise_live_system {
- my ($live) = @_;
+ my ($build) = @_;
my $previous_umask = umask;
#- workaround buggy installation of directories that are not owned by any packages
umask 022;
- mount_system_fs($live);
+ mount_system_fs($build);
#- copy resolv.conf for name resolution to work when adding media
- cp_f("/etc/resolv.conf", $live->get_system_root . "/etc/");
+ cp_f("/etc/resolv.conf", $build->get_system_root . "/etc/");
#- remove previous draklive leftovers if needed
- run_({ root => $live->get_system_root }, 'urpmi.removemedia', '-a');
+ run_({ root => $build->get_system_root }, 'urpmi.removemedia', '-a');
- foreach (@{$live->{system}{additional_media}}) {
- run_({ root => $live->get_system_root }, 'urpmi.addmedia', if_($_->{distrib}, '--distrib'), $_->{name}, $_->{path})
+ foreach (@{$build->{system}{additional_media}}) {
+ run_({ root => $build->get_system_root }, 'urpmi.addmedia', if_($_->{distrib}, '--distrib'), $_->{name}, $_->{path})
or die "unable to add media from $_->{path}\n";
@{$_->{packages} || []} or next;
- run_({ root => $live->get_system_root, targetarch => $live->{settings}{arch} },
+ run_({ root => $build->get_system_root, targetarch => $build->{settings}{arch} },
'urpmi', '--auto', '--no-verify-rpm', if_(!$_->{distrib}, '--searchmedia', $_->{name}), @{$_->{packages}})
or die "unable to install packages from $_->{path}\n";
}
#- additional rpms may have dependencies in additional media
- if (@{$live->{system}{rpms} || []}) {
+ if (@{$build->{system}{rpms} || []}) {
my $rpm_tmp_dir = '/tmp/draklive_rpms';
- mkdir_p($live->get_system_root . $rpm_tmp_dir);
- cp_f((map { $live->{settings}{config_root} . '/' . $_ } @{$live->{system}{rpms}}), $live->get_system_root . $rpm_tmp_dir);
- run_({ root => $live->get_system_root, targetarch => $live->{settings}{arch} },
+ mkdir_p($build->get_system_root . $rpm_tmp_dir);
+ cp_f((map { $build->{settings}{config_root} . '/' . $_ } @{$build->{system}{rpms}}), $build->get_system_root . $rpm_tmp_dir);
+ run_({ root => $build->get_system_root, targetarch => $build->{settings}{arch} },
'urpmi', '--auto', '--no-verify-rpm',
- map { $rpm_tmp_dir . '/' . basename($_) } @{$live->{system}{rpms}})
+ map { $rpm_tmp_dir . '/' . basename($_) } @{$build->{system}{rpms}})
or die "unable to install additional system rpms\n";
- rm_rf($live->get_system_root . $rpm_tmp_dir);
+ rm_rf($build->get_system_root . $rpm_tmp_dir);
}
#- remove urpmi media added by drakx-in-chroot and additional media, they're unusable
- run_({ root => $live->get_system_root }, 'urpmi.removemedia', '-a');
+ run_({ root => $build->get_system_root }, 'urpmi.removemedia', '-a');
- my $erase = join(' ', @{$live->{system}{erase_rpms} || []});
- run_({ root => $live->get_system_root, targetarch => $live->{settings}{arch} },
+ my $erase = join(' ', @{$build->{system}{erase_rpms} || []});
+ run_({ root => $build->get_system_root, targetarch => $build->{settings}{arch} },
'sh', '-c', "rpm -qa $erase | xargs rpm -e ") if $erase;
- run_({ root => $live->get_system_root }, 'systemctl', 'disable', $_ . '.service') foreach @{$live->{system}{disable_services}};
- run_({ root => $live->get_system_root }, 'systemctl', 'disable', $_ . '.timer') foreach @{$live->{system}{disable_timers}};
+ run_({ root => $build->get_system_root }, 'systemctl', 'disable', $_ . '.service') foreach @{$build->{system}{disable_services}};
+ run_({ root => $build->get_system_root }, 'systemctl', 'disable', $_ . '.timer') foreach @{$build->{system}{disable_timers}};
#- make sure harddrake is run:
#- if previous HW config file is empty, we assumes DrakX has just completed the installation
#- (do it in chroot, or else Storable from the build box may write an incompatible config file)
- run_({ root => $live->get_system_root },
+ run_({ root => $build->get_system_root },
'perl', '-MStorable', '-e', qq(Storable::store({ UNKNOWN => {} }, '/etc/sysconfig/harddrake2/previous_hw')));
#- remove some build-machine specific configuration
- clean_system_conf_file($live, $_)
+ clean_system_conf_file($build, $_)
foreach qw(/etc/mtab /etc/iftab /etc/shorewall/interfaces /etc/mdadm.conf),
- if_(!$live->{system}{skip_fstab}, '/etc/fstab');
- unlink($_) foreach map { glob($live->get_system_root . $_) } @{$live->{system}{remove_files} || []};
+ if_(!$build->{system}{skip_fstab}, '/etc/fstab');
+ unlink($_) foreach map { glob($build->get_system_root . $_) } @{$build->{system}{remove_files} || []};
- if ($live->{system}{modules_conf}) {
- local $::prefix = $live->get_system_root;
+ if ($build->{system}{modules_conf}) {
+ local $::prefix = $build->get_system_root;
local *modules::write_preload_conf = sub {}; #- FIXME, make this an option
my $modules_conf = modules::any_conf->vnew;
- put_in_hash($modules_conf, $live->{system}{modules_conf});
+ put_in_hash($modules_conf, $build->{system}{modules_conf});
$modules_conf->write;
}
- my $mount_options = $live->{media}->get_media_setting('mount_options') || "defaults";
- output_with_perm($live->get_system_root . '/etc/fstab', 0644,
- $live->{mount}{overlay}
- ? "none / $live->{mount}{overlay} $mount_options 0 0\n"
- : $live->{media}->get_media_setting('source') . " / " . $live->{media}->get_media_setting('fs') . " $mount_options 1 1\n"
- ) unless $live->{system}{skip_fstab};
+ my $mount_options = $build->{media}->get_media_setting('mount_options') || "defaults";
+ output_with_perm($build->get_system_root . '/etc/fstab', 0644,
+ $build->{mount}{overlay}
+ ? "none / $build->{mount}{overlay} $mount_options 0 0\n"
+ : $build->{media}->get_media_setting('source') . " / " . $build->{media}->get_media_setting('fs') . " $mount_options 1 1\n"
+ ) unless $build->{system}{skip_fstab};
#- interactive mode can lead to race in initscripts
#- (don't use addVarsInSh from MDK::Common, it breaks shell escapes)
- substInFile { s/^PROMPT=.*/PROMPT=no/ } $live->get_system_root . '/etc/sysconfig/init';
+ substInFile { s/^PROMPT=.*/PROMPT=no/ } $build->get_system_root . '/etc/sysconfig/init';
- configure_draklive_resize($live);
+ configure_draklive_resize($build);
- if ($live->{system}{preselect_kdm_user}) {
+ if ($build->{system}{preselect_kdm_user}) {
#- preselect specified user in kdm
- my $kdm_cfg = $live->get_system_root . '/etc/kde/kdm/kdmrc';
- update_gnomekderc($kdm_cfg, 'X-:0-Greeter' => (PreselectUser => 'Default', DefaultUser => $live->{system}{preselect_kdm_user})) if -f $kdm_cfg;
+ my $kdm_cfg = $build->get_system_root . '/etc/kde/kdm/kdmrc';
+ update_gnomekderc($kdm_cfg, 'X-:0-Greeter' => (PreselectUser => 'Default', DefaultUser => $build->{system}{preselect_kdm_user})) if -f $kdm_cfg;
}
#- apply patches and install files after the configuration is cleaned
#- to allow special configuration files (especially modprobe.preload)
- foreach (@{$live->{system}{patches}}) {
- my $patch = $live->{settings}{config_root} . '/' . $_;
- my @args = ('-p0', '-d', $live->get_system_root, '-i', $patch);
+ foreach (@{$build->{system}{patches}}) {
+ my $patch = $build->{settings}{config_root} . '/' . $_;
+ my @args = ('-p0', '-d', $build->get_system_root, '-i', $patch);
run_program::run('patch', '>', '/dev/null', '--dry-run', '-f', '-R', @args) || run_('patch', @args)
or die "unable to apply patch " . $patch . "\n";
}
- copy_files_to($live, $live->{system}{files}, $live->get_system_root);
- my @no_install_files = map { $_->[1] } grep { $_->[2] && $_->[2]{no_install} } @{$live->{system}{files}};
- output_p($live->get_system_root . '/etc/draklive-install.d/remove.d/draklive', map { "$_\n" } @no_install_files);
+ copy_files_to($build, $build->{system}{files}, $build->get_system_root);
+ my @no_install_files = map { $_->[1] } grep { $_->[2] && $_->[2]{no_install} } @{$build->{system}{files}};
+ output_p($build->get_system_root . '/etc/draklive-install.d/remove.d/draklive', map { "$_\n" } @no_install_files);
- eval { rm_rf($live->get_builddir('files')) };
- mkdir_p($live->get_builddir('files'));
- if ($live->{media}{files}) {
- copy_files_to($live, $live->{media}{files}, $live->get_builddir('files'));
+ eval { rm_rf($build->get_builddir('files')) };
+ mkdir_p($build->get_builddir('files'));
+ if ($build->{media}{files}) {
+ copy_files_to($build, $build->{media}{files}, $build->get_builddir('files'));
}
- remove_files_from($live->{media}{remove_files}, $live->get_builddir('files'));
+ remove_files_from($build->{media}{remove_files}, $build->get_builddir('files'));
- run_({ targetarch => $live->{settings}{arch} },
- "chroot", $live->get_system_root, "bash", "-c", $live->{system}{postInstall}) if $live->{system}{postInstall};
+ run_({ targetarch => $build->{settings}{arch} },
+ "chroot", $build->get_system_root, "bash", "-c", $build->{system}{postInstall}) if $build->{system}{postInstall};
- clean_system_conf_file($live, "/etc/resolv.conf");
- write_dist_lists($live);
+ clean_system_conf_file($build, "/etc/resolv.conf");
+ write_dist_lists($build);
- umount_external_fs($live);
+ umount_external_fs($build);
umask $previous_umask;
}
sub configure_draklive_resize {
- my ($live) = @_;
+ my ($build) = @_;
- my $resizable_loopback = find { $_->{min_size} } @{$live->{mount}{dirs} || []};
+ my $resizable_loopback = find { $_->{min_size} } @{$build->{mount}{dirs} || []};
if ($resizable_loopback) {
my $ext = $loop_types{$resizable_loopback->{type}}{extension};
- output($live->get_system_root . '/etc/sysconfig/draklive-resize', <<EOF);
+ output($build->get_system_root . '/etc/sysconfig/draklive-resize', <<EOF);
DRAKLIVE_RESIZE=yes
LOOPBACK=/live/media/loopbacks$resizable_loopback->{path}$ext
TYPE=$resizable_loopback->{fs}
@@ -199,12 +199,12 @@ EOF
}
sub copy_files_to {
- my ($live, $files, $root) = @_;
+ my ($build, $files, $root) = @_;
foreach (@$files) {
my ($source, $dest, $o_opts) = @$_;
$dest = $root . '/' . $dest;
mkdir_p($dest =~ m|/$| ? $dest : dirname($dest));
- my @sources = MGA::DrakISO::Utils::glob__($live->{settings}{config_root} . '/' . $source);
+ my @sources = MGA::DrakISO::Utils::glob__($build->{settings}{config_root} . '/' . $source);
print STDERR "copying @sources to $dest\n";
cp_af(@sources, $dest);
my $o_perm = $o_opts && $o_opts->{mode};
@@ -224,34 +224,34 @@ sub join_lists {
}
sub clean_system_conf_file {
- my ($live, $file) = @_;
- substInFile { undef $_ if /^[^#]/ } $live->get_system_root . $file;
+ my ($build, $file) = @_;
+ substInFile { undef $_ if /^[^#]/ } $build->get_system_root . $file;
}
sub write_dist_lists {
- my ($live) = @_;
+ my ($build) = @_;
- my $lists_dir = $live->get_builddir('dist');
+ my $lists_dir = $build->get_builddir('dist');
mkdir_p($lists_dir);
- run_("chroot " . $live->get_system_root . " rpm -qa | sort > " .
- $lists_dir . '/' . $live->get_name . '.lst');
+ run_("chroot " . $build->get_system_root . " rpm -qa | sort > " .
+ $lists_dir . '/' . $build->get_name . '.lst');
- run_("chroot " . $live->get_system_root . " rpm -qa --qf '%{name}\n' | sort > " .
- $lists_dir . '/' . $live->get_name . '.lst.names');
+ run_("chroot " . $build->get_system_root . " rpm -qa --qf '%{name}\n' | sort > " .
+ $lists_dir . '/' . $build->get_name . '.lst.names');
- run_("chroot " . $live->get_system_root .
+ run_("chroot " . $build->get_system_root .
qq( sh -c "rpm -qa --qf '[%{NAME} %{FILESIZES} %{FILESTATES}\n]' | awk '{if(\\\$3==0) {s[\\\$1]+=\\\$2}} END{for (p in s){print s[p],p}}' | sort -n" > ) .
- $lists_dir . '/' . $live->get_name . '.lst.full');
+ $lists_dir . '/' . $build->get_name . '.lst.full');
- run_("chroot " . $live->get_system_root .
+ run_("chroot " . $build->get_system_root .
qq( sh -c "urpmi_rpm-find-leaves | xargs rpm -q --qf '[%{NAME} %{FILESIZES} %{FILESTATES}\n]' | awk '{if(\\\$3==0) {s[\\\$1]+=\\\$2}} END{for (p in s){print s[p],p}}' | sort -n" > ) .
- $lists_dir . '/' . $live->get_name . '.lst.leaves');
+ $lists_dir . '/' . $build->get_name . '.lst.leaves');
require lang;
- my @live_langs = $live->get_langs;
+ my @live_langs = $build->get_langs;
my @langs = grep { member($_, @live_langs) || member(lang::locale_to_main_locale($_), @live_langs) } lang::list_langs();
- my $langs_file = $lists_dir . '/' . $live->get_name . '.langs';
+ my $langs_file = $lists_dir . '/' . $build->get_name . '.langs';
output_p($langs_file, map { lang::l2name($_) . " (" . $_ . ")\n" } sort(@langs));
}