Some packages (notably SCL packages) do not specfile=%{name}.spec, so we shouldn't assume or assert this in get_sources.
pushed
On 06/25/2014 02:46 PM, Mike McLean wrote:
From 5dc529359f59906716f50249cbaee000e747b7b7 Mon Sep 17 00:00:00 2001 From: Mike McLean mikem@redhat.com Date: Wed, 25 Jun 2014 15:42:08 -0400 Subject: [PATCH] don't assume specfile name matches package name in get_sources
get_sources.sh | 22 +++++++++------------- 1 file changed, 9 insertions(+), 13 deletions(-)
diff --git a/get_sources.sh b/get_sources.sh index 5533cfe..f1dd30c 100755 --- a/get_sources.sh +++ b/get_sources.sh @@ -47,23 +47,19 @@ do done
# check metadata file and extract package name -found=0 shopt -s nullglob -for meta in .*.metadata -do
- pn=${meta%.metadata}
- pn=${pn#.}
- if [ -e "SPECS/$pn.spec" ]
- then
found=1
break
- fi
-done -if (( $found != 1 )) +set -- .*.metadata +if (( $# == 0 )) then
- echo 'Missing metadata or spec. Please run from inside a sources git repo'
- echo 'Missing metadata. Please run from inside a sources git repo' exit 1
+elif (( $# > 1 )) +then
- echo "Warning: multiple metadata files found. Using $1"
fi +meta=$1 +pn=${meta%.metadata} +pn=${pn#.}
if [ ! -d .git ] || [ ! -d SPECS ]; then echo 'You need to run this from inside a sources git repo' -- 1.8.3.1
On Wed, 25 Jun 2014, Mike McLean wrote:
Some packages (notably SCL packages) do not specfile=%{name}.spec, so we shouldn't assume or assert this in get_sources.
that would explain many of my pull system failures ... amending to something based on: find . -maxdepth N -name "*.spec" soonest
thank you
-- Russ herrold
From: Pat Riehecky riehecky@fnal.gov
--- return_disttag.sh | 80 +++++++++++++++++++++++++++++++++++++++-------------- 1 files changed, 59 insertions(+), 21 deletions(-)
diff --git a/return_disttag.sh b/return_disttag.sh index d0ae030..de9ff29 100755 --- a/return_disttag.sh +++ b/return_disttag.sh @@ -18,6 +18,20 @@ usage() { 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 @@ -65,21 +79,18 @@ fi # check metadata file and extract package name packagename="" shopt -s nullglob -for fn in .*.metadata -do - pn=${fn%.metadata} - pn=${pn#.} - if [ -e "SPECS/$pn.spec" ] - then - packagename="$pn" - break - fi -done -if [ -z "$packagename" ] +set -- .*.metadata +if (( $# == 0 )) then - echo 'Missing metadata or spec. Please run from inside a sources git repo' + echo 'Missing metadata. Please run from inside a sources git repo' exit 1 +elif (( $# > 1 )) +then + warn "Warning: multiple metadata files found. Using $1" fi +meta=$1 +pn=${meta%.metadata} +pn=${pn#.}
filter () { # filter used for log messages @@ -97,32 +108,59 @@ set -- $msg pkg="$2"
# 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 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 -head=${nvr2%$mydist*} +head=${testnvr%$mydist*}
-if [ ".$head" = ".$nvr2" ] +if [ ".$head" = ".$testnvr" ] then #no dist tag echo "" exit fi
-tail=${nvr2#*$mydist} +tail=${testnvr#*$mydist}
-frag=${nvr1#$head} +frag=${git_nvr#$head} dist=${frag%$tail}
# sanity check -nvr3=$(rpm --define "dist $dist" -q --specfile "SPECS/$packagename.spec" --qf '%{n}-%{v}-%{r}\n' 2>/dev/null | head -n 1) -if [ ".$nvr3" != ".$nvr1" ] +if [[ "x${scl}" == 'x' ]]; then + verifynvr=$(build_with_dist_scl "SPECS/${SPEC}" ${dist}) +else + verifynvr=$(build_with_dist_scl "SPECS/${SPEC}" ${dist} ${scl}) +fi + +if [ ".$verifynvr" != ".$git_nvr" ] then - warn "Warning: $nvr3 != $nvr1" + warn "Warning: $verifynvr != $git_nvr" warn "Warning: check failed. The %{dist} value may be incorrect" fi
On 07/09/2014 12:10 PM, Pat Riehecky wrote:
return_disttag.sh | 80 +++++++++++++++++++++++++++++++++++++++-------------- 1 files changed, 59 insertions(+), 21 deletions(-)
diff --git a/return_disttag.sh b/return_disttag.sh index d0ae030..de9ff29 100755 --- a/return_disttag.sh +++ b/return_disttag.sh @@ -18,6 +18,20 @@ usage() { 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 @@ -65,21 +79,18 @@ fi # check metadata file and extract package name packagename="" shopt -s nullglob -for fn in .*.metadata -do
- pn=${fn%.metadata}
- pn=${pn#.}
- if [ -e "SPECS/$pn.spec" ]
- then
packagename="$pn"
break
- fi
-done -if [ -z "$packagename" ] +set -- .*.metadata +if (( $# == 0 )) then
- echo 'Missing metadata or spec. Please run from inside a sources git repo'
- echo 'Missing metadata. Please run from inside a sources git repo' exit 1
+elif (( $# > 1 )) +then
- warn "Warning: multiple metadata files found. Using $1"
fi +meta=$1 +pn=${meta%.metadata} +pn=${pn#.}
filter () { # filter used for log messages @@ -97,32 +108,59 @@ set -- $msg pkg="$2"
# 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 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 -head=${nvr2%$mydist*} +head=${testnvr%$mydist*}
-if [ ".$head" = ".$nvr2" ] +if [ ".$head" = ".$testnvr" ] then #no dist tag echo "" exit fi
-tail=${nvr2#*$mydist} +tail=${testnvr#*$mydist}
-frag=${nvr1#$head} +frag=${git_nvr#$head} dist=${frag%$tail}
# sanity check -nvr3=$(rpm --define "dist $dist" -q --specfile "SPECS/$packagename.spec" --qf '%{n}-%{v}-%{r}\n' 2>/dev/null | head -n 1) -if [ ".$nvr3" != ".$nvr1" ] +if [[ "x${scl}" == 'x' ]]; then
- verifynvr=$(build_with_dist_scl "SPECS/${SPEC}" ${dist})
+else
- verifynvr=$(build_with_dist_scl "SPECS/${SPEC}" ${dist} ${scl})
+fi
+if [ ".$verifynvr" != ".$git_nvr" ] then
- warn "Warning: $nvr3 != $nvr1"
- warn "Warning: $verifynvr != $git_nvr" warn "Warning: check failed. The %{dist} value may be incorrect"
fi
-- 1.7.1
pushed