]> rtime.felk.cvut.cz Git - jailhouse.git/commitdiff
tools: config-create: Differentiate between optional and mandatory files during collect
authorJan Kiszka <jan.kiszka@siemens.com>
Sun, 20 Jul 2014 21:25:44 +0000 (23:25 +0200)
committerJan Kiszka <jan.kiszka@siemens.com>
Mon, 28 Jul 2014 04:35:56 +0000 (06:35 +0200)
Bail out if a required file is missing but continue without irritating
warnings if an optional one cannot be found.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
tools/jailhouse-config-collect.tmpl
tools/jailhouse-config-create

index 9e98f9f7854ab7e77d7449974f7dcd79dde71df2..acdbeddd348f0c3e6e78c8264b761e5e5bc3e62e 100644 (file)
@@ -30,22 +30,29 @@ if test -z "$1"; then
 fi
 
 filelist="${filelist}"
+filelist_opt="${filelist_opt}"
 
 tmpdir=/tmp/jailhouse-config-collect.$$
 
 rm -rf $tmpdir
 mkdir $tmpdir
 
+copy_file()
+{
+       dstdir=$tmpdir/$(dirname $1)
+       if [ ! -d $dstdir ]; then
+               mkdir -p $dstdir
+       fi
+       cp -p $1 $tmpdir/$1
+}
+
 # copy all the files we need to a temporary directory first
 for f in $filelist; do
+       copy_file $f
+done
+for f in $filelist_opt; do
        if [ -f $f ]; then
-               dstdir=$tmpdir/$(dirname $f)
-               if [ ! -d $dstdir ]; then
-                       mkdir -p $dstdir
-               fi
-               cp -p $f $tmpdir/$f
-       else
-               echo "Warning: $f does not exist" 1>&2
+               copy_file $f
        fi
 done
 
index 40750c70be87c16f5f466ebd6259c72d5910df12..0f51758f5f8de9c35019016f77b9fcee049af181 100755 (executable)
@@ -53,7 +53,7 @@ parser.add_argument('file', metavar='FILE',
 
 options = parser.parse_args()
 
-inputs = {'files': set(), 'dirs': set()}
+inputs = {'files': set(), 'files_opt': set(), 'dirs': set()}
 
 
 class PCIDevice:
@@ -189,7 +189,7 @@ def kmg_multiply_str(str):
 
 
 def input_open(name, optional, *args):
-    inputs['files'].add(name)
+    inputs['files_opt' if optional else 'files'].add(name)
     try:
         f = open(options.root + name, *args)
     except Exception as e:
@@ -390,9 +390,10 @@ f = open(options.file, 'w')
 
 if options.generate_collector:
     filelist = ' '.join(inputs['files'].union(inputs['dirs']))
+    filelist_opt = ' '.join(inputs['files_opt'])
 
     tmpl = Template(filename='jailhouse-config-collect.tmpl')
-    f.write(tmpl.render(filelist=filelist))
+    f.write(tmpl.render(filelist=filelist, filelist_opt=filelist_opt))
 else:
     tmpl = Template(filename='root-cell-config.c.tmpl')
     f.write(tmpl.render(regions=regions,