From 908b68dd847b91fe6fc82a9303042769a4f90718 Mon Sep 17 00:00:00 2001 From: Anton Novojilov Date: Tue, 10 Sep 2024 00:03:18 +0300 Subject: [PATCH 1/6] Improvements --- SOURCES/libexec/build.shx | 17 ++++++++++++++--- SOURCES/rpmbuilder | 15 ++++++++------- rpmbuilder.spec | 15 ++++++++------- 3 files changed, 30 insertions(+), 17 deletions(-) diff --git a/SOURCES/libexec/build.shx b/SOURCES/libexec/build.shx index 1a1e866..a0834b9 100644 --- a/SOURCES/libexec/build.shx +++ b/SOURCES/libexec/build.shx @@ -326,6 +326,17 @@ checkOptions() { doExit $ERROR_UNKNOWN fi fi + + if [[ -n "$define" ]] ; then + local macro_def + + for macro_def in $define ; do + if [[ ${macro_def:0:1} != "_" ]] ; then + error "Invalid macro name definition (must start with \"_\")" + doExit $ERROR_UNKNOWN + fi + done + fi } # Print message and exit from utility @@ -525,11 +536,11 @@ getBuildOpts() { # Code: No # Echo: Options (String) getDefineOpts() { - local opts macros_def + local opts macro_def if [[ -n "$define" ]] ; then - for macros_def in $define ; do - opts="--define=\"${macros_def/=/ }\" ${opts}" + for macro_def in $define ; do + opts="--define=\"${macro_def/:/ }\" ${opts}" done fi diff --git a/SOURCES/rpmbuilder b/SOURCES/rpmbuilder index 1722d95..3d2a4ed 100755 --- a/SOURCES/rpmbuilder +++ b/SOURCES/rpmbuilder @@ -13,7 +13,7 @@ fi APP="RPMBuilder" # Utility version (String) -VER="3.3.4" +VER="3.4.0" # Utility description (String) DESC="RPM package build helper" @@ -473,8 +473,8 @@ usage() { show "" show " rpmbuilder package.spec -sl sources/current -d ~/mypackages" $GREY show " rpmbuilder package.spec --source-list files.list --dest ~/mypackages" $GREY - show " rpmbuilder package.spec --pack \"file1 file2 dir1 dir2 file3\"" $GREY - show " rpmbuilder package.spec -p \"file1 file2\" -p \"dir1 dir2 file3\" -p file4" $GREY + show ' rpmbuilder package.spec --pack "file1 file2 dir1 dir2 file3"' $GREY + show ' rpmbuilder package.spec -p "file1 file2" -p "dir1 dir2 file3" -p file4' $GREY show " rpmbuilder package.spec --git git://github.com/user/project.git --tag 1.3-12" $GREY show " rpmbuilder package.spec --git git://github.com/user/project.git -rb develop" $GREY show " rpmbuilder package.spec --git git://github.com/user/project.git -rr f8debbfdbebb97f5d0ee2218edf1425ac219cff5" $GREY @@ -505,7 +505,8 @@ usage() { show " rpmbuilder package.spec -r builder@192.168.1.100 -r builder@192.168.1.101 -k ~/.ssh/id_rsa" $GREY show " rpmbuilder package.spec -r builder:mypass@127.0.0.1:2022~i386 -k ~/.ssh/id_ed25519" $GREY show " rpmbuilder package.spec --remote ~/buildnodes.list --key ~/.ssh/id_ed25519" $GREY - show " rpmbuilder package.spec --remote builder@127.0.0.1:5001 --key \$(base64 -w0 ~/.ssh/id_ed25519)" $GREY + # shellcheck disable=SC2016 + show ' rpmbuilder package.spec --remote builder@127.0.0.1:5001 --key $(base64 -w0 ~/.ssh/id_ed25519)' $GREY show " rpmbuilder package.spec --parallel --remote ~/buildnodes.list --node 1,2" $GREY show "" show "Build options" $BOLD @@ -522,14 +523,14 @@ usage() { show "" showo "--with, -w" "Pass conditional parameters into a rpmbuild ${CL_DARK}(mergeable)${CL_NORM}" "param" showo "--without, -W" "Pass conditional parameters into a rpmbuild ${CL_DARK}(mergeable)${CL_NORM}" "param" - showo "--define, -D" "Define MACRO with value (exist macro will be not redefined) ${CL_DARK}(mergeable)${CL_NORM}" "\"macro=value\"" + showo "--define, -D" "Define MACRO with value (exist macro will be not redefined) ${CL_DARK}(mergeable)${CL_NORM}" 'name:value' show "" show " Examples" $BOLD show "" show " rpmbuilder package.spec --with ssl --with ldap" $GREY show " rpmbuilder package.spec -w ssl -w static -W ldap" $GREY - show " rpmbuilder package.spec --with \"ssl ldap\"" $GREY - show " rpmbuilder package.spec --define \"install_dir=/some/dir\" --define \"service_user=someone\"" $GREY + show ' rpmbuilder package.spec --with "ssl ldap"' $GREY + show ' rpmbuilder package.spec --define="_install_dir:/some/dir" --define="_service_user:someone' $GREY show "" show " More info: https://kaos.sh/rpmbuilder/w/Conditional-Builds" $DARK show "" diff --git a/rpmbuilder.spec b/rpmbuilder.spec index cdffdad..52ac3d2 100644 --- a/rpmbuilder.spec +++ b/rpmbuilder.spec @@ -6,7 +6,7 @@ Summary: RPM package build helper Name: rpmbuilder -Version: 3.3.4 +Version: 3.4.0 Release: 0%{?dist} License: Apache License, Version 2.0 Group: Development/Tools @@ -32,9 +32,8 @@ RPM package build helper. ################################################################################ %prep -%{crc_check} - -%setup -q +%crc_check +%autosetup %build %install @@ -47,9 +46,6 @@ install -pm 755 rpmbuilder %{buildroot}%{_bindir}/rpmbuilder install -pm 755 rpmunbuilder %{buildroot}%{_bindir}/rpmunbuilder install -pm 644 libexec/* %{buildroot}%{_libexecdir}/%{name}/ -%clean -rm -rf %{buildroot} - ################################################################################ %files @@ -62,6 +58,11 @@ rm -rf %{buildroot} ################################################################################ %changelog +* Mon Sep 09 2024 Anton Novojilov - 3.4.0-0 +- Added 'define' option validation +- Changed macro definition from 'name=value' to 'name:value' +- Code refactoring + * Thu Sep 05 2024 Anton Novojilov - 3.3.4-0 - Removed rpmlint from dependencies - Improved support of rpmlint installed from pip/uv From 60fe92488e60e0de0cb629d95b05e7111b14fa52 Mon Sep 17 00:00:00 2001 From: Anton Novojilov Date: Tue, 10 Sep 2024 00:04:19 +0300 Subject: [PATCH 2/6] Improvements --- .github/images/usage.svg | 203 ++++++++++++++++++++------------------- 1 file changed, 102 insertions(+), 101 deletions(-) diff --git a/.github/images/usage.svg b/.github/images/usage.svg index 99766cc..cd29d57 100644 --- a/.github/images/usage.svg +++ b/.github/images/usage.svg @@ -1,4 +1,4 @@ - + RPMBuilder Usage @@ -14,12 +14,13 @@ text { font-family: ui-monospace, 'JetBrains Mono', 'Fira Code', 'Iosevka', SFMono-Regular, 'SF Mono', Menlo, Consolas, 'Liberation Mono', monospace; font-size: 14px; font-display: swap; white-space: pre; } tspan { white-space: pre; } - .bold { font-weight: bold; } - .italic { font-style: italic; } - .underline { text-decoration-line: underline; } - .dim { opacity: 0.75; } .terminal { font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans", Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji"; font-weight: 500; font-size: 15px; } + tspan.BB { font-weight: bold; } + tspan.II { font-style: italic; } + tspan.UU { text-decoration-line: underline; } + tspan.DD { opacity: 0.75; } + text { fill: #F5F5F5; } .terminal { fill: #DDD; } .bg { fill: #222; stop-color: #222; } @@ -30,8 +31,8 @@ tspan.b { fill: #5C9AD8; } tspan.m { fill: #B6419E; } tspan.c { fill: #38AFC5; } - tspan.LG { fill: #AAA; } - tspan.DG { fill: #696969; } + tspan.s { fill: #AAA; } + tspan.d { fill: #696969; } tspan.R { fill: #EF5A56; } tspan.G { fill: #49E471; } tspan.Y { fill: #E3E342; } @@ -54,103 +55,103 @@ Terminal - Usage: rpmbuilder {spec-file} {options} - Spec file + Usage: rpmbuilder {spec-file} {options} + Spec file You can specify an absolute or relative path to the spec file. You can also specify spec name only (without extension). In this case, rpmbuilder will try to use {name}.spec file for build and try to find {name}.source file and use it as source list. - Source packaging - --pack, -p files ................... Pack specified files to archive with default source name (mergeable) - --relative-pack, -R ................ Use relative path in source archive instead of absolute - --source-dir, -sd path ............. Path to a directory which contains source files specified in spec file - --source-list, -sl file ............ Path to file which contains a list of source files specified in spec file - --dlcache, -dc dir ................. Path to a directory for downloads caching - --download, -dl dir ................ Download all remote sources to a specified directory - --no-validate, -nv ................. Don't validate sources - --git url .......................... Fetch sources from Git repository - --svn url .......................... Fetch sources from SVN repository - --hg url ........................... Fetch sources from Mercurial repository - --bzr url .......................... Fetch sources from Bazaar repository - --path, -rp path ................... Path to a directory with sources in repository - --branch, -rb branch ............... Use specified repository branch - --revision, -rr rev ................ Use specified revision - --tag, -rt tag ..................... Use specified tag - --svn-user, -su username ........... Username for access to SVN repository - --svn-pass, -sp password ........... Password for access to SVN repository - --github, -gh url .................. Fetch sources from github.com repository by url - --github, -gh user:project ......... Fetch sources from github.com repository by user and project - --github, -gh user/project ......... Fetch sources from github.com repository by user and project - --bitbucket, -bb url ............... Fetch sources from bitbucket.org repository by url - --bitbucket, -bb user:project ...... Fetch sources from bitbucket.org repository by user and project - --bitbucket, -bb user/project ...... Fetch sources from bitbucket.org repository by user and project - --launchpad, -lp url ............... Fetch sources from launchpad.net repository by url - --launchpad, -lp project-name ...... Fetch sources from launchpad.net repository by project name - --gopack, -G url ................... Fetch and pack golang sources using gopack - Examples - rpmbuilder package.spec -sl sources/current -d ~/mypackages - rpmbuilder package.spec --source-list files.list --dest ~/mypackages - rpmbuilder package.spec --pack "file1 file2 dir1 dir2 file3" - rpmbuilder package.spec -p "file1 file2" -p "dir1 dir2 file3" -p file4 - rpmbuilder package.spec --git git://github.com/user/project.git --tag 1.3-12 - rpmbuilder package.spec --git git://github.com/user/project.git -rb develop - rpmbuilder package.spec --git git://github.com/user/project.git -rr f8debbfdbebb97f5d0ee2218edf1425ac219cff5 - rpmbuilder package.spec -bb user:project - rpmbuilder package.spec --github https://github.com/user/project/ - rpmbuilder package.spec --gopack github.com/user/project --tag v1.2.3 - Dependencies install - --install, -I ...................... Install build dependencies before build process - --install-latest, -IL .............. Install the latest versions of build dependencies before build process - --enable-repo, -ER repo-name ....... Enable repositories (mergeable) - --disable-repo, -DR repo-name ...... Disable repositories (mergeable) - --exclude-package, -EX package ..... Exclude package by name or glob (mergeable) - Remote build - --parallel, -P ..................... Parallel build on all build nodes in the same time (tmux is required) - --remote, -r user:pass@host:port ... Build rpm package on the remote node with specified host, username and password (mergeable) - --remote, -r file .................. Build rpm package on the remote nodes listed in specified file - --key, -k file ..................... Path to the private key for specified user - --key, -k data ..................... Base64-encoded private key for specified user - --node, -N index-or-name ........... Node index or name from the file with build nodes - --attach, -A ....................... Attach to parallel build session in tmux - Examples - rpmbuilder package.spec -r builder@192.168.1.100 -r builder@192.168.1.101 -k ~/.ssh/id_rsa - rpmbuilder package.spec -r builder:mypass@127.0.0.1:2022~i386 -k ~/.ssh/id_ed25519 - rpmbuilder package.spec --remote ~/buildnodes.list --key ~/.ssh/id_ed25519 - rpmbuilder package.spec --remote builder@127.0.0.1:5001 --key $(base64 -w0 ~/.ssh/id_ed25519) - rpmbuilder package.spec --parallel --remote ~/buildnodes.list --node 1,2 - Build options - --no-build, -NB .................... Don't execute any build stages - --no-clean, -NC .................... Don't remove source files and spec file after build - --no-deps, -ND ..................... Don't verify build dependencies - --no-binary, -NR ................... Don't build binary packages - --no-source, -NS ................... Don't build source package - --arch, -a arch .................... Override target arch for a build - --qa-rpaths "<value>,<value>,..." .. Ignoring rpaths check - Arguments passing - --with, -w param ................... Pass conditional parameters into a rpmbuild (mergeable) - --without, -W param ................ Pass conditional parameters into a rpmbuild (mergeable) - --define, -D "macro=value" ......... Define MACRO with value (exist macro will be not redefined) (mergeable) - Examples - rpmbuilder package.spec --with ssl --with ldap - rpmbuilder package.spec -w ssl -w static -W ldap - rpmbuilder package.spec --with "ssl ldap" - rpmbuilder package.spec --define "install_dir=/some/dir" --define "service_user=someone" - More info: https://kaos.sh/rpmbuilder/w/Conditional-Builds - Spec validation - --no-lint, -0 ...................... Don't check spec file before package build - --strict, -1 ....................... Don't build package if perfecto found major problems in spec file - --pedantic, -2 ..................... Don't build package if perfecto found minor problems in spec file - --perfect, -3 ...................... Don't build package if perfecto found any problems in spec file - Other - --sign, -s ......................... Sign package after build - --dest, -d dir ..................... Save built packages to a specified directory - --keep-log, -kl .................... Save build log after an unsuccessful build - --bump, -b ......................... Bump release in spec file after a successful build - --bump-comment, -bc comment ........ Comment which will be added while release bump - --tmp dir .......................... Path to a temporary directory (default: /var/tmp) - --verbose, -V ...................... Verbose output - --no-color, -nc .................... Disable colors in output - --help, -h ......................... Show this help message - --version, -v ...................... Show information about version + Source packaging + --pack, -p files ................... Pack specified files to archive with default source name (mergeable) + --relative-pack, -R ................ Use relative path in source archive instead of absolute + --source-dir, -sd path ............. Path to a directory which contains source files specified in spec file + --source-list, -sl file ............ Path to file which contains a list of source files specified in spec file + --dlcache, -dc dir ................. Path to a directory for downloads caching + --download, -dl dir ................ Download all remote sources to a specified directory + --no-validate, -nv ................. Don't validate sources + --git url .......................... Fetch sources from Git repository + --svn url .......................... Fetch sources from SVN repository + --hg url ........................... Fetch sources from Mercurial repository + --bzr url .......................... Fetch sources from Bazaar repository + --path, -rp path ................... Path to a directory with sources in repository + --branch, -rb branch ............... Use specified repository branch + --revision, -rr rev ................ Use specified revision + --tag, -rt tag ..................... Use specified tag + --svn-user, -su username ........... Username for access to SVN repository + --svn-pass, -sp password ........... Password for access to SVN repository + --github, -gh url .................. Fetch sources from github.com repository by url + --github, -gh user:project ......... Fetch sources from github.com repository by user and project + --github, -gh user/project ......... Fetch sources from github.com repository by user and project + --bitbucket, -bb url ............... Fetch sources from bitbucket.org repository by url + --bitbucket, -bb user:project ...... Fetch sources from bitbucket.org repository by user and project + --bitbucket, -bb user/project ...... Fetch sources from bitbucket.org repository by user and project + --launchpad, -lp url ............... Fetch sources from launchpad.net repository by url + --launchpad, -lp project-name ...... Fetch sources from launchpad.net repository by project name + --gopack, -G url ................... Fetch and pack golang sources using gopack + Examples + rpmbuilder package.spec -sl sources/current -d ~/mypackages + rpmbuilder package.spec --source-list files.list --dest ~/mypackages + rpmbuilder package.spec --pack "file1 file2 dir1 dir2 file3" + rpmbuilder package.spec -p "file1 file2" -p "dir1 dir2 file3" -p file4 + rpmbuilder package.spec --git git://github.com/user/project.git --tag 1.3-12 + rpmbuilder package.spec --git git://github.com/user/project.git -rb develop + rpmbuilder package.spec --git git://github.com/user/project.git -rr f8debbfdbebb97f5d0ee2218edf1425ac219cff5 + rpmbuilder package.spec -bb user:project + rpmbuilder package.spec --github https://github.com/user/project/ + rpmbuilder package.spec --gopack github.com/user/project --tag v1.2.3 + Dependencies install + --install, -I ...................... Install build dependencies before build process + --install-latest, -IL .............. Install the latest versions of build dependencies before build process + --enable-repo, -ER repo-name ....... Enable repositories (mergeable) + --disable-repo, -DR repo-name ...... Disable repositories (mergeable) + --exclude-package, -EX package ..... Exclude package by name or glob (mergeable) + Remote build + --parallel, -P ..................... Parallel build on all build nodes in the same time (tmux is required) + --remote, -r user:pass@host:port ... Build rpm package on the remote node with specified host, username and password (mergeable) + --remote, -r file .................. Build rpm package on the remote nodes listed in specified file + --key, -k file ..................... Path to the private key for specified user + --key, -k data ..................... Base64-encoded private key for specified user + --node, -N index-or-name ........... Node index or name from the file with build nodes + --attach, -A ....................... Attach to parallel build session in tmux + Examples + rpmbuilder package.spec -r builder@192.168.1.100 -r builder@192.168.1.101 -k ~/.ssh/id_rsa + rpmbuilder package.spec -r builder:mypass@127.0.0.1:2022~i386 -k ~/.ssh/id_ed25519 + rpmbuilder package.spec --remote ~/buildnodes.list --key ~/.ssh/id_ed25519 + rpmbuilder package.spec --remote builder@127.0.0.1:5001 --key $(base64 -w0 ~/.ssh/id_ed25519) + rpmbuilder package.spec --parallel --remote ~/buildnodes.list --node 1,2 + Build options + --no-build, -NB .................... Don't execute any build stages + --no-clean, -NC .................... Don't remove source files and spec file after build + --no-deps, -ND ..................... Don't verify build dependencies + --no-binary, -NR ................... Don't build binary packages + --no-source, -NS ................... Don't build source package + --arch, -a arch .................... Override target arch for a build + --qa-rpaths "<value>,<value>,..." .. Ignoring rpaths check + Arguments passing + --with, -w param ................... Pass conditional parameters into a rpmbuild (mergeable) + --without, -W param ................ Pass conditional parameters into a rpmbuild (mergeable) + --define, -D name:value ............ Define MACRO with value (exist macro will be not redefined) (mergeable) + Examples + rpmbuilder package.spec --with ssl --with ldap + rpmbuilder package.spec -w ssl -w static -W ldap + rpmbuilder package.spec --with "ssl ldap" + rpmbuilder package.spec --define="_install_dir:/some/dir" --define="_service_user:someone + More info: https://kaos.sh/rpmbuilder/w/Conditional-Builds + Spec validation + --no-lint, -0 ...................... Don't check spec file before package build + --strict, -1 ....................... Don't build package if perfecto found major problems in spec file + --pedantic, -2 ..................... Don't build package if perfecto found minor problems in spec file + --perfect, -3 ...................... Don't build package if perfecto found any problems in spec file + Other + --sign, -s ......................... Sign package after build + --dest, -d dir ..................... Save built packages to a specified directory + --keep-log, -kl .................... Save build log after an unsuccessful build + --bump, -b ......................... Bump release in spec file after a successful build + --bump-comment, -bc comment ........ Comment which will be added while release bump + --tmp dir .......................... Path to a temporary directory (default: /var/tmp) + --verbose, -V ...................... Verbose output + --no-color, -nc .................... Disable colors in output + --help, -h ......................... Show this help message + --version, -v ...................... Show information about version From 78e4795f193b087e23fcaae8580c8a4e13edaeac Mon Sep 17 00:00:00 2001 From: Anton Novojilov Date: Tue, 10 Sep 2024 00:30:47 +0300 Subject: [PATCH 3/6] Code refactoring --- SOURCES/libexec/build-local.shx | 10 +++++----- SOURCES/libexec/build-remote.shx | 12 ++++++------ SOURCES/libexec/build.shx | 15 ++++++++++----- SOURCES/libexec/sources-remote.shx | 6 +++--- SOURCES/libexec/sources-scm.shx | 18 +++++++++--------- SOURCES/libexec/sources.shx | 10 +++++----- SOURCES/libexec/spec.shx | 2 +- SOURCES/rpmbuilder | 4 ++-- 8 files changed, 41 insertions(+), 36 deletions(-) diff --git a/SOURCES/libexec/build-local.shx b/SOURCES/libexec/build-local.shx index 361bfaf..0119f99 100644 --- a/SOURCES/libexec/build-local.shx +++ b/SOURCES/libexec/build-local.shx @@ -60,12 +60,12 @@ copySourcesToBuildDir() { if [[ $? -ne 0 ]] ; then source_file_name=$(basename "$source_file") - error "Can't copy source file ${CL_BL_RED}${source_file_name}${CL_RED} to directory ${CL_BL_RED}${src_dir}${CL_RED} - error while copy process" + error "Can't copy source file \"$source_file_name\" to directory \"$src_dir\" - error while copying file" doExit $ERROR_SOURCE fi done else - error "Error! Can't copy source files - directory ${CL_BL_RED}${src_dir}${CL_RED} doesn't exist" + error "Can't copy source files - directory \"$src_dir\" doesn't exist" doExit $ERROR_SOURCE fi @@ -79,7 +79,7 @@ copySourcesToBuildDir() { [[ -n "$bump" ]] && releaseBump "$specs_dir/$spec" else - error "Error! Can't copy spec file - directory ${CL_BL_RED}${specs_dir}${CL_RED} doesn't exist." + error "Can't copy spec file - directory \"$specs_dir\" doesn't exist" doExit $ERROR_SOURCE fi } @@ -203,7 +203,7 @@ localBuildProcess() { stopStatusObserver show "" - error "Error! Can't build a package." + error "Can't build a package" if [[ -z "$verbose" ]] ; then error "Last $LOG_QUOTE_SIZE lines from build log:" @@ -221,7 +221,7 @@ localBuildProcess() { cp "$tmp_output" "$CWD/$lname" - error "Build log saved to current directory as ${CL_BL_RED}${lname}" + error "Build log saved to current directory as \"${lname}\"" fi removeLocalLock diff --git a/SOURCES/libexec/build-remote.shx b/SOURCES/libexec/build-remote.shx index 8ea1f2b..e1389bd 100644 --- a/SOURCES/libexec/build-remote.shx +++ b/SOURCES/libexec/build-remote.shx @@ -15,7 +15,7 @@ require "build-remote-worker" # Echo: No parallelBuild() { if [[ -n "$dlcache" ]] ; then - warn "Warning! You can't use a parallel build with download cache." + warn "You can't use a parallel build with download cache." doExit $ERROR_ARGS fi @@ -28,7 +28,7 @@ parallelBuild() { build_hosts=($(filterNodeList "$remote")) if [[ ${#build_hosts[@]} -eq 0 ]] ; then - error "Error! Can't start parallel build process - there are no build nodes with given indices." + error "Can't start parallel build process - there are no build nodes with given indices" doExit $ERROR_ARGS fi @@ -199,11 +199,11 @@ remoteCheckEnv() { if isRemoteServerReachable "$host" ; then if ! isSSHConnectionWorks "$host" ; then - error "Can't connect to host ${CL_BL_RED}${host}:${port:-22}${CL_RED} (server is reachable but SSH command returned an error)" + error "Can't connect to host \"${host}:${port:-22}\" (server is reachable but SSH command returned an error)" doExit $ERROR_REMOTE fi else - error "Remote server ${CL_BL_RED}${host}:${port:-22}${CL_RED} is not reachable!" + error "Remote server \"${host}:${port:-22}\" is not reachable!" doExit $ERROR_REMOTE fi @@ -386,7 +386,7 @@ remoteBuildProcess() { show "All rpm packages saved to a current directory" $GREEN fi else - error "Error! Can't build a package." + error "Can't build a package" if [[ -z "$verbose" ]] ; then error "Last $LOG_QUOTE_SIZE lines from build log:" @@ -546,7 +546,7 @@ configurePrivateKey() { fi if ! ssh-keygen -lf "$key" &> /dev/null ; then - error "Error! Private key is not valid." + error "Private key is not valid" doExit $ERROR_ARGS fi } diff --git a/SOURCES/libexec/build.shx b/SOURCES/libexec/build.shx index a0834b9..d9190b5 100644 --- a/SOURCES/libexec/build.shx +++ b/SOURCES/libexec/build.shx @@ -29,8 +29,13 @@ startBuild() { spec="${spec}.spec" else err=$(validateSpec "$spec") - error "${CL_BL_RED}${spec}${CL_RED} is not a spec file!${CL_NORM}" - error "${CL_BL_RED}${err}${CL_NORM}" + + error "\"$spec\" is not a spec file!" + + if [[ -n "$err" ]] ; then + error "$err" + fi + doExit $ERROR_SPEC fi fi @@ -153,7 +158,7 @@ processSpec() { downloadSource "$source_file" "$dlcache" if [[ $? -ne 0 ]] ; then - error "Error! Can't download file ${CL_BL_RED}${source_file}${CL_RED}." + error "Can't download file \"$source_file\"" doExit $ERROR_SOURCE fi @@ -167,7 +172,7 @@ processSpec() { downloadSource "$source_file" "$tmp_dir" if [[ $? -ne 0 ]] ; then - error "Error! Can't download file ${CL_BL_RED}${source_file}${CL_RED}." + error "Can't download file \"$source_file\"" doExit $ERROR_SOURCE fi @@ -205,7 +210,7 @@ processSpec() { source_num=$(( source_num + 1 )) && continue else - error "Can't use file ${CL_BL_RED}${source_file}${CL_RED} for build - file not found in sources directory" + error "Can't use file \"$source_file\" for build - file not found in sources directory" doExit $ERROR_SOURCE fi fi diff --git a/SOURCES/libexec/sources-remote.shx b/SOURCES/libexec/sources-remote.shx index 2461c51..46e7e8c 100644 --- a/SOURCES/libexec/sources-remote.shx +++ b/SOURCES/libexec/sources-remote.shx @@ -51,7 +51,7 @@ downloadRemoteSources() { downloadSource "$source_file" "$download" if [[ $? -ne 0 ]] ; then - error "Error! Can't download file ${CL_BL_RED}${source_file}${CL_RED}." + error "Can't download file \"$source_file\"" doExit $ERROR_SOURCE fi @@ -82,7 +82,7 @@ downloadSource() { file_name=$(basename "$url") if ! isAccessibleURL "$url" ; then - error "Can't download file ${CL_BL_RED}${file_name}${CL_RED} - server return error code" + error "Can't download file \"$file_name\" - server return non-ok status code" doExit $ERROR_SOURCE else start=$(now) @@ -100,7 +100,7 @@ downloadSource() { fi if ! validateSourceFile "$dir/$file_name" ; then - error "Invalid file ${CL_BL_RED}${source_name}${CL_RED} - file type doesn't match to file content" + error "Invalid file \"$source_name\" - file type doesn't match to file content" doExit $ERROR_SOURCE fi fi diff --git a/SOURCES/libexec/sources-scm.shx b/SOURCES/libexec/sources-scm.shx index cb53589..811549d 100644 --- a/SOURCES/libexec/sources-scm.shx +++ b/SOURCES/libexec/sources-scm.shx @@ -232,7 +232,7 @@ packSourcesFromGit() { fi if [[ $? -ne 0 ]] ; then - error "Can't checkout revision ${CL_BL_RED}${revision}${CL_RED}:" + error "Can't checkout revision \"$revision\"" if [[ -z "$verbose" ]] ; then error "" @@ -255,7 +255,7 @@ packSourcesFromGit() { if [[ -n "$path" ]] ; then if [[ ! -d "$dir_name/$path" ]] ; then - error "Can't find path ${CL_BL_RED}${path}${CL_NORM} in git repository" + error "Can't find path \"$path\" in git repository" doExit $ERROR_SOURCE else mv "$dir_name/$path" "$source_name" @@ -342,7 +342,7 @@ packSourcesFromHg() { fi if [[ $? -ne 0 ]] ; then - error "Can't switch branch to ${CL_BL_RED}${branch}${CL_RED}:" + error "Can't switch branch to \"$branch\"" if [[ -z "$verbose" ]] ; then error "" @@ -363,7 +363,7 @@ packSourcesFromHg() { fi if [[ $? -ne 0 ]] ; then - error "Can't checkout revision ${CL_BL_RED}${revision}${CL_RED}:" + error "Can't checkout revision \"$revision\"" if [[ -z "$verbose" ]] ; then error "" @@ -382,7 +382,7 @@ packSourcesFromHg() { fi if [[ $? -ne 0 ]] ; then - error "Can't checkout tag ${CL_BL_RED}${tag}${CL_RED}:" + error "Can't checkout tag \"$tag\"" if [[ -z "$verbose" ]] ; then error "" @@ -400,7 +400,7 @@ packSourcesFromHg() { if [[ -n "$path" ]] ; then if [[ ! -d "$dir_name/$path" ]] ; then - error "Can't find path ${CL_BL_RED}${path}${CL_NORM} in mercurial repository" + error "Can't find path \"$path\" in mercurial repository" doExit $ERROR_SOURCE else mv "$dir_name/$path" "$source_name" @@ -490,7 +490,7 @@ packSourcesFromBzr() { fi if [[ $? -ne 0 ]] ; then - error "Can't revert to revision ${CL_BL_RED}${revision}" + error "Can't revert to revision \"$revision\"" if [[ -z "$verbose" ]] ; then error "" @@ -508,7 +508,7 @@ packSourcesFromBzr() { if [[ -n "$path" ]] ; then if [[ ! -d "$dir_name/$path" ]] ; then - error "Can't find path ${CL_BL_RED}${path}${CL_NORM} in bazaar repository" + error "Can't find path \"$path\" in bazaar repository" doExit $ERROR_SOURCE else mv "$dir_name/$path" "$source_name" @@ -599,7 +599,7 @@ packSourcesFromSvn() { fi if [[ $? -ne 0 ]] ; then - error "Can't checkout source code from ${CL_BL_RED}${svn}" + error "Can't checkout source code from \"$svn\"" if [[ -z "$verbose" ]] ; then error "" diff --git a/SOURCES/libexec/sources.shx b/SOURCES/libexec/sources.shx index fb643fe..567ed55 100644 --- a/SOURCES/libexec/sources.shx +++ b/SOURCES/libexec/sources.shx @@ -71,12 +71,12 @@ packLocalSources() { if [[ -n "$source_list" ]] ; then if [[ ! -r $source_list ]] ; then - error "Can't pack sources - file ${CL_BL_RED}${source_list}${CL_RED} not readable" + error "Can't pack sources - file \"$source_list\" not readable" doExit $ERROR_SOURCE fi if [[ ! -s $source_list ]] ; then - error "Can't pack sources - file ${CL_BL_RED}${source_list}${CL_RED} is empty" + error "Can't pack sources - file \"$source_list\" is empty" doExit $ERROR_SOURCE fi @@ -87,7 +87,7 @@ packLocalSources() { for src_target in $pack ; do if [[ ! -a $src_target ]] ; then - error "Can't pack sources - ${CL_BL_RED}${src_target}${CL_RED} not exist or not accessible" + error "Can't pack sources - \"$src_target\" not exist or not accessible" doExit $ERROR_SOURCE fi done @@ -158,7 +158,7 @@ packDir() { elif [[ "$ext" == "tar.xz" || "$ext" == "txz" ]] ; then tar cf - "$dir_name" | xz -9 -c - > "$arch_name.$ext" else - error "Error! Unknown archive type." + error "Unknown archive type" doExit $ERROR_SOURCE fi @@ -243,7 +243,7 @@ validateSources() { show "" fi - error "Can't use file ${CL_BL_RED}${source_name}${CL_RED} for build - file type doesn't match to file content" + error "Can't use file \"$source_name\" for build - file type doesn't match to file content" has_errors=true fi done diff --git a/SOURCES/libexec/spec.shx b/SOURCES/libexec/spec.shx index 3e9e013..08b465a 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 + spectool -n "$1" 1>/dev/null 2>&1 return $? } diff --git a/SOURCES/rpmbuilder b/SOURCES/rpmbuilder index 3d2a4ed..f4152e5 100755 --- a/SOURCES/rpmbuilder +++ b/SOURCES/rpmbuilder @@ -397,7 +397,7 @@ showo() { # Code: No # Echo: No error() { - show "▲ $*" $RED 1>&2 + show "$*" $RED 1>&2 } # Print warning message @@ -407,7 +407,7 @@ error() { # Code: No # Echo: No warn() { - show "▲ $*" $YELLOW 1>&2 + show "$*" $YELLOW 1>&2 } # Show message about unknown option From 9eea49c48dd853a0f8eebcba1806afecd988b826 Mon Sep 17 00:00:00 2001 From: Anton Novojilov Date: Tue, 10 Sep 2024 00:35:30 +0300 Subject: [PATCH 4/6] Code refactoring --- SOURCES/libexec/package.shx | 4 ++-- SOURCES/libexec/sources-scm.shx | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/SOURCES/libexec/package.shx b/SOURCES/libexec/package.shx index 57ee44f..92837c3 100644 --- a/SOURCES/libexec/package.shx +++ b/SOURCES/libexec/package.shx @@ -19,7 +19,7 @@ validatePackage() { if rpm -qp --scripts "$rpm_file" 2>&1 | grep -E -q '\%\{.*\}' ; then show "ERROR\n" $RED - show "RPM package ${CL_BL_RED}${rpm_name}${CL_RED} contains unexpanded macros in scriptlets:" $RED + show "RPM package \"$rpm_name\" contains unexpanded macros in scriptlets:" $RED show "${CL_GREY}" rpm -qp --scripts "$rpm_file" 2>&1 | grep -E -A1 -B1 '\%\{.*\}' | sed '/^$/d' | sed 's/^/ /g' show "${CL_NORM}" @@ -29,7 +29,7 @@ validatePackage() { if rpm -qlp "$rpm_file" 2>&1 | grep -E -q '\%\{.*\}' ; then show "ERROR\n" $RED - show "RPM package ${CL_BL_RED}${rpm_name}${CL_RED} contains unexpanded macros in files section:" $RED + show "RPM package \"$rpm_name\" contains unexpanded macros in files section:" $RED show "${CL_GREY}" rpm -qlp "$rpm_file" 2>&1 | grep -E -A1 -B1 '\%\{.*\}' | sed '/^$/d' | sed 's/^/ /g' show "${CL_NORM}" diff --git a/SOURCES/libexec/sources-scm.shx b/SOURCES/libexec/sources-scm.shx index 811549d..f9eba34 100644 --- a/SOURCES/libexec/sources-scm.shx +++ b/SOURCES/libexec/sources-scm.shx @@ -614,7 +614,7 @@ packSourcesFromSvn() { if [[ -n "$path" ]] ; then if [[ ! -d "${source_name}_tmp/$path" ]] ; then - error "Can't find path ${CL_BL_RED}${path}${CL_NORM} in svn repository" + error "Can't find path \"$path\" in svn repository" doExit $ERROR_SOURCE else mv "${source_name}_tmp/$path" "$source_name" From 14e5539eb1ed0b0d722991c2683e2bb68829bd73 Mon Sep 17 00:00:00 2001 From: Anton Novojilov Date: Tue, 10 Sep 2024 13:51:37 +0300 Subject: [PATCH 5/6] Pass macros from 'define' option into spec-builddep --- SOURCES/libexec/build-remote.shx | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/SOURCES/libexec/build-remote.shx b/SOURCES/libexec/build-remote.shx index e1389bd..1503c21 100644 --- a/SOURCES/libexec/build-remote.shx +++ b/SOURCES/libexec/build-remote.shx @@ -232,10 +232,17 @@ remoteDepsInstall() { yum_opts=$(getYumOpts "$verbose") if [[ -n "$install_latest" ]] ; then - yum_opts="$yum_opts --actual" + yum_opts="$yum_opts -A" fi - sshCommand "$host" "cd $specs_dir && sudo spec-builddep --clean $yum_opts $spec_name" + if [[ -n "$define" ]] ; then + local macro_def + for macro_def in $define ; do + yum_opts="$yum_opts -D $macro_def" + done + fi + + sshCommand "$host" "cd $specs_dir && sudo spec-builddep -C $yum_opts $spec_name" if [[ $? -ne 0 ]] ; then doExit $ERROR_DEPS From becf05bda2d87dc7e122a54bf3aea595abf7799a Mon Sep 17 00:00:00 2001 From: Anton Novojilov Date: Tue, 10 Sep 2024 13:52:30 +0300 Subject: [PATCH 6/6] Pass macros from 'define' option to spec-builddep --- rpmbuilder.spec | 1 + 1 file changed, 1 insertion(+) diff --git a/rpmbuilder.spec b/rpmbuilder.spec index 52ac3d2..4726caa 100644 --- a/rpmbuilder.spec +++ b/rpmbuilder.spec @@ -60,6 +60,7 @@ install -pm 644 libexec/* %{buildroot}%{_libexecdir}/%{name}/ %changelog * Mon Sep 09 2024 Anton Novojilov - 3.4.0-0 - Added 'define' option validation +- Pass macros from 'define' option to spec-builddep - Changed macro definition from 'name=value' to 'name:value' - Code refactoring