From 3a0ccf9afb09aeb24ddaad444eb75fe97692c21e Mon Sep 17 00:00:00 2001 From: Johnny Hughes Date: Nov 12 2014 17:31:51 +0000 Subject: update logic for SCLs --- diff --git a/into_srpm.sh b/into_srpm.sh index 922d899..5399dc9 100755 --- a/into_srpm.sh +++ b/into_srpm.sh @@ -174,35 +174,46 @@ fi SPECFILE=$(cd SPECS; ls *.spec) +# determine automatically unless we've got one set +if [[ "x${DIST}" == 'x' ]]; then + if [[ ${QUIET} -eq 1 ]]; then + DIST=$(return_disttag.sh -q) + else + DIST=$(return_disttag.sh) + fi +fi + # Determine if we are an SCL ISSCL=0 if [[ ${ALLOWSCL} -eq 1 ]]; then mytestsclname='DA39A3EE5E6B4B0D3255BFEF95601890AFD80709' - mysclcheck=$(rpm --define "dist el" --define "scl ${mytestsclname}" -q --specfile "SPECS/${SPECFILE}" --qf '%{n}-%{v}-%{r}\n' 2>/dev/null | head -n 1) + mysclcheck=$(rpm --define "dist ${DIST}" --define "scl ${mytestsclname}" -q --specfile "SPECS/${SPECFILE}" --qf '%{n}-%{v}-%{r}\n' 2>/dev/null | head -n 1) echo ${mysclcheck} | grep -q ${mytestsclname} if [[ $? -eq 0 ]]; then ISSCL=1 - SCLNAME=$(show_possible_srpms.sh | cut -d'-' -f1 | sort -u) + BASENAME=$(echo ${mysclcheck} | sed -e 's/DA39A3EE5E6B4B0D3255BFEF95601890AFD80709//') + RPMNAME=$(show_possible_srpms.sh | head -1) + SCLNAME=$(echo ${RPMNAME} | sed -e "s/${BASENAME}.src.rpm//") if [[ $(echo ${SCLNAME} | wc -l) -ne 1 ]]; then echo "$0 failed to determine unique SCL name" >&2 echo "Found:" >&2 echo "${SCLNAME}" >&2 fi + + scl_check=$(rpm --define "dist ${DIST}" --define "scl ${SCLNAME}" -q --specfile "SPECS/${SPECFILE}" --qf '%{n}-%{v}-%{r}.src.rpm\n' 2>/dev/null | head -n 1) + if [[ "${RPMNAME}" != "${scl_check}" ]]; then + echo "$0 failed to verify SCL name" >&2 + echo "Found:" >&2 + echo "${SCLNAME}" >&2 + echo "made: ${scl_check}" >&2 + echo "expected: ${RPMNAME}" >&2 + fi fi fi # build our rpmopts list RPMOPTS="-bs --nodeps" -# determine automatically unless we've got one set -if [[ "x${DIST}" == 'x' ]]; then - if [[ ${QUIET} -eq 1 ]]; then - DIST=$(return_disttag.sh -q) - else - DIST=$(return_disttag.sh) - fi -fi - # put it all together if [[ ${ISSCL} -eq 1 ]]; then rpmbuild --define "%_topdir `pwd`" ${RPMOPTS} --define "%dist ${DIST}" --define "%scl ${SCLNAME}" SPECS/${SPECFILE} diff --git a/return_disttag.sh b/return_disttag.sh index e846692..2c1e522 100755 --- a/return_disttag.sh +++ b/return_disttag.sh @@ -122,37 +122,38 @@ SPEC=$(cd SPECS; ls *.spec) #now get nvr from spec with placeholder dist mydist="XXXjsdf9ur7qlkasdh4gygXXX" -testnvr=$(build_with_dist_scl "SPECS/${SPEC}" ${mydist}) +test_nvr=$(build_with_dist_scl "SPECS/${SPEC}" ${mydist}) -git_name=$(echo ${git_nvr} | cut -d '-' -f 1) -test_name=$(echo ${testnvr} | cut -d '-' -f 1) +test_nodist=$(echo ${test_nvr} | sed -e 's/-[a-zA-Z0-9\.]*$//') +git_nodist=$(echo ${git_nvr} | sed -e 's/-[a-zA-Z0-9\._]*$//') -if [[ "${git_name}" != "${test_name}" ]]; then - warn "Warning: ${git_name} != ${test_name}" +if [[ "${git_nodist}" != "${test_nodist}" ]]; then + warn "Warning: ${git_nvr} != ${test_nvr}" warn "Warning: Trying as a Software Collection" - testnvr=$(build_with_dist_scl "SPECS/${SPEC}" ${mydist} ${git_name}) + scl=$(echo ${git_nodist} |sed -e "s/-${test_nodist}//") + test_nvr=$(build_with_dist_scl "SPECS/${SPEC}" ${mydist} ${scl}) + test_nodist=$(echo ${test_nvr} | sed -e 's/-[a-zA-Z0-9\.]*$//') fi -test_name=$(echo ${testnvr} | cut -d '-' -f 1) -if [[ "${git_name}" != "${test_name}" ]]; then +if [[ "${git_nodist}" != "${test_nodist}" ]]; then + git_name=$(echo ${git_nvr} | cut -d '-' -f 1) + test_name=$(echo ${test_nvr} | cut -d '-' -f 1) 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=${testnvr%$mydist*} +head=${test_nvr%$mydist*} -if [ ".$head" = ".$testnvr" ] +if [ ".$head" = ".$test_nvr" ] then #no dist tag echo "" exit fi -tail=${testnvr#*$mydist} +tail=${test_nvr#*$mydist} frag=${git_nvr#$head} dist=${frag%$tail}