From: Michael Tremer Date: Fri, 23 Sep 2011 22:49:49 +0000 (+0200) Subject: Add quality-agent clause. X-Git-Tag: 0.9.9~6 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=4d5abec734934083f9b3dbe77c0bd9867276c30e;p=pakfire.git Add quality-agent clause. --- diff --git a/macros/constants.macro b/macros/constants.macro index d7af33006..f7bcfd74e 100644 --- a/macros/constants.macro +++ b/macros/constants.macro @@ -27,14 +27,10 @@ sources = %{thisapp}.tar.gz # Guesses the compression type automatically. MACRO_EXTRACT = tar xaf -# Macro to define and start the quality agent. -# Long term goal is to improve the commited code. -MACRO_QUALITY_AGENT = /usr/lib/pakfire/quality-agent - # Macro to strip debugging symbols. MACRO_STRIP = /usr/lib/buildsystem-tools/stripper %{BUILDROOT} -def MACRO_PATCHES +MACRO_PATCHES patches="%{patches}" if [ -n "${patches}" ]; then @@ -67,7 +63,7 @@ def MACRO_PATCHES end # Remove rpath from libtool. -def MACRO_FIX_LIBTOOL +MACRO_FIX_LIBTOOL if [ -e "%{DIR_APP}/libtool" ]; then sed -e %{DIR_APP}/libtool \ -e 's|^hardcode_libdir_flag_spec=.*|hardcode_libdir_flag_spec=""|g' diff --git a/macros/quality-agent.macro b/macros/quality-agent.macro index 066169ed4..b82cba96b 100644 --- a/macros/quality-agent.macro +++ b/macros/quality-agent.macro @@ -4,14 +4,11 @@ # Quality agent # ############################################################################### -# Export variables for the quality agent -export QUALITY_AGENT_PERMIT_NOT_FULL_RELRO -export QUALITY_AGENT_RPATH_ALLOW_ORIGIN -export QUALITY_AGENT_WHITELIST_EXECSTACK -export QUALITY_AGENT_WHITELIST_NX -export QUALITY_AGENT_WHITELIST_RPATH -export QUALITY_AGENT_WHITELIST_SONAME -export QUALITY_AGENT_WHITELIST_SYMLINK -export QUALITY_AGENT_NO_DIRECTORY_CHECK -export QUALITY_AGENT_NO_DIRECTORY_PRUNE +# Macro to define and start the quality agent. +# Long term goal is to improve the commited code. +MACRO_QUALITY_AGENT = /usr/lib/pakfire/quality-agent + +# XXX to be moved to some place else +#export QUALITY_AGENT_NO_DIRECTORY_CHECK +#export QUALITY_AGENT_NO_DIRECTORY_PRUNE diff --git a/pakfire/packages/lexer.py b/pakfire/packages/lexer.py index 1560493e1..b9faeb3b8 100644 --- a/pakfire/packages/lexer.py +++ b/pakfire/packages/lexer.py @@ -75,6 +75,10 @@ LEXER_PACKAGE2_BEGIN = re.compile(r"^package$") LEXER_PACKAGE2_LINE = LEXER_BLOCK_LINE LEXER_PACKAGE2_END = LEXER_BLOCK_END +LEXER_QUALITY_AGENT_BEGIN = re.compile(r"^quality-agent$") +LEXER_QUALITY_AGENT_LINE = LEXER_BLOCK_LINE +LEXER_QUALITY_AGENT_END = LEXER_BLOCK_END + # Statements: LEXER_EXPORT = re.compile(r"^export\s+([A-Za-z0-9_\-]+)\s*(\+)?=\s*(.+)?$") LEXER_EXPORT2 = re.compile(r"^export\s+([A-Za-z0-9_\-]+)$") @@ -518,6 +522,47 @@ class DefaultLexer(Lexer): pass +class QualityAgentLexer(DefaultLexer): + """ + A lexer to read quality agent exceptions. + """ + @property + def exports(self): + exports = {} + + # Check if we permit full relro. + if self.get_var("permit_not_full_relro"): + exports["QUALITY_AGENT_PERMIT_NOT_FULL_RELRO"] = \ + self.get_var("permit_not_full_relro") + + # Check if we permit $ORIGIN in rpath. + if self.get_var("rpath_allow_origin"): + exports["QUALITY_AGENT_RPATH_ALLOW_ORIGIN"] = \ + self.get_var("rpath_allow_origin") + + # Load execstack whitelist. + if self.get_var("whitelist_execstack"): + exports["QUALITY_AGENT_WHITELIST_EXECSTACK"] = \ + self.get_var("whitelist_execstack") + + # Load nx whitelist. + if self.get_var("whitelist_nx"): + exports["QUALITY_AGENT_WHITELIST_NX"] = \ + self.get_var("whitelist_nx") + + # Load rpath whitelist. + if self.get_var("whitelist_rpath"): + exports["QUALITY_AGENT_WHITELIST_RPATH"] = \ + self.get_var("whitelist_rpath") + + # Load symlink whitelist + if self.get_var("whitelist_symlink"): + exports["QUALITY_AGENT_WHITELIST_SYMLINK"] = \ + self.get_var("whitelist_symlink") + + return exports + + class TemplateLexer(DefaultLexer): def init(self, environ): # A place to store the scriptlets. @@ -733,6 +778,9 @@ class RootLexer(ExportLexer): # Place for build instructions self.build = BuildLexer([], parent=self) + # Place for quality-agent exceptions + self.quality_agent = QualityAgentLexer([], parent=self) + # Include all macros. if not self.parent: for macro in MACRO_FILES: @@ -755,6 +803,7 @@ class RootLexer(ExportLexer): self.build.inherit(other.build) self.packages.inherit(other.packages) + self.quality_agent.inherit(other.quality_agent) @property def templates(self): @@ -766,6 +815,7 @@ class RootLexer(ExportLexer): (LEXER_INCLUDE, self.parse_include), (LEXER_PACKAGES_BEGIN, self.parse_packages), (LEXER_BUILD_BEGIN, self.parse_build), + (LEXER_QUALITY_AGENT_BEGIN, self.parse_quality_agent), ] return parsers @@ -832,6 +882,17 @@ class RootLexer(ExportLexer): pkgs = PackagesLexer(lines, parent=self) self.packages.inherit(pkgs) + def parse_quality_agent(self): + keys, lines = self.read_block( + pattern_start=LEXER_QUALITY_AGENT_BEGIN, + pattern_line=LEXER_QUALITY_AGENT_LINE, + pattern_end=LEXER_QUALITY_AGENT_END, + raw = True, + ) + + qa = QualityAgentLexer(lines, parent=self) + self.quality_agent.inherit(qa) + class PackagesLexer(DefaultLexer): def init(self, environ): diff --git a/pakfire/packages/make.py b/pakfire/packages/make.py index 1fdb6a78f..b73aa5a93 100644 --- a/pakfire/packages/make.py +++ b/pakfire/packages/make.py @@ -321,6 +321,9 @@ class Makefile(MakefileBase): def exports(self): exports = {} + # Include quality agent exports. + exports.update(self.lexer.quality_agent.exports) + for export in self.lexer.build.exports: exports[export] = self.lexer.build.get_var(export) diff --git a/po/pakfire.pot b/po/pakfire.pot index 3465efc59..1184c2761 100644 --- a/po/pakfire.pot +++ b/po/pakfire.pot @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2011-09-24 00:02+0200\n" +"POT-Creation-Date: 2011-09-24 00:42+0200\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n"