diff options
Diffstat (limited to 'tools')
| -rw-r--r-- | tools/Makefile | 2 | ||||
| -rwxr-xr-x | tools/drakx-in-chroot | 86 | ||||
| -rwxr-xr-x | tools/install-xml-file-list | 5 |
3 files changed, 59 insertions, 34 deletions
diff --git a/tools/Makefile b/tools/Makefile index 669b6f987..1d9d5d736 100644 --- a/tools/Makefile +++ b/tools/Makefile @@ -10,7 +10,7 @@ endif .PHONY: clean install $(DIRS) -all: $(DIRS) xhost+ rpcinfo-flushed +all: $(DIRS) rpcinfo-flushed $(DIRS): make -C $@ diff --git a/tools/drakx-in-chroot b/tools/drakx-in-chroot index 4c4e2ec99..312c5abfd 100755 --- a/tools/drakx-in-chroot +++ b/tools/drakx-in-chroot @@ -26,10 +26,12 @@ my ($disk_iso_repository, $repository_uri); --resolution=XXXxYYYY (eg: --resolution=1024x768)\n --repository=<path> path of packages repository --text text mode installer + --depth=XX set screen color depth + --stage2-update X,Y will mount --bind X on Y "; (my $repository, my $dir, @ARGV) = @ARGV; -my ($gdb); +my ($wrapper); foreach (@ARGV) { if (/--resolution=(.*)/) { $resolution = $1; @@ -38,7 +40,11 @@ foreach (@ARGV) { } elsif (/--repository=(.*)/) { $repository_uri = $1; } elsif (/--gdb/) { - $gdb = "gdb -q --args"; + $wrapper = "gdb -q --args"; + } elsif (/--strace/) { + $wrapper = "strace -e file"; + } elsif (/--depth=(.*)/) { + $resolution .= "x$1"; } } my ($repository_without_arch, $repository_arch) = basename($repository) eq arch() ? (dirname($repository), '/' . arch()) : ($repository, ''); @@ -50,6 +56,9 @@ if ($>) { $ENV{PATH} = "/sbin:/usr/sbin:$ENV{PATH}"; } +my @mounts; +my $_b = before_leaving { sys("$sudo umount $_") foreach reverse @mounts }; + undef $ENV{TMPDIR}; # prevent packdrake faillure on creating temporary files if (-d $SLASH_LOCATION) { @@ -58,7 +67,7 @@ if (-d $SLASH_LOCATION) { rm_rf($SLASH_LOCATION); } -mkdir_p("$SLASH_LOCATION$_") foreach '/dev', '/dev/usb', '/etc', '/var', '/proc', '/sys', '/run', $STAGE2_LOCATION_ROOTED, $MEDIA_LOCATION_ROOTED, $prefix_ROOTED; +mkdir_p("$SLASH_LOCATION$_") foreach '/dev', '/etc', '/var', '/proc', '/sys', '/run', $STAGE2_LOCATION_ROOTED, $MEDIA_LOCATION_ROOTED, $prefix_ROOTED; sys("$sudo rm -rf $dir") if $ENV{CLEAN}; -e $dir or sys("$sudo mkdir -p $dir"); @@ -71,43 +80,42 @@ if ($remote_repository) { sys("curl --silent -o $local_mdkinst $repository/$COMPRESSED_FILE_REL"); mount_mdkinst($local_mdkinst); } elsif (-d "$repository/$LIVE_LOCATION_REL") { - sys("$sudo mount -o bind $repository/$LIVE_LOCATION_REL $STAGE2_LOCATION"); + mount("$repository/$LIVE_LOCATION_REL", $STAGE2_LOCATION, "-o bind"); } elsif (-e "$repository/$COMPRESSED_FILE_REL") { mount_mdkinst("$repository/$COMPRESSED_FILE_REL"); } -sys("$sudo mount -o bind $dir $SLASH_LOCATION$prefix_ROOTED"); +mount($dir, "$SLASH_LOCATION$prefix_ROOTED", "-o bind"); $repository_uri ||= $repository_without_arch if !$remote_repository; -sys("$sudo mount -o bind $repository_uri $SLASH_LOCATION$MEDIA_LOCATION_ROOTED") if $repository_uri; - -sys("$sudo mount -t proc none $SLASH_LOCATION/proc"); -sys("$sudo mount -t sysfs none $SLASH_LOCATION/sys"); -sys("$sudo mount -t debugfs none $SLASH_LOCATION/sys/kernel/debug"); -sys("$sudo mount -t tmpfs none $SLASH_LOCATION/run"); +mount($repository_uri, "$SLASH_LOCATION$MEDIA_LOCATION_ROOTED", "-o bind") if $repository_uri; -if (-d "/run/udev") { - # Ensure we mount the udev run dir for various extra metadata from udevadm - mkdir_p("$SLASH_LOCATION/run/udev"); - sys("$sudo mount -o bind /run/udev $SLASH_LOCATION/run/udev"); -} - -if (-d "/run/initramfs") { - # If dracut has been used (and thus udev has yummy metadata) make sure - # drakx knows about it when running in the chroot - mkdir_p("$SLASH_LOCATION/run/initramfs"); - sys("$sudo mount -o bind /run/initramfs $SLASH_LOCATION/run/initramfs"); +# for draklive: +create_initial_devices(); +mount('/dev', "$SLASH_LOCATION/dev", " --bind -o ro"); +mount('none', "$SLASH_LOCATION/proc", "-t proc"); +mount('none', "$SLASH_LOCATION/sys", "-t sysfs"); +mount('none', "$SLASH_LOCATION/sys/kernel/debug", "-t debugfs"); +mount('none', "$SLASH_LOCATION/run", "-t tmpfs"); + +# - Ensure we mount the udev run dir for various extra metadata from udevadm +# - If dracut has been used (and thus udev has yummy metadata) make sure +# drakx knows about it when running in the chroot +# - Also speedup blkid by using its cache +foreach my $dir (qw(initramfs udev blkid)) { + next if !-d "/run/$dir"; + mkdir_p("$SLASH_LOCATION/run/$dir"); + mount("/run/$dir", "$SLASH_LOCATION/run/$dir", "-o bind"); } if ($disk_iso_repository) { my $repository_arch = $repository_arch || 'i586'; mkdir_p($LOOP_MOUNT_POINT); - sys("$sudo mount -o loop,ro $disk_iso_repository $LOOP_MOUNT_POINT"); + mount($disk_iso_repository, $LOOP_MOUNT_POINT, "-o loop,ro"); symlinkf('loop/' . $repository_arch, "$SLASH_LOCATION$IMAGE_LOCATION_ROOTED"); # FIXME: arch() } symlinkf('media' . $repository_arch, "$SLASH_LOCATION$IMAGE_LOCATION_ROOTED"); create_initial_symlinks(); -create_initial_devices(); apply_stage2_updates(); @@ -119,7 +127,7 @@ mkdir_p("$dir/dev"); eval { cp_af($_, "$dir$_") } foreach qw(/dev/root); #- if the DISPLAY is remote, we may need to resolve the name: -eval { cp_af($_, "$SLASH_LOCATION$_") } foreach qw(/etc/resolv.conf); +eval { cp_af('/etc/resolv.conf', "$SLASH_LOCATION/etc/resolv.conf") }; { chomp(my $kernel_version = `uname -r`); @@ -129,8 +137,8 @@ eval { cp_af($_, "$SLASH_LOCATION$_") } foreach qw(/etc/resolv.conf); } my $Xnest_pid; -my $Xnest_bin = find { whereis_binary($_) } 'Xephyr', 'Xnest'; -if (!-f ($SLASH_LOCATION . $AUTO_INSTALL_ROOTED) && $Xnest_bin && (join('', @ARGV) !~ /--text/)) { +my $Xnest_bin = find { whereis_binary($_) } 'Xephyr', 'Xnest' or die "Xephyr not find! Please install x11-server-xephyr!\n"; +if (!-f ($SLASH_LOCATION . $AUTO_INSTALL_ROOTED) && $Xnest_bin && join('', @ARGV) !~ /--text/) { my $DISPLAY = ':8'; $Xnest_pid = fork(); if (!$Xnest_pid) { @@ -155,7 +163,7 @@ if (my $pid = fork()) { if_($disk_iso_repository, "--method disk-iso"), if_($remote_repository, "--method $remote_repository"), @ARGV); - if ($gdb) { + if ($wrapper) { warn qq(GDB USAGE Beware that debug info won't be found so on segfault just generate a core dump with "gcore" and then @@ -166,7 +174,7 @@ Thus you sessions will look like: (gdb) exit ); } - exec "$sudo $gdb chroot $SLASH_LOCATION $cmd" or die "exec $cmd in $SLASH_LOCATION failed\n"; + exec "$sudo $wrapper chroot $SLASH_LOCATION $cmd" or die "exec $cmd in $SLASH_LOCATION failed\n"; } sub system_verbose { warn join(' ', @_), "\n" if $verbose; system(@_) } @@ -174,7 +182,7 @@ sub sys { &system_verbose; $? and die qq(running "@_" failed: $?\n) } sub mount_mdkinst { my ($mdkinst) = @_; - sys("$sudo mount -t squashfs -o loop,ro $mdkinst $STAGE2_LOCATION"); + mount($mdkinst, $STAGE2_LOCATION, "-t squashfs -o loop,ro"); } sub create_initial_symlinks() { foreach (cat_or_die("$STAGE2_LOCATION/usr/share/symlinks")) { @@ -185,6 +193,20 @@ sub create_initial_symlinks() { symlink $from, $to or die "symlinking $to failed\n"; } } + my $from = "$STAGE2_LOCATION_ROOTED/usr"; + my $to = "$SLASH_LOCATION/usr"; + symlink $from, $to or die "symlinking $to failed\n"; + foreach ('bin', 'sbin', 'lib', 'lib64') { + $from = "usr/$_"; + $to = "$SLASH_LOCATION/$_"; + symlink $from, $to or die "symlinking $to failed\n"; + } +} + +sub mount { + my ($from, $mntpt, @opts) = @_; + push @mounts, $mntpt; + sys("$sudo mount $from $mntpt " . join(' ', @opts)); } sub create_initial_devices() { @@ -194,7 +216,7 @@ sub create_initial_devices() { sub umount_all() { my $err; clean_stage2_updates(); - my @procs = ('/proc', '/sys/kernel/debug', '/sys', '/run/udev', '/run/initramfs', '/run'); + my @procs = (qw(/dev /proc /sys/kernel/debug /sys /run/udev /run/blkid /run/initramfs /run)); foreach ((map { "$prefix_ROOTED$_" } @procs, '/dev', ''), @procs, $STAGE2_LOCATION_ROOTED, $LOOP_MOUNT_POINT, $MEDIA_LOCATION_ROOTED, $IMAGE_LOCATION_ROOTED) { my $dir = "$SLASH_LOCATION$_"; rmdir $dir; @@ -246,7 +268,7 @@ sub apply_stage2_updates() { undef $ARGV[$::i+1]; undef $ARGV[$::i+2]; push @stage2_updates, $dest; - sys("$sudo mount --bind $file $STAGE2_LOCATION/$dest"); + mount($file, "$STAGE2_LOCATION/$dest", " --bind"); } } } @ARGV; diff --git a/tools/install-xml-file-list b/tools/install-xml-file-list index 56b7a0a4f..7bd0588fe 100755 --- a/tools/install-xml-file-list +++ b/tools/install-xml-file-list @@ -258,7 +258,9 @@ sub install { } elsif ($expand eq 'binary') { $disallow_from_dir->(); - my @PATH = qw(/sbin /bin /usr/bin /usr/sbin /usr/X11R6/bin); + my @PATH = qw(/usr/sbin /usr/bin /usr/X11R6/bin); + unshift(@PATH, "/bin") unless ( -l "/bin" ); + unshift(@PATH, "/sbin") unless ( -l "/sbin" ); foreach my $name (map { expand_macros($_) } @text_l) { my @l = grep { -x $_ } map { "$_/$name" } @PATH; @l or error("can't find binary $name"), next; @@ -353,6 +355,7 @@ sub apply_filter { @l = grep { ! -d $_ } @l or next; if (my $subst = $filter->{subst}) { + warn "running substition $subst \n" if $verbose; system('perl', '-pi', '-e', $subst, @l); } if (my $command = $filter->{command}) { |
