From b2a60ba7ff7eb43446e96fc5048109922d58b45d Mon Sep 17 00:00:00 2001 From: mulhern Date: Fri, 13 Sep 2013 13:51:59 -0400 Subject: bastille: Fix failure during install. [YOCTO #5177] On some systems the bitbake install step failed. The failure was due to some files that were being overwritten not having sufficient permissions. The install script in the recipe is changed so that the set_required_questions.py script is invoked on the files in the image directory, which are guaranteed to have adequate permission. Previously, it had been invoked on the files in the work directory. The set_required_questions.py script is changed in the following ways. * The xform_file function now handles the overwriting of the files in a more robust manner. * The script now accepts a debug flag. When set this flag will cause the script to display more developer friendly information on error. * The xform_file function has a descriptive comment. Signed-off-by: mulhern --- recipes-security/bastille/bastille_3.2.1.bb | 4 ++-- .../bastille/files/set_required_questions.py | 28 ++++++++++++++++++---- 2 files changed, 26 insertions(+), 6 deletions(-) (limited to 'recipes-security/bastille') diff --git a/recipes-security/bastille/bastille_3.2.1.bb b/recipes-security/bastille/bastille_3.2.1.bb index ef697d7..969ce30 100644 --- a/recipes-security/bastille/bastille_3.2.1.bb +++ b/recipes-security/bastille/bastille_3.2.1.bb @@ -143,14 +143,14 @@ do_install () { install -m 0644 OSMap/OSX.bastille ${D}${datadir}/Bastille/OSMap install -m 0644 OSMap/OSX.system ${D}${datadir}/Bastille/OSMap - ${THISDIR}/files/set_required_questions.py ${WORKDIR}/config Questions - install -m 0777 ${WORKDIR}/config ${D}${sysconfdir}/Bastille/config for file in `cat Modules.txt` ; do install -m 0644 Questions/$file.txt ${D}${datadir}/Bastille/Questions done + ${THISDIR}/files/set_required_questions.py ${D}${sysconfdir}/Bastille/config ${D}${datadir}/Bastille/Questions + ln -s ${D}${sbindir}/RevertBastille ${D}${sbindir}/UndoBastille } diff --git a/recipes-security/bastille/files/set_required_questions.py b/recipes-security/bastille/files/set_required_questions.py index ed299e5..4a28358 100755 --- a/recipes-security/bastille/files/set_required_questions.py +++ b/recipes-security/bastille/files/set_required_questions.py @@ -2,7 +2,7 @@ #Signed-off-by: Anne Mulhern -import argparse, os, shutil, sys, tempfile +import argparse, os, shutil, sys, tempfile, traceback from os import path @@ -76,12 +76,20 @@ def add_requires(the_ident, distro, lines): def xform_file(qfile, distro, qlabel): + """ + Transform a Questions file. + @param name qfile The designated questions file. + @param name distro The distribution to add to the required distributions. + @param name qlabel The question label for which the distro is to be added. + """ questions_in = open(qfile) questions_out = tempfile.NamedTemporaryFile(delete=False) for l in add_requires(qlabel, distro, questions_in): questions_out.write(l) questions_out.close() questions_in.close() + shutil.copystat(qfile, questions_out.name) + os.remove(qfile) shutil.move(questions_out.name, qfile) @@ -94,6 +102,9 @@ def handle_args(parser): parser.add_argument('--distro', '-d', help = "The distribution, the default is Yocto.", default = "Yocto") + parser.add_argument('--debug', '-b', + help = "Print debug information.", + action = 'store_true') return parser.parse_args() @@ -116,7 +127,10 @@ def main(): try: check_args(opts) except ValueError as e: - sys.exit("Fatal error: %s" % e) + if opts.debug: + traceback.print_exc() + else: + sys.exit("Fatal error:\n%s" % e) try: @@ -127,9 +141,15 @@ def main(): config_in.close() except IOError as e: - sys.exit("Fatal error reading config file: %s" % e) + if opts.debug: + traceback.print_exc() + else: + sys.exit("Fatal error reading or writing file:\n%s" % e) except ValueError as e: - sys.exit("Fatal error: %s" % e) + if opts.debug: + traceback.print_exc() + else: + sys.exit("Fatal error:\n%s" % e) -- cgit v1.2.3-54-g00ecf