mirror of
https://github.com/xcat2/xcat-core.git
synced 2025-05-22 03:32:04 +00:00
Merge pull request #128 from immarvin/master
use pigz to improve the performance of genimage/packimage/liteimg
This commit is contained in:
commit
d117851a30
@ -366,17 +366,26 @@ sub process_request {
|
||||
$callback->({data=>["$verb contents of $rootimg_dir"]});
|
||||
unlink("$destdir/rootimg.gz");
|
||||
unlink("$destdir/rootimg.sfs");
|
||||
|
||||
my $compress="gzip";
|
||||
#use "pigz" as the compress tool instead of gzip if "pigz" exist
|
||||
my $ispigz=system("bash -c 'type -p pigz' >/dev/null 2>&1");
|
||||
if($ispigz == 0){
|
||||
$compress="pigz";
|
||||
}
|
||||
|
||||
$callback->({info=>["compress method:$compress"]});
|
||||
|
||||
if ($method =~ /cpio/) {
|
||||
if ( ! $exlistloc ) {
|
||||
$excludestr = "find . -xdev |cpio -H newc -o | gzip -c - > ../rootimg.gz";
|
||||
$excludestr = "find . -xdev |cpio -H newc -o | $compress -c - > ../rootimg.gz";
|
||||
}else {
|
||||
chdir("$rootimg_dir");
|
||||
system("$excludestr >> $xcat_packimg_tmpfile");
|
||||
if ($includestr) {
|
||||
system("$includestr >> $xcat_packimg_tmpfile");
|
||||
}
|
||||
#$excludestr =~ s!-a \z!|cpio -H newc -o | gzip -c - > ../rootimg.gz!;
|
||||
$excludestr = "cat $xcat_packimg_tmpfile|cpio -H newc -o | gzip -c - > ../rootimg.gz";
|
||||
$excludestr = "cat $xcat_packimg_tmpfile|cpio -H newc -o | $compress -c - > ../rootimg.gz";
|
||||
}
|
||||
$oldmask = umask 0077;
|
||||
} elsif ($method =~ /squashfs/) {
|
||||
|
@ -522,15 +522,25 @@ sub process_request {
|
||||
my $oldmask;
|
||||
$callback->({data=>["$verb contents of $rootimg_dir"]});
|
||||
unlink("$destdir/rootimg-statelite.gz");
|
||||
|
||||
my $compress="gzip";
|
||||
#use "pigz" as the compress tool instead of gzip if "pigz" exist
|
||||
my $ispigz=system("bash -c 'type -p pigz' >/dev/null 2>&1");
|
||||
if($ispigz == 0){
|
||||
$compress="pigz";
|
||||
}
|
||||
|
||||
$callback->({info=>["compress method: $compress"]});
|
||||
|
||||
if ($exlistloc) {
|
||||
chdir("$rootimg_dir");
|
||||
system("$excludestr >> $xcat_packimg_tmpfile");
|
||||
if ( $includestr) {
|
||||
system("$includestr >> $xcat_packimg_tmpfile");
|
||||
}
|
||||
$excludestr = "cat $xcat_packimg_tmpfile |cpio -H newc -o | gzip -c - > ../rootimg-statelite.gz";
|
||||
$excludestr = "cat $xcat_packimg_tmpfile |cpio -H newc -o | $compress -c - > ../rootimg-statelite.gz";
|
||||
} else {
|
||||
$excludestr = "find . |cpio -H newc -o | gzip -c - > ../rootimg-statelite.gz";
|
||||
$excludestr = "find . |cpio -H newc -o | $compress -c - > ../rootimg-statelite.gz";
|
||||
}
|
||||
$oldmask = umask 0077;
|
||||
chdir("$rootimg_dir");
|
||||
|
@ -949,12 +949,20 @@ sub mkinitrd_dracut {
|
||||
$additional_options= qq{--include /tmp/cmdline /etc/cmdline};
|
||||
}
|
||||
|
||||
|
||||
|
||||
# force the dracut run in non-hostonly mode for dracut higher than version 033
|
||||
if ($dracutver > "033") {
|
||||
$additional_options .= " -N";
|
||||
}
|
||||
|
||||
#if "pigz" is available in the rootimg, use "pigz" instead of "gzip"
|
||||
my $compress=qx(chroot $rootimg_dir bash -c "type -p pigz"|tr -d "\n");
|
||||
if ($compress){
|
||||
#take the online cpu numerber as the pigz processes number
|
||||
my $processnum=qx(lscpu -p=cpu --online|grep -v '#'|wc -l|tr -d "\n");
|
||||
$additional_options .= " --compress \"$compress -p $processnum \"";
|
||||
}
|
||||
|
||||
print "\nchroot $rootimg_dir dracut $additional_options -f /tmp/initrd.$$.gz $kernelver\n";
|
||||
!system("chroot $rootimg_dir dracut $additional_options -f /tmp/initrd.$$.gz $kernelver")
|
||||
or die("Error: failed to generate the initial ramdisk for $mode.\n");
|
||||
print "the initial ramdisk for $mode is generated successfully.\n";
|
||||
|
@ -1088,6 +1088,15 @@ sub mkinitrd_dracut {
|
||||
$additional_options .= " -N";
|
||||
}
|
||||
|
||||
#if "pigz" is available in the rootimg, use "pigz" instead of "gzip"
|
||||
my $compress=qx(chroot $rootimg_dir bash -c "type -p pigz"|tr -d "\n");
|
||||
if ($compress){
|
||||
#take the online cpu numerber as the pigz processes number
|
||||
my $processnum=qx(lscpu -p=cpu --online|grep -v '#'|wc -l|tr -d "\n");
|
||||
$additional_options .= " --compress \"$compress -p $processnum \"";
|
||||
}
|
||||
|
||||
print "\nchroot $rootimg_dir dracut $additional_options -f /tmp/initrd.$$.gz $kernelver\n";
|
||||
!system("chroot $rootimg_dir dracut $additional_options -f /tmp/initrd.$$.gz $kernelver")
|
||||
or die("Error: failed to generate the initial ramdisk for $mode.\n");
|
||||
print "the initial ramdisk for $mode is generated successfully.\n";
|
||||
|
@ -1624,44 +1624,38 @@ EOMS
|
||||
}
|
||||
|
||||
|
||||
# if (-d "$rootimg_dir/lib/powerpc64le-linux-gnu/"){
|
||||
# system("cp -rf $rootimg_dir/lib/powerpc64le-linux-gnu/* /tmp/xcatinitrd.$$/lib/powerpc64le-linux-gnu/");
|
||||
# }
|
||||
|
||||
system("chroot /tmp/xcatinitrd.$$/ depmod $kernelver");
|
||||
# Copy udev and network scripts into initrd for s390x, which also works for other platforms
|
||||
# udev
|
||||
system("mkdir -p /tmp/xcatinitrd.$$/etc/udev");
|
||||
system("cp -r $rootimg_dir/etc/udev/* /tmp/xcatinitrd.$$/etc/udev");
|
||||
system("mkdir -p /tmp/xcatinitrd.$$/lib/udev");
|
||||
system("cp -r $rootimg_dir/lib/udev/* /tmp/xcatinitrd.$$/lib/udev");
|
||||
system("mkdir -p /tmp/xcatinitrd.$$/proc/self");
|
||||
system("cp -r /proc/self/oom_adj /tmp/xcatinitrd.$$/proc/self");
|
||||
|
||||
# Network related scripts
|
||||
#system("echo $kernelver\n");
|
||||
#system("mkdir -p /tmp/xcatinitrd.$$/sbin");
|
||||
#system("cp -r $rootimg_dir/sbin/* /tmp/xcatinitrd.$$/sbin");
|
||||
#system("mkdir -p /tmp/xcatinitrd.$$/lib/modules/$kernelver");
|
||||
#system("cp -r $rootimg_dir/lib/modules/$kernelver/modules.dep /tmp/xcatinitrd.$$/lib/modules/$kernelver/modules.dep");
|
||||
#system("mkdir -p /tmp/xcatinitrd.$$/etc/init.d");
|
||||
#system("cp -r $rootimg_dir/etc/init.d/* /tmp/xcatinitrd.$$/etc/init.d");
|
||||
#system("mkdir -p /tmp/xcatinitrd.$$/lib64");
|
||||
#system("cp -r $rootimg_dir/lib64/* /tmp/xcatinitrd.$$/lib64");
|
||||
#system("mkdir -p /tmp/xcatinitrd.$$/var/run/netreport");
|
||||
symlink("busybox","/tmp/xcatinitrd.$$/bin/pivot_root");
|
||||
symlink("busybox", "/tmp/xcatinitrd.$$/bin/udhcpc");
|
||||
symlink("busybox", "/tmp/xcatinitrd.$$/sbin/ifconfig");
|
||||
symlink("busybox", "/tmp/xcatinitrd.$$/bin/hostname");
|
||||
symlink("busybox", "/tmp/xcatinitrd.$$/bin/route");
|
||||
symlink("busybox", "/tmp/xcatinitrd.$$/bin/nc");
|
||||
symlink("bash", "/tmp/xcatinitrd.$$/bin/sh");
|
||||
symlink("bash", "/tmp/xcatinitrd.$$/sbin/sh");
|
||||
# Copy udev and network scripts into initrd for s390x, which also works for other platforms
|
||||
# udev
|
||||
system("mkdir -p /tmp/xcatinitrd.$$/etc/udev");
|
||||
system("cp -r $rootimg_dir/etc/udev/* /tmp/xcatinitrd.$$/etc/udev");
|
||||
system("mkdir -p /tmp/xcatinitrd.$$/lib/udev");
|
||||
system("cp -r $rootimg_dir/lib/udev/* /tmp/xcatinitrd.$$/lib/udev");
|
||||
system("mkdir -p /tmp/xcatinitrd.$$/proc/self");
|
||||
system("cp -r /proc/self/oom_adj /tmp/xcatinitrd.$$/proc/self");
|
||||
|
||||
# Network related scripts
|
||||
symlink("busybox","/tmp/xcatinitrd.$$/bin/pivot_root");
|
||||
symlink("busybox", "/tmp/xcatinitrd.$$/bin/udhcpc");
|
||||
symlink("busybox", "/tmp/xcatinitrd.$$/sbin/ifconfig");
|
||||
symlink("busybox", "/tmp/xcatinitrd.$$/bin/hostname");
|
||||
symlink("busybox", "/tmp/xcatinitrd.$$/bin/route");
|
||||
symlink("busybox", "/tmp/xcatinitrd.$$/bin/nc");
|
||||
symlink("bash", "/tmp/xcatinitrd.$$/bin/sh");
|
||||
symlink("bash", "/tmp/xcatinitrd.$$/sbin/sh");
|
||||
|
||||
|
||||
#copy("$rootimg_dir/lib/modules/*d","/tmp/xcatinitrd.$$/$_");
|
||||
system("cd /tmp/xcatinitrd.$$;find .|cpio -H newc -o|gzip -9 -c - > $destdir/initrd-$mode.gz");
|
||||
system("rm -rf /tmp/xcatinitrd.$$");
|
||||
my $compress="gzip";
|
||||
#if pigz is available,use pigz instead of gzip
|
||||
my $ispigz=system("bash -c 'type -p pigz' >/dev/null 2>&1");
|
||||
if($ispigz == 0){
|
||||
$compress="pigz";
|
||||
}
|
||||
|
||||
#copy("$rootimg_dir/lib/modules/*d","/tmp/xcatinitrd.$$/$_");
|
||||
print "\ncd /tmp/xcatinitrd.$$;find .|cpio -H newc -o|$compress -9 -c - > $destdir/initrd-$mode.gz \n";
|
||||
system("cd /tmp/xcatinitrd.$$;find .|cpio -H newc -o|$compress -9 -c - > $destdir/initrd-$mode.gz");
|
||||
system("rm -rf /tmp/xcatinitrd.$$");
|
||||
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user