# Testing if init is sufficient for grabbing the correct libraries for the
# Testing if init is sufficient for grabbing the correct libraries for the
# executables immediately above. This could be modified to test a
# executables immediately above. This could be modified to test a
# list of executables.
# list of executables. Now bzip2 uses libbz2.so.1.0, so if bzip2 is
# present on the system this will be the tester instead, and size
# has to be figured out differently.
info(0, ".. the libs\n");
info(0, ".. the libs\n");
open(L,"ldd /sbin/init|") or die "Oops, no init could be found :)\n"; # safe to use ldd, this is going to be fixed later with library_dependencies
my $lib_tester;
if ($bz2_toggle->active && -x find_file_in_path("bzip2") ) {
$lib_tester = find_file_in_path("bzip2");
}
else {
$lib_tester = find_file_in_path("init");
}
my $dir;
open(L,"ldd $lib_tester|") or die "Oops, no $lib_tester could be found :)\n"; # safe to use ldd, this is going to be fixed later with library_dependencies
while (<L>) {
while (<L>) {
$lib = (split(/=>/,$_))[0];
my $place;
($lib,$place) = (split(/=>/,$_))[0,1];
$place = (split(" ",$place))[0];
$lib =~ s/\s+//;
$lib =~ s/\s+//;
$lib = basename($lib);
$lib = basename($lib);
$lib =~ s/\s+$//;
$lib =~ s/\s+$//;
open (SL,"ls -l /lib/$lib|") or die "humm: $!\n";
$dir = dirname($place);
info(0,"$dir/$lib\n");
open (SL,"ls -l $dir/$lib|") or die "humm: $!\n";
while (<SL>) {
while (<SL>) {
# symbolic link
# symbolic link
if (-l "/lib/$lib") {
if (-l "$dir/$lib") {
$what = (split(/\s+/,$_))[10];
$what = (split(/\s+/,$_))[10];
($path,$value) = stripper("/lib/$lib","lib");
($path,$value) = stripper("$dir/$lib","lib");
$value == 0 ? ($tool = "cp -a") : ($tool = "mv");
$value == 0 ? ($tool = "cp -a") : ($tool = "mv");
return if errcp(sys("$tool $path $tmp/initrd_mnt/lib")) == 2;
return if errcp(sys("$tool $path $tmp/initrd_mnt$dir")) == 2;
($path,$value) = stripper("/lib/$what","lib");
($path,$value) = stripper("$dir/$what","lib");
$value == 0 ? ($tool = "cp -a") : ($tool = "mv");
$value == 0 ? ($tool = "cp -a") : ($tool = "mv");
return if errcp(sys("$tool $path $tmp/initrd_mnt/lib")) == 2;
return if errcp(sys("$tool $path $tmp/initrd_mnt$dir")) == 2;
}
}
# no symbolic link
# no symbolic link
else {
else {
($path,$value) = stripper("/lib/$lib","lib");
($path,$value) = stripper("$dir/$lib","lib");
return if errcp(sys("cp -a $path $tmp/initrd_mnt/lib")) == 2;
return if errcp(sys("cp -a $path $tmp/initrd_mnt$dir")) == 2;