diff options
author | Martin Whitaker <mageia@martin-whitaker.me.uk> | 2017-12-18 21:23:57 +0000 |
---|---|---|
committer | Martin Whitaker <mageia@martin-whitaker.me.uk> | 2017-12-18 21:23:57 +0000 |
commit | 996706b13c0354ae98e08f4cd54eae2a5868434c (patch) | |
tree | babaa5bcfbc3a51d6e0849757e5b3629a48a8047 /lib/MGA/DrakISO/Loopback.pm | |
parent | cd2fe6bf1129641d59614d6382c5819acd8252e4 (diff) | |
download | drakiso-996706b13c0354ae98e08f4cd54eae2a5868434c.tar drakiso-996706b13c0354ae98e08f4cd54eae2a5868434c.tar.gz drakiso-996706b13c0354ae98e08f4cd54eae2a5868434c.tar.bz2 drakiso-996706b13c0354ae98e08f4cd54eae2a5868434c.tar.xz drakiso-996706b13c0354ae98e08f4cd54eae2a5868434c.zip |
Remove ability to override default directory names.
It's unlikely anyone would want to do this, and it makes the code
considerably harder to read.
Diffstat (limited to 'lib/MGA/DrakISO/Loopback.pm')
-rw-r--r-- | lib/MGA/DrakISO/Loopback.pm | 72 |
1 files changed, 48 insertions, 24 deletions
diff --git a/lib/MGA/DrakISO/Loopback.pm b/lib/MGA/DrakISO/Loopback.pm index c48f2b6..5e8e38e 100644 --- a/lib/MGA/DrakISO/Loopback.pm +++ b/lib/MGA/DrakISO/Loopback.pm @@ -1,5 +1,6 @@ package MGA::DrakISO::Loopback; + use MDK::Common; use File::Temp; use MGA::DrakISO::Progress; @@ -19,7 +20,7 @@ our %loop_types; extension => '-lzma.sqfs', build => sub { my ($live, $dir) = @_; - my $dest = $live->get_builddir . $live->{prefix}{build}{loopbacks} . $dir->{path} . $loop_types{squashfs}{extension}; + my $dest = $live->get_builddir('loopbacks') . $dir->{path} . $loop_types{squashfs}{extension}; mkdir_p(dirname($dest)); my $root = $dir->{root} || $live->get_system_root; my $src = $root . $dir->{build_from}; @@ -47,12 +48,13 @@ our %loop_types; unlink $exclude_file; }, mount => sub { - my ($live, $dir) = @_; + my ($dir) = @_; $dir->{loop} = "/dev/loop" . $loop_number++; - my $media_loopbacks = $live->get_media_prefix('loopbacks'); + my $extension = $dir->{path} . $loop_types{squashfs}{extension}; + my $mountpoint = $dir->{mountpoint}; ( - "/bin/losetup $dir->{loop} $live->{prefix}{live}{mnt}$live->{prefix}{media}{mnt}${media_loopbacks}$dir->{path}$loop_types{squashfs}{extension}", - "nash-mount -o ro -t squashfs $dir->{loop} $live->{prefix}{live}{mnt}$dir->{mountpoint}", + "/bin/losetup $dir->{loop} /live/media/loopbacks$extension", + "nash-mount -o ro -t squashfs $dir->{loop} /live$mountpoint", ); }, }, @@ -60,15 +62,32 @@ our %loop_types; read_only => 1, delay_mount => 1, mount => sub { - my ($live, $dir) = @_; - my $media_loopbacks = $live->get_media_prefix('loopbacks'); - "sh -c 'modules=; for m in $live->{prefix}{live}{mnt}$live->{prefix}{media}{mnt}${media_loopbacks}$dir->{path}/*; do n=\$(basename \$m); n=\${n%.sqfs}; d=$live->{prefix}{live}{mnt}$dir->{mountpoint}/\$n; mkdir -p \$d; mount -n -o loop,ro -t squashfs \$m \$d && modules=\$modules\$d=ro:; done; echo \$modules | sed -e s/:\$// > $live->{prefix}{live}{mnt}/$dir->{list}'"; + my ($dir) = @_; + my $path = $dir->{path}; + my $mountpoint = $dir->{mountpoint}; + "sh -c 'modules=;" + . "for m in /live/media/loopbacks$path/*; do" + . "n=\$(basename \$m);" + . "n=\${n%.sqfs};" + . "d=/live$mountpoint/\$n;" + . "mkdir -p \$d;" + . "mount -n -o loop,ro -t squashfs \$m \$d && modules=\$modules\$d=ro:;" + . "done;" + . "echo \$modules | sed -e s/:\$// > /live/$dir->{list}'"; }, pivot_clean => sub { - my ($live, $dir, $initrdroot) = @_; + my ($dir, $initrdroot) = @_; + my $list = $dir->{list}; + my $mountpoint = $dir->{mountpoint}; ( - "sh -c 'cd $initrdroot$live->{prefix}{live}{mnt}$dir->{mountpoint}; for i in `ls -1`; do mkdir -p $live->{prefix}{live}{mnt}$dir->{mountpoint}/\$i; mount -n --move \$i $live->{prefix}{live}{mnt}$dir->{mountpoint}/\$i; rmdir \$i; done; rmdir $initrdroot$live->{prefix}{live}{mnt}$dir->{mountpoint}'", - "sh -c 'mv $initrdroot$live->{prefix}{live}{mnt}/$dir->{list} $live->{prefix}{live}{mnt}/'", + "sh -c 'cd $initrdroot/live$mountpoint;" + . "for i in `ls -1`; do" + . "mkdir -p /live$mountpoint/\$i;" + . "mount -n --move \$i /live$mountpoint/\$i;" + . "rmdir \$i;" + . "done;" + . "rmdir $initrdroot/live$mountpoint'", + "sh -c 'mv $initrdroot/live/$list /live/'", ); }, }, @@ -78,45 +97,50 @@ our %loop_types; extension => '.loop', build => sub { my ($live, $dir) = @_; - my $dest = $live->get_builddir . $live->{prefix}{build}{loopbacks} . $dir->{path} . $loop_types{loopfs}{extension}; + my $dest = $live->get_builddir('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}; }, mount => sub { - my ($live, $dir) = @_; + my ($dir) = @_; $dir->{loop} = "/dev/loop" . $loop_number++; - my $fsck = "chroot </dev/tty1 $live->{prefix}{live}{mnt}$dir_distrib_sqfs->{mountpoint} /sbin/fsck $dir->{loop}"; - my $media_loopbacks = $live->get_media_prefix('loopbacks'); + my $sqfs = $dir_distrib_sqfs->{mountpoint}; + my $fsck = "chroot </dev/tty1 /live/$sqfs /sbin/fsck $dir->{loop}"; + my $extension = $dir->{path} . $loop_types{loopfs}{extension}; + my $mountpoint = $dir->{mountpoint}; ( - "losetup $dir->{loop} $live->{prefix}{live}{mnt}$live->{prefix}{media}{mnt}${media_loopbacks}$dir->{path}$loop_types{loopfs}{extension}", + "losetup $dir->{loop} /live/media/loopbacks$extension", qq(sh -c "$fsck -a || $fsck -y"), - "nash-mount -t $dir->{fs} $dir->{loop} $live->{prefix}{live}{mnt}$dir->{mountpoint}", + "nash-mount -t $dir->{fs} $dir->{loop} /live$mountpoint", ); }, }, plain => { skip_mkdir => 1, mount => sub { - my ($live, $dir) = @_; - qq(sh -c "mkdir -p $live->{prefix}{live}{mnt}$dir->{mountpoint}"); + my ($dir) = @_; + my $mountpoint = $dir->{mountpoint}; + qq(sh -c "mkdir -p /live$mountpoint"); }, }, partition => { files => [ '/sbin/fsck', '/sbin/blkid' ], mount => sub { - my ($live, $dir) = @_; + my ($dir) = @_; my $fsck = "/bin/fsck"; + my $path = $dir->{path}; + my $mountpoint = $dir->{mountpoint}; ( - qq(sh -c 'dev=`blkid -l -t $dir->{path} -o device`; [ -z "\$dev" ] || $fsck -a \$dev || $fsck -y \$dev'), - "nash-mount -t $dir->{fs} $dir->{path} $live->{prefix}{live}{mnt}$dir->{mountpoint}", + qq(sh -c 'dev=`blkid -l -t $path -o device`; [ -z "\$dev" ] || $fsck -a \$dev || $fsck -y \$dev'), + "nash-mount -t $dir->{fs} $path /live$mountpoint", ); }, }, tmpfs => { mount => sub { - my ($live, $dir) = @_; - my $mnt = $live->{prefix}{live}{mnt} . $dir->{mountpoint}; + my ($dir) = @_; + my $mnt = '/live' . $dir->{mountpoint}; my $mount_opts = $dir->{mount_opts} ? "-o $dir->{mount_opts}" : ""; my $cmd = "mount -t tmpfs $mount_opts $mnt $mnt"; $dir->{fallback} ? qq(sh -c 'if ! grep -q " $mnt " /proc/mounts; then $cmd; fi') : $cmd; |