2
0
mirror of https://github.com/xcat2/xcat-core.git synced 2025-06-15 10:50:28 +00:00

add new option to indicate compress method (#1669)

This commit is contained in:
penguhyang
2016-08-11 16:09:43 +08:00
committed by yangsong
parent 7831ea277d
commit 79426ad21e
35 changed files with 247 additions and 107 deletions

View File

@ -64,6 +64,8 @@ OPTIONS
\ **-m**\ Archive Method (cpio,tar,squashfs, default is cpio)
\ **-c**\ Compress Method (pigz,gzip,xz, default is pigz)
************
RETURN VALUE

View File

@ -38,6 +38,8 @@ B<-a> Architecture (ppc64,x86_64,etc)
B<-m> Archive Method (cpio,tar,squashfs, default is cpio)
B<-c> Compress Method (pigz,gzip,xz, default is pigz)
=head1 RETURN VALUE

View File

@ -462,9 +462,11 @@ sub mknetboot
}
$platform = xCAT_plugin::anaconda::getplatform($osver);
my $suffix = 'gz';
my $suffix = 'cpio.gz';
$suffix = 'sfs' if (-r "$rootimgdir/rootimg.sfs");
$suffix = 'tgz' if (-r "$rootimgdir/rootimg.tgz");
$suffix = 'cpio.xz' if (-r "$rootimgdir/rootimg.cpio.xz");
$suffix = 'tar.gz' if (-r "$rootimgdir/rootimg.tar.gz");
$suffix = 'tar.xz' if (-r "$rootimgdir/rootimg.tar.xz");
# statelite images are not packed.
if ($statelite) {
@ -513,7 +515,7 @@ sub mknetboot
copy("$rootimgdir/initrd.gz", "$rootimgdir/initrd-stateless.gz");
}
}
unless (-r "$rootimgdir/rootimg.gz" or -r "$rootimgdir/rootimg.tgz" or -r "$rootimgdir/rootimg.sfs") {
unless (-r "$rootimgdir/rootimg.cpio.gz" or -r "$rootimgdir/rootimg.cpio.xz" or -r "$rootimgdir/rootimg.tar.gz" or -r "$rootimgdir/rootimg.tar.xz" or -r "$rootimgdir/rootimg.sfs") {
$callback->({
error => ["No packed image for platform $osver, architecture $arch, and profile $profile found at $rootimgdir/rootimg.gz or $rootimgdir/rootimg.sfs on $myname, please run packimage (e.g. packimage -o $osver -p $profile -a $arch"],
errorcode => [1] });

View File

@ -1170,9 +1170,10 @@ sub mknetboot
}
$platform = xCAT_plugin::debian::getplatform($osver);
my $suffix = 'gz';
$suffix = 'sfs' if (-r "$rootimgdir/rootimg.sfs");
$suffix = 'tgz' if (-r "$rootimgdir/rootimg.tgz");
my $suffix = 'cpio.gz';
$suffix = 'cpio.xz' if (-r "$rootimgdir/rootimg.cpio.xz");
$suffix = 'tar.gz' if (-r "$rootimgdir/rootimg.tar.gz");
$suffix = 'tar.xz' if (-r "$rootimgdir/rootimg.tar.xz");
# statelite images are not packed.
if ($statelite) {
@ -1222,7 +1223,7 @@ sub mknetboot
copy("$rootimgdir/initrd.gz", "$rootimgdir/initrd-stateless.gz");
}
}
unless (-r "$rootimgdir/rootimg.gz" or -r "$rootimgdir/rootimg.tgz" or -r "$rootimgdir/rootimg.sfs") {
unless (-r "$rootimgdir/rootimg.cpio.gz" or -r "$rootimgdir/rootimg.cpio.xz" or -r "$rootimgdir/rootimg.tar.gz" or -r "$rootimgdir/rootimg.tar.xz" or -r "$rootimgdir/rootimg.sfs") {
$callback->({
error => ["No packed image for platform $osver, architecture $arch, and profile $profile, please run packimage (e.g. packimage -o $osver -p $profile -a $arch"],
errorcode => [1] });

View File

@ -87,6 +87,7 @@ sub process_request {
my $arch;
my $profile;
my $method = 'cpio';
my $compress;
my $exlistloc;
my $syncfile;
my $rootimg_dir;
@ -102,6 +103,7 @@ sub process_request {
"arch|a=s" => \$arch,
"osver|o=s" => \$osver,
"method|m=s" => \$method,
"compress|c=s" => \$compress,
"tracker=s" => \$dotorrent,
"help|h" => \$help,
"version|v" => \$version
@ -419,51 +421,77 @@ sub process_request {
unlink("$destdir/rootimg.gz");
unlink("$destdir/rootimg.sfs");
$callback->({ info => ["archive method:$method"] });
if ($method =~ /cpio/) {
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) {
$excludestr = "find . -xdev -print0 | cpio -H newc -o -0 | $compress -c - > ../rootimg.gz";
} else {
chdir("$rootimg_dir");
system("$excludestr >> $xcat_packimg_tmpfile");
if ($includestr) {
system("$includestr >> $xcat_packimg_tmpfile");
my $suffix;
if ($compress) {
if ($compress eq 'gzip') {
my $isgzip = system("bash -c 'type -p gzip' >/dev/null 2>&1");
unless ($isgzip == 0) {
$callback->({ error => ["Command gzip does not exist, please make sure it is installed."] });
return 1;
}
$excludestr = "cat $xcat_packimg_tmpfile|cpio -H newc -o | $compress -c - > ../rootimg.gz";
$suffix = "gz";
} elsif ($compress eq 'pigz') {
my $ispigz = system("bash -c 'type -p pigz' >/dev/null 2>&1");
unless ($ispigz == 0) {
$callback->({ error => ["Command pigz does not exist, please make sure it is installed."] });
return 1;
}
$suffix = "gz";
} elsif ($compress eq 'xz') {
my $isxz = system("bash -c 'type -p xz' >/dev/null 2>&1");
unless ($isxz == 0) {
$callback->({ error => ["Command xz does not exist, please make sure it is installed."] });
return 1;
}
$suffix = "xz";
} else {
$callback->({ error => ["Invalid compress method '$compress' requested"], errorcode => [1] });
return 1;
}
$oldmask = umask 0077;
} elsif ($method =~ /tar/) {
my $compress = "gzip";
#use "pigz" as the compress tool instead of gzip if "pigz" exist
} else {
my $ispigz = system("bash -c 'type -p pigz' >/dev/null 2>&1");
if ($ispigz == 0) {
$compress = "pigz";
} else {
my $isgzip = system("bash -c 'type -p gzip' >/dev/null 2>&1");
unless ($isgzip == 0) {
$callback->({ error => ["Command gzip does not exist, please make sure it works."] });
if ($isgzip == 0) {
$compress = "gzip";
} else {
$callback->({ error => ["The default compress tool 'gzip' and 'pigz' does not exist, please specify an available compress method with '-c'."] });
return 1;
}
}
$suffix = "gz";
}
$callback->({ info => ["archive method:$method"] });
unless ($method =~ /squashfs/) {
$callback->({ info => ["compress method:$compress"] });
}
$suffix = $method.".".$suffix;
if ($method =~ /cpio/) {
if (!$exlistloc) {
$excludestr = "find . -xdev -print0 | tar --selinux --xattrs-include='*' --null -T - -c | $compress -c - > ../rootimg.tgz";
$excludestr = "find . -xdev -print0 | cpio -H newc -o -0 | $compress -c - > ../rootimg.$suffix";
} else {
chdir("$rootimg_dir");
system("$excludestr >> $xcat_packimg_tmpfile");
if ($includestr) {
system("$includestr >> $xcat_packimg_tmpfile");
}
$excludestr = "cat $xcat_packimg_tmpfile| tar --selinux --xattrs-include='*' -T - -c | $compress -c - > ../rootimg.tgz";
$excludestr = "cat $xcat_packimg_tmpfile|cpio -H newc -o | $compress -c - > ../rootimg.$suffix";
}
$oldmask = umask 0077;
} elsif ($method =~ /tar/) {
if (!$exlistloc) {
$excludestr = "find . -xdev -print0 | tar --selinux --xattrs-include='*' --null -T - -c | $compress -c - > ../rootimg.$suffix";
} else {
chdir("$rootimg_dir");
system("$excludestr >> $xcat_packimg_tmpfile");
if ($includestr) {
system("$includestr >> $xcat_packimg_tmpfile");
}
$excludestr = "cat $xcat_packimg_tmpfile| tar --selinux --xattrs-include='*' -T - -c | $compress -c - > ../rootimg.$suffix";
}
$oldmask = umask 0077;
} elsif ($method =~ /squashfs/) {
@ -476,24 +504,25 @@ sub process_request {
}
$excludestr = "cat $xcat_packimg_tmpfile|cpio -dump $temppath";
} else {
$callback->({ error => ["Invalid method '$method' requested"], errorcode => [1] });
$callback->({ error => ["Invalid archive method '$method' requested"], errorcode => [1] });
return 1;
}
chdir("$rootimg_dir");
my $outputmsg = `$excludestr`;
$callback->({ info => ["$outputmsg"] });
if ($method =~ /cpio/) {
chmod 0644, "$destdir/rootimg.gz";
chmod 0644, "$destdir/rootimg.$suffix";
if ($dotorrent) {
my $currdir = getcwd;
chdir($destdir);
unlink("rootimg.gz.metainfo");
system("ctorrent -t -u $dotorrent -l 1048576 -s rootimg.gz.metainfo rootimg.gz");
chmod 0644, "rootimg.gz.metainfo";
unlink("rootimg.$suffix.metainfo");
system("ctorrent -t -u $dotorrent -l 1048576 -s rootimg.$suffix.metainfo rootimg.$suffix");
chmod 0644, "rootimg.$suffix.metainfo";
chdir($currdir);
}
umask $oldmask;
} elsif ($method =~ /tar/) {
chmod 0644, "$destdir/rootimg.tgz";
chmod 0644, "$destdir/rootimg.$suffix";
umask $oldmask;
} elsif ($method =~ /squashfs/) {
my $flags;

View File

@ -327,9 +327,11 @@ sub mknetboot
$platform = "sles";
}
my $suffix = 'gz';
my $suffix = 'cpio.gz';
$suffix = 'sfs' if (-r "$rootimgdir/rootimg.sfs");
$suffix = 'tgz' if (-r "$rootimgdir/rootimg.tgz");
$suffix = 'cpio.xz' if (-r "$rootimgdir/rootimg.cpio.xz");
$suffix = 'tar.gz' if (-r "$rootimgdir/rootimg.tar.gz");
$suffix = 'tar.xz' if (-r "$rootimgdir/rootimg.tar.xz");
if ($statelite) {
unless (-r "$rootimgdir/kernel") {
@ -381,7 +383,7 @@ sub mknetboot
}
}
unless (-r "$rootimgdir/rootimg.gz" or -r "$rootimgdir/rootimg.tgz" or -r "$rootimgdir/rootimg.sfs") {
unless (-r "$rootimgdir/rootimg.cpio.gz" or -r "$rootimgdir/rootimg.cpio.xz" or -r "$rootimgdir/rootimg.tar.gz" or -r "$rootimgdir/rootimg.tar.xz" or -r "$rootimgdir/rootimg.sfs") {
$callback->({
error => [qq{No packed image for platform $osver, architecture $arch, and profile $profile, please run packimage before nodeset}],
errorcode => [1]

View File

@ -14,3 +14,4 @@ rpm
rsync
tar
gzip
xz

View File

@ -15,3 +15,4 @@ rsyslog
e2fsprogs
gzip
tar
xz

View File

@ -26,3 +26,4 @@ procps
parted
gzip
tar
xz

View File

@ -22,3 +22,4 @@ e2fsprogs
parted
gzip
tar
xz

View File

@ -26,3 +26,4 @@ parted
net-tools
gzip
tar
xz

View File

@ -21,3 +21,4 @@ parted
net-tools
gzip
tar
xz

View File

@ -1,6 +1,6 @@
#!/bin/sh
echo $drivers
dracut_install wget tar cpio gzip dash modprobe touch echo cut wc
dracut_install wget tar cpio gzip dash modprobe touch echo cut wc xz
dracut_install -o ctorrent
dracut_install grep ifconfig hostname awk egrep grep dirname expr
dracut_install mount.nfs

View File

@ -67,8 +67,8 @@ if [ -r /rootimg.sfs ]; then
mkdir -p $NEWROOT/rw
mount --move /ro $NEWROOT/ro
mount --move /rw $NEWROOT/rw
elif [ -r /rootimg.gz ]; then
[ "$xcatdebugmode" > "0" ] && logger -t xcat -p debug "rootimg.gz downloaded,setting up RAM-root tmpfs...."
elif [ -r /rootimg.cpio.gz ] || [ -r /rootimg.cpio.xz ]; then
[ "$xcatdebugmode" > "0" ] && logger -t xcat -p debug "rootimg downloaded,setting up RAM-root tmpfs...."
echo Setting up RAM-root tmpfs.
if [ -z $rootlimit ];then
mount -t tmpfs -o mode=755 rootfs $NEWROOT
@ -79,15 +79,23 @@ elif [ -r /rootimg.gz ]; then
cd $NEWROOT
[ "$xcatdebugmode" > "0" ] && logger -t xcat -p debug "Extracting root filesystem:"
echo -n "Extracting root filesystem:"
if [ -x /bin/cpio ]; then
gzip -cd /rootimg.gz |/bin/cpio -idum
else
gzip -cd /rootimg.gz |cpio -idum
if [ -r /rootimg.cpio.gz ]; then
if [ -x /bin/cpio ]; then
gzip -cd /rootimg.cpio.gz |/bin/cpio -idum
else
gzip -cd /rootimg.cpio.gz |cpio -idum
fi
elif [ -r /rootimg.cpio.xz ]; then
if [ -x /bin/cpio ]; then
xz -cd /rootimg.cpio.xz |/bin/cpio -idum
else
xz -cd /rootimg.cpio.xz |cpio -idum
fi
fi
$NEWROOT/etc/init.d/localdisk
[ "$xcatdebugmode" > "0" ] && logger -t xcat -p debug "Done...."
echo Done
elif [ -r /rootimg.tgz ]; then
elif [ -r /rootimg.tar.gz ] || [ -r /rootimg.tar.xz ]; then
echo Setting up RAM-root tmpfs.
if [ -z $rootlimit ];then
mount -t tmpfs -o mode=755 rootfs $NEWROOT
@ -97,7 +105,11 @@ elif [ -r /rootimg.tgz ]; then
cd $NEWROOT
echo -n "Extracting root filesystem:"
tar --selinux --xattrs-include='*' -zxvf /rootimg.tgz
if [ -r /rootimg.tar.gz ]; then
tar --selinux --xattrs-include='*' -zxvf /rootimg.tar.gz
elif [ -r /rootimg.tar.xz ]; then
tar --selinux --xattrs-include='*' -Jxvf /rootimg.tar.xz
fi
$NEWROOT/etc/init.d/localdisk
echo Done
elif [ -r /rootimg-statelite.gz ]; then

View File

@ -1,6 +1,6 @@
#!/bin/sh
echo $drivers
dracut_install wget tar cpio gzip modprobe touch echo cut wc
dracut_install wget tar cpio gzip modprobe touch echo cut wc xz
dracut_install grep ifconfig hostname awk egrep grep dirname expr
dracut_install mount.nfs
dracut_install parted mke2fs bc mkswap swapon chmod

View File

@ -69,8 +69,8 @@ if [ -r /rootimg.sfs ]; then
mkdir -p $NEWROOT/rw
mount --move /ro $NEWROOT/ro
mount --move /rw $NEWROOT/rw
elif [ -r /rootimg.gz ]; then
[ "$xcatdebugmode" > "0" ] && logger -t xcat -p debug "rootimg.gz downloaded,setting up RAM-root tmpfs...."
elif [ -r /rootimg.cpio.gz ] || [ -r /rootimg.cpio.xz ]; then
[ "$xcatdebugmode" > "0" ] && logger -t xcat -p debug "rootimg downloaded,setting up RAM-root tmpfs...."
echo Setting up RAM-root tmpfs.
if [ -z $rootlimit ];then
mount -t tmpfs -o mode=755 rootfs $NEWROOT
@ -81,16 +81,24 @@ elif [ -r /rootimg.gz ]; then
cd $NEWROOT
[ "$xcatdebugmode" > "0" ] && logger -t xcat -p debug "Extracting root filesystem:"
echo -n "Extracting root filesystem:"
if [ -x /bin/cpio ]; then
gzip -cd /rootimg.gz |/bin/cpio -idum
else
gzip -cd /rootimg.gz |cpio -idum
if [ -r /rootimg.cpio.gz ]; then
if [ -x /bin/cpio ]; then
gzip -cd /rootimg.cpio.gz |/bin/cpio -idum
else
gzip -cd /rootimg.cpio.gz |cpio -idum
fi
elif [ -r /rootimg.cpio.xz ]; then
if [ -x /bin/cpio ]; then
xz -cd /rootimg.cpio.xz |/bin/cpio -idum
else
xz -cd /rootimg.cpio.xz |cpio -idum
fi
fi
$NEWROOT/etc/init.d/localdisk
[ "$xcatdebugmode" > "0" ] && logger -t xcat -p debug "Done...."
echo Done
elif [ -r /rootimg.tgz ]; then
[ "$xcatdebugmode" > "0" ] && logger -t xcat -p debug "rootimg.tgz downloaded,setting up RAM-root tmpfs...."
elif [ -r /rootimg.tar.gz ] || [ -r /rootimg.tar.xz ]; then
[ "$xcatdebugmode" > "0" ] && logger -t xcat -p debug "rootimg downloaded,setting up RAM-root tmpfs...."
echo Setting up RAM-root tmpfs.
if [ -z $rootlimit ];then
mount -t tmpfs -o mode=755 rootfs $NEWROOT
@ -101,7 +109,11 @@ elif [ -r /rootimg.tgz ]; then
cd $NEWROOT
[ "$xcatdebugmode" > "0" ] && logger -t xcat -p debug "Extracting root filesystem:"
echo -n "Extracting root filesystem:"
tar --selinux --xattrs-include='*' -zxvf /rootimg.tgz
if [ -r /rootimg.tar.gz ]; then
tar --selinux --xattrs-include='*' -zxvf /rootimg.tar.gz
elif [ -r /rootimg.tar.xz ]; then
tar --selinux --xattrs-include='*' -Jxvf /rootimg.tar.xz
fi
$NEWROOT/etc/init.d/localdisk
[ "$xcatdebugmode" > "0" ] && logger -t xcat -p debug "Done...."
echo Done

View File

@ -1606,7 +1606,7 @@ if [ -r /rootimg.sfs ]; then
mount --move /ro \$NEWROOT/ro
mount --move /rw \$NEWROOT/rw
EOMS
print $inifile "elif [ -r /rootimg.gz ]; then\n";
print $inifile "elif [ -r /rootimg.cpio.gz ] || [ -r /rootimg.cpio.xz ]; then\n";
print $inifile "echo Setting up RAM-root tmpfs.\n";
if ($rootlimit) {
print $inifile " mount -o size=$rootlimit,mode=755 -t tmpfs rootfs \$NEWROOT\n";
@ -1615,13 +1615,21 @@ EOMS
}
print $inifile " cd \$NEWROOT\n";
print $inifile " echo -n \"Extracting root filesystem:\"\n";
print $inifile " if [ -x /bin/cpio ]; then\n";
print $inifile " zcat /rootimg.gz |/bin/cpio -idum\n";
print $inifile " else\n";
print $inifile " zcat /rootimg.gz |cpio -idum\n";
print $inifile " if [ -r /rootimg.cpio.gz ]; then\n";
print $inifile " if [ -x /bin/cpio ]; then\n";
print $inifile " zcat /rootimg.cpio.gz |/bin/cpio -idum\n";
print $inifile " else\n";
print $inifile " zcat /rootimg.cpio.gz |cpio -idum\n";
print $inifile " fi\n";
print $inifile " elif [ -r /rootimg.cpio.xz ]; then\n";
print $inifile " if [ -x /bin/cpio ]; then\n";
print $inifile " xz -cd /rootimg.cpio.xz |/bin/cpio -idum\n";
print $inifile " else\n";
print $inifile " xz -cd /rootimg.cpio.xz |cpio -idum\n";
print $inifile " fi\n";
print $inifile " fi\n";
print $inifile " echo Done\n";
print $inifile "elif [ -r /rootimg.tgz ]; then\n";
print $inifile "elif [ -r /rootimg.tar.gz ] || [ -r /rootimg.tar.xz ]; then\n";
print $inifile " echo Setting up RAM-root tmpfs.\n";
if ($rootlimit) {
@ -1631,7 +1639,11 @@ EOMS
}
print $inifile " cd \$NEWROOT\n";
print $inifile " echo -n \"Extracting root filesystem:\"\n";
print $inifile " tar --selinux --xattrs-include='*' -zxvf /rootimg.tgz\n";
print $inifile " if [ -r /rootimg.tar.gz ]; then\n";
print $inifile " tar --selinux --xattrs-include='*' -zxvf /rootimg.tar.gz\n";
print $inifile " elif [ -r /rootimg.tar.xz ]; then\n";
print $inifile " tar --selinux --xattrs-include='*' -Jxvf /rootimg.tar.xz\n";
print $inifile " fi\n";
print $inifile " echo Done\n";
print $inifile "else\n";
print $inifile " echo -n Failed to download image, panicing in 5...\n";
@ -1708,7 +1720,7 @@ EOMS
}
# add rsync for statelite
foreach ("bin/cpio", "sbin/nash", "sbin/busybox.anaconda", "sbin/rmmod", "bin/bash", "usr/sbin/chroot", "sbin/mount.nfs", "usr/bin/rsync", "usr/bin/wc", "usr/bin/gzip", "usr/bin/tar") {
foreach ("bin/cpio", "sbin/nash", "sbin/busybox.anaconda", "sbin/rmmod", "bin/bash", "usr/sbin/chroot", "sbin/mount.nfs", "usr/bin/rsync", "usr/bin/wc", "usr/bin/xz", "usr/bin/gzip", "usr/bin/tar") {
getlibs($_);
push @filestoadd, $_;
}

View File

@ -13,3 +13,4 @@ timezone
ntp
tar
gzip
xz

View File

@ -19,3 +19,4 @@ bc
ntp
gzip
tar
xz

View File

@ -21,3 +21,4 @@ procps
ntp
gzip
tar
xz

View File

@ -41,3 +41,4 @@ udev
kernel-default
kernel-firmware
adaptec-firmware
xz

View File

@ -41,3 +41,4 @@ udev
kernel-default
kernel-firmware
adaptec-firmware
xz

View File

@ -1,6 +1,6 @@
#!/bin/sh
echo $drivers
dracut_install wget tar cpio gzip modprobe touch echo cut wc
dracut_install wget tar cpio gzip modprobe touch echo cut wc xz
dracut_install grep ifconfig hostname awk egrep grep dirname expr
dracut_install mount.nfs
dracut_install parted mke2fs bc mkswap swapon chmod

View File

@ -67,8 +67,8 @@ if [ -r /rootimg.sfs ]; then
mkdir -p $NEWROOT/rw
mount --move /ro $NEWROOT/ro
mount --move /rw $NEWROOT/rw
elif [ -r /rootimg.gz ]; then
[ "$xcatdebugmode" > "0" ] && logger -t xcat -p debug "rootimg.gz downloaded,setting up RAM-root tmpfs...."
elif [ -r /rootimg.cpio.gz ] || [ -r /rootimg.cpio.xz ]; then
[ "$xcatdebugmode" > "0" ] && logger -t xcat -p debug "rootimg downloaded,setting up RAM-root tmpfs...."
echo Setting up RAM-root tmpfs.
if [ -z $rootlimit ];then
mount -t tmpfs -o mode=755 rootfs $NEWROOT
@ -79,16 +79,24 @@ elif [ -r /rootimg.gz ]; then
cd $NEWROOT
[ "$xcatdebugmode" > "0" ] && logger -t xcat -p debug "Extracting root filesystem:"
echo -n "Extracting root filesystem:"
if [ -x /bin/cpio ]; then
gzip -cd /rootimg.gz |/bin/cpio -idum
else
gzip -cd /rootimg.gz |cpio -idum
if [ -r /rootimg.cpio.gz ]; then
if [ -x /bin/cpio ]; then
gzip -cd /rootimg.cpio.gz |/bin/cpio -idum
else
gzip -cd /rootimg.cpio.gz |cpio -idum
fi
elif [ -r /rootimg.cpio.xz ]; then
if [ -x /bin/cpio ]; then
xz -cd /rootimg.cpio.xz |/bin/cpio -idum
else
xz -cd /rootimg.cpio.xz |cpio -idum
fi
fi
$NEWROOT/etc/init.d/localdisk
[ "$xcatdebugmode" > "0" ] && logger -t xcat -p debug "Done...."
echo Done
elif [ -r /rootimg.tgz ]; then
[ "$xcatdebugmode" > "0" ] && logger -t xcat -p debug "rootimg.tgz downloaded,setting up RAM-root tmpfs...."
elif [ -r /rootimg.tar.gz ] || [ -r /rootimg.tar.xz ]; then
[ "$xcatdebugmode" > "0" ] && logger -t xcat -p debug "rootimg downloaded,setting up RAM-root tmpfs...."
echo Setting up RAM-root tmpfs.
if [ -z $rootlimit ];then
mount -t tmpfs -o mode=755 rootfs $NEWROOT
@ -99,7 +107,11 @@ elif [ -r /rootimg.tgz ]; then
cd $NEWROOT
[ "$xcatdebugmode" > "0" ] && logger -t xcat -p debug "Extracting root filesystem:"
echo -n "Extracting root filesystem:"
tar --selinux --xattrs-include='*' -zxvf /rootimg.tgz
if [ -r /rootimg.tar.gz ]; then
tar --selinux --xattrs-include='*' -zxvf /rootimg.tar.gz
elif [ -r /rootimg.tar.xz ]; then
tar --selinux --xattrs-include='*' -Jxvf /rootimg.tar.xz
fi
$NEWROOT/etc/init.d/localdisk
[ "$xcatdebugmode" > "0" ] && logger -t xcat -p debug "Done...."
echo Done

View File

@ -1624,7 +1624,7 @@ if [ -r /rootimg.sfs ]; then
mount --move /ro /sysroot/ro
mount --move /rw /sysroot/rw
EOMS
print $inifile "elif [ -r /rootimg.gz ]; then\n";
print $inifile "elif [ -r /rootimg.cpio.gz ] || [ -r /rootimg.cpio.xz ]; then\n";
print $inifile "echo Setting up RAM-root tmpfs.\n";
if ($rootlimit) {
print $inifile " mount -o size=$rootlimit,mode=755 -t tmpfs rootfs \$NEWROOT\n";
@ -1633,13 +1633,21 @@ EOMS
}
print $inifile " cd /sysroot\n";
print $inifile " echo -n \"Extracting root filesystem:\"\n";
print $inifile " if [ -x /bin/cpio ]; then\n";
print $inifile " zcat /rootimg.gz |/bin/cpio -idum\n";
print $inifile " else\n";
print $inifile " zcat /rootimg.gz |cpio -idum\n";
print $inifile " if [ -r /rootimg.cpio.gz ]; then\n";
print $inifile " if [ -x /bin/cpio ]; then\n";
print $inifile " zcat /rootimg.cpio.gz |/bin/cpio -idum\n";
print $inifile " else\n";
print $inifile " zcat /rootimg.cpio.gz |cpio -idum\n";
print $inifile " fi\n";
print $inifile " elif [ -r /rootimg.cpio.xz ]; then\n";
print $inifile " if [ -x /bin/cpio ]; then\n";
print $inifile " xz -cd /rootimg.cpio.xz |/bin/cpio -idum\n";
print $inifile " else\n";
print $inifile " xz -cd /rootimg.cpio.xz |cpio -idum\n";
print $inifile " fi\n";
print $inifile " fi\n";
print $inifile " echo Done\n";
print $inifile "elif [ -r /rootimg.tgz ]; then\n";
print $inifile "elif [ -r /rootimg.tar.gz ] || [ -r /rootimg.tar.xz ]; then\n";
print $inifile " echo Setting up RAM-root tmpfs.\n";
if ($rootlimit) {
@ -1649,7 +1657,11 @@ EOMS
}
print $inifile " cd \$NEWROOT\n";
print $inifile " echo -n \"Extracting root filesystem:\"\n";
print $inifile " tar --selinux --xattrs-include='*' -zxvf /rootimg.tgz\n";
print $inifile " if [ -r /rootimg.tar.gz ]; then\n";
print $inifile " tar --selinux --xattrs-include='*' -zxvf /rootimg.tar.gz\n";
print $inifile " elif [ -r /rootimg.tar.xz ]; then\n";
print $inifile " tar --selinux --xattrs-include='*' -Jxvf /rootimg.tar.xz\n";
print $inifile " fi\n";
print $inifile " echo Done\n";
print $inifile "else\n";
print $inifile " echo -n Failed to download image, panicing in 5...\n";
@ -1758,7 +1770,7 @@ EOMS
}
}
if ($mode eq "statelite") {
foreach ("sbin/ifconfig", "usr/bin/clear", "usr/bin/touch", "bin/hostname", "usr/bin/egrep", "bin/ln", "bin/ls", "usr/bin/dirname", "usr/bin/expr", "usr/bin/chroot", "usr/bin/grep", "bin/cpio", "bin/sleep", "bin/mount", "bin/umount", "sbin/dhcpcd", "bin/bash", "sbin/insmod", "bin/mkdir", "bin/mknod", "sbin/ip", "bin/cat", "usr/bin/awk", "usr/bin/wget", "bin/cp", "usr/bin/cpio", "usr/bin/zcat", "usr/bin/gzip", "lib/mkinitrd/bin/run-init", "usr/bin/uniq", "usr/bin/sed", "usr/bin/wc", "bin/sed", "sbin/udevd", "usr/bin/readlink", "usr/sbin/parted", "sbin/mke2fs", "sbin/mkswap", "sbin/swapon", "bin/chmod", "usr/bin/bc", "usr/bin/gzip", "usr/bin/tar") {
foreach ("sbin/ifconfig", "usr/bin/clear", "usr/bin/touch", "bin/hostname", "usr/bin/egrep", "bin/ln", "bin/ls", "usr/bin/dirname", "usr/bin/expr", "usr/bin/chroot", "usr/bin/grep", "bin/cpio", "bin/sleep", "bin/mount", "bin/umount", "sbin/dhcpcd", "bin/bash", "sbin/insmod", "bin/mkdir", "bin/mknod", "sbin/ip", "bin/cat", "usr/bin/awk", "usr/bin/wget", "bin/cp", "usr/bin/cpio", "usr/bin/zcat", "usr/bin/gzip", "lib/mkinitrd/bin/run-init", "usr/bin/uniq", "usr/bin/sed", "usr/bin/wc", "bin/sed", "sbin/udevd", "usr/bin/readlink", "usr/sbin/parted", "sbin/mke2fs", "sbin/mkswap", "sbin/swapon", "bin/chmod", "usr/bin/bc", "usr/bin/xz", "usr/bin/gzip", "usr/bin/tar") {
getlibs($_);
push @filestoadd, $_;
}
@ -1770,7 +1782,7 @@ EOMS
}
} else {
foreach ("sbin/ifconfig", "usr/bin/clear", "usr/bin/touch", "usr/bin/grep", "usr/bin/egrep", "bin/cpio", "bin/sleep", "bin/mount", "sbin/dhcpcd", "bin/bash", "sbin/insmod", "bin/mkdir", "bin/mknod", "sbin/ip", "bin/cat", "usr/bin/awk", "usr/bin/wget", "bin/cp", "usr/bin/cpio", "usr/bin/zcat", "usr/bin/gzip", "lib/mkinitrd/bin/run-init", "usr/bin/uniq", "usr/bin/sed", "sbin/udevd", "usr/bin/readlink", "usr/bin/expr", "usr/sbin/parted", "sbin/mke2fs", "sbin/mkswap", "sbin/swapon", "bin/chmod", "usr/bin/bc", "usr/bin/gzip", "usr/bin/tar") {
foreach ("sbin/ifconfig", "usr/bin/clear", "usr/bin/touch", "usr/bin/grep", "usr/bin/egrep", "bin/cpio", "bin/sleep", "bin/mount", "sbin/dhcpcd", "bin/bash", "sbin/insmod", "bin/mkdir", "bin/mknod", "sbin/ip", "bin/cat", "usr/bin/awk", "usr/bin/wget", "bin/cp", "usr/bin/cpio", "usr/bin/zcat", "usr/bin/gzip", "lib/mkinitrd/bin/run-init", "usr/bin/uniq", "usr/bin/sed", "sbin/udevd", "usr/bin/readlink", "usr/bin/expr", "usr/sbin/parted", "sbin/mke2fs", "sbin/mkswap", "sbin/swapon", "bin/chmod", "usr/bin/bc", "usr/bin/xz", "usr/bin/gzip", "usr/bin/tar") {
getlibs($_);
push @filestoadd, $_;
}

View File

@ -14,3 +14,4 @@ busybox-static
gawk
tar
gzip
xz-utils

View File

@ -15,3 +15,4 @@ gawk
dnsutils
tar
gzip
xz-utils

View File

@ -15,3 +15,4 @@ gawk
dnsutils
tar
gzip
xz-utils

View File

@ -14,3 +14,4 @@ busybox-static
gawk
tar
gzip
xz-utils

View File

@ -14,3 +14,4 @@ busybox-static
gawk
tar
gzip
xz-utils

View File

@ -16,3 +16,4 @@ gawk
dnsutils
tar
gzip
xz-utils

View File

@ -16,3 +16,4 @@ gawk
dnsutils
tar
gzip
xz-utils

View File

@ -1,6 +1,6 @@
#!/bin/sh
echo $drivers
dracut_install wget tar cpio gzip dash modprobe touch echo cut wc
dracut_install wget tar cpio gzip dash modprobe touch echo cut wc xz
dracut_install grep ifconfig hostname awk egrep grep dirname expr
dracut_install mount.nfs
inst "$moddir/xcatroot" "/sbin/xcatroot"

View File

@ -39,23 +39,35 @@ if [ -r /rootimg.sfs ]; then
mkdir -p $NEWROOT/rw
mount --move /ro $NEWROOT/ro
mount --move /rw $NEWROOT/rw
elif [ -r /rootimg.gz ]; then
elif [ -r /rootimg.cpio.gz ] || [ -r /rootimg.cpio.xz ]; then
echo Setting up RAM-root tmpfs.
mount -t tmpfs -o mode=755 rootfs $NEWROOT
cd $NEWROOT
echo -n "Extracting root filesystem:"
if [ -x /bin/cpio ]; then
gzip -cd /rootimg.gz |/bin/cpio -idum
else
gzip -cd /rootimg.gz |cpio -idum
if [ -r /rootimg.cpio.gz ]; then
if [ -x /bin/cpio ]; then
gzip -cd /rootimg.cpio.gz |/bin/cpio -idum
else
gzip -cd /rootimg.cpio.gz |cpio -idum
fi
elif [ -r /rootimg.cpio.xz ]; then
if [ -x /bin/cpio ]; then
xz -cd /rootimg.cpio.xz |/bin/cpio -idum
else
xz -cd /rootimg.cpio.xz |cpio -idum
fi
fi
echo Done
elif [ -r /rootimg.tgz ]; then
elif [ -r /rootimg.tar.gz ] || [ -r /rootimg.tar.xz ]; then
echo Setting up RAM-root tmpfs.
mount -t tmpfs -o mode=755 rootfs $NEWROOT
cd $NEWROOT
echo -n "Extracting root filesystem:"
tar --selinux --xattrs-include='*' -zxvf /rootimg.tgz
if [ -r /rootimg.tar.gz ]; then
tar --selinux --xattrs-include='*' -zxvf /rootimg.tar.gz
elif [ -r /rootimg.tar.xz ]; then
tar --selinux --xattrs-include='*' -Jxvf /rootimg.tar.xz
fi
echo Done
elif [ -r /rootimg-statelite.gz ]; then
echo Setting up RAM-root tmpfs for statelite mode.

View File

@ -1441,8 +1441,8 @@ if [ -r /rootimg.sfs ]; then
mount --move /ro \$NEWROOT/ro
mount --move /rw \$NEWROOT/rw
EOMS
print $inifile "elif [ -r /rootimg.gz ]; then\n";
print $inifile " ([ \"\$xcatdebugmode\" = \"1\" ] || [ \"\$xcatdebugmode\" = \"2\" ]) && logger -t xcat -p debug \"rootimg.gz downloaded,setting up RAM-root tmpfs...\"\n";
print $inifile "elif [ -r /rootimg.cpio.gz ] || [ -r /rootimg.cpio.xz ]; then\n";
print $inifile " ([ \"\$xcatdebugmode\" = \"1\" ] || [ \"\$xcatdebugmode\" = \"2\" ]) && logger -t xcat -p debug \"rootimg downloaded,setting up RAM-root tmpfs...\"\n";
print $inifile " echo Setting up RAM-root tmpfs.\n";
if ($rootlimit) {
print $inifile " mount -o \"size=$rootlimit,mode=755\" -t tmpfs rootfs \$NEWROOT\n";
@ -1452,15 +1452,23 @@ EOMS
print $inifile " cd \$NEWROOT\n";
print $inifile " ([ \"\$xcatdebugmode\" = \"1\" ] || [ \"\$xcatdebugmode\" = \"2\" ]) && logger -t xcat -p debug \"Extracting root filesystem:\"\n";
print $inifile " echo -n \"Extracting root filesystem:\"\n";
print $inifile " if [ -x /bin/cpio ]; then\n";
print $inifile " zcat /rootimg.gz |/bin/cpio -idum\n";
print $inifile " else\n";
print $inifile " zcat /rootimg.gz |cpio -idum\n";
print $inifile " if [ -r /rootimg.cpio.gz ]; then\n";
print $inifile " if [ -x /bin/cpio ]; then\n";
print $inifile " zcat /rootimg.cpio.gz |/bin/cpio -idum\n";
print $inifile " else\n";
print $inifile " zcat /rootimg.cpio.gz |cpio -idum\n";
print $inifile " fi\n";
print $inifile " elif [ -r /rootimg.cpio.xz ]; then\n";
print $inifile " if [ -x /bin/cpio ]; then\n";
print $inifile " xz -cd /rootimg.cpio.xz |/bin/cpio -idum\n";
print $inifile " else\n";
print $inifile " xz -cd /rootimg.cpio.xz |cpio -idum\n";
print $inifile " fi\n";
print $inifile " fi\n";
print $inifile " ([ \"\$xcatdebugmode\" = \"1\" ] || [ \"\$xcatdebugmode\" = \"2\" ]) && logger -t xcat -p debug \"Done...\"\n";
print $inifile " echo Done\n";
print $inifile "elif [ -r /rootimg.tgz ]; then\n";
print $inifile " ([ \"\$xcatdebugmode\" = \"1\" ] || [ \"\$xcatdebugmode\" = \"2\" ]) && logger -t xcat -p debug \"rootimg.tgz downloaded,setting up RAM-root tmpfs...\"\n";
print $inifile "elif [ -r /rootimg.tar.gz ] || [ -r /rootimg.tar.xz ]; then\n";
print $inifile " ([ \"\$xcatdebugmode\" = \"1\" ] || [ \"\$xcatdebugmode\" = \"2\" ]) && logger -t xcat -p debug \"rootimg downloaded,setting up RAM-root tmpfs...\"\n";
print $inifile " echo Setting up RAM-root tmpfs.\n";
if ($rootlimit) {
@ -1471,7 +1479,11 @@ EOMS
print $inifile " cd \$NEWROOT\n";
print $inifile " ([ \"\$xcatdebugmode\" = \"1\" ] || [ \"\$xcatdebugmode\" = \"2\" ]) && logger -t xcat -p debug \"Extracting root filesystem:\"\n";
print $inifile " echo -n \"Extracting root filesystem:\"\n";
print $inifile " tar --selinux --xattrs-include='*' -zxvf /rootimg.tgz\n";
print $inifile " if [ -r /rootimg.tar.gz ]; then\n";
print $inifile " tar --selinux --xattrs-include='*' -zxvf /rootimg.tar.gz\n";
print $inifile " elif [ -r /rootimg.tar.xz ]; then\n";
print $inifile " tar --selinux --xattrs-include='*' -Jxvf /rootimg.tar.xz\n";
print $inifile " fi\n";
print $inifile " ([ \"\$xcatdebugmode\" = \"1\" ] || [ \"\$xcatdebugmode\" = \"2\" ]) && logger -t xcat -p debug \"Done...\"\n";
print $inifile " echo Done\n";
print $inifile "else\n";
@ -1612,7 +1624,7 @@ EOMS
}
# add rsync for statelite
foreach ("usr/bin/dig", "bin/busybox", "bin/bash", "sbin/mount.nfs", "usr/bin/rsync", "sbin/insmod", "sbin/udevd", "sbin/udevadm", "sbin/modprobe", "sbin/blkid", "sbin/depmod", "usr/bin/wget", "usr/bin/gzip", "usr/bin/tar") {
foreach ("usr/bin/dig", "bin/busybox", "bin/bash", "sbin/mount.nfs", "usr/bin/rsync", "sbin/insmod", "sbin/udevd", "sbin/udevadm", "sbin/modprobe", "sbin/blkid", "sbin/depmod", "usr/bin/wget", "usr/bin/xz", "usr/bin/gzip", "usr/bin/tar") {
getlibs($_);
push @filestoadd, $_;
}