mirror of
https://git.centos.org/centos-git-common.git
synced 2025-02-23 16:22:56 +00:00
return_disttag now works with SCL packages
This commit is contained in:
parent
d96c00fa0f
commit
01a821d933
1 changed files with 59 additions and 21 deletions
|
@ -18,6 +18,20 @@ usage() {
|
||||||
exit 1
|
exit 1
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#####################################################################
|
||||||
|
build_with_dist_scl() {
|
||||||
|
SPECFILE=$1
|
||||||
|
DIST=$2
|
||||||
|
SCL=${3:-}
|
||||||
|
|
||||||
|
if [[ "x${SCL}" == 'x' ]]; then
|
||||||
|
result=$(rpm --define "dist ${DIST}" -q --specfile "${SPECFILE}" --qf '%{n}-%{v}-%{r}\n' 2>/dev/null | head -n 1)
|
||||||
|
else
|
||||||
|
result=$(rpm --define "dist ${DIST}" --define "scl ${SCL}" -q --specfile "${SPECFILE}" --qf '%{n}-%{v}-%{r}\n' 2>/dev/null | head -n 1)
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo $result
|
||||||
|
}
|
||||||
|
|
||||||
#####################################################################
|
#####################################################################
|
||||||
# setup args in the right order for making getopt evaluation
|
# setup args in the right order for making getopt evaluation
|
||||||
|
@ -65,21 +79,18 @@ fi
|
||||||
# check metadata file and extract package name
|
# check metadata file and extract package name
|
||||||
packagename=""
|
packagename=""
|
||||||
shopt -s nullglob
|
shopt -s nullglob
|
||||||
for fn in .*.metadata
|
set -- .*.metadata
|
||||||
do
|
if (( $# == 0 ))
|
||||||
pn=${fn%.metadata}
|
|
||||||
pn=${pn#.}
|
|
||||||
if [ -e "SPECS/$pn.spec" ]
|
|
||||||
then
|
then
|
||||||
packagename="$pn"
|
echo 'Missing metadata. Please run from inside a sources git repo'
|
||||||
break
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
if [ -z "$packagename" ]
|
|
||||||
then
|
|
||||||
echo 'Missing metadata or spec. Please run from inside a sources git repo'
|
|
||||||
exit 1
|
exit 1
|
||||||
|
elif (( $# > 1 ))
|
||||||
|
then
|
||||||
|
warn "Warning: multiple metadata files found. Using $1"
|
||||||
fi
|
fi
|
||||||
|
meta=$1
|
||||||
|
pn=${meta%.metadata}
|
||||||
|
pn=${pn#.}
|
||||||
|
|
||||||
filter () {
|
filter () {
|
||||||
# filter used for log messages
|
# filter used for log messages
|
||||||
|
@ -97,32 +108,59 @@ set -- $msg
|
||||||
pkg="$2"
|
pkg="$2"
|
||||||
|
|
||||||
# strip .src.rpm if present
|
# strip .src.rpm if present
|
||||||
nvr1="${pkg%.src.rpm}"
|
git_nvr="${pkg%.src.rpm}"
|
||||||
|
|
||||||
|
scl=''
|
||||||
|
|
||||||
|
SPEC=$(cd SPECS; ls *.spec)
|
||||||
|
|
||||||
#now get nvr from spec with placeholder dist
|
#now get nvr from spec with placeholder dist
|
||||||
mydist="XXXjsdf9ur7qlkasdh4gygXXX"
|
mydist="XXXjsdf9ur7qlkasdh4gygXXX"
|
||||||
nvr2=$(rpm --define "dist $mydist" -q --specfile "SPECS/$packagename.spec" --qf '%{n}-%{v}-%{r}\n' 2>/dev/null | head -n 1)
|
testnvr=$(build_with_dist_scl "SPECS/${SPEC}" ${mydist})
|
||||||
|
|
||||||
|
git_name=$(echo ${git_nvr} | cut -d '-' -f 1)
|
||||||
|
test_name=$(echo ${testnvr} | cut -d '-' -f 1)
|
||||||
|
|
||||||
|
if [[ "${git_name}" != "${test_name}" ]]; then
|
||||||
|
warn "Warning: ${git_name} != ${test_name}"
|
||||||
|
warn "Warning: Trying as a Software Collection"
|
||||||
|
testnvr=$(build_with_dist_scl "SPECS/${SPEC}" ${mydist} ${git_name})
|
||||||
|
fi
|
||||||
|
|
||||||
|
test_name=$(echo ${testnvr} | cut -d '-' -f 1)
|
||||||
|
if [[ "${git_name}" != "${test_name}" ]]; then
|
||||||
|
warn "Warning: ${git_name} != ${test_name}"
|
||||||
|
echo "Warning: Couldn't match srpm name" >&2
|
||||||
|
exit 1
|
||||||
|
else
|
||||||
|
scl=${git_name}
|
||||||
|
fi
|
||||||
|
|
||||||
#use our placeholder dist to split the nvr
|
#use our placeholder dist to split the nvr
|
||||||
head=${nvr2%$mydist*}
|
head=${testnvr%$mydist*}
|
||||||
|
|
||||||
if [ ".$head" = ".$nvr2" ]
|
if [ ".$head" = ".$testnvr" ]
|
||||||
then
|
then
|
||||||
#no dist tag
|
#no dist tag
|
||||||
echo ""
|
echo ""
|
||||||
exit
|
exit
|
||||||
fi
|
fi
|
||||||
|
|
||||||
tail=${nvr2#*$mydist}
|
tail=${testnvr#*$mydist}
|
||||||
|
|
||||||
frag=${nvr1#$head}
|
frag=${git_nvr#$head}
|
||||||
dist=${frag%$tail}
|
dist=${frag%$tail}
|
||||||
|
|
||||||
# sanity check
|
# sanity check
|
||||||
nvr3=$(rpm --define "dist $dist" -q --specfile "SPECS/$packagename.spec" --qf '%{n}-%{v}-%{r}\n' 2>/dev/null | head -n 1)
|
if [[ "x${scl}" == 'x' ]]; then
|
||||||
if [ ".$nvr3" != ".$nvr1" ]
|
verifynvr=$(build_with_dist_scl "SPECS/${SPEC}" ${dist})
|
||||||
|
else
|
||||||
|
verifynvr=$(build_with_dist_scl "SPECS/${SPEC}" ${dist} ${scl})
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ ".$verifynvr" != ".$git_nvr" ]
|
||||||
then
|
then
|
||||||
warn "Warning: $nvr3 != $nvr1"
|
warn "Warning: $verifynvr != $git_nvr"
|
||||||
warn "Warning: check failed. The %{dist} value may be incorrect"
|
warn "Warning: check failed. The %{dist} value may be incorrect"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue