summaryrefslogtreecommitdiffstats
path: root/lib/MGA
diff options
context:
space:
mode:
authorMartin Whitaker <mageia@martin-whitaker.me.uk>2017-12-18 23:13:49 +0000
committerMartin Whitaker <mageia@martin-whitaker.me.uk>2017-12-18 23:13:49 +0000
commit7f97b53ea0cadced2321414a2b7054a4811eda6f (patch)
treef0121a7ecd1cdf31e95a376b7cda14692880df97 /lib/MGA
parentfce42d85023e9e0cbd3b7fbd98ff3b734814612a (diff)
downloaddrakiso-7f97b53ea0cadced2321414a2b7054a4811eda6f.tar
drakiso-7f97b53ea0cadced2321414a2b7054a4811eda6f.tar.gz
drakiso-7f97b53ea0cadced2321414a2b7054a4811eda6f.tar.bz2
drakiso-7f97b53ea0cadced2321414a2b7054a4811eda6f.tar.xz
drakiso-7f97b53ea0cadced2321414a2b7054a4811eda6f.zip
Remove unused code.
Diffstat (limited to 'lib/MGA')
-rw-r--r--lib/MGA/DrakISO/Live.pm7
-rw-r--r--lib/MGA/DrakISO/Loopback.pm9
-rw-r--r--lib/MGA/DrakISO/Media.pm47
-rw-r--r--lib/MGA/DrakISO/Progress.pm33
-rw-r--r--lib/MGA/DrakISO/Storage.pm45
-rw-r--r--lib/MGA/DrakISO/StorageFS.pm58
-rw-r--r--lib/MGA/DrakISO/Utils.pm25
7 files changed, 4 insertions, 220 deletions
diff --git a/lib/MGA/DrakISO/Live.pm b/lib/MGA/DrakISO/Live.pm
index 654b066..8f54e62 100644
--- a/lib/MGA/DrakISO/Live.pm
+++ b/lib/MGA/DrakISO/Live.pm
@@ -64,13 +64,6 @@ sub get_initrd_name {
'initrd-' . $live->find_kernel->{version} . '.img';
}
-sub get_lib_prefix {
- my ($live) = @_;
- 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';
- $lib_prefix;
-}
-
sub get_absolute_path {
my ($live, $path) = @_;
if (defined $path && substr($path, 0, 1) ne '/') {
diff --git a/lib/MGA/DrakISO/Loopback.pm b/lib/MGA/DrakISO/Loopback.pm
index c86f798..f3ba5ae 100644
--- a/lib/MGA/DrakISO/Loopback.pm
+++ b/lib/MGA/DrakISO/Loopback.pm
@@ -143,15 +143,6 @@ our %loop_types;
},
);
-sub get_loop_modules {
- my ($live, $type) = @_;
- my $modules = $loop_types{$_}{modules};
- my $type = ref $modules;
- return $type eq 'CODE' ? $modules->($live) :
- $type eq 'ARRAY' ? @$modules :
- ();
-}
-
sub has_squashfs4_with {
my ($live, $comp) = @_;
my $ucomp = uc($comp);
diff --git a/lib/MGA/DrakISO/Media.pm b/lib/MGA/DrakISO/Media.pm
index 169d22d..d69854f 100644
--- a/lib/MGA/DrakISO/Media.pm
+++ b/lib/MGA/DrakISO/Media.pm
@@ -3,10 +3,11 @@ package MGA::DrakISO::Media;
use strict;
use MDK::Common;
-use MGA::DrakISO::Storage;
use POSIX;
use common;
+use MGA::DrakISO::Storage;
+
sub new {
my ($media) = @_;
@@ -27,64 +28,20 @@ sub new {
$media;
}
-sub get_initrd_path {
- my ($media) = @_;
- '/' . $media->{storage} . '/initrd.gz';
-}
-
-#- mainly for storage-specific subroutines
sub get_storage_setting {
my ($media, $setting) = @_;
$MGA::DrakISO::Storage::storage_types{$media->{storage}}{$setting};
}
-#- for actions that support an optional boot storage type
-sub get_boot_setting {
- my ($media, $setting, $opts) = @_;
- $opts->{boot} ? $MGA::DrakISO::Storage::storage_types{$opts->{boot}}{$setting} : get_media_setting($media, $setting);
-}
-
#- for user-customisable media setting, that can override storage setting
sub get_media_setting {
my ($media, $setting) = @_;
$media->{$setting} || $media->get_storage_setting($setting);
}
-sub get_media_fs_module {
- my ($media) = @_;
- my $fs = $media->get_media_setting('fs');
- $fs eq 'iso9660' ? 'isofs' : $fs eq 'ext2' ? @{[]} : $fs;
-}
-
sub get_media_label {
my ($media) = @_;
first($media->get_media_setting('source') =~ /^LABEL=(.*)$/);
}
-sub get_media_source_for_nash {
- my ($media) = @_;
- my $label = $media->get_media_label;
- #- strip vfat labels to 11 chars and upper-case it
- $label && $media->get_media_setting('fs') eq 'vfat' ?
- 'LABEL=' . uc(substr($label, 0, 11)) :
- $media->get_media_setting('source');
-}
-
-sub find_partition_index {
- my ($media, $mntpoint) = @_;
- eval { find_index { $_->{mntpoint} eq $mntpoint } @{$media->{partitions}} };
-}
-
-sub find_boot_partition_index {
- my ($media) = @_;
- $media->find_partition_index('/boot') || $media->find_partition_index('/');
-}
-
-sub supplement_slash_size {
- my ($media, $total_size) = @_;
- my $correction = 1.2;
- my $slash = find { $_->{mntpoint} eq '/' } @{$media->{partitions}};
- $slash->{size} ||= POSIX::ceil($total_size * $correction / $common::SECTORSIZE);
-}
-
1;
diff --git a/lib/MGA/DrakISO/Progress.pm b/lib/MGA/DrakISO/Progress.pm
deleted file mode 100644
index c3e55bc..0000000
--- a/lib/MGA/DrakISO/Progress.pm
+++ /dev/null
@@ -1,33 +0,0 @@
-package MGA::DrakISO::Progress;
-
-use strict;
-
-use POSIX qw(strftime);
-
-sub new {
- my ($class, $total, $time, $o_exp_divide) = @_;
- bless {
- total => $total,
- current => 0,
- start_time => $time,
- exp_divide => $o_exp_divide,
- maxl => length($total) - $o_exp_divide,
- }, $class;
-}
-
-sub show {
- my ($progress, $time) = @_;
- my $elapsed_time = $time - $progress->{start_time};
- my $eta = $progress->{current} ? int($elapsed_time*$progress->{total}/$progress->{current}) : -1;
- printf("\r%3d%% (%$progress->{maxl}s/%-$progress->{maxl}s), %8s/%8s (ETA)",
- int(100*$progress->{current}/$progress->{total}),
- (map { substr($_, 0, length($_)-$progress->{exp_divide}) } $progress->{current}, $progress->{total}),
- (map { POSIX::strftime("%H:%M:%S", gmtime($_)) } $elapsed_time, $eta));
-}
-
-sub end {
- my ($_progress) = @_;
- print "\n";
-}
-
-1;
diff --git a/lib/MGA/DrakISO/Storage.pm b/lib/MGA/DrakISO/Storage.pm
index 9949e76..b949731 100644
--- a/lib/MGA/DrakISO/Storage.pm
+++ b/lib/MGA/DrakISO/Storage.pm
@@ -2,54 +2,11 @@ package MGA::DrakISO::Storage;
use strict;
-use detect_devices;
-
our %storage_types = (
iso => {
- modules => 'bus/firewire|usb disk/firewire|hardware_raid|ide|sata|scsi|usb',
- fs => 'iso9660',
- source => 'LABEL=MGAISOROOT',
- read_only => 1,
- create => \&main::create_iso_master,
- },
- cdrom => {
- modules => 'bus/firewire|usb disk/firewire|hardware_raid|ide|sata|scsi|usb',
- media_modules => 'disk/cdrom',
fs => 'iso9660',
- can_hide => 0,
- source => 'LABEL=MGACDROOT',
read_only => 1,
- detect => \&detect_devices::burners,
- create => \&main::create_cdrom_master,
- format => \&main::format_cdrom_device,
- record_needs_master => 1,
- record => \&main::record_cdrom_master,
- replicator => \&main::create_cdrom_replicator,
- record_replicator => \&main::record_cdrom_replicator,
- },
- usb => {
- modules => 'bus/usb disk/usb',
- media_modules => 'disk/raw',
- fs => 'vfat',
- can_hide => 1,
- bootloader => 'grub',
- source => 'LABEL=MGAUSBROOT',
- detect => sub { grep { detect_devices::isKeyUsb($_) } detect_devices::get() },
- create => \&main::create_disk_master,
- format => \&main::format_disk,
- record => \&main::record_usb_master,
- image => \&main::create_disk_image,
- replicator => \&main::create_usb_replicator,
- record_replicator => \&main::record_usb_replicator,
- },
- harddisk => {
- fs => 'ext4',
- bootloader => 'grub',
- source => 'LABEL=MGAROOT',
- create => \&main::create_disk_master,
- format => \&main::format_disk,
- record => \&main::record_harddisk_master,
- image => \&main::create_disk_image,
+ source => 'LABEL=MGAISOROOT',
},
);
diff --git a/lib/MGA/DrakISO/StorageFS.pm b/lib/MGA/DrakISO/StorageFS.pm
deleted file mode 100644
index 371fb80..0000000
--- a/lib/MGA/DrakISO/StorageFS.pm
+++ /dev/null
@@ -1,58 +0,0 @@
-package MGA::DrakISO::StorageFS;
-
-use strict;
-
-use MDK::Common;
-
-my %storage_fs;
-%storage_fs = (
- generic => {
- mount => sub {
- my ($live, $media) = @_;
- my @mount_options = (
- if_($media->get_media_setting('read_only'), "ro"),
- grep { $_ } $media->get_media_setting('mount_options'),
- );
- 'nash-mount' . if_(@mount_options, " -o " . join(",", @mount_options)) . " -t " . $media->get_media_setting('fs') .
- " " . $media->get_media_source_for_nash . " $live->{prefix}{live}{mnt}$live->{prefix}{media}{mnt}";
- },
- },
- nfs => {
- files => [ '/sbin/ifconfig', '/bin/mount' ], #- needed to mount NFS (with nolock)
- mount => sub {
- my ($live, $media) = @_;
- '/bin/mount -n -o ro,nolock -t nfs ' . $media->get_media_source_for_nash . " $live->{prefix}{live}{mnt}$live->{prefix}{media}{mnt}";
- }
- },
- ext2 => {
- files => [ '/sbin/fsck.ext2' ],
- mount => sub {
- my ($live, $media) = @_;
- my $fsck = "/bin/fsck.ext2";
- my $source = $media->get_media_setting('source');
- qq(sh -c '$fsck -a $source || $fsck -y $source'),
- $storage_fs{generic}{mount}->($live, $media);
- },
- },
- vfat => {
- #files => [ '/sbin/dosfsck' ],
- mount => sub {
- my ($live, $media) = @_;
- #$storage_fs{generic}{mount}->($live, $media),
- #qq(awk '\$2 == "$live->{prefix}{live}{mnt}$live->{prefix}{media}{mnt}" { system("umount " \$1 "; mount; echo dosfsck -a " \$1 "; dosfsck -a " \$1) }' /proc/mounts),
- $storage_fs{generic}{mount}->($live, $media);
- },
- },
-);
-
-sub get_files {
- my ($fs) = @_;
- @{$storage_fs{$fs} && $storage_fs{$fs}{files} || []};
-}
-
-sub get_mount {
- my ($fs) = @_;
- $storage_fs{exists $storage_fs{$fs}{mount} ? $fs : 'generic'}{mount};
-}
-
-1;
diff --git a/lib/MGA/DrakISO/Utils.pm b/lib/MGA/DrakISO/Utils.pm
index 11295c9..b20cb32 100644
--- a/lib/MGA/DrakISO/Utils.pm
+++ b/lib/MGA/DrakISO/Utils.pm
@@ -11,7 +11,7 @@ use IO::Select;
use Exporter;
our @ISA = qw(Exporter);
-our @EXPORT = qw(directory_usage run_ run_foreach mount_system_fs umount_external_fs);
+our @EXPORT = qw(directory_usage run_ mount_system_fs umount_external_fs);
sub directory_usage {
my ($dir, $o_apparent) = @_;
@@ -38,29 +38,6 @@ sub run_ {
run_program::raw($options, @cmd);
}
-sub run_foreach {
- my ($foreach, @command) = @_;
- print STDERR "running " . join(' ', @command) . "\n";
- my $pid = open3(my $cmd_in, my $cmd_out, undef, @command);
- my $selector = IO::Select->new($cmd_out);
- while (my @ready = $selector->can_read) {
- foreach my $fh (@ready) {
- local $_ = scalar <$fh>;
- return if /^open3:/;
- $foreach->();
- $selector->remove($fh) if eof($fh);
- }
- }
- close($cmd_out);
- close($cmd_in);
- return waitpid($pid, 0) > 0 && !($? >> 8);
-}
-
-sub mtools_run_ {
- local $ENV{MTOOLS_SKIP_CHECK} = 1;
- &run_;
-}
-
sub device_allocate_file {
my ($device, $size) = @_;
run_('dd', "of=$device", 'count=0', 'bs=1', "seek=" . removeXiBSuffix($size));