From 196ad1b56e2e791f9f4d4aa82d96ac6a5681664c Mon Sep 17 00:00:00 2001 From: Anton Novojilov Date: Wed, 11 Sep 2024 13:27:01 +0300 Subject: [PATCH 1/2] Improve spec validation --- SOURCES/libexec/build.shx | 24 +++++++++++++----------- SOURCES/libexec/spec.shx | 2 +- SOURCES/rpmbuilder | 2 +- rpmbuilder.spec | 5 ++++- 4 files changed, 19 insertions(+), 14 deletions(-) diff --git a/SOURCES/libexec/build.shx b/SOURCES/libexec/build.shx index d9190b5..f356f86 100644 --- a/SOURCES/libexec/build.shx +++ b/SOURCES/libexec/build.shx @@ -23,21 +23,23 @@ startBuild() { local spec="$1" local err - if ! isSpecFile "$spec" ; then - if isSpecFile "${spec}.spec" ; then - [[ -r "${spec}.source" && -z "$source_list" ]] && source_list="$spec.source" - spec="${spec}.spec" - else - err=$(validateSpec "$spec") + if isSpecFile "${spec}.spec" ; then + spec="${spec}.spec" + if [[ -r "${spec}.source" && -z "$source_list" ]] ; then + source_list="$spec.source" + fi + fi - error "\"$spec\" is not a spec file!" + if ! isSpecFile "$spec" ; then + err=$(validateSpec "$spec") - if [[ -n "$err" ]] ; then - error "$err" - fi + error "\"$spec\" is not a valid spec file!" - doExit $ERROR_SPEC + if [[ -n "$err" ]] ; then + error "$err" fi + + doExit $ERROR_SPEC fi checkOptions diff --git a/SOURCES/libexec/spec.shx b/SOURCES/libexec/spec.shx index 08b465a..b3b6360 100644 --- a/SOURCES/libexec/spec.shx +++ b/SOURCES/libexec/spec.shx @@ -36,7 +36,7 @@ isSpecFile() { # Code: Yes # Echo: Validation error (String) validateSpec() { - spectool -n "$1" 1>/dev/null 2>&1 + spectool -n "$1" 2>&1 | grep 'error: ' return $? } diff --git a/SOURCES/rpmbuilder b/SOURCES/rpmbuilder index f4152e5..de39e4e 100755 --- a/SOURCES/rpmbuilder +++ b/SOURCES/rpmbuilder @@ -13,7 +13,7 @@ fi APP="RPMBuilder" # Utility version (String) -VER="3.4.0" +VER="3.4.1" # Utility description (String) DESC="RPM package build helper" diff --git a/rpmbuilder.spec b/rpmbuilder.spec index 4726caa..f18585a 100644 --- a/rpmbuilder.spec +++ b/rpmbuilder.spec @@ -6,7 +6,7 @@ Summary: RPM package build helper Name: rpmbuilder -Version: 3.4.0 +Version: 3.4.1 Release: 0%{?dist} License: Apache License, Version 2.0 Group: Development/Tools @@ -58,6 +58,9 @@ install -pm 644 libexec/* %{buildroot}%{_libexecdir}/%{name}/ ################################################################################ %changelog +* Wed Sep 11 2024 Anton Novojilov - 3.4.1-0 +- Improved spec validation + * Mon Sep 09 2024 Anton Novojilov - 3.4.0-0 - Added 'define' option validation - Pass macros from 'define' option to spec-builddep From 8a03ba817839827c5de43b4cc1b3e1c6803dcb15 Mon Sep 17 00:00:00 2001 From: Anton Novojilov Date: Wed, 11 Sep 2024 14:25:34 +0300 Subject: [PATCH 2/2] Improve spec validation --- SOURCES/libexec/build.shx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SOURCES/libexec/build.shx b/SOURCES/libexec/build.shx index f356f86..c58f26b 100644 --- a/SOURCES/libexec/build.shx +++ b/SOURCES/libexec/build.shx @@ -24,10 +24,10 @@ startBuild() { local err if isSpecFile "${spec}.spec" ; then - spec="${spec}.spec" if [[ -r "${spec}.source" && -z "$source_list" ]] ; then source_list="$spec.source" fi + spec="${spec}.spec" fi if ! isSpecFile "$spec" ; then