Log In
Log In
Places
All Projects
Status Monitor
Collapse sidebar
Fedora:27
build-compare
build-compare-substitute-vars.patch
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File build-compare-substitute-vars.patch of Package build-compare
From 43aba317eda3ed73aa6d2ed462dd4ddd8e8baba2 Mon Sep 17 00:00:00 2001 From: Oleg Girko <ol@infoserver.lv> Date: Mon, 11 Dec 2017 18:18:44 +0000 Subject: [PATCH] Substitute some variables in Release header of spec file. Replacing release taken from source RPM metadate with "@RELEASE@" placeholder in "Release:" header of spec file before comparing doesn't work if there is a variable substitution in this header. For example, you may have this in your project config: Release: <CI_CNT>%%{?dist}.<B_CNT> This will cause i"Release:" header look like this in generated spec file: Release: 1%{?dist}.2 whereas release extracted from source RPM metadata will look like "1.fc27.2", and these substitutions will not work: sed -i -e "s,Release:.*${ver_rel_old}$,Release: @RELEASE@," old/$file sed -i -e "s,Release:.*${ver_rel_new}$,Release: @RELEASE@," new/$file This change adds rudimentary substitution of a couple of variables in "Release:" header. These variables are taken from system RPM macros using "rpm -E" command. This workaround works in simple cases, but more comprehensive solution would require rework of build-compare's architecture to make it access project configuration. Signed-off-by: Oleg Girko <ol@infoserver.lv> --- build-compare.changes | 5 +++++ srpm-check.sh | 22 ++++++++++++++++++++-- 2 files changed, 25 insertions(+), 2 deletions(-) diff --git a/build-compare.changes b/build-compare.changes index 4ec9484..b30d3b1 100644 --- a/build-compare.changes +++ b/build-compare.changes @@ -1,3 +1,8 @@ +------------------------------------------------------------------- +Mon Dec 11 18:11:00 UTC 2017 - ol@infoserver.lv + +- Substitute some variables in Release header of spec file + ------------------------------------------------------------------- Fri Dec 8 16:57:00 UTC 2017 - ol@infoserver.lv diff --git a/srpm-check.sh b/srpm-check.sh index 2d7e60e..9b2882a 100644 --- a/srpm-check.sh +++ b/srpm-check.sh @@ -24,6 +24,9 @@ fi source $FUNCTIONS +# Variables to substitute in Release header of spec file +declare -a subst_var_names=(dist _vendor) + oldrpm=`readlink -f $1` newrpm=`readlink -f $2` rename_script= @@ -59,6 +62,21 @@ esac # Now check that only the spec file has a changed release number and # nothing else +declare -A subst_vars + +for v in "${subst_var_names[@]}"; do + subst_vars["$v"]="$(rpm -E "%{$v}")" +done + +declare -a subst_sed_cmd=(sed -i) +for v in "${!subst_vars[@]}"; do + subst_sed_cmd=( + ${subst_sed_cmd[@]} + -e "/^Release:/s;%{$v};${subst_vars[$v]};" + -e "/^Release:/s;%{?$v};${subst_vars[$v]};" + ) +done + dir=`mktemp -d` unpackage $oldrpm $dir/old unpackage $newrpm $dir/new @@ -69,8 +87,8 @@ check_single_file() local file=$1 case $file in *.spec) - sed -i -e "s,Release:.*${ver_rel_old}$,Release: @RELEASE@," old/$file - sed -i -e "s,Release:.*${ver_rel_new}$,Release: @RELEASE@," new/$file + ${subst_sed_cmd[@]} -e "s,Release:.*${ver_rel_old}$,Release: @RELEASE@," old/$file + ${subst_sed_cmd[@]} -e "s,Release:.*${ver_rel_new}$,Release: @RELEASE@," new/$file if ! cmp -s old/$file new/$file; then echo "$file differs (spec file)" diff -u old/$file new/$file | head -n 20 -- 2.14.3
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Contact
Support
@OBShq
The Open Build Service is an
openSUSE project
.
Log In
Places
Places
All Projects
Status Monitor