[CentOS-devel] [PATCH] return_disttag now works with SCL packages

Johnny Hughes johnny at centos.org
Wed Jul 9 23:22:15 UTC 2014


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

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 198 bytes
Desc: OpenPGP digital signature
URL: <http://lists.centos.org/pipermail/centos-devel/attachments/20140709/7d6542bf/attachment.sig>


More information about the CentOS-devel mailing list