summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/MGA/DrakISO/BuildBoot.pm6
-rw-r--r--lib/MGA/DrakISO/BuildISO.pm11
-rw-r--r--lib/MGA/DrakISO/BuildMedia.pm16
-rw-r--r--lib/MGA/DrakISO/BuildRoot.pm14
-rw-r--r--lib/MGA/DrakISO/Utils.pm31
5 files changed, 37 insertions, 41 deletions
diff --git a/lib/MGA/DrakISO/BuildBoot.pm b/lib/MGA/DrakISO/BuildBoot.pm
index c1097de..2572099 100644
--- a/lib/MGA/DrakISO/BuildBoot.pm
+++ b/lib/MGA/DrakISO/BuildBoot.pm
@@ -198,7 +198,7 @@ sub prepare_iso_bootloader {
my $grub_cfg_template = $build->get_absolute_path($build->{media}{grub2_cfg});
-e $grub_cfg_template or die "ERROR: cannot find grub2 config file $grub_cfg_template\n";
cp_f($grub_cfg_template, $grub2_cfg);
- run_("sed", "-i", "s/VOLUME_LABEL/$label/g", $grub2_cfg);
+ run_('sed', '-i', "s/VOLUME_LABEL/$label/g", $grub2_cfg);
} else {
output($grub2_cfg, build_grub2_cfg($build, $theme_name, \@theme_fonts, $add_lang_menu, $add_kbd_menu));
}
@@ -253,8 +253,8 @@ sub prepare_iso_bootloader {
# Construct an ESP image. This is needed for USB boot.
my $esp_image = $images_dir . '/esp.img';
eval { rm_rf($esp_image) };
- run_("/sbin/mkdosfs", "-F12", "-C", $esp_image, "4096");
- run_("mcopy", "-s", "-i", $esp_image, $efi_root_dir, "::");
+ run_('/sbin/mkdosfs', '-F12', '-C', $esp_image, '4096');
+ run_('mcopy', '-s', '-i', $esp_image, $efi_root_dir, '::');
# Now we've built the ESP image, we can delete the grub2 image. We need
# to leave the grub2.cfg file, as DVD boot sets the initial grub2 root
diff --git a/lib/MGA/DrakISO/BuildISO.pm b/lib/MGA/DrakISO/BuildISO.pm
index b3ca5d2..8e90c55 100644
--- a/lib/MGA/DrakISO/BuildISO.pm
+++ b/lib/MGA/DrakISO/BuildISO.pm
@@ -114,7 +114,7 @@ sub build_iso_image {
chomp($xorriso_version);
my $date_file = $build_dir . '/DATE.txt';
- run_('date', '>', $date_file);
+ run_("date > $date_file");
run_('xorrisofs',
if_($::verbose < 2, '-quiet'),
@@ -149,11 +149,10 @@ sub build_iso_image {
'/DATE.txt=' . $date_file,
) or die "ERROR: unable to run xorrisofs\n";
- my $filename = basename($dest);
- run_('mgaiso-addmd5', '>', '/dev/null', '2>', '/dev/null', $dest);
- run_({ chdir => $build_dir }, 'md5sum', '>', $dest . '.md5', $filename);
- run_({ chdir => $build_dir }, 'sha1sum', '>', $dest . '.sha1', $filename);
- run_({ chdir => $build_dir }, 'sha512sum', '>', $dest . '.sha512', $filename);
+ run_("mgaiso-addmd5 $dest > /dev/null 2> /dev/null");
+ run_("md5sum $dest > $dest.md5");
+ run_("sha1sum $dest > $dest.sha1");
+ run_("sha512sum $dest > $dest.sha512");
if (my $suffix = $build->get_set_suffix) {
if (my ($prefix, $ext) = $dest =~ /(.*)(\.[^.]+)$/) {
my $link = $prefix . $suffix . $ext;
diff --git a/lib/MGA/DrakISO/BuildMedia.pm b/lib/MGA/DrakISO/BuildMedia.pm
index b2171b4..d9bc0fc 100644
--- a/lib/MGA/DrakISO/BuildMedia.pm
+++ b/lib/MGA/DrakISO/BuildMedia.pm
@@ -34,6 +34,10 @@ use urpm::media;
use MGA::DrakISO::ClassicBuild;
use MGA::DrakISO::Utils;
+use Exporter;
+our @ISA = qw(Exporter);
+our @EXPORT = qw(prepare_media);
+
###############################################################################
# Global Variables
###############################################################################
@@ -484,9 +488,9 @@ sub build_installer_media {
copy_or_link($repo_media_dir . '/media_info/rpmsrate', $media_dir . 'media_info/rpmsrate');
# Generate the remaining media info.
- my $silent = $::verbose < 3 ? ' -s' : '';
+ my $silent = $::verbose < 3;
print "-- messages from gendistrib -----------------------\n" if !$silent;
- system("gendistrib $silent $arch_dir\n") == 0
+ run_('gendistrib', if_($silent, '-s'), $arch_dir)
or die "ERROR: gendistrib failed to generate the media info\n";
print "---------------------------------------------------\n" if !$silent;
}
@@ -526,11 +530,11 @@ sub check_installer_media {
my $arch = $build->{settings}{arch};
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
+ run_("zcat -q $media_dir/$class/media_info/hdlist.cz | rpmcheck -explain -failures > $log_file")
or die "ERROR: failed to run rpmcheck\n";
- if (system("grep -q FAILED $log_file") == 0) {
- system("cat $log_file");
+ if (system('grep', '-q', 'FAILED', $log_file) == 0) {
+ system('cat', $log_file);
$::force or die "ERROR: some package dependencies are not satisfied\n";
print "NOTE: **** continuing due to --force option ****\n";
print "NOTE: **** this ISO is not suitable for final release ****\n";
@@ -602,7 +606,7 @@ sub run_urpm {
my $urpmi_root = '--urpmi-root ' . $build->get_chroot_dir;
- my $error = system("LC_ALL=C sudo $cmd $urpmi_root $parameters");
+ my $error = system("LC_ALL=C $sudo $cmd $urpmi_root $parameters");
$error == 0 || $o_not_fatal or die "ERROR: $cmd command failed\n";
$error;
}
diff --git a/lib/MGA/DrakISO/BuildRoot.pm b/lib/MGA/DrakISO/BuildRoot.pm
index 187e8a2..a0cc6a2 100644
--- a/lib/MGA/DrakISO/BuildRoot.pm
+++ b/lib/MGA/DrakISO/BuildRoot.pm
@@ -78,25 +78,25 @@ sub install_live_system {
my $error_message;
try {
# Mount the directory where we want to install the Live system.
- mount($chroot . '/mnt', $live_root, '-o bind');
+ mount($chroot . '/mnt', $live_root, '--bind');
# Mount the standard system pseudo-filesystems, so that the installer
# has a proper environment to run in.
mount_system_fs($chroot);
- mount($chroot . '/sys/kernel/debug', 'none', '-t debugfs');
+ mount($chroot . '/sys/kernel/debug', 'none', '-t', 'debugfs');
# Mount the stage2 installer filesystem.
if ($remote_method) {
my $local_mdkinst = $chroot . '/tmp/mdkinst.sqfs';
- system("curl --silent -o $local_mdkinst $arch_repository/install/stage2/mdkinst.sqfs")
+ run_('curl', '--silent', '-o', $local_mdkinst, $arch_repository . '/install/stage2/mdkinst.sqfs')
or die "ERROR: failed to download mdkinst.sqfs from remote repository\n";
- mount($chroot_stage2, $local_mdkinst, '-t squashfs -o loop,ro');
+ mount($chroot_stage2, $local_mdkinst, '-t', 'squashfs', '-o', 'loop,ro');
} elsif (-d $arch_repository . '/install/stage2/live') {
- mount($chroot_stage2, $arch_repository . '/install/stage2/live', '-o bind,ro');
+ mount($chroot_stage2, $arch_repository . '/install/stage2/live', '--bind', '-o', 'ro');
} elsif (-f $arch_repository . '/install/stage2/mdkinst.sqfs') {
- mount($chroot_stage2, $arch_repository . '/install/stage2/mdkinst.sqfs', '-t squashfs -o loop,ro');
+ mount($chroot_stage2, $arch_repository . '/install/stage2/mdkinst.sqfs', '-t', 'squashfs', '-o', 'loop,ro');
} else {
die "ERROR: failed to find installer stage2\n";
@@ -104,7 +104,7 @@ sub install_live_system {
# The stage2 installer expects to find the full repository in this
# location...
- mount($chroot . '/tmp/media', $base_repository, '-o bind,ro') if !$remote_method;
+ mount($chroot . '/tmp/media', $base_repository, '--bind', '-o', 'ro') if !$remote_method;
# and the arch-specific repository in this location.
symlinkf('media/' . $arch, $chroot . '/tmp/image');
# Because the installer uses the above symlink, relative paths in
diff --git a/lib/MGA/DrakISO/Utils.pm b/lib/MGA/DrakISO/Utils.pm
index dcccf0b..f98e46d 100644
--- a/lib/MGA/DrakISO/Utils.pm
+++ b/lib/MGA/DrakISO/Utils.pm
@@ -28,7 +28,6 @@ use strict;
use MDK::Common;
use common;
use fs;
-use run_program;
use IPC::Open3;
use IO::Select;
@@ -52,27 +51,21 @@ sub glob__ {
}
sub run_ {
- my $options = ref $_[0] eq 'HASH' ? shift @_ : {};
my @cmd = @_;
- $options->{timeout} ||= 'never';
- if (arch() !~ /^arm/) {
- my $targetarch = delete $options->{targetarch};
- unshift @cmd, 'setarch', $targetarch if $targetarch;
- }
- print "running " . (exists $options->{root} && "(in chroot) ") . join(' ', @cmd) . "\n" if $::verbose > 1;
- run_program::raw($options, @cmd);
+
+ print "@cmd\n" if $::verbose > 2;
+ system(@cmd) == 0;
}
sub run_as_root {
- my (@cmd) = @_;
+ my @cmd = @_;
if (@cmd > 1) {
unshift @cmd, $sudo if $sudo;
} else {
@cmd[0] = join(' ', $sudo, @cmd[0]);
}
- print "@cmd\n" if $::verbose > 2;
- system(@cmd) == 0;
+ run_(@cmd);
}
sub run_in_root {
@@ -124,18 +117,18 @@ sub copy_or_link {
}
sub mount {
- my ($dst, $src, $o_options) = @_;
+ my ($dst, $src, @o_options) = @_;
mkdir_p($dst);
- system(join(' ', 'sudo mount', $o_options, $src, $dst)) == 0
+ run_as_root('mount', @o_options, $src, $dst)
or die "ERROR: failed to mount $src on $dst\n";
}
sub mount_system_fs {
my ($root) = @_;
- mount($root . '/dev', '/dev', '--bind -o ro');
- mount($root . '/proc', 'none', '-t proc');
- mount($root . '/sys', 'none', '-t sysfs');
- mount($root . '/run', 'none', '-t tmpfs');
+ mount($root . '/dev', '/dev', '--bind', '-o', 'ro');
+ mount($root . '/proc', 'none', '-t', 'proc');
+ mount($root . '/sys', 'none', '-t', 'sysfs');
+ mount($root . '/run', 'none', '-t', 'tmpfs');
}
sub umount_all_in_root {
@@ -144,7 +137,7 @@ sub umount_all_in_root {
my @mounts = grep { $_ =~ $root } split("\n", cat_('/proc/mounts'));
foreach (reverse(@mounts)) {
my @field = split(' ' , $_);
- system(join(' ', 'sudo umount', $field[1]));
+ run_as_root('umount', $field[1]);
}
}