diff --git a/src/backend/build.py b/src/backend/build.py new file mode 100644 index 0000000000000000000000000000000000000000..23a49b890d57d676bdcfa4376bfc30e339896632 --- /dev/null +++ b/src/backend/build.py @@ -0,0 +1,12 @@ +import argparse +from pcc.antlr.build import update + +parser = argparse.ArgumentParser() +parser.add_argument('--language', '-l', default='rpmspec') +parser.add_argument('--verbose', '-v', action='count') +parser.add_argument('--force', '-f', action='store_true') + +args = parser.parse_args() +if args.verbose is None: + args.verbose = 0 +update(args.language, verbose=args.verbose, force_update=args.force) diff --git a/src/backend/main.py b/src/backend/main.py new file mode 100644 index 0000000000000000000000000000000000000000..78b2513a645701c570f45e8c43b0f42d21285c6d --- /dev/null +++ b/src/backend/main.py @@ -0,0 +1,33 @@ +import argparse +import os + +from antlr4 import FileStream, CommonTokenStream, ParseTreeWalker, ParseTreeListener, TerminalNode, ErrorNode, \ + ParserRuleContext +from loguru import logger + +from pcc.parse import parse +from pcc.source_related.JSON.JSONLexer import JSONLexer +from pcc.source_related.JSON.JSONParser import JSONParser +from pcc.source_related.rpmspec.rpmspecLexer import rpmspecLexer +from pcc.source_related.rpmspec.rpmspecParser import rpmspecParser + +parser = argparse.ArgumentParser() +parser.add_argument('input', help='Path to the package config file') +parser.add_argument('-s', '--source', choices=['JSON', 'rpmspec'], required=False, help='Source language') +parser.add_argument('-o', '--output', required=False, help='Path to the output file') + +parser.add_argument('--tokens', action='store_true', help='Only lex and print tokens instead of compile') +parser.add_argument('-r', '--run', action='store_true', help='Run after compile') +parser.add_argument('-v', '--verbose', action='count', default=0, help='Verbosity') + +args = parser.parse_args() + +if not os.path.isfile(args.input): + logger.critical(f'No such file: {args.input}') + exit(1) +name, sep, extension = args.input.rpartition('.') +if args.source is None and sep == '.': + source = extension +input_stream = FileStream(args.input) + +parse(input_stream) diff --git a/src/backend/pcc/__init__.py b/src/backend/pcc/__init__.py new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/src/backend/pcc/__pycache__/__init__.cpython-310.pyc b/src/backend/pcc/__pycache__/__init__.cpython-310.pyc new file mode 100644 index 0000000000000000000000000000000000000000..17fd97c99b222d15d4ec01dc14fac9eb4c80dd78 Binary files /dev/null and b/src/backend/pcc/__pycache__/__init__.cpython-310.pyc differ diff --git a/src/backend/pcc/__pycache__/base.cpython-310.pyc b/src/backend/pcc/__pycache__/base.cpython-310.pyc new file mode 100644 index 0000000000000000000000000000000000000000..676df23b103c25ab10c4100518067ac58eee67eb Binary files /dev/null and b/src/backend/pcc/__pycache__/base.cpython-310.pyc differ diff --git a/src/backend/pcc/__pycache__/parse.cpython-310.pyc b/src/backend/pcc/__pycache__/parse.cpython-310.pyc new file mode 100644 index 0000000000000000000000000000000000000000..a62bd90dc2c37ecc5f0fc9868e6d5978c9da5bc4 Binary files /dev/null and b/src/backend/pcc/__pycache__/parse.cpython-310.pyc differ diff --git a/src/backend/pcc/antlr/__init__.py b/src/backend/pcc/antlr/__init__.py new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/src/backend/pcc/antlr/__pycache__/__init__.cpython-310.pyc b/src/backend/pcc/antlr/__pycache__/__init__.cpython-310.pyc new file mode 100644 index 0000000000000000000000000000000000000000..1dd59417e25d3d0eb79a31dcc40b01229cd9faf2 Binary files /dev/null and b/src/backend/pcc/antlr/__pycache__/__init__.cpython-310.pyc differ diff --git a/src/backend/pcc/antlr/__pycache__/build.cpython-310.pyc b/src/backend/pcc/antlr/__pycache__/build.cpython-310.pyc new file mode 100644 index 0000000000000000000000000000000000000000..dea6adb85ab5959aa5562278f62becca348dd406 Binary files /dev/null and b/src/backend/pcc/antlr/__pycache__/build.cpython-310.pyc differ diff --git a/src/backend/pcc/antlr/build.py b/src/backend/pcc/antlr/build.py new file mode 100644 index 0000000000000000000000000000000000000000..e8c255ee13b069b636fdbad1ef8b7cba926d65ea --- /dev/null +++ b/src/backend/pcc/antlr/build.py @@ -0,0 +1,84 @@ +import os +import time + +from loguru import logger + +from pcc.base import * + +antlr_alias = f'java -Xmx500M -cp "{os.path.join(lib_dir, "antlr4-4.13.1-complete.jar")}" org.antlr.v4.Tool' + + +def language_folder(language: str): + return os.path.join(lib_dir, 'source_related', language) + + +def grammar_file_path(language: str): + return os.path.join(language_folder(language), f'{language}.g4') + + +def generated_files_path(language: str): + return [os.path.join(language_folder(language), filename) for filename in [ + f'{language}Lexer.py', f'{language}Parser.py', f'{language}Listener.py' + ]] + + +def build(language: str, verbose: int = 0): + if verbose > 1: + logger.debug('Run ANTLR:') + logger.debug(f' ANTLR alias is: {antlr_alias}') + cmd = f'{antlr_alias} -Dlanguage=Python3 {grammar_file_path(language)}' + if verbose > 1: + logger.debug(f' Run build command: {cmd}') + os.system(cmd) + if verbose > 1: + logger.debug('Build finished.') + + +def clean(language: str, verbose: int = 0): + if verbose > 1: + logger.debug('Clean existing files:') + to_remove = list(map(lambda x: os.path.join(language_folder(language), x), + filter(lambda x: x.split('.')[-1] not in ['g4', 'py'], os.listdir(language_folder(language))))) + to_remove += generated_files_path(language) + for path in to_remove: + if verbose > 1: + logger.debug(f' Remove file {path}') + if os.path.isfile(path): + os.remove(path) + if verbose > 1: + logger.debug('Clean finished.') + + +def up_to_date(language, verbose=0): + if not all(map(lambda x: os.path.exists(x), generated_files_path(language))): + if verbose > 1: + logger.debug("Some generated file doesn't exist, build isn't up to date.") + return False + gen_time = min(map(lambda x: os.stat(x).st_mtime, generated_files_path(language))) + grammar_time = os.stat(grammar_file_path(language)).st_mtime + if verbose > 1: + logger.debug( + f'Generated files earliest updated time: {time.strftime("%Y%m%d-%H:%M:%S", time.localtime(gen_time))}') + logger.debug(f'Grammar file updated time: {time.strftime("%Y%m%d-%H:%M:%S", time.localtime(grammar_time))}') + if gen_time < grammar_time: + if verbose > 1: + logger.debug("Grammar file updated later, need to update.") + return False + if verbose > 1: + logger.debug("Grammar file updated earlier, build is up to date.") + return True + + +def update(language, verbose=0, force_update=False): + if not force_update and up_to_date(language, verbose=verbose): + if verbose > 0: + logger.debug('Build already up to date.') + return + if verbose > 0: + logger.debug('Rebuilding...') + clean(language, verbose=verbose) + build(language, verbose=verbose) + if verbose > 0: + logger.debug('Rebuild finished.') + logger.info('Rebuilt code, Please run the program again to compile.') + exit(1) diff --git a/src/backend/pcc/antlr4-4.13.1-complete.jar b/src/backend/pcc/antlr4-4.13.1-complete.jar new file mode 100644 index 0000000000000000000000000000000000000000..f539ab040312b1c008b1d17236505ecf5f808d95 Binary files /dev/null and b/src/backend/pcc/antlr4-4.13.1-complete.jar differ diff --git a/src/backend/pcc/base.py b/src/backend/pcc/base.py new file mode 100644 index 0000000000000000000000000000000000000000..e9f29806c292dbad1a74e5bd5eb958ca7f585a8d --- /dev/null +++ b/src/backend/pcc/base.py @@ -0,0 +1,3 @@ +import os.path + +lib_dir = os.path.dirname(__file__) diff --git a/src/backend/pcc/parse.py b/src/backend/pcc/parse.py new file mode 100644 index 0000000000000000000000000000000000000000..ae0f3fc8a32349502c890e68da00f442667cc425 --- /dev/null +++ b/src/backend/pcc/parse.py @@ -0,0 +1,58 @@ +from antlr4 import ParseTreeWalker, CommonTokenStream, TerminalNode, ErrorNode, ParserRuleContext, ParseTreeListener, \ + InputStream + +from pcc.antlr.build import update +from pcc.source_related.rpmspec.rpmspecLexer import rpmspecLexer +from pcc.source_related.rpmspec.rpmspecParser import rpmspecParser + + +class A(ParseTreeListener): + + def __init__(self): + self.failed = False + self.result = [] + + def visitTerminal(self, node: TerminalNode): + # print(f'terminal [{node}]') + pass + + def visitErrorNode(self, node: ErrorNode): + self.result.append(f'error {node}') + self.failed = True + + def enterEveryRule(self, ctx: ParserRuleContext): + # print(f'enter', ctx) + pass + + def exitEveryRule(self, ctx: ParserRuleContext): + # print(f'exit', ctx) + pass + + def enterMacroDefine(self, ctx: ParserRuleContext): + self.result.append(f'Define {list(map(lambda x: x.getText(), ctx.children))}') + + def enterMacroUndefine(self, ctx: ParserRuleContext): + self.result.append(f'Undefine {list(map(lambda x: x.getText(), ctx.children))}') + + def enterBracketMacroRef(self, ctx: ParserRuleContext): + self.result.append(f'Bracket Ref {list(map(lambda x: x.getText(), ctx.children))}') + + def enterDirectMacroRef(self, ctx: ParserRuleContext): + self.result.append(f'Direct Ref {list(map(lambda x: x.getText(), ctx.children))}') + + +updated = False + + +def parse(input_stream: InputStream): + global updated + if not updated: + update('rpmspec', verbose=2, force_update=False) + updated = True + ast = rpmspecParser(CommonTokenStream(rpmspecLexer(input_stream))).specFile() + # print('AST:') + # print(ast.toStringTree().replace('\\n', '\n')) + walker = ParseTreeWalker() + a = A() + walker.walk(a, ast) + return a diff --git a/src/backend/pcc/source_related/.gitignore b/src/backend/pcc/source_related/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..1e722de3ba02ecbfcf3f1029f89a4f8c4a6c26d6 --- /dev/null +++ b/src/backend/pcc/source_related/.gitignore @@ -0,0 +1,5 @@ +*/*.interp +*/*.tokens +*/*Lexer.py +*/*Parser.py +*/*Listener.py diff --git a/src/backend/pcc/source_related/rpmspec/__pycache__/rpmspecLexer.cpython-310.pyc b/src/backend/pcc/source_related/rpmspec/__pycache__/rpmspecLexer.cpython-310.pyc new file mode 100644 index 0000000000000000000000000000000000000000..82e31e51b0c8b2ebb85d4cc177401a55e9d1255d Binary files /dev/null and b/src/backend/pcc/source_related/rpmspec/__pycache__/rpmspecLexer.cpython-310.pyc differ diff --git a/src/backend/pcc/source_related/rpmspec/__pycache__/rpmspecParser.cpython-310.pyc b/src/backend/pcc/source_related/rpmspec/__pycache__/rpmspecParser.cpython-310.pyc new file mode 100644 index 0000000000000000000000000000000000000000..8561fdf0997f871dae3849a2ca3f15a6211ad202 Binary files /dev/null and b/src/backend/pcc/source_related/rpmspec/__pycache__/rpmspecParser.cpython-310.pyc differ diff --git a/src/backend/pcc/source_related/rpmspec/rpmspec.g4 b/src/backend/pcc/source_related/rpmspec/rpmspec.g4 new file mode 100644 index 0000000000000000000000000000000000000000..febb7a05068fe2783862284591df6f33db2cb7fe --- /dev/null +++ b/src/backend/pcc/source_related/rpmspec/rpmspec.g4 @@ -0,0 +1,148 @@ +grammar rpmspec; + +specFile + : startSection? section* EOF + ; + +section + : packageSection + | otherSection + | changelogSection + ; + + +startSection + : (statementLine | emptyLine)+ + ; + +otherSection + : '%' SHELL_SECTIONS EOL? (statementLine | emptyLine)+ + ; + +packageSection + : (packageInfoLine | emptyLine)+ + ; + +changelogSection + : '%' 'changelog' EOL (statementLine | emptyLine)* + ; + +statementLine + : SPACE? statement SPACE? EOL + ; + +packageInfoLine + : anyIdentifier+ ':' SPACE? statement EOL + ; + +emptyLine + : SPACE? EOL + ; + +multipleLineStatements + : (SPACE? statement? SPACE? EOL)* SPACE? statement + ; + +statement + : defineMacro + | undefineMacro + | anything + ; + +defineMacro + : '%' 'define' SPACE anyIdentifier ('(' anyWord* ')')? SPACE anything # MacroDefine + ; + +undefineMacro + : '%undefined' anyIdentifier # MacroUndefine + ; + +builtinMacro + : '%' (DIRECT_OR_BRACKET_BUILTIN_MACRO | DIRECT_BUILTIN_MACRO) SPACE statement + | '%{' (DIRECT_OR_BRACKET_BUILTIN_MACRO | BRACKET_BUILTIN_MACRO) ':' multipleLineStatements RB + ; + +condition + : '%{' MACRO_CONDITION SPACE anyIdentifier RB + ; + +shellLikeMacro + : '%' INTEGER_LITERAL + | '%*' + | '%**' + | '%#' + | '%{-f}' + | '%{-f*}' + ; + +referenceMacro + : '%' anyIdentifier # DirectMacroRef + | '%{' anyIdentifier RB # BracketMacroRef + | ('%{?' | '%{!?' | '%{?!') anyIdentifier (':' statement)? RB # ConditionallyMacroRef + ; + +wordOrMacro + : condition + | referenceMacro + | builtinMacro + | shellLikeMacro + | anyWord + ; + +anyWord + : anyIdentifier + | SHELL_SECTIONS + | BOOL_LITERAL + | FLOAT_LITERAL + | INTEGER_LITERAL + | CODE + | ':' + | '%%' + | '-' + ; + +anyIdentifier + : IDENTIFIER + | DIRECT_OR_BRACKET_BUILTIN_MACRO + | DIRECT_BUILTIN_MACRO + | BRACKET_BUILTIN_MACRO + | SHELL_SECTIONS + | MACRO_CONDITION + ; + +anything + : (wordOrMacro | SPACE | '?' | '!' | '(' | ')' | '<' | '>' | LB | RB | '\\' | '$')+ + ; + +INTEGER_LITERAL: NUMERIC+; +FLOAT_LITERAL: INTEGER_LITERAL '.' INTEGER_LITERAL; +DIRECT_OR_BRACKET_BUILTIN_MACRO: 'getncpus' | 'verbose'; +DIRECT_BUILTIN_MACRO: 'if' | 'elif' | 'endif' | 'global' + | 'getconfdir' | 'rpmversion' | 'trace' | 'dump'; +BRACKET_BUILTIN_MACRO: 'load' | 'expand' | 'expr' | 'lua' | 'macrobody' | 'quote' + | 'gsub' | 'len' | 'lower' | 'rep' | 'reverse' | 'sub' | 'upper' | 'shescape' | 'shrink' + | 'basename' | 'dirname' | 'exists' | 'suffix' | 'url2path' | 'uncompress' + | 'getenv' + | 'echo' | 'warn' + | 'S' | 'P' + ; +SHELL_SECTIONS: 'generate_buildrequires'|'prep'|'build'|'install'|'check'|'post'|'postun' + | 'posttrans'|'pre'|'preun'|'pretrans'|'clean'|'verifyscript'|'triggerpostun'|'triggerprein' + | 'triggerun'|'triggerin'|'trigger'|'filetriggerin'|'filetrigger'|'filetriggerun' + | 'filetriggerpostun'|'transfiletriggerin'|'transfiletrigger'|'transfiletriggerun' + | 'transfiletriggerpostun' | 'description' + ; +MACRO_CONDITION: 'defined' | 'undefined' | 'with'; +IDENTIFIER: (ALPHA|NUMERIC|'_')+; + +CODE: (~[\r\n \t\f{}()%:?!<>0-9a-zA-Z])+; +ALPHA: [a-zA-Z]; +NUMERIC: [0-9]; +LB: '{'; +RB: '}'; +SPACE: [ \t]+; +EOL: '\r'? '\n' | '\r'; +BOOL_LITERAL: 'true' | 'false'; + +LINE_COMMENT: '#' ~[\r\n]* EOL -> skip; +BSNL : '\\' [ \t]* EOL -> skip; diff --git a/src/backend/rpm-tests/attrtest.spec b/src/backend/rpm-tests/attrtest.spec new file mode 100644 index 0000000000000000000000000000000000000000..e71c471e8f20f2b514129e44c0f1da8304d8f384 --- /dev/null +++ b/src/backend/rpm-tests/attrtest.spec @@ -0,0 +1,60 @@ +Name: attrtest +Version: 1.0 +Release: 1 +Summary: Testing file attr behavior +Group: Testing +License: GPL +BuildArch: noarch + +%description +%{summary} + +%install +for x in a b c d e f g h i j; do + mkdir -p $RPM_BUILD_ROOT/${x} + mkdir -p $RPM_BUILD_ROOT/${x}/dir + echo "This is file ${x}" > $RPM_BUILD_ROOT/${x}/file + chmod 700 $RPM_BUILD_ROOT/${x}/dir + chmod 400 $RPM_BUILD_ROOT/${x}/file +done + +%files -n %{name} +/a/dir +/a/file + +%attr(-,daemon,adm) /b/dir +%attr(-,daemon,adm) /b/file + +%attr(750,-,adm) /c/dir +%attr(640,daemon,-) /c/file + +%attr(751,daemon,bin) /d/dir +%attr(644,bin,daemon) /d/file + +%defattr(-,foo,bar) +/e/dir +/e/file + +%defattr(-,bar,foo) +%attr(770,-,-) /f/dir +%attr(660,-,-) /f/file + +%defattr(-,bar,foo) +%attr(-,adm,-) /g/dir +%attr(-,-,adm) /g/file + +%defattr(644,foo,bar,755) +/h/dir +/h/file + +%defattr(4755,root,root,750) +%attr(-,adm,-) /i/dir +%attr(-,-,adm) /i/file + +%defattr(640,zoot,zoot,750) +%attr(777,-,-) /j/dir +%attr(222,-,-) /j/file + +%changelog +* Tue Jun 28 2011 Panu Matilainen +- Initial package diff --git a/src/backend/rpm-tests/badescape.spec b/src/backend/rpm-tests/badescape.spec new file mode 100644 index 0000000000000000000000000000000000000000..3e09e8046e024711b5eec619db5a5861ac0c3253 --- /dev/null +++ b/src/backend/rpm-tests/badescape.spec @@ -0,0 +1,19 @@ +Name: badescape +Version: 1.0 +Release: 1 +Summary: Testing trailing backslash in filename +Group: Testing +License: GPL +BuildArch: noarch + +%description +%{summary}. + + +%build + +%install + +%files +/opt/foo\ + diff --git a/src/backend/rpm-tests/badftrigger.spec b/src/backend/rpm-tests/badftrigger.spec new file mode 100644 index 0000000000000000000000000000000000000000..2f5ef8e4155966a973f04fa10d031b4262c8375a --- /dev/null +++ b/src/backend/rpm-tests/badftrigger.spec @@ -0,0 +1,14 @@ +Name: badftrigger +Version: 1.0 +Release: 1 +Summary: Testing error reporting +License: GPL +BuildArch: noarch + +%description +%{summary} + +%transfiletriggerin -- /something %{nosuchmacro} +echo bad + +%files diff --git a/src/backend/rpm-tests/badquote.spec b/src/backend/rpm-tests/badquote.spec new file mode 100644 index 0000000000000000000000000000000000000000..0f9842f0308159d508e228b78d41d39852c466ec --- /dev/null +++ b/src/backend/rpm-tests/badquote.spec @@ -0,0 +1,18 @@ +Name: badquote +Version: 1.0 +Release: 1 +Summary: Testing no closing quote in filename +Group: Testing +License: GPL +BuildArch: noarch + +%description +%{summary}. + + +%build + +%install + +%files +"/opt/foo diff --git a/src/backend/rpm-tests/bcondtest.spec b/src/backend/rpm-tests/bcondtest.spec new file mode 100644 index 0000000000000000000000000000000000000000..7172a31d2997babaee95d90a62fa262100f9f503 --- /dev/null +++ b/src/backend/rpm-tests/bcondtest.spec @@ -0,0 +1,33 @@ +Name: bcondtest +Version: 1.0 +Release: 1 +Group: Testing +License: CC0 +BuildArch: noarch +Summary: Test package for the bcond macro + +%bcond normally_on 1 +%bcond normally_off 0 +%bcond both_features %[%{with normally_on} && %{with normally_off}] + +%if %{with normally_on} +Provides: has_bcond(normally_on) +%endif +%if %{with normally_off} +Provides: has_bcond(normally_off) +%endif +%if %{with both_features} +Provides: has_bcond(both_features) +%endif + +%description +%{summary} + +%install +mkdir -p %{buildroot}/opt +touch %{buildroot}/opt/file + +%files +/opt/file + +%changelog diff --git a/src/backend/rpm-tests/buildrequires.spec b/src/backend/rpm-tests/buildrequires.spec new file mode 100644 index 0000000000000000000000000000000000000000..4be0e82476102da9417634471c2b2b7db9862fba --- /dev/null +++ b/src/backend/rpm-tests/buildrequires.spec @@ -0,0 +1,38 @@ +Summary: Test dynamic BuildRequires +Name: buildrequires +Version: 1.0 +Release: 1 +Group: Utilities +License: GPL +Distribution: RPM test suite. +Source0: buildrequires-1.0.tar.gz +Prefix: /usr +BuildArch: noarch + +%description +Simple build requires demonstration. + +%prep +%setup -q + +%generate_buildrequires +echo foo-bar = 2.0 +cat buildrequires.txt + +%build + +%install +mkdir -p $RPM_BUILD_ROOT/usr/local/bin +cat < EOF >> $RPM_BUILD_ROOT/usr/local/bin/hello +#!/bin/sh +echo hello +EOF +chmod a+x $RPM_BUILD_ROOT/usr/local/bin/hello + +%files +%defattr(-,root,root) +%doc FAQ +#%readme README +#%license COPYING +%attr(0751,root,root) /usr/local/bin/hello + diff --git a/src/backend/rpm-tests/captest.spec b/src/backend/rpm-tests/captest.spec new file mode 100644 index 0000000000000000000000000000000000000000..21864baf15a25df7bdbd764b583708ae9613da71 --- /dev/null +++ b/src/backend/rpm-tests/captest.spec @@ -0,0 +1,27 @@ +Name: capstest +Version: 1.0 +Release: 1 +Summary: Testing file capabilities behavior +Group: Testing +License: GPL +BuildArch: noarch + +%description +%{summary} + +%install +mkdir -p $RPM_BUILD_ROOT/a +echo "x" > $RPM_BUILD_ROOT/a/emptyCaps1 +echo "x" > $RPM_BUILD_ROOT/a/emptyCaps2 +echo "x" > $RPM_BUILD_ROOT/a/noCaps + + +%files -n %{name} +%attr(0777,root,root) %caps(=) /a/emptyCaps1 +%attr(0777,root,root) %caps() /a/emptyCaps2 +%attr(0777,root,root) /a/noCaps + + +%changelog +* Mon Nov 5 2018 Pavlina Moravcova Varekova +- Initial package diff --git a/src/backend/rpm-tests/configtest.spec b/src/backend/rpm-tests/configtest.spec new file mode 100644 index 0000000000000000000000000000000000000000..63a7335372c65846dbba600b9ba407884b3475bc --- /dev/null +++ b/src/backend/rpm-tests/configtest.spec @@ -0,0 +1,34 @@ +# avoid depending on rpm configuration +%define _sysconfdir /etc + +%{!?filetype: %global filetype file} + +Name: configtest%{?subpkg:-%{subpkg}} +Version: %{ver} +Release: 1 +Summary: Testing config file behavior + +Group: Testing +License: GPL +BuildArch: noarch + +%description +%{summary} + +%install +mkdir -p $RPM_BUILD_ROOT/%{_sysconfdir} +case %{filetype} in +file) + echo "%{filedata}" > $RPM_BUILD_ROOT/%{_sysconfdir}/my.conf + ;; +link) + ln -s "%{filedata}" $RPM_BUILD_ROOT/%{_sysconfdir}/my.conf + ;; +dir) + mkdir -p $RPM_BUILD_ROOT/%{_sysconfdir}/my.conf + ;; +esac + +%files +%defattr(-,root,root,-) +%{?fileattr} %{!?noconfig:%config%{?noreplace:(noreplace)}} %{_sysconfdir}/my.conf diff --git a/src/backend/rpm-tests/conflicttest.spec b/src/backend/rpm-tests/conflicttest.spec new file mode 100644 index 0000000000000000000000000000000000000000..d29b7b5ac17eb04178733678ad60459f23a9dfee --- /dev/null +++ b/src/backend/rpm-tests/conflicttest.spec @@ -0,0 +1,22 @@ +# avoid depending on rpm configuration +%define _datadir /usr/share + +Name: conflict%{pkg} +Version: 1.0 +Release: 1 +Summary: Testing file conflict behavior + +Group: Testing +License: GPL +BuildArch: noarch + +%description +%{summary} + +%install +mkdir -p $RPM_BUILD_ROOT/%{_datadir} +echo "%{filedata}" > $RPM_BUILD_ROOT/%{_datadir}/my.version + +%files +%defattr(-,root,root,-) +%{?fileattr} %{_datadir}/my.version diff --git a/src/backend/rpm-tests/deptest.spec b/src/backend/rpm-tests/deptest.spec new file mode 100644 index 0000000000000000000000000000000000000000..164571a40a191fcb689efe98609f492a7b609ee3 --- /dev/null +++ b/src/backend/rpm-tests/deptest.spec @@ -0,0 +1,30 @@ +Name: deptest-%{pkg} +Version: 1.0 +Release: 1 +Summary: Testing dependency behavior + +Group: Testing +License: GPL +BuildArch: noarch +%{?reqs:Requires: %{reqs}} +%{?provs:Provides: %{provs}} +%{?cfls:Conflicts: %{cfls}} +%{?obs:Obsoletes: %{obs}} +%{?recs:Recommends: %{recs}} +%{?sugs:Suggests: %{sugs}} +%{?sups:Supplements: %{sups}} +%{?ens:Enhances: %{ens}} +%{?ord:OrderWithRequires: %{ord}} +%{?buildreqs:BuildRequires: %{buildreqs}} +%{?buildcfls:BuildConflicts: %{buildcfls}} + +%description +%{summary} + +%install +mkdir -p %{buildroot}/opt/ +echo FOO > %{buildroot}/opt/bar + +%files +%defattr(-,root,root,-) +/opt/bar diff --git a/src/backend/rpm-tests/dev.spec b/src/backend/rpm-tests/dev.spec new file mode 100644 index 0000000000000000000000000000000000000000..d784fe11457a1f5fcdb8f0b6b8a5d6f7bb49242e --- /dev/null +++ b/src/backend/rpm-tests/dev.spec @@ -0,0 +1,14 @@ +Name: dev +Version: 1.0 +Release: 1 +Group: Testing +License: GPL +Summary: Testing dev behavior +BuildArch: noarch + +%description +%{summary} + +%files +%dev(c 11 22) /test-char +%dev(b 33 44) /test-block diff --git a/src/backend/rpm-tests/docmiss.spec b/src/backend/rpm-tests/docmiss.spec new file mode 100644 index 0000000000000000000000000000000000000000..2c4937024140bbdb93acbc9f6660f44e9cfe4001 --- /dev/null +++ b/src/backend/rpm-tests/docmiss.spec @@ -0,0 +1,24 @@ +Name: docmiss +Version: 1.0 +Release: 1 +Summary: Testing missing doc behavior +Group: Testing +License: GPL + +%description +%{summary} + + +%prep +%setup -c -n %{name}-%{version} -T + +cat << EOF > COPYING +This is not a license +EOF + +cat << EOF > README +This is a dog project +EOF + +%files +%doc CREDITS COPYING README diff --git a/src/backend/rpm-tests/dynamic.spec b/src/backend/rpm-tests/dynamic.spec new file mode 100644 index 0000000000000000000000000000000000000000..5dbaa8584e4853cdea8be8e92ca5da3dd4981200 --- /dev/null +++ b/src/backend/rpm-tests/dynamic.spec @@ -0,0 +1,39 @@ +Summary: dynamic hello -- hello, world rpm +Name: dynamic +Version: 1.0 +Release: 1 +Group: Utilities +License: GPL +Distribution: RPM test suite. +URL: http://rpm.org +BuildArch: noarch + +%description +Simple rpm demonstration. + +%prep +%setup -q -T -c + +%build +echo "Q: Why?\nA: Because we can!" > FAQ + +%install +mkdir -p $RPM_BUILD_ROOT/usr/local/bin +echo " " > $RPM_BUILD_ROOT/usr/local/bin/hello + + +echo "%package docs" >> %{specpartsdir}/docs.specpart +%{?!FAIL:echo "Summary: Documentation for dynamic spec" >> %{specpartsdir}/docs.specpart} +echo "BuildArch: noarch" >> %{specpartsdir}/docs.specpart +echo "%description docs" >> %{specpartsdir}/docs.specpart +echo "Test for dynamically generated spec files" >> %{specpartsdir}/docs.specpart +echo "%files docs" >> $RPM_SPECPARTS_DIR/docs.specpart +echo "%doc FAQ" >> $RPM_SPECPARTS_DIR/docs.specpart + +%files +%defattr(-,root,root) +%attr(0751,root,root) /usr/local/bin/hello + +%changelog +* Mon Oct 24 2022 Florian Festi +- create. diff --git a/src/backend/rpm-tests/eliftest.spec b/src/backend/rpm-tests/eliftest.spec new file mode 100644 index 0000000000000000000000000000000000000000..3a7374291b60b8bd7543b1b6bd09da735ca1a53c --- /dev/null +++ b/src/backend/rpm-tests/eliftest.spec @@ -0,0 +1,116 @@ +Name: eliftest +Version: 1.0 +Release: 1 +Summary: Testing %if, %elif, %else options +License: GPL +Group: Testing +BuildArch: noarch + +%if 0%{?testif} == 2 + %if 0%{?rhel} == 6 +Requires: pkg1 + %elif 0%{?rhel} == 7 +Requires: pkg2 + %else +Requires: pkg3 + %endif +%endif + +%description +%{summary} + +%build +%define actecho0 exit +%define actecho1 0 + +%if 0%{?testif} == 2 + + %if 0%{?fedora} >= 23 + %{actecho0} %{actecho1} + %elif 0%{?fedora} >= 10 || 0%{?rhel} >= 6 + %{actecho0} %{actecho1} + %else + %{actecho0} %{actecho1} + %endif + +%elif 0%{testif} == 1 + + %if %{variable1} + %{action1} + %elif %{variable2} + %{action2} + %elif %{variable3} + %{action3} + %else + %{action4} + %endif + +%else + + %if 0 + exit 1 + %elif 0 + exit 1 + %else + %global iftest1_macro defined + %endif + %{!?iftest1_macro:exit 1} + + %if 0 + exit 1 + %elif 0 + exit 1 + %elif 1 + %global iftest2_macro defined + %elif 1 + exit 1 + %elif 0 + exit 1 + %else + exit 1 + %endif + %{!?iftest2_macro:exit 1} + + %if 1 + %global iftest3_macro defined + %elif 0 + exit 1 + %elif 1 + exit 1 + %else + exit 1 + %endif + %{!?iftest3_macro:exit 1} + + %if 0 + exit 1 + %elif 1 + %if 0 + exit 1 + %elif 0 + exit 1 + %elif 1 + %global iftest4_macro defined + %else + exit 1 + %endif + %elif 1 + exit 1 + %endif + %{!?iftest4_macro:exit 1} + + %if 0 + exit 0 + %elif 0 + exit 0 + %elif 1 + %global iftest5_macro defined + %elif 1 + exit 1 + %elif 0 + exit 1 + %else + exit 1 + %endif + %{!?iftest5_macro:exit 1} +%endif diff --git a/src/backend/rpm-tests/fakeshell.spec b/src/backend/rpm-tests/fakeshell.spec new file mode 100644 index 0000000000000000000000000000000000000000..88b5fe190ca5e45f1402176d0b13084ba9fc54e5 --- /dev/null +++ b/src/backend/rpm-tests/fakeshell.spec @@ -0,0 +1,12 @@ +Name: fakeshell +Version: 1.0 +Release: 1 +Summary: Fake provides for shell +License: GPL +BuildArch: noarch +Provides: /bin/sh + +%description +%{summary} + +%files diff --git a/src/backend/rpm-tests/fifo.spec b/src/backend/rpm-tests/fifo.spec new file mode 100644 index 0000000000000000000000000000000000000000..20b30b2435208af33b9a0a0e46a553cde5da8168 --- /dev/null +++ b/src/backend/rpm-tests/fifo.spec @@ -0,0 +1,16 @@ +Name: fifo +Version: 1.0 +Release: 1 +Group: Testing +License: GPL +Summary: Testing fifo behavior +BuildArch: noarch + +%description +%{summary} + +%install +mknod ${RPM_BUILD_ROOT}/test-fifo p + +%files +/test-fifo diff --git a/src/backend/rpm-tests/filedep.spec b/src/backend/rpm-tests/filedep.spec new file mode 100644 index 0000000000000000000000000000000000000000..d403058810ad113bac1eb5e7021d7d1102f0ff61 --- /dev/null +++ b/src/backend/rpm-tests/filedep.spec @@ -0,0 +1,49 @@ +Name: filedep +Version: 1.0 +Release: 1 +Summary: Testing file dependencies +License: GPL +BuildArch: noarch + +%description +%{summary} + +%prep +%setup -q -T -c %{name}-%{version} + + +%build +cat << EOF >> foo +#!/bin/sh +cat /etc/foo.conf +EOF + +cat << EOF >> bar +#!/bin/f00f +echo BUG +EOF + +cat << EOF >> foo.conf +hello there +EOF + +cat << EOF >> README +Some stuff, huh? +EOF + +%install +mkdir -p %{buildroot}/etc +mkdir -p %{buildroot}/usr/bin +mkdir -p %{buildroot}/usr/share/doc/filedep +install -D -m 644 foo.conf %{buildroot}/etc +install -D -m 755 foo bar %{buildroot}/usr/bin/ +install -D -m 644 README %{buildroot}/usr/share/doc/filedep + +%files +/etc/* +/usr/bin/* +/usr/share/doc/filedep/ + + +%changelog + diff --git a/src/backend/rpm-tests/filemiss.spec b/src/backend/rpm-tests/filemiss.spec new file mode 100644 index 0000000000000000000000000000000000000000..921fb065022e18b351f77896316be528b44acee9 --- /dev/null +++ b/src/backend/rpm-tests/filemiss.spec @@ -0,0 +1,26 @@ +# Make sure %%doc files are installed into a hard-coded prefix so that we can +# then compare them against a static list using "rpm -qpl" in +# tests/rpmbuild.at. +%global _prefix /opt + +Name: filemisstest +Version: 1.0 +Release: 1 +Summary: Testing missing file behavior +Group: Testing +License: GPL +BuildArch: noarch + +%description +%{summary}. + + +%build +%install + +%files +%doc /opt/share/doc/%{name}-%{version}/CREDITS +%doc INSTALL README* +%license LICENSE OTHERLICENSE? +/opt/foo +/opt/bar{a,b} diff --git a/src/backend/rpm-tests/filetriggers.spec b/src/backend/rpm-tests/filetriggers.spec new file mode 100644 index 0000000000000000000000000000000000000000..35d0fb9eec96d5d50dd7c9bd66d50000683f6fc1 --- /dev/null +++ b/src/backend/rpm-tests/filetriggers.spec @@ -0,0 +1,95 @@ +Name: filetriggers +Version: 1.0 +Release: 1 +Summary: Testing file triggers + +Group: testing +License: GPL +BuildArch: noarch + + +%description +%{summary} + + +%filetriggerin -- /usr/bin +echo "filetriggerin(/usr/bin*): $*" +cat +echo + +%filetriggerun -- /usr/bin +echo "filetriggerun(/usr/bin*): $*" +cat +echo + +%filetriggerpostun -- /usr/bin +echo "filetriggerpostun(/usr/bin*): $*" +cat +echo + +%transfiletriggerin -- /usr/bin +echo "transfiletriggerin(/usr/bin*): $*" +cat +echo + +%transfiletriggerun -- /usr/bin +echo "transfiletriggerun(/usr/bin*): $*" +cat +echo + +%transfiletriggerpostun -- /usr/bin +echo "transfiletriggerpostun(/usr/bin*): $*" +cat +echo + +%filetriggerin -p -- /usr/bin +print("filetriggerin(/usr/bin*): "..arg[2]) +a = rpm.next_file() +while a do + print(a) + a = rpm.next_file() +end +print("") +io.flush() + +%filetriggerin -- /foo +echo "filetriggerin(/foo*):" +cat +echo + +%filetriggerun -- /foo +echo "filetriggerun(/foo*):" +cat +echo + +%filetriggerpostun -- /foo +echo "filetriggerpostun(/foo*):" +cat +echo + +%transfiletriggerin -- /foo +echo "transfiletriggerin(/foo*):" +cat +echo + +%transfiletriggerun -- /foo +echo "transfiletriggerun(/foo*):" +cat +echo + +%transfiletriggerpostun -- /foo +echo "transfiletriggerpostun(/foo*):" +cat +echo + +%filetriggerin -p -- /foo +print("filetriggerin(/foo*):") +a = rpm.next_file() +while a do + print(a) + a = rpm.next_file() +end +print("") +io.flush() + +%files diff --git a/src/backend/rpm-tests/find-lang-test.spec b/src/backend/rpm-tests/find-lang-test.spec new file mode 100644 index 0000000000000000000000000000000000000000..04a92d7b14eb6718510a56725f84c2479ad1eb4b --- /dev/null +++ b/src/backend/rpm-tests/find-lang-test.spec @@ -0,0 +1,35 @@ +# avoid depending on rpm configuration +%define _datadir /usr/share + +Name: find-lang-test +Version: 1.0 +Release: 1 +Summary: Testing find-lang behavior +Group: Testing +License: GPL +BuildArch: noarch + +%description +%{summary} + +%prep +%setup -c -T + +%install +for f in fi de_DE pl ""; do + mkdir -p $RPM_BUILD_ROOT/%{_datadir}/man/$f/man1 + echo "This is $f language" | gzip > $RPM_BUILD_ROOT/%{_datadir}/man/$f/man1/%{name}.1.gz +done + + +#echo "This is en language" | gzip > $RPM_BUILD_ROOT/%{_datadir}/man/man1/%{name}.1.gz + +mkdir -p $RPM_BUILD_ROOT/%{_datadir}/%{name} +touch $RPM_BUILD_ROOT/%{_datadir}/%{name}/empty.txt + +%find_lang %{name} --with-man --without-mo %{?langpacks:--generate-subpackages} + +%files -f %{name}.lang +%defattr(-,root,root,-) +%{_datadir}/%{name}/empty.txt +%{_datadir}/man/man1/%{name}* diff --git a/src/backend/rpm-tests/flangtest.spec b/src/backend/rpm-tests/flangtest.spec new file mode 100644 index 0000000000000000000000000000000000000000..6d732747348b50a16c6254822f335ef28f4fb964 --- /dev/null +++ b/src/backend/rpm-tests/flangtest.spec @@ -0,0 +1,29 @@ +# avoid depending on rpm configuration +%define _datadir /usr/share + +Name: flangtest +Version: 1.0 +Release: 1 +Summary: Testing file lang behavior +Group: Testing +License: GPL +BuildArch: noarch + +%description +%{summary} + +%install +mkdir -p $RPM_BUILD_ROOT/%{_datadir}/%{name} +for f in fi de en pl none; do + echo "This is $f language" > $RPM_BUILD_ROOT/%{_datadir}/%{name}/$f.txt +done +touch $RPM_BUILD_ROOT/%{_datadir}/%{name}/empty.txt + +%files +%defattr(-,root,root,-) +%lang(fi) %{_datadir}/%{name}/fi.txt +%lang(de) %{_datadir}/%{name}/de.txt +%lang(en) %{_datadir}/%{name}/en.txt +%lang(pl) %{_datadir}/%{name}/pl.txt +%{_datadir}/%{name}/none.txt +%{_datadir}/%{name}/empty.txt diff --git a/src/backend/rpm-tests/foo.spec b/src/backend/rpm-tests/foo.spec new file mode 100644 index 0000000000000000000000000000000000000000..859e9814209bd6f20b20a1b1bff4dcfe3ce57a47 --- /dev/null +++ b/src/backend/rpm-tests/foo.spec @@ -0,0 +1,36 @@ +%bcond_with bus + +Summary: foo +Name: foo +Version: 1.0 +Release: 1 +Source: hello-2.0.tar.gz +Patch1: hello-1.0-modernize.patch +Group: Testing +License: GPLv2+ +BuildArch: noarch + +%description +Simple rpm demonstration. + +%package sub +Summary: %{summary} +Requires: %{name} = %{version}-%{release} + +%description sub +%{summary} + +%package bus +Summary: %{summary} +Requires: %{name} = %{version}-%{release} + +%description bus +%{summary} + +%files + +%files sub + +%if %{with bus} +%files bus +%endif diff --git a/src/backend/rpm-tests/fs.spec b/src/backend/rpm-tests/fs.spec new file mode 100644 index 0000000000000000000000000000000000000000..6d202e34f8ff24d2c841ca79ab1e19cda80bcfc9 --- /dev/null +++ b/src/backend/rpm-tests/fs.spec @@ -0,0 +1,15 @@ +Name: fs +Version: 1.0 +Release: 1 +Summary: filesystem +License: GPL +BuildArch: noarch + +%description +%{summary} + +%install +mkdir -p %{buildroot}/{bin,lib,opt,etc,tmp,var} + +%files +/ diff --git a/src/backend/rpm-tests/globesctest.spec b/src/backend/rpm-tests/globesctest.spec new file mode 100644 index 0000000000000000000000000000000000000000..36ca516c6eec5eae6b91e6caa1c19723974dc06b --- /dev/null +++ b/src/backend/rpm-tests/globesctest.spec @@ -0,0 +1,125 @@ +# Make sure %%doc files are installed into a hard-coded prefix so that we can +# then compare them against a static list using "rpm -qpl" in +# tests/rpmbuild.at. +%global _prefix /opt + +Name: globesctest +Version: 1.0 +Release: 1 +Summary: Testing file glob escape behavior +Group: Testing +License: GPL +BuildArch: noarch + +%description +%{summary}. + + +%build +touch 'foo[bar]' bar baz 'foo bar' foo%%name 'docfb[123]' 'licfb[123]' +touch 'foo b' 'foo a' 'foo r' +touch 'foo & bar !' + +%install +mkdir -p %{buildroot}/opt + +# Glob escaping +touch '%{buildroot}/opt/foo[bar]' +touch '%{buildroot}/opt/foo\[bar\]' +touch '%{buildroot}/opt/foo*' +touch '%{buildroot}/opt/foo\bar' +touch %{buildroot}/opt/foo\\ +touch '%{buildroot}/opt/foo?bar' +touch '%{buildroot}/opt/foo{bar,baz}' +touch '%{buildroot}/opt/foo"bar"' +touch '%{buildroot}/opt/foo*b' +touch '%{buildroot}/opt/foo*a' +touch '%{buildroot}/opt/foo*r' + +# Macro escaping +touch '%{buildroot}/opt/foo%%name' + +# Space escaping +touch '%{buildroot}/opt/foo[bax bay]' +touch '%{buildroot}/opt/foo bar' +touch '%{buildroot}/opt/foo" bar"' +touch '%{buildroot}/opt/foo b' +touch '%{buildroot}/opt/foo a' +touch '%{buildroot}/opt/foo r' + +# Quoting +touch '%{buildroot}/opt/foo bar.conf' +touch '%{buildroot}/opt/foo [baz]' +touch '%{buildroot}/opt/foo[bar baz]' +touch '%{buildroot}/opt/foo\[baz\]' +touch '%{buildroot}/opt/foo\bay' +touch '%{buildroot}/opt/foo"baz"' + +# Regression checks +touch '%{buildroot}/opt/foo-bar1' +touch '%{buildroot}/opt/foo-bar2' +touch '%{buildroot}/opt/fooxbarybaz' +touch "%{buildroot}/opt/foo\"'baz\"'" +touch '%{buildroot}/opt/foobar' +touch '%{buildroot}/opt/foobaz' +touch '%{buildroot}/opt/foobara' +touch '%{buildroot}/opt/foobarb' +touch '%{buildroot}/opt/foobaza' +touch '%{buildroot}/opt/foobazb' +touch '%{buildroot}/opt/foobaya' +touch '%{buildroot}/opt/foobayb' +touch '%{buildroot}/opt/foobawa' +touch '%{buildroot}/opt/foobawb' + +# Fallback +touch '%{buildroot}/opt/foo[123]' + +%files + +# Glob escaping +%doc foo\[bar\] +/opt/foo\[bar\] +/opt/foo\*[bar] +/opt/foo\\\[bar\\\] +/opt/foo\* +/opt/foo\\bar +/opt/foo\\ +/opt/foo\?bar +/opt/foo\{bar,baz\} +/opt/foo\"bar\" + +# Macro escaping +%doc foo%%name +/opt/foo%%name + +# Space escaping +%doc foo\ [bar] +/opt/foo\[bax\ bay\] +/opt/foo\ bar +/opt/foo"\ bar" +/opt/foo\ [bar] + +# Quoting +%config "/opt/foo bar.conf" +"/opt/foo [baz]" +"/opt/foo[bar baz]" +"/opt/foo\\[baz\\]" +"/opt/foo\\bay" +"/opt/foo\"baz\"" + +# Regression checks +%doc ba* "foo bar" +/opt/foo-bar* +/opt/foo?bar?baz +/opt/foo"'baz"' +/opt/foo{bar,baz} +/opt/foo{bar{a,b},baz{a,b}} +/opt/foo{bay*,baw*} + +# Fallback +%doc docfb[123] +%license licfb[123] +/opt/foo[123] + +# Shell control chars (#1294) +%doc "foo & bar !" diff --git a/src/backend/rpm-tests/globtest.spec b/src/backend/rpm-tests/globtest.spec new file mode 100644 index 0000000000000000000000000000000000000000..7722d6f27d648e200ab261e6ce3a86ffba58ccc8 --- /dev/null +++ b/src/backend/rpm-tests/globtest.spec @@ -0,0 +1,42 @@ +Name: globtest +Version: 1.0 +Release: 1 +Summary: Testing file glob behavior +Group: Testing +License: GPL +BuildArch: noarch + +%description +%{summary} + +%define testdir /opt/%{name} + +%install +mkdir -p $RPM_BUILD_ROOT/%{testdir} +echo "foo" > $RPM_BUILD_ROOT/%{testdir}/weird%%name +for f in bif baf zab zeb zib brace grace; do + echo "$f" > $RPM_BUILD_ROOT/%{testdir}/$f +done +for f in bing bang bong; do + mkdir -p $RPM_BUILD_ROOT/%{testdir}/$f +done +mkdir -p $RPM_BUILD_ROOT/%{testdir}/foo +for f in one two three; do + echo "$f" > $RPM_BUILD_ROOT/%{testdir}/foo/$f +done + +ln -s %{testdir}/zab $RPM_BUILD_ROOT/%{testdir}/linkgood +ln -s %{testdir}/zub $RPM_BUILD_ROOT/%{testdir}/linkbad + +%files +%defattr(-,root,root,-) +%{testdir}/b?? +%{testdir}/{brace,grace} +%{testdir}/weird?name +%{testdir}/z* +%{testdir}/l* +%{testdir}/b*g/ +%dir %{testdir}/foo +%{testdir}/foo/* +# Regression test for #2347 +%dev(b 1 2) /test-block diff --git a/src/backend/rpm-tests/hello-attr-buildid.spec b/src/backend/rpm-tests/hello-attr-buildid.spec new file mode 100644 index 0000000000000000000000000000000000000000..cdab95fff58e8b61fabfd1feca8335e187640c33 --- /dev/null +++ b/src/backend/rpm-tests/hello-attr-buildid.spec @@ -0,0 +1,27 @@ +Name: test +Version: 1.0 +Release: 1 +Summary: Test + +License: Public Domain +URL: https://fedoraproject.org +Source: hello.c + +%description +%{summary}. + +%prep +%autosetup -c -D -T +cp -a %{S:0} . + +%build +gcc -g hello.c -o hello + +%install +mkdir -p %{buildroot}%{_bindir} +install -D -p -m 0755 -t %{buildroot}%{_bindir} hello + +%files +%attr(644,root,root) %{_bindir}/hello + +%changelog diff --git a/src/backend/rpm-tests/hello-auto.spec b/src/backend/rpm-tests/hello-auto.spec new file mode 100644 index 0000000000000000000000000000000000000000..ea0491b06b53c9130f54ab8c686fe14246ef69df --- /dev/null +++ b/src/backend/rpm-tests/hello-auto.spec @@ -0,0 +1,30 @@ +Name: hello +Version: 1.0 +Release: 1 +Group: Testing +License: GPL +Summary: Simple rpm demonstration. + +%sourcelist +hello-1.0.tar.gz + +%patchlist +hello-1.0-modernize.patch +hello-1.0-install.patch + +%description +Simple rpm demonstration. + +%prep +%autosetup + +%build +%make_build CFLAGS="$RPM_OPT_FLAGS" + +%install +%make_install + +%files +%doc FAQ +/usr/local/bin/hello + diff --git a/src/backend/rpm-tests/hello-autopatch.spec b/src/backend/rpm-tests/hello-autopatch.spec new file mode 100644 index 0000000000000000000000000000000000000000..a6319f1931a66d0968a76b13972cb64398298dcb --- /dev/null +++ b/src/backend/rpm-tests/hello-autopatch.spec @@ -0,0 +1,32 @@ +Name: hello +Version: 1.0 +Release: 1 +Group: Testing +License: GPL +Summary: Simple rpm demonstration. + +%sourcelist +hello-1.0.tar.gz + +%patchlist +hello-1.0-modernize.patch +hello-1.0-install.patch + +%description +Simple rpm demonstration. + +%prep +%autosetup -N +%autopatch 1 +%autopatch -m 2 + +%build +%make_build CFLAGS="$RPM_OPT_FLAGS" + +%install +%make_install + +%files +%doc FAQ +/usr/local/bin/hello + diff --git a/src/backend/rpm-tests/hello-cd.spec b/src/backend/rpm-tests/hello-cd.spec new file mode 100644 index 0000000000000000000000000000000000000000..ab1e3008b39f46ef989b82ce2f92d39fd208de4e --- /dev/null +++ b/src/backend/rpm-tests/hello-cd.spec @@ -0,0 +1,29 @@ +Name: test +Version: 1.0 +Release: 1 +Summary: Test + +License: Public Domain +URL: https://fedoraproject.org +Source: hello.c + +%description +%{summary}. + +%prep +%autosetup -c -D -T +cp -a %{S:0} . + +%build +gcc -g hello.c -o hello + +%install +mkdir -p %{buildroot}/bin +install -D -p -m 0755 -t %{buildroot}/bin hello +# Pretend we need to do something in /tmp +cd /tmp + +%files +%attr(644,root,root) /bin/hello + +%changelog diff --git a/src/backend/rpm-tests/hello-config-buildid.spec b/src/backend/rpm-tests/hello-config-buildid.spec new file mode 100644 index 0000000000000000000000000000000000000000..ca2d30db32c9b4bb4990ffca6601f44de8eaa3b7 --- /dev/null +++ b/src/backend/rpm-tests/hello-config-buildid.spec @@ -0,0 +1,30 @@ +Name: test +Version: 1.0 +Release: 1 +Summary: Test + +License: Public Domain +URL: https://fedoraproject.org +Source: hello.c + +%description +%{summary}. + +%prep +%autosetup -c -D -T +cp -a %{S:0} . + +%build +gcc -g hello.c -o hello + +%install +mkdir -p %{buildroot}/bin +install -D -p -m 0755 -t %{buildroot}/bin hello +mkdir -p %{buildroot}/etc +echo "settings" > %{buildroot}/etc/config.file + +%files +%attr(644,root,root) /bin/hello +%config(noreplace) /etc/config.file + +%changelog diff --git a/src/backend/rpm-tests/hello-g3.spec b/src/backend/rpm-tests/hello-g3.spec new file mode 100644 index 0000000000000000000000000000000000000000..40c876b806087db09b59d9ceb23b1b83be12b853 --- /dev/null +++ b/src/backend/rpm-tests/hello-g3.spec @@ -0,0 +1,43 @@ +Summary: hello-g3 -- double hello, world rpm, .debug_macro -g3 +Name: hello-g3 +Version: 1.0 +Release: 1 +Group: Testing +License: GPL +Source0: hello-1.0.tar.gz +Patch0: hello-1.0-modernize.patch + +%description +Simple rpm demonstration. + +%prep +%setup -q -n hello-1.0 +%patch -p1 -b .modernize 0 + +%build + +%if "%{__cc}" == "clang" +%global debug_flags -fdebug-macro +%endif + +make CFLAGS="-g3 -O1 -DDEBUG_DEFINE=1 %{?debug_flags}" CC=%{__cc} +mv hello hello-g3 +make CFLAGS="-g3 -O2 -D_FORTIFY_SOURCE=2 %{?debug_flags}" CC=%{__cc} + +%install +mkdir -p $RPM_BUILD_ROOT/usr/local/bin +make DESTDIR=$RPM_BUILD_ROOT install +cp hello-g3 $RPM_BUILD_ROOT/usr/local/bin/ + +%files +%defattr(-,root,root) +%doc FAQ +%attr(0751,root,root) /usr/local/bin/hello +%attr(0751,root,root) /usr/local/bin/hello-g3 + +%changelog +* Mon Jun 3 2019 Mark Wielaard +- Create hello-g3 for -g3 .debug_macro testing. + +* Wed May 18 2016 Mark Wielaard +- Add hello2 for dwz testing support. diff --git a/src/backend/rpm-tests/hello-patch.spec b/src/backend/rpm-tests/hello-patch.spec new file mode 100644 index 0000000000000000000000000000000000000000..9f5b6cef202b4578d75596dad552bdcf1a21d4cb --- /dev/null +++ b/src/backend/rpm-tests/hello-patch.spec @@ -0,0 +1,20 @@ +Name: hello +Version: 1.0 +Release: 1 +Group: Testing +License: GPL +Summary: Simple rpm demonstration. + +Source0: hello-1.0.tar.gz +Patch0: hello-1.0-install.patch +Patch1: hello-1.0-modernize.patch + +%description +Simple rpm demonstration. + +%prep +%setup -q +%patch0 -p1 -b .install +%patch1 -p1 -b .modernize + +%changelog diff --git a/src/backend/rpm-tests/hello-r2.spec b/src/backend/rpm-tests/hello-r2.spec new file mode 100644 index 0000000000000000000000000000000000000000..fe60be1588b6e8ff7bcc905c0e693bdd75333c16 --- /dev/null +++ b/src/backend/rpm-tests/hello-r2.spec @@ -0,0 +1,39 @@ +Summary: hello -- hello, world rpm +Name: hello +Version: 1.0 +Release: 2 +Group: Utilities +License: GPL +Distribution: RPM test suite. +URL: http://rpm.org +Source0: hello-1.0.tar.gz +Patch0: hello-1.0-modernize.patch +Prefix: /usr + +%description +Simple rpm demonstration. + +%prep +%setup -q +%patch -p1 -b .modernize 0 + +%build +make + +%install +mkdir -p $RPM_BUILD_ROOT/usr/local/bin +make DESTDIR=$RPM_BUILD_ROOT install + +%files +%defattr(-,root,root) +%doc FAQ +#%readme README +#%license COPYING +%attr(0751,root,root) /usr/local/bin/hello + +%changelog +* Wed Jun 8 2016 Mark Wielaard +- Update release for unique build-id generation tests. + +* Tue Oct 20 1998 Jeff Johnson +- create. diff --git a/src/backend/rpm-tests/hello-script.spec b/src/backend/rpm-tests/hello-script.spec new file mode 100644 index 0000000000000000000000000000000000000000..09943a98fce874473e6d7c4633b84af3d25da5d8 --- /dev/null +++ b/src/backend/rpm-tests/hello-script.spec @@ -0,0 +1,23 @@ +Name: hello-script +Version: 1.0 +Release: 1 +Summary: Testing file conflict behavior + +Group: Testing +License: GPL +BuildArch: noarch + +%description +%{summary} + +%install +mkdir -p $RPM_BUILD_ROOT/usr/bin +mkdir -p $RPM_BUILD_ROOT/zoot +cat << EOF > $RPM_BUILD_ROOT/usr/bin/hello +echo "Hello world!" +EOF + +%files +%defattr(-,root,root,-) +/usr/bin/hello +/zoot diff --git a/src/backend/rpm-tests/hello-sources.spec b/src/backend/rpm-tests/hello-sources.spec new file mode 100644 index 0000000000000000000000000000000000000000..53a8afb712c006fd87e384a8ab706f32e951dcee --- /dev/null +++ b/src/backend/rpm-tests/hello-sources.spec @@ -0,0 +1,30 @@ +Name: hello +Version: 1.0 +Release: 1 +Group: Testing +License: GPL +Summary: Simple rpm demonstration. + +%sourcelist +hello-1.0 %tar.gz +hello-addon ! tar\.gz + +%patchlist +hello-1.0-mdernize&renew.patch +hello-1.0-inst(a);;.patch + +%description +Simple rpm demonstration. + +%prep +for f in %{sources} ; do + echo "$f" +done +for f in %{patches} ; do + echo "$f" +done + +%files +%doc FAQ +/usr/local/bin/hello + diff --git a/src/backend/rpm-tests/hello.spec b/src/backend/rpm-tests/hello.spec new file mode 100644 index 0000000000000000000000000000000000000000..120aa8d2265e52dce66b5e7f30d2ee206ea7d6b9 --- /dev/null +++ b/src/backend/rpm-tests/hello.spec @@ -0,0 +1,43 @@ +# To whom it may concern: +# DO NOT COPY THIS SPEC or its derivates to your testcase. That is, +# unless your test-case actually requires running a compiler and +# inspecting it's output. Everybody else should use a simple noarch +# package which can be built under runroot in the test-suite. + +Summary: hello -- hello, world rpm +Name: hello +Version: 1.0 +Release: 1 +Group: Utilities +License: GPL +SourceLicense: GPL, ASL 1.0 +Distribution: RPM test suite. +URL: http://rpm.org +Source0: hello-1.0.tar.gz +Patch0: hello-1.0-modernize.patch +Prefix: /usr + +%description +Simple rpm demonstration. + +%prep +%setup -q +%patch -p1 -b .modernize 0 + +%build +make + +%install +mkdir -p $RPM_BUILD_ROOT/usr/local/bin +make DESTDIR=$RPM_BUILD_ROOT install + +%files +%defattr(-,root,root) +%doc FAQ +#%readme README +#%license COPYING +%attr(0751,root,root) /usr/local/bin/hello + +%changelog +* Tue Oct 20 1998 Jeff Johnson +- create. diff --git a/src/backend/rpm-tests/hello2-suid.spec b/src/backend/rpm-tests/hello2-suid.spec new file mode 100644 index 0000000000000000000000000000000000000000..c9333dec3cdabcbb69046bf17688a391d047c847 --- /dev/null +++ b/src/backend/rpm-tests/hello2-suid.spec @@ -0,0 +1,48 @@ +Summary: hello2 -- double hello, world rpm +Name: hello2 +Version: 1.0 +Release: 1 +Group: Utilities +License: GPL +Distribution: RPM test suite. +URL: http://rpm.org +Source0: hello-1.0.tar.gz +Patch0: hello-1.0-modernize.patch +Prefix: /usr + +%description +Simple rpm demonstration. + +%prep +%setup -q -n hello-1.0 +%patch0 -p1 -b .modernize + +%build +make CFLAGS="-g -O1" +mv hello hello2 +make CFLAGS="-g -O2 -D_FORTIFY_SOURCE=2" + +%install +mkdir -p $RPM_BUILD_ROOT/usr/local/bin +# Note explicit install hello as suid +install -m 4755 hello $RPM_BUILD_ROOT/usr/local/bin +install -m 755 hello2 $RPM_BUILD_ROOT/usr/local/bin + +%files +# Note we don't set any attrs. We expect the suid flag to have been picked up. +/usr/local/bin/hello +/usr/local/bin/hello2 +%defattr(-,root,root) +%doc FAQ +#%readme README +#%license COPYING + +%changelog +* Tue Jun 14 2016 Mark Wielaard +- Make hello (implicit) suid + +* Wed May 18 2016 Mark Wielaard +- Add hello2 for dwz testing support. + +* Tue Oct 20 1998 Jeff Johnson +- create. diff --git a/src/backend/rpm-tests/hello2.spec b/src/backend/rpm-tests/hello2.spec new file mode 100644 index 0000000000000000000000000000000000000000..aed3add9069ac47ed7fa8415052dffcdbf398f07 --- /dev/null +++ b/src/backend/rpm-tests/hello2.spec @@ -0,0 +1,43 @@ +Summary: hello2 -- double hello, world rpm +Name: hello2 +Version: 1.0 +Release: 1 +Group: Utilities +License: GPL +Distribution: RPM test suite. +URL: http://rpm.org +Source0: hello-1.0.tar.gz +Patch0: hello-1.0-modernize.patch +Prefix: /usr + +%description +Simple rpm demonstration. + +%prep +%setup -q -n hello-1.0 +%patch -p1 -b .modernize -P0 + +%build +make CFLAGS="-g -O1" +mv hello hello2 +make CFLAGS="-g -O2 -D_FORTIFY_SOURCE=2" + +%install +mkdir -p $RPM_BUILD_ROOT/usr/local/bin +make DESTDIR=$RPM_BUILD_ROOT install +cp hello2 $RPM_BUILD_ROOT/usr/local/bin/ + +%files +%defattr(-,root,root) +%doc FAQ +#%readme README +#%license COPYING +%attr(0751,root,root) /usr/local/bin/hello +%attr(0751,root,root) /usr/local/bin/hello2 + +%changelog +* Wed May 18 2016 Mark Wielaard +- Add hello2 for dwz testing support. + +* Tue Oct 20 1998 Jeff Johnson +- create. diff --git a/src/backend/rpm-tests/hello2cp.spec b/src/backend/rpm-tests/hello2cp.spec new file mode 100644 index 0000000000000000000000000000000000000000..0ca4c29003014637e3ec8fb7a2a4a37318fe2aa7 --- /dev/null +++ b/src/backend/rpm-tests/hello2cp.spec @@ -0,0 +1,43 @@ +Summary: hello2 -- double hello, world rpm +Name: hello2 +Version: 1.0 +Release: 1 +Group: Utilities +License: GPL +Distribution: RPM test suite. +URL: http://rpm.org +Source0: hello-1.0.tar.gz +Patch0: hello-1.0-modernize.patch +Prefix: /usr + +%description +Simple rpm demonstration. + +%prep +%setup -q -n hello-1.0 +%patch -p1 -b .modernize 0 + +%build +make CFLAGS="-g -O1" +cp hello hello2 + +%install +mkdir -p $RPM_BUILD_ROOT/usr/local/bin +make DESTDIR=$RPM_BUILD_ROOT install +cp hello2 $RPM_BUILD_ROOT/usr/local/bin/ + +%files +%defattr(-,root,root) +%doc FAQ +%attr(0751,root,root) /usr/local/bin/hello +%attr(0751,root,root) /usr/local/bin/hello2 + +%changelog +* Mon Jun 6 2016 Mark Wielaard +- Copy hello to hello2 for duplicate build-id testing. + +* Wed May 18 2016 Mark Wielaard +- Add hello2 for dwz testing support. + +* Tue Oct 20 1998 Jeff Johnson +- create. diff --git a/src/backend/rpm-tests/hello2ln.spec b/src/backend/rpm-tests/hello2ln.spec new file mode 100644 index 0000000000000000000000000000000000000000..441a7c1f8383fc7f1d9217b0c2daa214f68a876d --- /dev/null +++ b/src/backend/rpm-tests/hello2ln.spec @@ -0,0 +1,42 @@ +Summary: hello2 -- double hello, world rpm +Name: hello2 +Version: 1.0 +Release: 1 +Group: Utilities +License: GPL +Distribution: RPM test suite. +URL: http://rpm.org +Source0: hello-1.0.tar.gz +Patch0: hello-1.0-modernize.patch +Prefix: /usr + +%description +Simple rpm demonstration. + +%prep +%setup -q -n hello-1.0 +%patch -p1 -b .modernize 0 + +%build +make CFLAGS="-g -O1" + +%install +mkdir -p $RPM_BUILD_ROOT/usr/local/bin +make DESTDIR=$RPM_BUILD_ROOT install +ln $RPM_BUILD_ROOT/usr/local/bin/hello $RPM_BUILD_ROOT/usr/local/bin/hello2 + +%files +%defattr(-,root,root) +%doc FAQ +%attr(0751,root,root) /usr/local/bin/hello +%attr(0751,root,root) /usr/local/bin/hello2 + +%changelog +* Mon Jun 6 2016 Mark Wielaard +- Hard link hello to hello2 for duplicate build-id testing. + +* Wed May 18 2016 Mark Wielaard +- Add hello2 for dwz testing support. + +* Tue Oct 20 1998 Jeff Johnson +- create. diff --git a/src/backend/rpm-tests/hlbreak.spec b/src/backend/rpm-tests/hlbreak.spec new file mode 100644 index 0000000000000000000000000000000000000000..d96d17261df9af7b15e010aa3cd27d90a051780c --- /dev/null +++ b/src/backend/rpm-tests/hlbreak.spec @@ -0,0 +1,22 @@ +Name: hlbreak +Version: %{ver} +Release: 0 +License: GPL +Summary: Testing changing hardlink behavior +BuildArch: noarch + +%description +%{summary} + +%install +mkdir -p %{buildroot}/opt +echo "content" > %{buildroot}/opt/file2 +%if %{ver} == 1 +ln %{buildroot}/opt/file2 %{buildroot}/opt/file1 +%endif + +%files +%if %{ver} == 1 +/opt/file1 +%endif +/opt/file2 diff --git a/src/backend/rpm-tests/hlinktest.spec b/src/backend/rpm-tests/hlinktest.spec new file mode 100644 index 0000000000000000000000000000000000000000..0248ac71d4726bcc6ffce685b05f3c4b0d7c6525 --- /dev/null +++ b/src/backend/rpm-tests/hlinktest.spec @@ -0,0 +1,54 @@ +%bcond_with unpackaged_dirs +%bcond_with unpackaged_files +%bcond_with owned_dir +%bcond_with crossdir_links + +Summary: Testing hard link behavior +Name: hlinktest +Version: 1.0 +Release: 1 +License: Testing +Group: Testing +BuildArch: noarch +Provides: /bin/sh +%description + +%install +mkdir -p $RPM_BUILD_ROOT/foo +cat << EOF >> $RPM_BUILD_ROOT/foo/hello +#!/bin/sh +echo %{name}-%{version} +EOF + +cd $RPM_BUILD_ROOT/foo +cat hello > copyllo +cat hello > aaaa +ln aaaa zzzz +chmod a+x hello copyllo +for f in foo bar world; do + ln hello hello-${f} +done + +%if %{with crossdir_links} +mkdir -p $RPM_BUILD_ROOT/xmark +ln $RPM_BUILD_ROOT/foo/aaaa $RPM_BUILD_ROOT/xmark/ +ln $RPM_BUILD_ROOT/foo/hello $RPM_BUILD_ROOT/xmark/ +%endif + +%if %{with unpackaged_dirs} +mkdir -p $RPM_BUILD_ROOT/zoo/ +%endif + +%if %{with unpackaged_files} +touch $RPM_BUILD_ROOT/toot +%endif + +%files +%defattr(-,root,root) +%if %{with owned_dir} +%dir /foo +%endif +%if %{with crossdir_links} +/xmark +%endif +/foo/* diff --git a/src/backend/rpm-tests/ifmultiline.spec b/src/backend/rpm-tests/ifmultiline.spec new file mode 100644 index 0000000000000000000000000000000000000000..0ffd04ea0aeef7011aeeae220244b4ed165c9816 --- /dev/null +++ b/src/backend/rpm-tests/ifmultiline.spec @@ -0,0 +1,26 @@ +Name: ifmultiline +Version: 1.0 +Release: 1 +Group: Testing +License: GPL +BuildArch: noarch +Summary: Test multiline if conditions + +%description +%{summary} + +%install +mkdir -p $RPM_BUILD_ROOT/a +echo "x" > $RPM_BUILD_ROOT/a/empty\ +Caps1 + +%if 1 && ( 9|| \ +1) + +%endif + +%files -n %{name} +/a/emptyCaps1 + + +%changelog diff --git a/src/backend/rpm-tests/iftest.spec b/src/backend/rpm-tests/iftest.spec new file mode 100644 index 0000000000000000000000000000000000000000..c6b04aa1a35e04d53215d0ab7c8fc7beac2f3ca7 --- /dev/null +++ b/src/backend/rpm-tests/iftest.spec @@ -0,0 +1,27 @@ +%define mymacro0 \ +%if 0 \ +%global bbb0 ccc0\ +Summary: macro 0\ +%endif \ +%{nil} + +%define mymacro1 \ +%if 1 \ +%global bbb1 ccc1 \ +Summary: macro 1\ +%endif +%{nil} + +Name: iftest +Version: 1.0 +Release: 1 +Group: Testing +License: GPL +BuildArch: noarch + +%mymacro0 +%mymacro1 + +%description +%bbb0 +%bbb1 diff --git a/src/backend/rpm-tests/klang.spec b/src/backend/rpm-tests/klang.spec new file mode 100644 index 0000000000000000000000000000000000000000..7e917fdc7f7e94430120085deb1e38329454ef63 --- /dev/null +++ b/src/backend/rpm-tests/klang.spec @@ -0,0 +1,63 @@ +Name: klang +Version: 1.0 +Release: 1 +BuildArch: noarch +License: GPL +Summary: Klang frobnizer + +%description +%{summary} + +%package common +Summary: %{SUMMARY} common + +%description common +%{summary} + +%package client +Summary: %{SUMMARY} client + +%description client +%{summary} + +%package server +Summary: %{SUMMARY} server + +%description server +%{summary} + +%install +mkdir -p ${RPM_BUILD_ROOT}/var/lib/klangd +mkdir -p ${RPM_BUILD_ROOT}/usr/bin/ +mkdir -p ${RPM_BUILD_ROOT}/etc +mkdir -p ${RPM_BUILD_ROOT}/%{_sysusersdir} + +echo "aaaa" > ${RPM_BUILD_ROOT}/usr/bin/klang +echo "bbbb" > ${RPM_BUILD_ROOT}/usr/bin/klangd +echo "xxxx" > ${RPM_BUILD_ROOT}/etc/klang.cfg + +cat << EOF > ${RPM_BUILD_ROOT}/%{_sysusersdir}/klang.conf +g klang - +EOF + +cat << EOF > ${RPM_BUILD_ROOT}/%{_sysusersdir}/klangd.conf +u klangd - "Klang server" /var/lib/klangd /sbin/nologin +EOF +cat << EOF > ${RPM_BUILD_ROOT}/%{_sysusersdir}/plong.conf +u plong - "Plong fu" /var/lib/plong /sbin/nologin +g klong - +EOF + +%files common +%{_sysusersdir}/klang.conf +%attr(-,-,klang) /etc/klang.cfg + +%files client +%attr(-,-,klang) /usr/bin/klang + +%files server +%{_sysusersdir}/klangd.conf +%{_sysusersdir}/plong.conf +%attr(-,klangd,klangd) /var/lib/klangd +%attr(-,plong,klong) /var/lib/klangd +/usr/bin/klangd diff --git a/src/backend/rpm-tests/mini.spec b/src/backend/rpm-tests/mini.spec new file mode 100644 index 0000000000000000000000000000000000000000..41b5ec1deb99b04c31c6944284dad4ff4393e6eb --- /dev/null +++ b/src/backend/rpm-tests/mini.spec @@ -0,0 +1,7 @@ +Name: mini +Version: 1 +Release: 1 +License: k +Summary: Minimal spec + +%description diff --git a/src/backend/rpm-tests/parallel.spec b/src/backend/rpm-tests/parallel.spec new file mode 100644 index 0000000000000000000000000000000000000000..f54fc3aa4fc5965a4b93ff6091899f0d7c3aa23b --- /dev/null +++ b/src/backend/rpm-tests/parallel.spec @@ -0,0 +1,50 @@ +Name: parallel +Version: %{ver} +Release: 1 +Summary: Testing parallel install behavior +BuildArch: noarch +License: GPL + +%description +%{summary} + +%package trigger +Summary: %{summary} + +%description trigger +%{summary} + +%transfiletriggerin trigger -- /opt/parallel +echo %transfiletriggerin: $* +cat | wc -l + +%transfiletriggerun trigger -- /opt/parallel +echo %transfiletriggerun: $* +cat | wc -l + +%transfiletriggerpostun trigger -- /opt/parallel +echo %transfiletriggerpostun: $* +cat | wc -l + +%filetriggerin trigger -- /opt/parallel +echo %filetriggerin: $* +cat | wc -l + +%filetriggerpostun trigger -- /opt/parallel +echo %filetriggerpostun: $* +cat | wc -l + + +%install +for d in mydir yourdir; do + datadir=%{buildroot}/opt/parallel/%{version}/${d} + mkdir -p ${datadir} + for f in 1 2 3 4; do + echo ${f} > ${datadir}/${f} + done +done + +%files +/opt/%{name} + +%files trigger diff --git a/src/backend/rpm-tests/poltest.spec b/src/backend/rpm-tests/poltest.spec new file mode 100644 index 0000000000000000000000000000000000000000..625d249737bf000321dfa89500ff4c1c7c33ebe1 --- /dev/null +++ b/src/backend/rpm-tests/poltest.spec @@ -0,0 +1,47 @@ +%define debug_package %{nil} + +Summary: Policy in rpm example +Name: poltest +Version: 1.0 +Release: 2 +Group: Utilities +License: GPL +Requires: poltest-policy +Source0: poltest-%{version}.tar.bz2 +Source1: poltest-policy-%{version}.tar.bz2 +%description +Example for installing policy included in a package header + +%prep +%setup -q +%setup -q -T -D -a 1 + +%build +make CFLAGS="$RPM_OPT_FLAGS" +make -f /usr/share/selinux/devel/Makefile -C poltest-policy-%{version} + +%install +make DESTDIR=%{buildroot} prefix=%{_prefix} install + +%files +%defattr(-,root,root) +%{_bindir}/foo +%{_bindir}/bar + + +%package policy +Summary: Policy for the poltest package +Group: System/Policy +Collections: sepolicy +%description policy +Policy for the poltest package + +%sepolicy policy +%semodule -n foo -t default poltest-policy-%{version}/foo.pp +%semodule -n bar -t mls,targeted poltest-policy-%{version}/bar.pp + +%files policy + +%changelog +* Wed Jul 1 2009 Steve Lawrence +- create diff --git a/src/backend/rpm-tests/prefixtest.spec b/src/backend/rpm-tests/prefixtest.spec new file mode 100644 index 0000000000000000000000000000000000000000..2cde01020876bd2f2a20be3a426867e682f01860 --- /dev/null +++ b/src/backend/rpm-tests/prefixtest.spec @@ -0,0 +1,40 @@ +Name: prefixtest +Version: 1.0 +Release: 1 +Summary: Testing file glob behavior +Group: Testing +License: GPL +BuildArch: noarch +RemovePathPostfixes: g:f + +%description +%{summary} + +%define testdir /opt/%{name} + +%install +mkdir -p $RPM_BUILD_ROOT/%{testdir} +echo "foo" > $RPM_BUILD_ROOT/%{testdir}/weird%%name +for f in bif baf zab zeb zib; do + echo "$f" > $RPM_BUILD_ROOT/%{testdir}/$f +done +for f in bing bang bong; do + mkdir -p $RPM_BUILD_ROOT/%{testdir}/$f +done +mkdir -p $RPM_BUILD_ROOT/%{testdir}/foo +for f in one two three; do + echo "$f" > $RPM_BUILD_ROOT/%{testdir}/foo/$f +done + +ln -s %{testdir}/zab $RPM_BUILD_ROOT/%{testdir}/linkgood +ln -s %{testdir}/zub $RPM_BUILD_ROOT/%{testdir}/linkbad + +%files +%defattr(-,root,root,-) +%{testdir}/b?? +%{testdir}/weird?name +%{testdir}/z* +%{testdir}/l* +%{testdir}/b*g/ +%dir %{testdir}/foo +%{testdir}/foo/* diff --git a/src/backend/rpm-tests/reloc.spec b/src/backend/rpm-tests/reloc.spec new file mode 100644 index 0000000000000000000000000000000000000000..43bb1d2300e8347f23fc5ea9678035e76d0feee1 --- /dev/null +++ b/src/backend/rpm-tests/reloc.spec @@ -0,0 +1,33 @@ +Name: reloc +Version: 1.0 +Release: 1 +Summary: Testing relocation behavior +Group: Testing +License: GPL +Prefixes: /opt/bin /opt/etc /opt/lib +BuildArch: noarch + +%description +%{summary} + +%install +mkdir -p $RPM_BUILD_ROOT/opt/bin +mkdir -p $RPM_BUILD_ROOT/opt/lib +mkdir -p $RPM_BUILD_ROOT/opt/etc +touch $RPM_BUILD_ROOT/opt/bin/typo +touch $RPM_BUILD_ROOT/opt/lib/notlib +touch $RPM_BUILD_ROOT/opt/etc/conf + +%pre -p +for i, p in ipairs(RPM_INSTALL_PREFIX) do + print(i..": "..p) +end + +%post +echo 0: $RPM_INSTALL_PREFIX0 +echo 1: $RPM_INSTALL_PREFIX1 +echo 2: $RPM_INSTALL_PREFIX2 + +%files +%defattr(-,root,root,-) +/opt diff --git a/src/backend/rpm-tests/replacetest.spec b/src/backend/rpm-tests/replacetest.spec new file mode 100644 index 0000000000000000000000000000000000000000..0f86ea62815a12d2176da65e04a7942e2a6fb732 --- /dev/null +++ b/src/backend/rpm-tests/replacetest.spec @@ -0,0 +1,48 @@ +%{!?filetype: %global filetype file} +%{?fixit: %global havepretrans 1} +%{!?user: %global user root} +%{!?grp: %global grp root} + +Name: replacetest%{?subpkg:-%{subpkg}} +Version: %{ver} +Release: 1 +Summary: Testing file replacement behavior + +Group: Testing +License: GPL +BuildArch: noarch + +%description +%{summary} + +%install +mkdir -p $RPM_BUILD_ROOT/opt +case %{filetype} in +file) + echo "%{filedata}" > $RPM_BUILD_ROOT/opt/foo + ;; +link) + ln -s "%{filedata}" $RPM_BUILD_ROOT/opt/foo + ;; +dir) + mkdir -p $RPM_BUILD_ROOT/opt/foo + ;; +datadir) + mkdir -p $RPM_BUILD_ROOT/opt/foo + echo WOOT > $RPM_BUILD_ROOT/opt/foo/%{filedata} + ;; +esac +mkdir -p $RPM_BUILD_ROOT/opt/zoo +echo FOO > $RPM_BUILD_ROOT/opt/goo + +%clean +rm -rf $RPM_BUILD_ROOT + +%if 0%{?havepretrans} +%pretrans -p +%{fixit} +%endif + +%files +%defattr(-,%{user},%{grp},-) +%{?fileattr} /opt/* diff --git a/src/backend/rpm-tests/scriptfail.spec b/src/backend/rpm-tests/scriptfail.spec new file mode 100644 index 0000000000000000000000000000000000000000..6101b4fbba228f32eb052071f5ba92f739ee6d2b --- /dev/null +++ b/src/backend/rpm-tests/scriptfail.spec @@ -0,0 +1,24 @@ +%{!?ver:%define ver 1.0} + +Name: scriptfail +Version: %{ver} +Release: 1 +Summary: Testing script errore behavior + +Group: Testing +License: GPL +BuildArch: noarch + +%description +%{summary} + +%{lua: +for i, s in ipairs({"pre","preun","pretrans","post","postun","posttrans","preuntrans","postuntrans"}) do + print('%'..s..' -e\n') + print('%{!?exit'..s..':%global exit'..s..' 0}\n') + print('exit %{exit'..s..'}\n\n') +end +} + +%files +%defattr(-,root,root,-) diff --git a/src/backend/rpm-tests/scriptfile.spec b/src/backend/rpm-tests/scriptfile.spec new file mode 100644 index 0000000000000000000000000000000000000000..e3a0c2802808f52a02758c989f4d0f2183771cab --- /dev/null +++ b/src/backend/rpm-tests/scriptfile.spec @@ -0,0 +1,54 @@ +Name: scriptfile +Version: 1 +Release: 1 +License: GPL +Group: Testing +Summary: Testing scriptlet file behavior +BuildArch: noarch + +%description + +%build + +for s in verifyscript \ + pre pretrans post posttrans preun preuntrans postun postuntrans \ + triggerprein triggerin triggerun triggerpostun \ + filetriggerin filetriggerun transfiletriggerin transfiletriggerun; do + echo ${s} > ${s}.sh +done + +%pre -f pre.sh + +%pretrans -f pretrans.sh + +%post -f post.sh + +%posttrans -f posttrans.sh + +%preun -f preun.sh + +%preuntrans -f preuntrans.sh + +%postun -f postun.sh + +%postuntrans -f postuntrans.sh + +%verifyscript -f verifyscript.sh + +%triggerprein -f triggerprein.sh -- %{name} + +%triggerin -f triggerin.sh -- %{name} + +%triggerun -f triggerun.sh -- %{name} + +%triggerpostun -f triggerpostun.sh -- %{name} + +%transfiletriggerin -f transfiletriggerin.sh -- /path + +%transfiletriggerun -f transfiletriggerun.sh -- /path + +%filetriggerin -f filetriggerin.sh -- /path + +%filetriggerun -f filetriggerun.sh -- /path + +%files diff --git a/src/backend/rpm-tests/scripts-nice-ionice.spec b/src/backend/rpm-tests/scripts-nice-ionice.spec new file mode 100644 index 0000000000000000000000000000000000000000..d54bf98d557409164c57aade3190256da1309504 --- /dev/null +++ b/src/backend/rpm-tests/scripts-nice-ionice.spec @@ -0,0 +1,48 @@ +Name: scripts-nice-ionice +Version: 1.0 +Release: %{rel} +Summary: Testing reset of nice/ionice levels on scripts +Group: Testing +License: GPL +BuildArch: noarch + +%description +%{summary} + +%files +%defattr(-,root,root,-) + +%pretrans +echo %{name}-%{version}-%{release} PRETRANS $* +echo Nice value is $(/bin/nice) +echo IOnice value is $(/usr/bin/ionice | sed -e 's/^unknown:/none:/') + +%pre +echo %{name}-%{version}-%{release} PRE $* +echo Nice value is $(/bin/nice) +echo IOnice value is $(/usr/bin/ionice | sed -e 's/^unknown:/none:/') + +%post +echo %{name}-%{version}-%{release} POST $* +echo Nice value is $(/bin/nice) +echo IOnice value is $(/usr/bin/ionice | sed -e 's/^unknown:/none:/') + +%preun +echo %{name}-%{version}-%{release} PREUN $* +echo Nice value is $(/bin/nice) +echo IOnice value is $(/usr/bin/ionice | sed -e 's/^unknown:/none:/') + +%postun +echo %{name}-%{version}-%{release} POSTUN $* +echo Nice value is $(/bin/nice) +echo IOnice value is $(/usr/bin/ionice | sed -e 's/^unknown:/none:/') + +%posttrans +echo %{name}-%{version}-%{release} POSTTRANS $* +echo Nice value is $(/bin/nice) +echo IOnice value is $(/usr/bin/ionice | sed -e 's/^unknown:/none:/') + +%verifyscript +echo %{name}-%{version}-%{release} VERIFY $* +echo Nice value is $(/bin/nice) +echo IOnice value is $(/usr/bin/ionice | sed -e 's/^unknown:/none:/') diff --git a/src/backend/rpm-tests/scripts.spec b/src/backend/rpm-tests/scripts.spec new file mode 100644 index 0000000000000000000000000000000000000000..09f45399875cccbe1b742c0d34286ef65bee3895 --- /dev/null +++ b/src/backend/rpm-tests/scripts.spec @@ -0,0 +1,41 @@ +Name: scripts +Version: 1.0 +Release: %{rel} +Summary: Testing script behavior +Group: Testing +License: GPL +BuildArch: noarch + +%description +%{summary} + +%files +%defattr(-,root,root,-) + +%pretrans +echo %{name}-%{version}-%{release} PRETRANS $* + +%preuntrans +echo %{name}-%{version}-%{release} PREUNTRANS $* + +%pre +echo %{name}-%{version}-%{release} PRE $* + +%post +echo %{name}-%{version}-%{release} POST $* + +%preun +echo %{name}-%{version}-%{release} PREUN $* + +%postun +echo %{name}-%{version}-%{release} POSTUN $* + +%posttrans +echo %{name}-%{version}-%{release} POSTTRANS $* + +%postuntrans +echo %{name}-%{version}-%{release} POSTUNTRANS $* + +%verifyscript +echo %{name}-%{version}-%{release} VERIFY $* + diff --git a/src/backend/rpm-tests/selfconflict.spec b/src/backend/rpm-tests/selfconflict.spec new file mode 100644 index 0000000000000000000000000000000000000000..433669f72ae0d2a1fe98e2d44e4f047ea0cdc30b --- /dev/null +++ b/src/backend/rpm-tests/selfconflict.spec @@ -0,0 +1,21 @@ +Name: selfconflict +Version: 1.0 +Release: 1 +Summary: Testing file conflict behavior within package itself + +Group: Testing +License: GPL +BuildArch: noarch + +%description +%{summary} + +%install +mkdir -p $RPM_BUILD_ROOT/opt/mydir/one +mkdir -p $RPM_BUILD_ROOT/opt/mydir/two +echo "foo" > $RPM_BUILD_ROOT/opt/mydir/one/somefile +echo "bar" > $RPM_BUILD_ROOT/opt/mydir/two/somefile + +%files +%defattr(-,root,root,-) +/opt/mydir diff --git a/src/backend/rpm-tests/shebang.spec b/src/backend/rpm-tests/shebang.spec new file mode 100644 index 0000000000000000000000000000000000000000..fb99ed62d89859ea8d293a74ef176fb72ab2126a --- /dev/null +++ b/src/backend/rpm-tests/shebang.spec @@ -0,0 +1,23 @@ +Name: shebang +Version: 0.1 +Release: 1 +Summary: Testing shebang dependency generation +Group: Testing +License: GPL +BuildArch: noarch + +%description +%{summary} + +%install +mkdir -p %{buildroot}/bin +cat << EOF > %{buildroot}/bin/shebang +#!/bin/blabla +echo shebang +EOF + +chmod a+x %{buildroot}/bin/shebang + +%files +%defattr(-,root,root,-) +/bin/shebang diff --git a/src/backend/rpm-tests/sigpipe.spec b/src/backend/rpm-tests/sigpipe.spec new file mode 100644 index 0000000000000000000000000000000000000000..9a4ef285ce53d004ef58909a5c900476650f6da0 --- /dev/null +++ b/src/backend/rpm-tests/sigpipe.spec @@ -0,0 +1,47 @@ +%bcond_with buildpipe +%bcond_with manyfiles + +Name: sigpipe +Version: 1.0 +Release: 1 +Summary: Testing SIGPIPE behavior + +Group: Testing +License: GPLv2 +BuildArch: noarch + +%description +%{summary} +%end + +%define datadir /opt/%{name}/data + +# Reproducer for https://bugzilla.redhat.com/show_bug.cgi?id=651463 +%if %{with buildpipe} +%prep +bash -c 's=$SECONDS +set -o pipefail +for ((i=0; i < 30; i++)) +do printf hello 2>/dev/null + sleep .1 +done | /bin/sleep 1 +(( (SECONDS-s) < 2 )) || exit 1' +%endif + +%install +mkdir -p %{buildroot}/%{datadir} +%if %{with manyfiles} +for i in {1..32}; do + mkdir %{buildroot}/%{datadir}/${i} + for j in {a..z}; do + touch %{buildroot}/%{datadir}/${i}/${j} + done +done +%endif + +# For simulating https://bugzilla.redhat.com/show_bug.cgi?id=1264198 +%post +kill -PIPE ${PPID} + +%files +%{datadir} diff --git a/src/backend/rpm-tests/source_space.spec b/src/backend/rpm-tests/source_space.spec new file mode 100644 index 0000000000000000000000000000000000000000..b8156c37a012d3e13ec86b02025ded65c893f93c --- /dev/null +++ b/src/backend/rpm-tests/source_space.spec @@ -0,0 +1,14 @@ +Name: source_space +Version: 1.0 +Release: 1 +Summary: Testing source space +License: GPLv2+ +BuildArch: noarch +Source0: source space.tar.gz + +%description +Testing source space + +%prep +%setup -q -c -n source_space + diff --git a/src/backend/rpm-tests/specstep.spec b/src/backend/rpm-tests/specstep.spec new file mode 100644 index 0000000000000000000000000000000000000000..52afb0291d83b456bb8d61ba7ea09211f0868073 --- /dev/null +++ b/src/backend/rpm-tests/specstep.spec @@ -0,0 +1,22 @@ +Name: specstep +Version: 1.0 +Release: 1 +Summary: Testing spec steps +License: GPL +%{?preamble} + +%description +%{summary} + +%prep + +%generate_buildrequires + +%conf + +%build + +%install + +%check + diff --git a/src/backend/rpm-tests/suicidal.spec b/src/backend/rpm-tests/suicidal.spec new file mode 100644 index 0000000000000000000000000000000000000000..77d17d8c9ceea40b18d8d3ff01b2bad68c67874d --- /dev/null +++ b/src/backend/rpm-tests/suicidal.spec @@ -0,0 +1,19 @@ +Name: suicidal +Version: 1 +Release: %{rel} +License: GPL +Group: Testing +Summary: Testing suicidal package behavior +BuildArch: noarch + +%description + +%build +mkdir -p %{buildroot}/opt +echo shoot > %{buildroot}/opt/foot + +%pre -p +os.remove('/opt/foot') + +%files +/opt/foot diff --git a/src/backend/rpm-tests/symlinktest.spec b/src/backend/rpm-tests/symlinktest.spec new file mode 100644 index 0000000000000000000000000000000000000000..a2bee07e7a51aa756d33eded2a8fa2fe8acc12ba --- /dev/null +++ b/src/backend/rpm-tests/symlinktest.spec @@ -0,0 +1,30 @@ +%bcond_with symlink + +Name: symlinktest +Version: 1.0 +Release: %{rel} +Summary: Testing symlink behavior +Group: Testing +License: GPL +BuildArch: noarch + +%description +%{summary} + +%install +mkdir -p $RPM_BUILD_ROOT/usr/share +%if %{with symlink} +mkdir -p $RPM_BUILD_ROOT/usr/lib/%{name} +echo %{name} > $RPM_BUILD_ROOT/usr/lib/%{name}/README +ln -s ../lib/%{name} $RPM_BUILD_ROOT/usr/share/%{name} +%else +mkdir -p $RPM_BUILD_ROOT/usr/share/%{name} +echo %{name} > $RPM_BUILD_ROOT/usr/share/%{name}/README +%endif + +%files +%defattr(-,root,root,-) +%if %{with symlink} +/usr/lib/%{name} +%endif +/usr/share/%{name} diff --git a/src/backend/rpm-tests/test-parsebits.spec b/src/backend/rpm-tests/test-parsebits.spec new file mode 100644 index 0000000000000000000000000000000000000000..99ac54b7c46acf40f29db39c4bb623e7c8c1c838 --- /dev/null +++ b/src/backend/rpm-tests/test-parsebits.spec @@ -0,0 +1,27 @@ +Name: test-parsebits +Version: v1 +Release: r1 + +Summary: a test of parseBits behaviour +License: GPLv2+ +BuildArch: noarch + +%{?extra:%{extra}} +Requires: good.0.1 +Requires(): good.0.2 = v0 +Requires(interp): good.1.1 > v1 +Requires(preun): good.2.1 >= v2 +Requires(pre): good.3.1 < v3 +Requires(postun): good.4.1 <= v4 +Requires(post): good.5.1 +Requires(rpmlib): good.6.1 = v6 +Requires(verify): good.7.1 > v7 +Requires(pretrans): good.8.1 >= v8 +Requires(posttrans): good.9.1 < v9 +Requires(pre,postun): good.34.1 <= v34 +Requires(interp,preun,pre,postun,post,rpmlib,verify,pretrans,posttrans): good.19.1 + +%description +This is %summary. + +%files diff --git a/src/backend/rpm-tests/test-subpackages-exclude.spec b/src/backend/rpm-tests/test-subpackages-exclude.spec new file mode 100644 index 0000000000000000000000000000000000000000..e93b10b70ae87be3395d1733e33eabff8f6f4f81 --- /dev/null +++ b/src/backend/rpm-tests/test-subpackages-exclude.spec @@ -0,0 +1,42 @@ +Name: test +Version: 1.0 +Release: 1 +Summary: Test + +License: Public Domain +URL: https://fedoraproject.org +Source: hello.c + +%description +%{summary}. + +%package test2 +Summary: Test2. +%description test2 + +%prep +%autosetup -c -D -T +cp -a %{S:0} . + +%build +gcc -g hello.c -o hello +cp hello.c hello2.c +gcc -g hello2.c -o hello2 +cp hello.c hello3.c +gcc -g hello3.c -o hello3 + +%install +mkdir -p %{buildroot}/bin +install -D -p -m 0755 -t %{buildroot}/bin hello +install -D -p -m 0755 -t %{buildroot}/bin hello2 +# Install it, but then exclude it... +install -D -p -m 0755 -t %{buildroot}/bin hello3 + +%files +/bin/hello + +%files test2 +/bin/hello2 +%exclude /bin/hello3 + +%changelog diff --git a/src/backend/rpm-tests/test-subpackages-pathpostfixes.spec b/src/backend/rpm-tests/test-subpackages-pathpostfixes.spec new file mode 100644 index 0000000000000000000000000000000000000000..19b3b9e97a9ddcdb08ec59f0824da416629d2581 --- /dev/null +++ b/src/backend/rpm-tests/test-subpackages-pathpostfixes.spec @@ -0,0 +1,39 @@ +Name: test +Version: 1.0 +Release: 1 +Summary: Test + +License: Public Domain +URL: https://fedoraproject.org +Source: hello.c + +%description +%{summary}. + +%package test2 +RemovePathPostfixes: .foobar +Summary: Test2. +%description test2 + +%prep +%autosetup -c -D -T +cp -a %{S:0} . + +%build +gcc -g hello.c -o hello +cp hello.c hello2.c +gcc -g hello2.c -o hello.foobar + +%install +mkdir -p %{buildroot}/bin +install -D -p -m 0755 -t %{buildroot}/bin hello +# Install as hello.foobar, but we want the postfix removed in the package... +install -D -p -m 0755 -t %{buildroot}/bin hello.foobar + +%files +/bin/hello + +%files test2 +/bin/hello.foobar + +%changelog diff --git a/src/backend/rpm-tests/test-subpackages.spec b/src/backend/rpm-tests/test-subpackages.spec new file mode 100644 index 0000000000000000000000000000000000000000..830660082634c4112c3249c63eca00d69b5516e3 --- /dev/null +++ b/src/backend/rpm-tests/test-subpackages.spec @@ -0,0 +1,47 @@ +Name: test +Version: 1.0 +Release: 1 +Summary: Test + +License: Public Domain +URL: https://fedoraproject.org +Source: hello.c + +%description +%{summary}. + +%package test2 +Summary: Test2. +%description test2 + +%package test3 +Summary: Test3. +%description test3 + +%prep +%autosetup -c -D -T +cp -a %{S:0} . + +%build +gcc -g hello.c -o hello +cp hello.c hello2.c +gcc -g hello2.c -o hello2 +cp hello.c hello3.c +gcc -g hello3.c -o hello3 + +%install +mkdir -p %{buildroot}/bin +install -D -p -m 0755 -t %{buildroot}/bin hello +install -D -p -m 0755 -t %{buildroot}/bin hello2 +install -D -p -m 0755 -t %{buildroot}/bin hello3 + +%files +/bin/hello + +%files test2 +/bin/hello2 + +%files test3 +/bin/hello3 + +%changelog diff --git a/src/backend/rpm-tests/testdoc.spec b/src/backend/rpm-tests/testdoc.spec new file mode 100644 index 0000000000000000000000000000000000000000..7cdfb7433091aec11d5a452f20f380d6695b8e2c --- /dev/null +++ b/src/backend/rpm-tests/testdoc.spec @@ -0,0 +1,32 @@ +Summary: testdoc +Name: testdoc +Version: 1.0 +Release: 1 +Group: Utilities +License: GPLv2+ +Distribution: RPM test suite. +BuildArch: noarch + +%description +Package for testing rpm install option "--excludedocs". + +%install +mkdir -p %{buildroot}%{_datadir}/testdoc +echo "nodoc" > %{buildroot}%{_datadir}/testdoc/nodoc + +mkdir -p %{buildroot}%{_docdir}/testdoc +echo "doc1" > %{buildroot}%{_docdir}/testdoc/documentation1 +echo "doc2" > %{buildroot}%{_docdir}/testdoc/documentation2 + +mkdir -p %{buildroot}%{_docdir}/testdoc/examples +echo "example1" > %{buildroot}%{_docdir}/testdoc/examples/example1 +echo "example2" > %{buildroot}%{_docdir}/testdoc/examples/example2 + +%files +%{_datadir}/testdoc/nodoc +%dir %{_docdir}/testdoc +%doc %{_docdir}/testdoc/documentation1 +%doc %{_docdir}/testdoc/documentation2 +%dir %{_docdir}/testdoc/examples +%doc %{_docdir}/testdoc/examples/example1 +%doc %{_docdir}/testdoc/examples/example2 diff --git a/src/backend/rpm-tests/triggers.spec b/src/backend/rpm-tests/triggers.spec new file mode 100644 index 0000000000000000000000000000000000000000..ae447b60b31ebbfbc2aef2cc027ecb0ba1724be6 --- /dev/null +++ b/src/backend/rpm-tests/triggers.spec @@ -0,0 +1,26 @@ +Name: triggers +Version: 1.0 +Release: %{rel} +Summary: Testing trigger behavior +Group: Testing +License: GPL +BuildArch: noarch + +%description +%{summary} + +%files +%defattr(-,root,root,-) + +%triggerprein -- %{trigpkg} +echo %{name}-%{version}-%{release} TRIGGERPREIN $* + +%triggerin -- %{trigpkg} +echo %{name}-%{version}-%{release} TRIGGERIN $* + +%triggerun -- %{trigpkg} +echo %{name}-%{version}-%{release} TRIGGERUN $* + +%triggerpostun -- %{trigpkg} +echo %{name}-%{version}-%{release} TRIGGERPOSTUN $* + diff --git a/src/backend/rpm-tests/vattrtest.spec b/src/backend/rpm-tests/vattrtest.spec new file mode 100644 index 0000000000000000000000000000000000000000..8504c8325bba2f941a39bf3e999faebd0d758254 --- /dev/null +++ b/src/backend/rpm-tests/vattrtest.spec @@ -0,0 +1,27 @@ +Name: vattrtest +Version: 1.0 +Release: 1 +Summary: Testing virtual file attribute behavior +Group: Testing +License: GPL +BuildArch: noarch + +%description +%{summary} + +%install +mkdir -p $RPM_BUILD_ROOT/opt/%{name} +for x in a c cn d g l m r; do + echo ${x} > $RPM_BUILD_ROOT/opt/%{name}/${x} +done + +%files +%dir /opt/%{name} +%artifact /opt/%{name}/a +%config /opt/%{name}/c +%config(noreplace) /opt/%{name}/cn +%doc /opt/%{name}/d +%ghost /opt/%{name}/g +%license /opt/%{name}/l +%missingok /opt/%{name}/m +%readme /opt/%{name}/r diff --git a/src/backend/rpm-tests/verifyfiles.spec b/src/backend/rpm-tests/verifyfiles.spec new file mode 100644 index 0000000000000000000000000000000000000000..44989f7eee32df8504b16af9fb99328b94301a43 --- /dev/null +++ b/src/backend/rpm-tests/verifyfiles.spec @@ -0,0 +1,22 @@ +Name: verifyfiles +Version: 1.0 +Release: 1 +Group: Testing +License: GPL +Summary: Testing verifyfiles behavior +BuildArch: noarch + +%description +%summary. + +%prep + +%build + +%install +touch %{buildroot}/test-verify1 +touch %{buildroot}/test-verify2 + +%files +%verify(mode md5 size mtime) /test-verify1 +%verify(not mode) /test-verify2 diff --git a/src/backend/rpm-tests/verifyscript.spec b/src/backend/rpm-tests/verifyscript.spec new file mode 100644 index 0000000000000000000000000000000000000000..cc7a1249ed4497f9db0c3f5eb6e2c71ca6eb7a9c --- /dev/null +++ b/src/backend/rpm-tests/verifyscript.spec @@ -0,0 +1,19 @@ +Name: verifyscript +Version: 1.0 +Release: 1 +Summary: Testing verifyscript behavior + +Group: Testing +License: GPL +BuildArch: noarch + +%description +%{summary} + +%verifyscript -p +if not posix.access("/var/checkme", "f") then + error("bad") +end + +%files +%defattr(-,root,root) diff --git a/src/backend/rpm-tests/versiontest.spec b/src/backend/rpm-tests/versiontest.spec new file mode 100644 index 0000000000000000000000000000000000000000..c9964014369d0ea92d30a8bd00108fea0d73fe76 --- /dev/null +++ b/src/backend/rpm-tests/versiontest.spec @@ -0,0 +1,17 @@ +Name: versiontest +Version: %{ver} +Release: 1 +%if %{defined:epoch} +Epoch: %{epoch} +%endif +Summary: Testing version behavior + +Group: Testing +License: GPL +BuildArch: noarch + +%description +%{summary} + +%files +%defattr(-,root,root) diff --git a/src/backend/rpm-tests/weirdnames.spec b/src/backend/rpm-tests/weirdnames.spec new file mode 100644 index 0000000000000000000000000000000000000000..e241e4c264029f2a7853cd43689add9d33311ffa --- /dev/null +++ b/src/backend/rpm-tests/weirdnames.spec @@ -0,0 +1,37 @@ +%bcond_with illegal + +Name: weirdnames +Version: 1.0 +Release: 1 +Summary: Testing weird filename behavior +License: GPL +BuildArch: noarch + +%description +%{summary} + +%install +mkdir -p %{buildroot}/opt +cd %{buildroot}/opt +touch "foo'ed" 'bar"ed' "just space" "\$talks" \ + "to?be" "the * are falling" '#nocomment' "(maybe)" \ + "perhaps;not" "true:false" "!absolutely" "&ground" \ + "after{all}" "index[this]" "equals=not" "tee|two" "~right" \ + "" +%if %{with illegal} +touch "only time" +# the dependency generator cannot handle newlines in filenames +touch "new +line" + +%endif +for f in *; do + echo -e "#!/bin/ary\ndada\n" > ${f} +done +chmod a+x * + +# script.req fails on the backslash +touch "\.back" + +%files +/opt/* diff --git a/src/backend/test.py b/src/backend/test.py new file mode 100644 index 0000000000000000000000000000000000000000..9fd3c355e75b9294da9ac6ded0edb140da1ba2c3 --- /dev/null +++ b/src/backend/test.py @@ -0,0 +1,24 @@ +import os +import time + +from tqdm import tqdm +from antlr4 import FileStream + +from pcc.parse import parse + +folder = os.path.join(os.path.dirname(__file__), 'rpm-tests') +filenames = os.listdir(folder) +failed_count = 0 +for filename in tqdm(filenames): + path = os.path.join(folder, filename) + a = parse(FileStream(path)) + if a.failed: + print('='*40+f'\nParse {filename}\n'+'='*40) + print('Text:') + with open(path) as f: + print(''.join(f'{line_no+1: 3d} | {txt}' for line_no, txt in enumerate(f.readlines()))) + print('-'*40) + print('\n'.join(a.result)) + failed_count += 1 + input('...') +print(f'Parse success: {len(filenames) - failed_count} / {len(filenames)}')