summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorMartin Whitaker <mageia@martin-whitaker.me.uk>2018-01-09 23:34:24 +0000
committerMartin Whitaker <mageia@martin-whitaker.me.uk>2018-01-10 00:38:35 +0000
commit57060f5254e48a9eead04426803d4f102f2b0a4b (patch)
tree3dc19e87420be8334dd7411c91fdfd8c8984df5b /lib
parent63555aa270059488b013e6c802cca64a8d6eebdc (diff)
downloaddrakiso-57060f5254e48a9eead04426803d4f102f2b0a4b.tar
drakiso-57060f5254e48a9eead04426803d4f102f2b0a4b.tar.gz
drakiso-57060f5254e48a9eead04426803d4f102f2b0a4b.tar.bz2
drakiso-57060f5254e48a9eead04426803d4f102f2b0a4b.tar.xz
drakiso-57060f5254e48a9eead04426803d4f102f2b0a4b.zip
Miscellaneous code cleanup.
Diffstat (limited to 'lib')
-rw-r--r--lib/MGA/DrakISO/BuildBoot.pm18
-rw-r--r--lib/MGA/DrakISO/BuildISO.pm12
-rw-r--r--lib/MGA/DrakISO/BuildLoop.pm19
-rw-r--r--lib/MGA/DrakISO/BuildMedia.pm16
-rw-r--r--lib/MGA/DrakISO/BuildRoot.pm10
-rw-r--r--lib/MGA/DrakISO/Config.pm8
-rw-r--r--lib/MGA/DrakISO/ISOBuild.pm2
-rw-r--r--lib/MGA/DrakISO/LiveBuild.pm10
-rw-r--r--lib/MGA/DrakISO/Loopback.pm8
-rw-r--r--lib/MGA/DrakISO/Utils.pm2
10 files changed, 53 insertions, 52 deletions
diff --git a/lib/MGA/DrakISO/BuildBoot.pm b/lib/MGA/DrakISO/BuildBoot.pm
index 276217b..c1097de 100644
--- a/lib/MGA/DrakISO/BuildBoot.pm
+++ b/lib/MGA/DrakISO/BuildBoot.pm
@@ -51,11 +51,11 @@ our @EXPORT = qw(prepare_live_system_boot prepare_iso_bootloader);
sub prepare_live_system_boot {
my ($build) = @_;
- my $root = $build->get_system_root;
+ my $root = $build->get_live_root;
# Create a build directory. This will contain all the files we need to
# exist in /boot on the ISO.
- my $boot_dir = $build->get_builddir('boot');
+ my $boot_dir = $build->get_build_dir('boot');
mkdir_p($boot_dir);
# Locate the kernel we want to boot.
@@ -97,14 +97,14 @@ sub prepare_iso_bootloader {
# do that now. We may need some of those files to correctly auto-detect
# the default kernel and initrd.
my $repo_prefix = $build->{settings}{repository} . '/' . $build->{settings}{arch} . '/';
- my $copy_prefix = $build->get_builddir . '/';
+ my $copy_prefix = $build->get_build_dir . '/';
foreach (group_by2(@{$build->{copy_from_repo}})) {
my ($src, $dst) = @$_;
copy_or_link($repo_prefix . $src, $copy_prefix . $dst);
}
# Create a subdirectory to hold the grub2 bootloader.
- my $grub2_dir = $build->get_builddir('boot/grub2');
+ my $grub2_dir = $build->get_build_dir('boot/grub2');
mkdir_p($grub2_dir);
# Locate and copy the default font for the bootloader. If we can't find a
@@ -219,7 +219,7 @@ sub prepare_iso_bootloader {
# Create another build directory. This will contain all the files we need
# to exist in the /EFI directory on the ISO.
- my $efi_root_dir = $build->get_builddir('EFI');
+ my $efi_root_dir = $build->get_build_dir('EFI');
my $efi_boot_dir = $efi_root_dir . '/BOOT';
mkdir_p($efi_boot_dir);
@@ -247,7 +247,7 @@ sub prepare_iso_bootloader {
}
# Create another build directory for temporarily storing the ESP image.
- my $images_dir = $build->get_builddir('images');
+ my $images_dir = $build->get_build_dir('images');
mkdir_p($images_dir);
# Construct an ESP image. This is needed for USB boot.
@@ -394,14 +394,14 @@ sub get_bootloader_timeout {
sub get_default_image {
my ($build, $name) = @_;
- -e ($build->get_builddir('boot') . '/vmlinuz') && '/boot/vmlinuz'
+ -e ($build->get_build_dir('boot') . '/vmlinuz') && '/boot/vmlinuz'
or die "ERROR: no boot image found for '$name' boot entry\n";
}
sub get_default_initrd {
my ($build) = @_;
- -e ($build->get_builddir('boot') . '/initrd.gz') && '/boot/initrd.gz' ||
- -e ($build->get_builddir('boot') . '/all.rdz') && '/boot/all.rdz';
+ -e ($build->get_build_dir('boot') . '/initrd.gz') && '/boot/initrd.gz' ||
+ -e ($build->get_build_dir('boot') . '/all.rdz') && '/boot/all.rdz';
}
sub get_default_append {
diff --git a/lib/MGA/DrakISO/BuildISO.pm b/lib/MGA/DrakISO/BuildISO.pm
index 41f562a..b3ca5d2 100644
--- a/lib/MGA/DrakISO/BuildISO.pm
+++ b/lib/MGA/DrakISO/BuildISO.pm
@@ -46,14 +46,14 @@ our @EXPORT = qw(build_iso);
sub build_iso {
my ($build) = @_;
- my $loopbacks = $build->get_builddir('loopbacks');
- my $files = $build->get_builddir('files');
+ my $loopbacks = $build->get_build_dir('loopbacks');
+ my $files = $build->get_build_dir('files');
build_iso_image(
$build,
- '/boot=' . $build->get_builddir('boot'),
+ '/boot=' . $build->get_build_dir('boot'),
if_($build->{settings}{arch} eq 'x86_64',
- '/EFI=' . $build->get_builddir('EFI'),
+ '/EFI=' . $build->get_build_dir('EFI'),
),
if_(-d $loopbacks,
map {
@@ -102,10 +102,10 @@ sub build_iso_image {
my $mbr_image = $build->get_absolute_path($build->{media}{mbr_boot_img}) // '/usr/lib/grub/i386-pc/boot_hybrid.img';
-e $mbr_image or die "ERROR: cannot find MBR boot image $mbr_image\n";
- my $esp_image = $build->get_builddir('images') . '/esp.img';
+ my $esp_image = $build->get_build_dir('images') . '/esp.img';
-e $esp_image || $arch ne 'x86_64' or die "ERROR: cannot find ESP image $esp_image\n";
- my $build_dir = $build->get_builddir('dist');
+ my $build_dir = $build->get_build_dir('dist');
mkdir_p($build_dir);
my $dest = $build_dir . '/' . $build->get_name . '.iso';
diff --git a/lib/MGA/DrakISO/BuildLoop.pm b/lib/MGA/DrakISO/BuildLoop.pm
index 01aefca..9f0475b 100644
--- a/lib/MGA/DrakISO/BuildLoop.pm
+++ b/lib/MGA/DrakISO/BuildLoop.pm
@@ -44,8 +44,11 @@ our @EXPORT = qw(build_live_loopback_files list_loopback_modules);
#
sub build_live_loopback_files {
my ($build) = @_;
+
+ my $root = $build->get_live_root;
+
# make sure no external filesystems are mounted before creating the loopback
- umount_all_in_root($build->get_system_root);
+ umount_all_in_root($root);
my @excluded_files = expand_file_list($build, @{$build->{loopbacks}{exclude}{files} || []});
my @modules_files = expand_file_list($build, @{$build->{loopbacks}{modules} || []});
@@ -56,21 +59,21 @@ sub build_live_loopback_files {
}
foreach my $module (list_loopback_modules($build)) {
- my $copy_tree = $build->get_system_root . "/tmp/draklive/loop/$module->{name}";
+ my $copy_tree = $root . "/tmp/draklive/loop/$module->{name}";
run_as_root('rm', '-rf', $copy_tree);
- hardlink_filtered($build->get_system_root, $copy_tree, $module->{files});
+ hardlink_filtered($root, $copy_tree, $module->{files});
my $loop = $loop_types{$module->{type}};
$loop->{build}->($build, { path => "/modules/$module->{name}", root => $copy_tree, exclude => \@excluded_files });
run_as_root('rm', '-rf', $copy_tree);
}
if (@excluded_files) {
- my $excluded_tree = $build->get_system_root . "/tmp/draklive/excluded/all";
+ my $excluded_tree = $root . "/tmp/draklive/excluded/all";
eval { rm_rf($excluded_tree) };
- hardlink_filtered($build->get_system_root, $excluded_tree, \@excluded_files);
+ hardlink_filtered($root, $excluded_tree, \@excluded_files);
foreach my $module (list_loopback_modules($build)) {
- my $copy_tree = $build->get_system_root . "/tmp/draklive/excluded/$module->{name}";
+ my $copy_tree = $root . "/tmp/draklive/excluded/$module->{name}";
run_as_root('rm', '-rf', $copy_tree);
hardlink_filtered($excluded_tree, $copy_tree, $module->{files});
my $loop = $loop_types{$module->{type}};
@@ -90,7 +93,7 @@ sub expand_file_list {
map {
$_->{path} ?
$_->{path} :
- chomp_(cat_(glob(($_->{rooted} && $build->get_system_root) . $_->{source})));
+ chomp_(cat_(glob(($_->{rooted} && $build->get_live_root) . $_->{source})));
} @files;
}
@@ -114,7 +117,7 @@ sub list_loopback_modules {
my $name = basename($list);
$name =~ s/\.[^.]+$//;
{ type => $l->{type}, name => $name, files => [ expand_file_list($build, { source => $list }) ] };
- } glob(($_->{rooted} && $build->get_system_root) . $_->{source});
+ } glob(($_->{rooted} && $build->get_live_root) . $_->{source});
} @{$build->{loopbacks}{modules}};
}
diff --git a/lib/MGA/DrakISO/BuildMedia.pm b/lib/MGA/DrakISO/BuildMedia.pm
index 5e75c1c..b2171b4 100644
--- a/lib/MGA/DrakISO/BuildMedia.pm
+++ b/lib/MGA/DrakISO/BuildMedia.pm
@@ -79,7 +79,7 @@ sub prepare_media {
# Create a working directory to hold any temporary files we generate.
# Nothing in this directory is needed after we exit this function.
- mkdir_p($build->get_builddir('tmp'));
+ mkdir_p($build->get_build_dir('tmp'));
prepare_urpmi_media($build);
get_available_packages($build);
@@ -103,7 +103,7 @@ sub prepare_media {
my $version = $build->{settings}{version};
my $tag = $build->{settings}{tag};
- my $arch_dir = $build->get_builddir('files/' . $arch);
+ my $arch_dir = $build->get_build_dir('files/' . $arch);
create_product_id($build, $arch_dir . '/product.id');
create_index($build, $arch_dir . '/pkg-' . $version . '-' . $tag . '.idx');
@@ -127,7 +127,7 @@ sub prepare_urpmi_media {
my %media;
# Get a list of the currently configured media in our urpmi root.
- my $list_file = $build->get_builddir('tmp') . '/media_url.lst';
+ my $list_file = $build->get_build_dir('tmp') . '/media_url.lst';
run_urpm($build, "urpmq", "--list-url > $list_file");
foreach my $line (cat_($list_file)) {
chomp($line);
@@ -232,7 +232,7 @@ sub include_groups {
# Use the distribution rpmsrate file to select and add packages in the
# requested groups.
my $rpmsrate_src = $build->{settings}{repository} . '/' . $build->{settings}{arch} . '/media/media_info/rpmsrate';
- my $rpmsrate_tmp = $build->get_builddir('tmp') . '/rpmsrate';
+ my $rpmsrate_tmp = $build->get_build_dir('tmp') . '/rpmsrate';
copy_or_link($rpmsrate_src, $rpmsrate_tmp);
add_rated_packages($build, $rpmsrate_tmp);
report_package_count();
@@ -439,7 +439,7 @@ sub build_installer_media {
# Create a clean set of media directories
my $arch = $build->{settings}{arch};
- my $arch_dir = $build->get_builddir('files/' . $arch);
+ my $arch_dir = $build->get_build_dir('files/' . $arch);
my $media_dir = $arch_dir . '/media/';
rm_rf($media_dir) if -e $media_dir;
mkdir_p($media_dir . 'media_info');
@@ -524,8 +524,8 @@ sub check_installer_media {
print "Checking installer media [$class]\n" if $::verbose;
my $arch = $build->{settings}{arch};
- my $media_dir = $build->get_builddir('files/' . $arch . '/media');
- my $log_file = $build->get_builddir('tmp') . '/rpmcheck.log';
+ my $media_dir = $build->get_build_dir('files/' . $arch . '/media');
+ my $log_file = $build->get_build_dir('tmp') . '/rpmcheck.log';
system("zcat -q $media_dir/$class/media_info/hdlist.cz | rpmcheck -explain -failures > $log_file") == 0
or die "ERROR: failed to run rpmcheck\n";
@@ -565,7 +565,7 @@ sub create_index {
my $arch = $build->{settings}{arch};
- my $media_dir = $build->get_builddir('files/' . $arch . '/media/');
+ my $media_dir = $build->get_build_dir('files/' . $arch . '/media/');
my @hdlists = glob("$media_dir/*/media_info/hdlist.cz");
my @tab;
diff --git a/lib/MGA/DrakISO/BuildRoot.pm b/lib/MGA/DrakISO/BuildRoot.pm
index af06769..187e8a2 100644
--- a/lib/MGA/DrakISO/BuildRoot.pm
+++ b/lib/MGA/DrakISO/BuildRoot.pm
@@ -66,7 +66,7 @@ sub install_live_system {
my $rooted_stage2 = '/tmp/stage2';
my $chroot_stage2 = $chroot . $rooted_stage2;
- my $live_root = $build->get_system_root;
+ my $live_root = $build->get_live_root;
if (-e $live_root) {
# We want a clean start...
umount_all_in_root($live_root);
@@ -367,7 +367,7 @@ sub customise_live_system {
print "Customising Live system\n" if $::verbose;
my $arch = $build->{settings}{arch};
- my $root = $build->get_system_root;
+ my $root = $build->get_live_root;
# Workaround buggy installation of directories that are not owned by any
# packages.
@@ -530,7 +530,7 @@ sub configure_draklive_resize {
"OLD_MOUNT=/live$resizable_loopback->{mountpoint}",
"UNION=/",
);
- output_to_root($build->get_system_root, '/etc/sysconfig/draklive-resize', undef, @text);
+ output_to_root($build->get_live_root, '/etc/sysconfig/draklive-resize', undef, @text);
}
}
@@ -543,10 +543,10 @@ sub clean_system_conf_file {
sub write_dist_lists {
my ($build) = @_;
- my $lists_dir = $build->get_builddir('dist');
+ my $lists_dir = $build->get_build_dir('dist');
mkdir_p($lists_dir);
- my $root = $build->get_system_root;
+ my $root = $build->get_live_root;
run_in_root($root, undef, "rpm -qa | sort > " .
$lists_dir . '/' . $build->get_name . '.lst');
diff --git a/lib/MGA/DrakISO/Config.pm b/lib/MGA/DrakISO/Config.pm
index a3d0511..e78d595 100644
--- a/lib/MGA/DrakISO/Config.pm
+++ b/lib/MGA/DrakISO/Config.pm
@@ -44,7 +44,7 @@ sub read_config {
add2hash($build->{settings} ||= {}, { getVarsFromSh($config_root . '/' . $settings_path) }) if $settings_path;
if ($config_path) {
#- don't use do(), since it can't see lexicals in the enclosing scope
- my $cfg = eval(cat_($config_root . '/' . $config_path)) or die "unable to load $config_path: $@\n";
+ my $cfg = eval(cat_($config_root . '/' . $config_path)) or die "ERROR: unable to load $config_path: $@\n";
put_in_hash($build, $cfg);
print "Loaded $config_path as config file\n";
}
@@ -61,7 +61,7 @@ sub check_config {
$build->{settings}{arch}
or die "ERROR: you must specify an architecture\n";
$build->{media}{storage}
- or die "ERROR: you must specify the media storage type.\n";
+ or die "ERROR: you must specify the media storage type\n";
$build->{media}{label}
or die "ERROR: you must supply a media label\n";
}
@@ -71,9 +71,7 @@ sub complete_config {
$build->{settings}{workdir} ||= '/var/lib/drakiso';
- $build->{settings}{arch} ||= chomp_(`rpm --eval '%{_target_cpu}'`);
-
- mkdir_p($build->get_builddir);
+ mkdir_p($build->get_build_dir);
mkdir_p($build->get_chroot_dir);
}
diff --git a/lib/MGA/DrakISO/ISOBuild.pm b/lib/MGA/DrakISO/ISOBuild.pm
index e6c2aef..0212f31 100644
--- a/lib/MGA/DrakISO/ISOBuild.pm
+++ b/lib/MGA/DrakISO/ISOBuild.pm
@@ -49,7 +49,7 @@ sub get_set_suffix {
$build->{settings}{set} ? "-$build->{settings}{set}" : "";
}
-sub get_builddir {
+sub get_build_dir {
my ($build, $o_subdir) = @_;
$build->{settings}{workdir} . '/build/' . $build->get_name . $build->get_set_suffix . if_($o_subdir, '/' . $o_subdir);
}
diff --git a/lib/MGA/DrakISO/LiveBuild.pm b/lib/MGA/DrakISO/LiveBuild.pm
index c41618b..99450e0 100644
--- a/lib/MGA/DrakISO/LiveBuild.pm
+++ b/lib/MGA/DrakISO/LiveBuild.pm
@@ -55,22 +55,22 @@ sub get_langs {
);
}
-sub get_system_root {
+sub get_live_root {
my ($build) = @_;
- $build->get_builddir('root');
+ $build->get_build_dir('root');
}
sub find_kernel {
my ($build) = @_;
require bootloader;
- local $::prefix = $build->get_system_root;
+ local $::prefix = $build->get_live_root;
my @kernels = bootloader::get_kernels_and_labels();
my $kernel;
if ($build->{system}{kernel}) {
$kernel = find { $_->{version} eq $build->{system}{kernel} } @kernels;
- $kernel or die "kernel $build->{system}{kernel} can not be found\n";
+ $kernel or die "ERROR: kernel $build->{system}{kernel} can not be found\n";
}
- $kernel ||= first(@kernels) or die "no kernel can be found\n";
+ $kernel ||= first(@kernels) or die "ERROR: no kernel can be found\n";
}
sub get_initrd_name {
diff --git a/lib/MGA/DrakISO/Loopback.pm b/lib/MGA/DrakISO/Loopback.pm
index 219b9b8..4a994b5 100644
--- a/lib/MGA/DrakISO/Loopback.pm
+++ b/lib/MGA/DrakISO/Loopback.pm
@@ -50,9 +50,9 @@ our %loop_types;
extension => '-lzma.sqfs',
build => sub {
my ($build, $dir) = @_;
- my $dest = $build->get_builddir('loopbacks') . $dir->{path} . $loop_types{squashfs}{extension};
+ my $dest = $build->get_build_dir('loopbacks') . $dir->{path} . $loop_types{squashfs}{extension};
mkdir_p(dirname($dest));
- my $root = $dir->{root} || $build->get_system_root;
+ my $root = $dir->{root} || $build->get_live_root;
my $src = $root . $dir->{build_from};
my $total = directory_usage($src);
print "Have to process " . int($total/1000000) . " MB\n" if $::verbose;
@@ -125,7 +125,7 @@ our %loop_types;
extension => '.loop',
build => sub {
my ($build, $dir) = @_;
- my $dest = $build->get_builddir('loopbacks') . $dir->{path} . $loop_types{loopfs}{extension};
+ my $dest = $build->get_build_dir('loopbacks') . $dir->{path} . $loop_types{loopfs}{extension};
mkdir_p(dirname($dest));
MGA::DrakISO::Utils::device_allocate_file($dest, $dir->{pre_allocate});
MGA::DrakISO::Utils::device_mkfs($dest, $dir->{fs}) if !defined $dir->{min_size};
@@ -179,7 +179,7 @@ our %loop_types;
sub has_squashfs4_with {
my ($build, $comp) = @_;
my $ucomp = uc($comp);
- cat_($build->get_system_root . "/boot/config-" . $build->find_kernel->{version}) =~ /^CONFIG_SQUASHFS_$ucomp=y$/m;
+ cat_($build->get_live_root . "/boot/config-" . $build->find_kernel->{version}) =~ /^CONFIG_SQUASHFS_$ucomp=y$/m;
}
sub mksquashfs4_compressors() {
diff --git a/lib/MGA/DrakISO/Utils.pm b/lib/MGA/DrakISO/Utils.pm
index 4e85207..dcccf0b 100644
--- a/lib/MGA/DrakISO/Utils.pm
+++ b/lib/MGA/DrakISO/Utils.pm
@@ -111,7 +111,7 @@ sub device_mkfs {
} elsif ($type eq 'swap') {
run_('mkswap', if_(defined $o_label, '-L', $o_label), $device);
} else {
- die "unable to mkfs for unsupported media type $type\n";
+ die "ERROR: unable to mkfs for unsupported media type $type\n";
}
}