summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorOlivier Blin <oblin@mandriva.org>2005-12-07 18:42:19 +0000
committerOlivier Blin <oblin@mandriva.org>2005-12-07 18:42:19 +0000
commit08a020e7dbce9d024b77336df053af9bff1cece4 (patch)
tree00b38bf5dd7cfcf89e36e40bd183b7634a11e67c
parent180a1a1fcbb285c97bcb1d27ae705180331186de (diff)
downloaddrakx-backup-do-not-use-08a020e7dbce9d024b77336df053af9bff1cece4.tar
drakx-backup-do-not-use-08a020e7dbce9d024b77336df053af9bff1cece4.tar.gz
drakx-backup-do-not-use-08a020e7dbce9d024b77336df053af9bff1cece4.tar.bz2
drakx-backup-do-not-use-08a020e7dbce9d024b77336df053af9bff1cece4.tar.xz
drakx-backup-do-not-use-08a020e7dbce9d024b77336df053af9bff1cece4.zip
rename sparsefs mount as loopfs, make it take loopback file size as option (pre_allocate), and add new predefined squash mounts
-rwxr-xr-xtools/draklive82
1 files changed, 53 insertions, 29 deletions
diff --git a/tools/draklive b/tools/draklive
index aaea54715..a089953a7 100755
--- a/tools/draklive
+++ b/tools/draklive
@@ -29,19 +29,25 @@ use Cwd 'abs_path';
use Getopt::Long;
use Pod::Usage;
+my $dir_distrib_sqfs = {
+ mountpoint => '/distrib',
+ type => 'squashfs',
+ source => 'distrib.sqfs',
+ build_from => '/',
+};
+my $dir_memory = {
+ mountpoint => '/memory',
+ type => 'tmpfs',
+};
+
my %predefined = (
mounts => {
simple_union => {
root => '/union',
overlay => 'unionfs',
dirs => [
- {
- mountpoint => '/memory',
- type => 'tmpfs',
- },
- {
- mountpoint => '/media',
- },
+ $dir_memory,
+ { mountpoint => '/media' },
],
},
squash_union => {
@@ -49,20 +55,33 @@ my %predefined = (
overlay => 'unionfs',
dirs => [
{
- mountpoint => '/memory',
- type => 'tmpfs',
+ mountpoint => '/system',
+ type => 'loopfs',
+ pre_allocate => '100k',
+ source => 'system.loop'
},
+ $dir_distrib_sqfs,
+ ],
+ },
+ volatile_squash_union => {
+ root => '/union',
+ overlay => 'unionfs',
+ dirs => [
+ $dir_memory,
+ $dir_distrib_sqfs,
+ ],
+ },
+ multi_squash_union => {
+ root => '/union',
+ overlay => 'unionfs',
+ dirs => [
+ $dir_memory,
{
mountpoint => '/system',
type => 'squashfs',
source => 'system.sqfs'
},
- {
- mountpoint => '/distrib',
- type => 'squashfs',
- source => 'distrib.sqfs',
- build_from => '/',
- },
+ $dir_distrib_sqfs,
],
},
},
@@ -133,12 +152,13 @@ sub progress_show_incr {
sub progress_end() { print "\n" }
+my $loop_number = 0;
my %loop = (
squashfs => {
read_only => 1,
modules => [ qw(loop squashfs) ],
build => sub {
- my ($root, $dest) = @_;
+ my ($dest, $root) = @_;
my $total = first(split /\s/, `du -sb $root`);
print "have to process " . int($total/1000000) . " MB\n";
my $progress = progress_start($total, time(), 6);
@@ -153,26 +173,30 @@ my %loop = (
}
progress_end();
},
- mount => do { my $lo = 0; sub {
+ mount => sub {
my ($live, $dir) = @_;
my @mnt = (
($live->{media}{fs} eq 'nfs' ? '/bin/losetup -r' : 'losetup') .
- " /dev/loop$lo $live->{media}{mountpoint}/$dir->{source}",
- "mount -o ro -t squashfs /dev/loop$lo $dir->{mountpoint}");
- $lo++;
+ " /dev/loop$loop_number $live->{media}{mountpoint}/$dir->{source}",
+ "mount -o ro -t squashfs /dev/loop$loop_number $dir->{mountpoint}");
+ $loop_number++;
@mnt;
- } },
+ },
},
- sparsefs => {
+ loopfs => {
modules => [],
create => sub {
- my ($dest) = @_;
- run_('dd', "of=$dest", 'count=0', 'seek=1000000', 'bs=1k');
+ my ($dest, $size) = @_;
+ run_('dd', "of=$dest", 'count=0', "seek=$size", 'bs=1k');
run_('mke2fs', '-F', $dest);
},
mount => sub {
my ($live, $dir) = @_;
- "mount -t ext2 $live->{media}{mountpoint}/$dir->{source} none $dir->{mountpoint}";
+ my @mnt = (
+ "losetup /dev/loop$loop_number $live->{media}{mountpoint}/$dir->{source}",
+ "mount -t ext2 /dev/loop$loop_number $dir->{mountpoint}");
+ $loop_number++;
+ @mnt;
},
},
tmpfs => {
@@ -405,12 +429,12 @@ sub create_loopback_files {
my $tree = $live->{system}{root} . $_->{build_from};
my $dest = $live->{images_dir} . '/' . $_->{source};
unlink($dest);
- $loop{$_->{type}}{build}->($tree, $dest);
+ $loop{$_->{type}}{build}->($dest, $tree);
}
- foreach (grep { $_->{pre_create} } @{$live->{mount}{dirs} || []}) {
+ foreach (grep { $_->{pre_allocate} } @{$live->{mount}{dirs} || []}) {
my $dest = $live->{images_dir} . '/' . $_->{source};
unlink($dest);
- $loop{$_->{type}}{create}->($dest);
+ $loop{$_->{type}}{create}->($dest, $_->{pre_allocate});
}
}
@@ -463,7 +487,7 @@ sub record_master {
cp_f(glob($live->{boot_dir} . '/*'), $live->{mnt});
output($live->{mnt} . '/syslinux.cfg', build_syslinux_cfg($live));
unless ($o_refresh_boot_only) {
- foreach (grep { $_->{build_from} || $_->{pre_create} } @{$live->{mount}{dirs} || []}) {
+ foreach (grep { $_->{build_from} || $_->{pre_allocate} } @{$live->{mount}{dirs} || []}) {
print "copying $_->{source}\n";
cp_f($live->{images_dir} . '/' . $_->{source}, $live->{mnt});
}