summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorOlivier Blin <oblin@mandriva.com>2008-10-28 20:24:15 +0000
committerOlivier Blin <oblin@mandriva.com>2008-10-28 20:24:15 +0000
commit218b22da76f5ebc2d954813246c8822c38685ed4 (patch)
tree25330306bd8de7a9c0fdab848435dd84ea9f3822
parentc3327e6b1a783c8afee54c5ccd2b5d44afdba66b (diff)
downloaddraklive-218b22da76f5ebc2d954813246c8822c38685ed4.tar
draklive-218b22da76f5ebc2d954813246c8822c38685ed4.tar.gz
draklive-218b22da76f5ebc2d954813246c8822c38685ed4.tar.bz2
draklive-218b22da76f5ebc2d954813246c8822c38685ed4.tar.xz
draklive-218b22da76f5ebc2d954813246c8822c38685ed4.zip
move get_builddir and get_system_root as methods in MDV::Draklive::Live object
-rwxr-xr-xdraklive238
-rw-r--r--lib/MDV/Draklive/Live.pm10
2 files changed, 124 insertions, 124 deletions
diff --git a/draklive b/draklive
index 06dd708..e17f434 100755
--- a/draklive
+++ b/draklive
@@ -258,9 +258,9 @@ my %loop;
extension => '-lzma.sqfs',
build => sub {
my ($live, $dir) = @_;
- my $dest = get_builddir($live) . $live->{prefix}{build}{loopbacks} . $dir->{path} . $loop{squashfs}{extension};
+ my $dest = $live->get_builddir . $live->{prefix}{build}{loopbacks} . $dir->{path} . $loop{squashfs}{extension};
mkdir_p(dirname($dest));
- my $root = $dir->{root} || get_system_root($live);
+ my $root = $dir->{root} || $live->get_system_root;
my $src = $root . $dir->{build_from};
my $total = directory_usage($src);
print "have to process " . int($total/1000000) . " MB\n";
@@ -307,7 +307,7 @@ my %loop;
extension => '.loop',
build => sub {
my ($live, $dir) = @_;
- my $dest = get_builddir($live) . $live->{prefix}{build}{loopbacks} . $dir->{path} . $loop{loopfs}{extension};
+ my $dest = $live->get_builddir . $live->{prefix}{build}{loopbacks} . $dir->{path} . $loop{loopfs}{extension};
mkdir_p(dirname($dest));
device_allocate_file($dest, $dir->{pre_allocate});
device_mkfs($dest, $dir->{fs}) if !defined $dir->{min_size};
@@ -368,16 +368,6 @@ my %overlay = (
},
);
-sub get_builddir {
- my ($live) = @_;
- $live->{settings}{builddir} . '/' . $live->get_name;
-}
-
-sub get_system_root {
- my ($live) = @_;
- $live->{settings}{chroot} . '/' . $live->get_name;
-}
-
sub get_initrd_path {
my ($media) = @_;
'/' . $media->{storage} . '/initrd.gz';
@@ -392,8 +382,8 @@ sub find_kernel {
my ($live) = @_;
my $kernel = $live->{system}{kernel};
unless ($kernel) {
- my $vmlinuz = readlink(get_system_root($live) . '/boot/vmlinuz');
- $vmlinuz ||= find { -e $_ && ! -l $_ } glob_(get_system_root($live) . '/boot/vmlinuz-*');
+ my $vmlinuz = readlink($live->get_system_root . '/boot/vmlinuz');
+ $vmlinuz ||= find { -e $_ && ! -l $_ } glob_($live->get_system_root . '/boot/vmlinuz-*');
($kernel) = $vmlinuz =~ /\bvmlinuz-(.*)$/ or die "no kernel can be found\n";
}
$kernel;
@@ -409,7 +399,7 @@ sub create_media_initrd {
foreach ($live->{media}) {
create_initrd_for_media($live, $_);
}
- cp_f(get_builddir($live) . $live->{prefix}{build}{boot} . get_initrd_path($live->{media}),
+ cp_f($live->get_builddir . $live->{prefix}{build}{boot} . get_initrd_path($live->{media}),
$live->{copy_initrd}) if $live->{copy_initrd};
}
@@ -444,10 +434,10 @@ sub inst_initrd_bin {
sub create_initrd_for_media {
my ($live, $media) = @_;
- my $lib_prefix = find { glob(get_system_root($live) . $_ . '/libc.so.*') } qw(/lib64 /lib);
+ my $lib_prefix = find { glob($live->get_system_root . $_ . '/libc.so.*') } qw(/lib64 /lib);
$lib_prefix or die 'unable to find system libraries in /lib or /lib64';
- my $initrd_tree = get_builddir($live) . $live->{prefix}{build}{initrd} . '/' . $media->{storage};
+ my $initrd_tree = $live->get_builddir . $live->{prefix}{build}{initrd} . '/' . $media->{storage};
rm_rf($initrd_tree) if -e $initrd_tree;
mkdir_p($initrd_tree . $_) foreach
@@ -458,30 +448,30 @@ sub create_initrd_for_media {
map { $_->{mountpoint} } @{$live->{mount}{dirs} || []};
#- use nash with label support
- inst_initrd_bin(get_system_root($live), $initrd_tree, '/sbin/nash');
- inst_initrd_bin(get_system_root($live), $initrd_tree, '/usr' . $lib_prefix . '/drakx-installer-binaries/probe-modules');
- inst_initrd_bin(get_system_root($live), $initrd_tree, '/sbin/blockdev')
+ inst_initrd_bin($live->get_system_root, $initrd_tree, '/sbin/nash');
+ inst_initrd_bin($live->get_system_root, $initrd_tree, '/usr' . $lib_prefix . '/drakx-installer-binaries/probe-modules');
+ inst_initrd_bin($live->get_system_root, $initrd_tree, '/sbin/blockdev')
if get_media_setting($media, 'rereadpt');
- inst_initrd_bin(get_system_root($live), $initrd_tree, '/usr/bin/strace')
+ inst_initrd_bin($live->get_system_root, $initrd_tree, '/usr/bin/strace')
if $live->{debug};
- foreach (chomp_(run_program::rooted_get_stdout(get_system_root($live), "/usr/sbin/splashy_find_files"))) {
- inst_initrd_file(get_system_root($live), $initrd_tree, $_);
+ foreach (chomp_(run_program::rooted_get_stdout($live->get_system_root, "/usr/sbin/splashy_find_files"))) {
+ inst_initrd_file($live->get_system_root, $initrd_tree, $_);
}
#- busybox is required to:
#- detect usb-storage process (we need sh/while/ps/grep)
#- mount loopbacks read-only with losetup (useful over NFS)
my $busybox = '/usr/bin/busybox';
- inst_initrd_bin(get_system_root($live), $initrd_tree, $busybox);
- my $busybox_rooted = get_system_root($live) . $busybox;
+ inst_initrd_bin($live->get_system_root, $initrd_tree, $busybox);
+ my $busybox_rooted = $live->get_system_root . $busybox;
my @l = map { /functions:/ .. /^$/ ? do { s/\s//g; split /,/ } : () } `$busybox_rooted`;
shift @l;
symlink('busybox', $initrd_tree . "/bin/$_") foreach @l;
my $fs = get_media_setting($media, 'fs');
my @loop_types = uniq(map { $_->{type} } @{$live->{mount}{dirs}});
- inst_initrd_bin(get_system_root($live), $initrd_tree, $_) foreach
+ inst_initrd_bin($live->get_system_root, $initrd_tree, $_) foreach
@{$storage_fs{$fs} && $storage_fs{$fs}{files} || []},
(map { @{$loop{$_} && $loop{$_}{files} || []} } @loop_types);
@@ -504,7 +494,7 @@ sub create_initrd_for_media {
my $kernel = find_kernel($live);
print "using kernel $kernel\n";
my $kernel_root = "/lib/modules/" . $kernel;
- list_modules::load_dependencies(get_system_root($live) . $kernel_root . "/modules.dep");
+ list_modules::load_dependencies($live->get_system_root . $kernel_root . "/modules.dep");
my ($storage_modules, $skipped) = partition { list_modules::modname2filename($_) }
uniq(map { modules::cond_mapping_24_26($_) } category2modules(get_media_setting($media, 'modules')));
@@ -532,7 +522,7 @@ sub create_initrd_for_media {
foreach my $m (@modules_closure) {
my $full = list_modules::modname2path($m);
mkdir_p(dirname($initrd_tree . $full));
- cp_f(get_system_root($live) . $full, $initrd_tree . $full);
+ cp_f($live->get_system_root . $full, $initrd_tree . $full);
}
foreach my $f (@{$live->{system}{additional_modules}}) {
my $destdir = $initrd_tree . $kernel_root . "/kernel";
@@ -547,10 +537,10 @@ sub create_initrd_for_media {
mkdir_p($initrd_tree . "/etc/blkid"); #- for nash and showlabels cache
mkdir_p($initrd_tree . "/lib/module-init-tools");
- cp_f(get_system_root($live) . "/lib/module-init-tools/ldetect-lst-modules.alias", $initrd_tree . "/lib/module-init-tools");
+ cp_f($live->get_system_root . "/lib/module-init-tools/ldetect-lst-modules.alias", $initrd_tree . "/lib/module-init-tools");
mkdir_p($initrd_tree . "/usr/share/ldetect-lst");
- cp_f(get_system_root($live) . "/usr/share/pci.ids", $initrd_tree . "/usr/share");
- cp_f(get_system_root($live) . "/usr/share/ldetect-lst/" . $_, $initrd_tree . "/usr/share/ldetect-lst")
+ cp_f($live->get_system_root . "/usr/share/pci.ids", $initrd_tree . "/usr/share");
+ cp_f($live->get_system_root . "/usr/share/ldetect-lst/" . $_, $initrd_tree . "/usr/share/ldetect-lst")
foreach qw(fallback-modules.alias pcitable.gz usbtable.gz);
@$skipped and print STDERR "skipped modules: " . join(' ', sort(@$skipped)) . "\n";
@@ -572,7 +562,7 @@ sub create_initrd_scriptlet {
my ($mount_first, $mount_last) = partition { !$loop{$_->{type}}{delay_mount} }
grep { exists $loop{$_->{type}}{mount} } @{$live->{mount}{dirs} || []};
- output_with_perm(get_builddir($live) . $live->{prefix}{build}{initrd} . '/' . $media->{storage} . '/linuxrc', 0755,
+ output_with_perm($live->get_builddir . $live->{prefix}{build}{initrd} . '/' . $media->{storage} . '/linuxrc', 0755,
join("\n",
"#!/bin/nash",
#- required for labels and ps
@@ -612,12 +602,12 @@ sub create_initrd_scriptlet {
sub compress_initrd_tree {
my ($live, $media) = @_;
- my $initrd_tree = get_builddir($live) . $live->{prefix}{build}{initrd} . '/' . $media->{storage};
+ my $initrd_tree = $live->get_builddir . $live->{prefix}{build}{initrd} . '/' . $media->{storage};
my $size = chomp_(run_program::get_stdout("du -ks $initrd_tree | awk '{print \$1}'"));
my $inodes = chomp_(run_program::get_stdout("find $initrd_tree | wc -l")) + 100;
my $initrd_size = $size + 350 + int($inodes / 10); #- 10 inodes needs 1K
$initrd_size += 600; # splashy
- my $initrd = get_builddir($live) . $live->{prefix}{build}{boot} . get_initrd_path($media);
+ my $initrd = $live->get_builddir . $live->{prefix}{build}{boot} . get_initrd_path($media);
$initrd =~ s/.gz$//;
mkdir_p(dirname($initrd));
@@ -637,15 +627,15 @@ sub add_splash {
my ($live, $media) = @_;
if ($live->{system}{vga_mode} && $live->{system}{splash} ne 'no') {
require bootloader;
- my $initrd = get_builddir($live) . $live->{prefix}{build}{boot} . get_initrd_path($media);
+ my $initrd = $live->get_builddir . $live->{prefix}{build}{boot} . get_initrd_path($media);
my $tmp_initrd = '/tmp/initrd.gz';
- cp_f($initrd, get_system_root($live) . $tmp_initrd);
+ cp_f($initrd, $live->get_system_root . $tmp_initrd);
{
- local $::prefix = get_system_root($live);
+ local $::prefix = $live->get_system_root;
bootloader::add_boot_splash($tmp_initrd, $live->{system}{vga_mode});
}
- cp_f(get_system_root($live) . $tmp_initrd, $initrd);
- unlink(get_system_root($live) . $tmp_initrd);
+ cp_f($live->get_system_root . $tmp_initrd, $initrd);
+ unlink($live->get_system_root . $tmp_initrd);
}
}
@@ -658,13 +648,13 @@ sub create_classical_initrd {
my $initrd_short = '/boot/initrd.img';
my $vmlinuz_long = '/boot/vmlinuz-' . $kernel;
my $vmlinuz_short = '/boot/vmlinuz';
- my $root = get_system_root($live);
+ my $root = $live->get_system_root;
run_({ root => $root }, 'mkinitrd', '-v', '-f', $initrd_long, $kernel);
symlinkf(basename($initrd_long), $root . $initrd_short);
symlinkf(basename($vmlinuz_long), $root . $vmlinuz_short);
if ($live->{system}{vga_mode} && $live->{system}{splash} ne 'no') {
require bootloader;
- local $::prefix = get_system_root($live);
+ local $::prefix = $live->get_system_root;
bootloader::add_boot_splash($initrd_long, $live->{system}{vga_mode});
}
}
@@ -697,7 +687,7 @@ sub build_syslinux_cfg {
my ($initrd, $kernel, $bootlogo, $help) = map { $to_root ? basename($_) : $_ }
map { $boot . $_ } get_initrd_path($media), @syslinux_boot_files;
my $has_bootlogo = $live->{system}{gfxboot} &&
- -e get_builddir($live) . $live->{prefix}{build}{boot} . '/syslinux/bootlogo';
+ -e $live->get_builddir . $live->{prefix}{build}{boot} . '/syslinux/bootlogo';
my $timeout = get_bootloader_timeout($live) * 10;
my $title = $media->{title} || $live->{media}{title};
join("\n",
@@ -760,7 +750,7 @@ sub install_system {
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 = get_builddir($live) . $live->{prefix}{build}{scripts} . '/drakx-in-chroot';
+ my $local_drakx_in_chroot = $live->get_builddir . $live->{prefix}{build}{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";
@@ -773,7 +763,7 @@ sub install_system {
run_({ setarch => $live->{settings}{arch} },
'perl', $drakx_in_chroot,
$repository,
- get_system_root($live),
+ $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}),
@@ -788,7 +778,7 @@ sub configure_draklive_resize {
my $resizable_loopback = find { $_->{min_size} } @{$live->{mount}{dirs} || []};
if ($resizable_loopback) {
my $media_loopbacks = get_media_prefix($live, 'loopbacks');
- output(get_system_root($live) . '/etc/sysconfig/draklive-resize', <<EOF);
+ output($live->get_system_root . '/etc/sysconfig/draklive-resize', <<EOF);
DRAKLIVE_RESIZE=yes
LOOPBACK=$live->{prefix}{live}{mnt}$live->{prefix}{media}{mnt}${media_loopbacks}$resizable_loopback->{path}
TYPE=$resizable_loopback->{fs}
@@ -833,16 +823,16 @@ sub post_install_system {
umask 022;
#- copy resolv.conf for name resolution to work when adding media
- cp_f("/etc/resolv.conf", get_system_root($live) . "/etc");
+ cp_f("/etc/resolv.conf", $live->get_system_root . "/etc");
#- remove previous draklive leftovers if needed
- run_({ root => get_system_root($live) }, 'urpmi.removemedia', '-a');
+ run_({ root => $live->get_system_root }, 'urpmi.removemedia', '-a');
foreach (@{$live->{system}{additional_media}}) {
- run_({ root => get_system_root($live) }, 'urpmi.addmedia', if_($_->{distrib}, '--distrib'), $_->{name}, $_->{path})
+ run_({ root => $live->get_system_root }, 'urpmi.addmedia', if_($_->{distrib}, '--distrib'), $_->{name}, $_->{path})
or die "unable to add media from $_->{path}\n";
@{$_->{packages}} or next;
- run_({ root => get_system_root($live), setarch => $live->{settings}{arch} },
+ run_({ root => $live->get_system_root, setarch => $live->{settings}{arch} },
'urpmi', '--auto', '--no-verify-rpm', if_(!$_->{distrib}, '--searchmedia', $_->{name}), @{$_->{packages}})
or die "unable to install packages from $_->{path}\n";
}
@@ -850,44 +840,44 @@ sub post_install_system {
#- additional rpms may have dependencies in additional media
if (@{$live->{system}{rpms}}) {
my $rpm_tmp_dir = '/tmp/draklive_rpms';
- mkdir_p(get_system_root($live) . $rpm_tmp_dir);
- cp_f((map { $live->{settings}{config_root} . '/' . $_ } @{$live->{system}{rpms}}), get_system_root($live) . $rpm_tmp_dir);
- run_({ root => get_system_root($live), setarch => $live->{settings}{arch} },
+ 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, setarch => $live->{settings}{arch} },
'urpmi', '--auto', '--no-verify-rpm',
map { $rpm_tmp_dir . '/' . basename($_) } @{$live->{system}{rpms}})
or die "unable to install additional system rpms\n";
- rm_rf(get_system_root($live) . $rpm_tmp_dir);
+ rm_rf($live->get_system_root . $rpm_tmp_dir);
}
#- remove urpmi media added by drakx-in-chroot and additional media, they're unusable
- run_({ root => get_system_root($live) }, 'urpmi.removemedia', '-a');
+ run_({ root => $live->get_system_root }, 'urpmi.removemedia', '-a');
my $erase = join(' ', @{$live->{system}{erase_rpms}});
- run_({ root => get_system_root($live), setarch => $live->{settings}{arch} },
+ run_({ root => $live->get_system_root, setarch => $live->{settings}{arch} },
'sh', '-c', "rpm -qa $erase | xargs rpm -e ") if $erase;
- run_({ root => get_system_root($live) }, 'chkconfig', '--del', $_) foreach @{$live->{system}{disable_services}};
+ run_({ root => $live->get_system_root }, 'chkconfig', '--del', $_) foreach @{$live->{system}{disable_services}};
#- 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 => get_system_root($live) },
+ run_({ root => $live->get_system_root },
'perl', '-MStorable', '-e', qq(Storable::store({ UNKNOWN => {} }, '/etc/sysconfig/harddrake2/previous_hw')));
#- remove some build-machine specific configuration
- substInFile { undef $_ if /^[^#]/ } get_system_root($live) . $_
+ substInFile { undef $_ if /^[^#]/ } $live->get_system_root . $_
foreach qw(/etc/fstab /etc/mtab /etc/modprobe.conf /etc/modprobe.preload /etc/iftab /etc/shorewall/interfaces /etc/mdadm.conf /etc/resolv.conf);
- unlink($_) foreach map { glob(get_system_root($live) . $_) } @{$live->{system}{remove_files} || []};
+ unlink($_) foreach map { glob($live->get_system_root . $_) } @{$live->{system}{remove_files} || []};
if ($live->{system}{modules_conf}) {
- local $::prefix = get_system_root($live);
+ local $::prefix = $live->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});
$modules_conf->write;
}
- output_with_perm(get_system_root($live) . '/etc/fstab', 0644,
+ output_with_perm($live->get_system_root . '/etc/fstab', 0644,
$live->{mount}{overlay}
? "none / $live->{mount}{overlay} rw 0 0\n"
: get_media_setting($live->{media}, 'source') . " / " . get_media_setting($live->{media}, 'fs') . " defaults 1 1\n"
@@ -895,13 +885,13 @@ sub post_install_system {
#- interactive mode can lead to race in initscripts
#- (don't use addVarsInSh from MDK::Common, it breaks shell escapes)
- substInFile { s/^PROMPT=.*/PROMPT=no/ } get_system_root($live) . '/etc/sysconfig/init';
+ substInFile { s/^PROMPT=.*/PROMPT=no/ } $live->get_system_root . '/etc/sysconfig/init';
configure_draklive_resize($live);
if ($live->{system}{preselect_kdm_user}) {
#- preselect specified user in kdm
- my $kdm_cfg = get_system_root($live) . '/etc/kde/kdm/kdmrc';
+ 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;
}
@@ -909,24 +899,24 @@ sub post_install_system {
#- to allow special configuration files (especially modprobe.preload)
foreach (@{$live->{system}{patches}}) {
my $patch = $live->{settings}{config_root} . '/' . $_;
- my @args = ('-p0', '-d', get_system_root($live), '-i', $patch);
+ my @args = ('-p0', '-d', $live->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}, get_system_root($live));
+ 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(get_system_root($live) . '/etc/draklive-install.d/remove.d/draklive', map { "$_\n" } @no_install_files);
+ output_p($live->get_system_root . '/etc/draklive-install.d/remove.d/draklive', map { "$_\n" } @no_install_files);
- eval { rm_rf(get_builddir($live) . $live->{prefix}{build}{files}) };
- mkdir_p(get_builddir($live) . $live->{prefix}{build}{files});
+ eval { rm_rf($live->get_builddir . $live->{prefix}{build}{files}) };
+ mkdir_p($live->get_builddir . $live->{prefix}{build}{files});
if ($live->{media}{files}) {
- copy_files_to($live, $live->{media}{files}, get_builddir($live) . $live->{prefix}{build}{files});
+ copy_files_to($live, $live->{media}{files}, $live->get_builddir . $live->{prefix}{build}{files});
}
- remove_files_from($live->{media}{remove_files}, get_builddir($live) . $live->{prefix}{build}{files});
+ remove_files_from($live->{media}{remove_files}, $live->get_builddir . $live->{prefix}{build}{files});
run_({ setarch => $live->{settings}{arch} },
- "chroot", get_system_root($live), "bash", "-c", $live->{system}{postInstall}) if $live->{system}{postInstall};
+ "chroot", $live->get_system_root, "bash", "-c", $live->{system}{postInstall}) if $live->{system}{postInstall};
write_dist_lists($live);
@@ -936,30 +926,30 @@ sub post_install_system {
sub write_dist_lists {
my ($live) = @_;
- my $lst = get_builddir($live) . $live->{prefix}{build}{dist} . '/' . $live->get_name . '.lst';
+ my $lst = $live->get_builddir . $live->{prefix}{build}{dist} . '/' . $live->get_name . '.lst';
mkdir_p(dirname($lst));
- run_("chroot " . get_system_root($live) . " rpm -qa | sort > " . $lst);
+ run_("chroot " . $live->get_system_root . " rpm -qa | sort > " . $lst);
- my $full = get_builddir($live) . $live->{prefix}{build}{dist} . '/' . $live->get_name . '.lst.full';
+ my $full = $live->get_builddir . $live->{prefix}{build}{dist} . '/' . $live->get_name . '.lst.full';
mkdir_p(dirname($full));
- run_("chroot " . get_system_root($live) .
+ run_("chroot " . $live->get_system_root .
qq( sh -c "rpm -qa --qf '%{size} \t%{name}\n' | sort -n" > ) . $full);
- my $leaves = get_builddir($live) . $live->{prefix}{build}{dist} . '/' . $live->get_name . '.lst.leaves';
+ my $leaves = $live->get_builddir . $live->{prefix}{build}{dist} . '/' . $live->get_name . '.lst.leaves';
mkdir_p(dirname($leaves));
- run_("chroot " . get_system_root($live) .
+ run_("chroot " . $live->get_system_root .
qq( sh -c "urpmi_rpm-find-leaves | xargs rpm -q --qf '%{size} \t%{name}\n' | sort -n" > ) . $leaves);
require lang;
my @live_langs = get_langs($live);
my @langs = grep { member(lang::locale_to_main_locale($_), @live_langs) } lang::list_langs();
- my $langs_file = get_builddir($live) . $live->{prefix}{build}{dist} . '/' . $live->get_name . '.langs';
+ my $langs_file = $live->get_builddir . $live->{prefix}{build}{dist} . '/' . $live->get_name . '.langs';
output_p($langs_file, map { lang::l2name($_) . " (" . $_ . ")\n" } sort(@langs));
}
sub umount_external_filesystem {
my ($live) = @_;
- my $mnt = get_system_root($live) . "/mnt/";
+ my $mnt = $live->get_system_root . "/mnt/";
eval { fs::mount::umount("$mnt/$_") } foreach all($mnt);
}
@@ -968,7 +958,7 @@ sub expand_file_list {
map {
$_->{path} ?
$_->{path} :
- chomp_(cat_(glob(($_->{rooted} && get_system_root($live)) . $_->{source})));
+ chomp_(cat_(glob(($_->{rooted} && $live->get_system_root) . $_->{source})));
} @files;
}
@@ -995,7 +985,7 @@ sub list_loopback_modules {
my $name = basename($list);
$name =~ s/\.[^.]+$//;
{ type => $l->{type}, name => $name, files => [ expand_file_list($live, { source => $list }) ] };
- } glob(($_->{rooted} && get_system_root($live)) . $_->{source});
+ } glob(($_->{rooted} && $live->get_system_root) . $_->{source});
} @{$live->{loopbacks}{modules}};
}
@@ -1013,21 +1003,21 @@ sub create_loopback_files {
}
foreach my $module (list_loopback_modules($live)) {
- my $copy_tree = get_system_root($live) . "/tmp/draklive/loop/$module->{name}";
+ my $copy_tree = $live->get_system_root . "/tmp/draklive/loop/$module->{name}";
eval { rm_rf($copy_tree) };
- hardlink_filtered(get_system_root($live), $copy_tree, $module->{files});
+ hardlink_filtered($live->get_system_root, $copy_tree, $module->{files});
my $loop = $loop{$module->{type}};
$loop->{build}->($live, { path => "$live->{prefix}{build}{modules}/$module->{name}$loop->{extension}", root => $copy_tree, exclude => \@excluded_files });
eval { rm_rf($copy_tree) };
}
if (@excluded_files) {
- my $excluded_tree = get_system_root($live) . "/tmp/draklive/excluded/all";
+ my $excluded_tree = $live->get_system_root . "/tmp/draklive/excluded/all";
eval { rm_rf($excluded_tree) };
- hardlink_filtered(get_system_root($live), $excluded_tree, \@excluded_files);
+ hardlink_filtered($live->get_system_root, $excluded_tree, \@excluded_files);
foreach my $module (list_loopback_modules($live)) {
- my $copy_tree = get_system_root($live) . "/tmp/draklive/excluded/$module->{name}";
+ my $copy_tree = $live->get_system_root . "/tmp/draklive/excluded/$module->{name}";
eval { rm_rf($copy_tree) };
hardlink_filtered($excluded_tree, $copy_tree, $module->{files});
my $loop = $loop{$module->{type}};
@@ -1125,34 +1115,34 @@ sub create_bootloader {
create_classical_bootloader($live);
}
- run_({ root => get_system_root($live) }, '/usr/sbin/grub-gfxmenu', '--update-gfxmenu');
- my $boot_dir = get_builddir($live) . $live->{prefix}{build}{boot};
+ run_({ root => $live->get_system_root }, '/usr/sbin/grub-gfxmenu', '--update-gfxmenu');
+ my $boot_dir = $live->get_builddir . $live->{prefix}{build}{boot};
mkdir_p($boot_dir);
- cp_f(get_system_root($live) . '/boot/gfxmenu', $boot_dir);
+ cp_f($live->get_system_root . '/boot/gfxmenu', $boot_dir);
}
sub create_media_bootloader {
my ($live) = @_;
- cp_f(get_system_root($live) . '/boot/vmlinuz-' . find_kernel($live), get_builddir($live) . $live->{prefix}{build}{boot} . '/vmlinuz');
+ cp_f($live->get_system_root . '/boot/vmlinuz-' . find_kernel($live), $live->get_builddir . $live->{prefix}{build}{boot} . '/vmlinuz');
require bootsplash;
my $theme = do {
- local $::prefix = get_system_root($live);
+ local $::prefix = $live->get_system_root;
bootsplash::themes_read_sysconfig('800x600');
};
- my $syslinux_dir = get_builddir($live) . $live->{prefix}{build}{boot} . '/syslinux';
+ my $syslinux_dir = $live->get_builddir . $live->{prefix}{build}{boot} . '/syslinux';
mkdir_p($syslinux_dir);
my $default_gfxboot_theme = "Mandriva";
print "copying $default_gfxboot_theme gfxboot theme\n";
- cp_f(glob_(get_system_root($live) . "/usr/share/gfxboot/themes/$default_gfxboot_theme/install/*"), $syslinux_dir);
+ cp_f(glob_($live->get_system_root . "/usr/share/gfxboot/themes/$default_gfxboot_theme/install/*"), $syslinux_dir);
if ($theme->{name} ne $default_gfxboot_theme) {
print "copying $theme->{name} gfxboot theme\n";
- cp_f(glob_(get_system_root($live) . "/usr/share/gfxboot/themes/$theme->{name}/*"), $syslinux_dir);
+ cp_f(glob_($live->get_system_root . "/usr/share/gfxboot/themes/$theme->{name}/*"), $syslinux_dir);
}
my $bootlogo = $syslinux_dir . '/bootlogo';
warn "unable to find gfxboot splash ($bootlogo)\n" if ! -f $bootlogo;
output_p($syslinux_dir . '/gfxboot.cfg', "livecd=1\n");
- output(get_builddir($live) . $live->{prefix}{build}{boot} . '/help.msg',
+ output($live->get_builddir . $live->{prefix}{build}{boot} . '/help.msg',
pack("C*", 0x0E, 0x80, 0x03, 0x00, 0xC) . qq(
Welcome to Mandriva live!
@@ -1165,7 +1155,7 @@ $live->{media}{title} <kernel options>
foreach my $media ($live->{media}) {
foreach my $boot ('', @{$media->{extra_boot}}) {
my $opts = { boot => $boot };
- output(get_builddir($live) . $live->{prefix}{build}{boot} . get_syslinux_path($media, $opts),
+ output($live->get_builddir . $live->{prefix}{build}{boot} . get_syslinux_path($media, $opts),
build_syslinux_cfg($live, $media, $opts));
}
}
@@ -1174,7 +1164,7 @@ $live->{media}{title} <kernel options>
sub create_classical_bootloader {
my ($live) = @_;
my $part_nb = 1; #- FIXME: get from partition layout config
- output_p(get_system_root($live) . '/boot/grub/menu.lst', build_grub_cfg_raw($live, $live->{media}, "/initrd.img", {}, $part_nb));
+ output_p($live->get_system_root . '/boot/grub/menu.lst', build_grub_cfg_raw($live, $live->{media}, "/initrd.img", {}, $part_nb));
}
sub device_allocate_file {
@@ -1207,7 +1197,7 @@ sub set_device_label {
sub get_cdrom_master_path {
my ($live, $opts) = @_;
- get_builddir($live) . $live->{prefix}{build}{dist} . '/' . $live->get_name . ($opts->{boot} && "-boot-$opts->{boot}") . '.iso';
+ $live->get_builddir . $live->{prefix}{build}{dist} . '/' . $live->get_name . ($opts->{boot} && "-boot-$opts->{boot}") . '.iso';
}
sub create_cdrom_master {
@@ -1240,20 +1230,20 @@ sub create_cdrom_master {
'-boot-load-size', 4, '-boot-info-table',
'-graft-points',
if_($dest, '-o', $dest),
- 'isolinux=' . get_builddir($live) . $live->{prefix}{build}{boot} . '/syslinux',
+ 'isolinux=' . $live->get_builddir . $live->{prefix}{build}{boot} . '/syslinux',
'isolinux/isolinux.bin=/usr/lib/syslinux/isolinux.bin',
- 'isolinux/isolinux.cfg=' . get_builddir($live) . $live->{prefix}{build}{boot} . get_syslinux_path($live->{media}, $opts),
- get_media_prefix($live, 'boot', $opts->{boot}) . '=' . get_builddir($live) . $live->{prefix}{build}{boot},
+ 'isolinux/isolinux.cfg=' . $live->get_builddir . $live->{prefix}{build}{boot} . get_syslinux_path($live->{media}, $opts),
+ get_media_prefix($live, 'boot', $opts->{boot}) . '=' . $live->get_builddir . $live->{prefix}{build}{boot},
if_(!$opts->{boot_only},
(map {
get_media_prefix($live, 'loopbacks', $opts->{boot}) . $_ .
'=' .
- get_builddir($live) . $live->{prefix}{build}{loopbacks} . $_;
+ $live->get_builddir . $live->{prefix}{build}{loopbacks} . $_;
} list_selected_loopbacks($live)),
if_($live->{media}{files},
map {
- $_ . '=' . get_builddir($live) . $live->{prefix}{build}{files} . '/' . $_;
- } all(get_builddir($live) . $live->{prefix}{build}{files})
+ $_ . '=' . $live->get_builddir . $live->{prefix}{build}{files} . '/' . $_;
+ } all($live->get_builddir . $live->{prefix}{build}{files})
),
),
) or die "unable to run genisoimage\n";
@@ -1270,7 +1260,7 @@ sub create_cdrom_master {
sub get_disk_master_path {
my ($live) = @_;
- get_builddir($live) . $live->{prefix}{build}{dist} . '/' . $live->get_name . '.img';
+ $live->get_builddir . $live->{prefix}{build}{dist} . '/' . $live->get_name . '.img';
}
sub allocate_master {
@@ -1322,9 +1312,9 @@ sub create_disk_master {
my $dest = get_disk_master_path($live);
#- dumb guess, a bit too large, and valid for FAT only
my $part_size = @{$live->{mount}{dirs} || []} ?
- (directory_usage(get_builddir($live) . $live->{prefix}{build}{loopbacks}) +
- directory_usage(get_builddir($live) . $live->{prefix}{build}{boot})) :
- directory_usage(get_system_root($live));
+ (directory_usage($live->get_builddir . $live->{prefix}{build}{loopbacks}) +
+ directory_usage($live->get_builddir . $live->{prefix}{build}{boot})) :
+ directory_usage($live->get_system_root);
my $loop = allocate_master($dest, 500000000 + $part_size, get_media_setting($live->{media}, 'fs'));
local $opts->{device} = $loop;
@@ -1387,7 +1377,7 @@ sub record_cdrom_master {
sub install_grub_to_image {
my ($live, $img) = @_;
- cp_af(glob_(get_system_root($live) . "/lib/grub/i386-mandriva/*"), $live->{mnt} . "/boot/grub");
+ cp_af(glob_($live->get_system_root . "/lib/grub/i386-mandriva/*"), $live->{mnt} . "/boot/grub");
open(my $grub, "| /sbin/grub --batch --no-floppy");
# using disk loopback fails, have to use image path
print $grub <<EOF;
@@ -1408,14 +1398,14 @@ sub install_usb_bootloader {
member($bootloader, 'grub', 'syslinux') or die "no bootloader defined in media configuration\n";
my $grub_device_map = $live->{mnt} . $media_boot . "/grub/device.map";
if ($bootloader eq 'syslinux') {
- cp_f(get_builddir($live) . $_, $live->{mnt}) foreach map {
+ cp_f($live->get_builddir . $_, $live->{mnt}) foreach map {
$live->{prefix}{boot} . $_;
} get_syslinux_path($media, $opts), get_initrd_path($media), @syslinux_boot_files;
} elsif ($bootloader eq 'grub') {
#- FIXME: add get_grub_path (when building boot configuration files)
# and get_bootloader_path (when copying)
mkdir_p($live->{mnt} . $media_boot . '/grub');
- cp_f(get_builddir($live) . $live->{prefix}{build}{boot} . '/gfxmenu', $live->{mnt} . $media_boot);
+ cp_f($live->get_builddir . $live->{prefix}{build}{boot} . '/gfxmenu', $live->{mnt} . $media_boot);
output_p($live->{mnt} . $media_boot . '/grub/menu.lst', build_grub_cfg($live, $media, $opts, $device));
unlink $grub_device_map;
}
@@ -1432,10 +1422,10 @@ sub install_usb_bootloader {
$master_device =~ s/(\d+)$//;
}
if ($master_device =~ m!/dev/!) {
- my $local_grub_install = get_builddir($live) . $live->{prefix}{build}{scripts} . '/grub-install';
+ my $local_grub_install = $live->get_builddir . $live->{prefix}{build}{scripts} . '/grub-install';
mkdir_p(dirname($local_grub_install));
- cp_f(get_system_root($live) . '/sbin/grub-install', $local_grub_install);
- my $root = get_system_root($live);
+ cp_f($live->get_system_root . '/sbin/grub-install', $local_grub_install);
+ my $root = $live->get_system_root;
substInFile {
s!^\s*exec_prefix=.*!exec_prefix=$root!;
s!^\s*grub_prefix=/boot/!grub_prefix=${media_boot}/!;
@@ -1471,12 +1461,12 @@ sub record_usb_master {
run_('mount', if_(-f $device, '-o', 'loop'), $device, $live->{mnt})
or die "unable to mount $device\n";
rm_rf($live->{mnt} . $media_boot) if -e $live->{mnt} . $media_boot;
- cp_af(get_builddir($live) . $live->{prefix}{build}{boot}, $live->{mnt} . $media_boot);
+ cp_af($live->get_builddir . $live->{prefix}{build}{boot}, $live->{mnt} . $media_boot);
install_usb_bootloader($live, $media, $opts);
do {
- my $loopbacks_source = get_builddir($live) . $live->{prefix}{build}{loopbacks} . '/';
+ my $loopbacks_source = $live->get_builddir . $live->{prefix}{build}{loopbacks} . '/';
my $total = directory_usage($loopbacks_source);
my $all_files = 0;
my $current_file = 0;
@@ -1504,7 +1494,7 @@ sub record_usb_master {
die "unable to copy loopback files\n";
}
- cp_af(glob_(get_builddir($live) . $live->{prefix}{build}{files} . '/*'), $live->{mnt});
+ cp_af(glob_($live->get_builddir . $live->{prefix}{build}{files} . '/*'), $live->{mnt});
} unless $opts->{boot_only};
my @hidden_files = map { basename($_) } glob_($live->{mnt} . "/.*"), glob_($live->{mnt} . "/autorun.*");
@@ -1536,7 +1526,7 @@ sub record_harddisk_master {
or die "unable to mount $device\n";
do {
- my $source = get_system_root($live);
+ my $source = $live->get_system_root;
my $total = directory_usage($source);
my $all_files = 0;
my $current_file = 0;
@@ -1655,7 +1645,7 @@ sub create_image {
sub get_disk_replicator_path {
my ($live) = @_;
- get_builddir($live) . $live->{prefix}{build}{dist} . '/' . $live->get_name . '.rest.img';
+ $live->get_builddir . $live->{prefix}{build}{dist} . '/' . $live->get_name . '.rest.img';
}
sub get_disk_replicator_files {
@@ -1918,9 +1908,9 @@ sub complete_config {
$live->{settings}{arch} ||= chomp_(`rpm --eval '%{_target_cpu}'`);
$live->{media}{title} ||= "live";
- mkdir_p(get_builddir($live));
- mkdir_p(get_system_root($live));
- $live->{mnt} ||= get_builddir($live) . "/mnt";
+ mkdir_p($live->get_builddir);
+ mkdir_p($live->get_system_root);
+ $live->{mnt} ||= $live->get_builddir . "/mnt";
}
sub dump_config {
@@ -1933,7 +1923,7 @@ sub clean {
my ($live) = @_;
# umount filesystem in the live before cleaning
umount_external_filesystem($live);
- rm_rf($_) foreach grep { -e $_ } get_builddir($live), get_system_root($live);
+ rm_rf($_) foreach grep { -e $_ } $live->get_builddir, $live->get_system_root;
}
my @actions = (
diff --git a/lib/MDV/Draklive/Live.pm b/lib/MDV/Draklive/Live.pm
index 7d5a3fd..25ec4c2 100644
--- a/lib/MDV/Draklive/Live.pm
+++ b/lib/MDV/Draklive/Live.pm
@@ -12,4 +12,14 @@ sub get_name {
join('-', grep { $_ } @{$live->{settings}}{qw(name product version desktop region media arch)});
}
+sub get_builddir {
+ my ($live) = @_;
+ $live->{settings}{builddir} . '/' . $live->get_name;
+}
+
+sub get_system_root {
+ my ($live) = @_;
+ $live->{settings}{chroot} . '/' . $live->get_name;
+}
+
1;