From 592a67639c05b9dbba07120f63ede8f55e92f490 Mon Sep 17 00:00:00 2001 From: mellor Date: Wed, 31 Aug 2011 12:11:14 +0000 Subject: [PATCH] added include_file subroutine to statelite.pm copied from packimage.pm git-svn-id: https://svn.code.sf.net/p/xcat/code/xcat-core/trunk@10408 8638fb3e-16cb-4fca-ae20-7b5d299a9bcd --- xCAT-server/lib/xcat/plugins/statelite.pm | 25 +++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/xCAT-server/lib/xcat/plugins/statelite.pm b/xCAT-server/lib/xcat/plugins/statelite.pm index 2ab2a5931..2ff16d761 100644 --- a/xCAT-server/lib/xcat/plugins/statelite.pm +++ b/xCAT-server/lib/xcat/plugins/statelite.pm @@ -559,6 +559,31 @@ sub getRelDir { return $l } +sub include_file +{ + my $file = shift; + my $idir = shift; + my @text = (); + unless ($file =~ /^\//) { + $file = $idir."/".$file; + } + + open(INCLUDE,$file) || \ + return "#INCLUDEBAD:cannot open $file#"; + + while() { + chomp($_); + s/\s+$//; #remove trailing spaces + next if /^\s*$/; #-- skip empty lines + push(@text, $_); + } + + close(INCLUDE); + + return join("\n", @text); +} + + =head3 parseLiteFiles In the liteentry table, one directory and its sub-items (including sub-directory and entries) can co-exist; In order to handle such a scenario, one hash is generated to show the hirarachy relationship