[build] Generate yaml report file

Generate yaml report file for each package
   Report layout:

       Source: {source name}
       Version: {version string}
       Binary:
         - {list of binaries}
       Build_time: {time}
       Code_project:
         {source project name}: {git sha}
         [{spec project name}: {git sha}]

   PROD: 8936

Change-Id: Iefe1f50d3a1977810fcbbbdcf2af95865e9ee6e3
This commit is contained in:
Dmitry Burmistrov 2017-01-26 17:50:30 +04:00
parent 84307dbfb5
commit ea888357b7
6 changed files with 95 additions and 0 deletions

View File

@ -29,7 +29,13 @@ main () {
# Get last commit info
# $message $author $email $cdate $commitsha $lastgitlog
if [ "$IS_OPENSTACK" == "true" ] ; then
local gitspecsha=$(git -C ${_specpath} log -n 1 --pretty=format:%H)
local gitspecprj=$(git -C ${_specpath} remote -v | head -n 1 | awk '{print $2}' | awk -F '/' '{print $NF}' | sed 's|.git$||' )
fi
get_last_commit_info ${_srcpath}
local gitsrcsha=$(git -C ${_srcpath} log -n 1 --pretty=format:%H)
local gitsrcprj=$(git -C ${_srcpath} remote -v | head -n 1 | awk '{print $2}' | awk -F '/' '{print $NF}' | sed 's|.git$||' )
TAR_NAME="${srcpackagename}_${pkg_version}.orig.tar.gz"
if [ "$IS_OPENSTACK" == "true" ] ; then
@ -124,6 +130,7 @@ main () {
fi
popd &>/dev/null
else
local fullver=$version_string
# Update changelog
DEBFULLNAME=$author DEBEMAIL=$email dch -c ${_debianpath}/debian/changelog -a "$commitsha $message"
# Prepare source tarball
@ -232,6 +239,20 @@ main () {
REPO_TYPE=deb
DIST=$DIST
EOL
# Fill yaml file
yaml_report_file=${tmpdir}/${srcpackagename}.yaml
echo "Source: ${srcpackagename}" > $yaml_report_file
echo "Version: ${fullver}" >> $yaml_report_file
echo "Binary:" >> $yaml_report_file
for binary in $(find ${tmpdir}/ -name *deb) ; do
_binary=${binary##*/}
echo " - ${_binary%%_*}" >> $yaml_report_file
done
echo "Build_time: $(date '+%F-%H-%M-%S')" >> $yaml_report_file
echo "Code_project:" >> $yaml_report_file
echo " ${gitsrcprj}: ${gitsrcsha}" >> $yaml_report_file
[ "$IS_OPENSTACK" == "true" ] \
&& echo " ${gitspecprj}: ${gitspecsha}" >> $yaml_report_file
fi
exit $exitstatus

View File

@ -40,6 +40,8 @@ main () {
# Get last commit info
# $message $author $email $cdate $commitsha $lastgitlog
get_last_commit_info ${_srcpath}
local gitsrcsha=$(git -C ${_srcpath} log -n 1 --pretty=format:%H)
local gitsrcprj=$(git -C ${_srcpath} remote -v | head -n 1 | awk '{print $2}' | awk -F '/' '{print $NF}' | sed 's|.git$||' )
# Get revision number as commit count for src+spec projects
local _rev=`git -C $_srcpath rev-list --no-merges origin/${SOURCE_BRANCH} | wc -l`
@ -174,6 +176,18 @@ main () {
REPO_TYPE=deb
DIST=$DIST
EOL
# Fill yaml file
yaml_report_file=${tmpdir}/${srcpackagename}.yaml
echo "Source: ${srcpackagename}" > $yaml_report_file
echo "Version: ${fullver}" >> $yaml_report_file
echo "Binary:" >> $yaml_report_file
for binary in $(find ${tmpdir}/ -name *deb) ; do
_binary=${binary##*/}
echo " - ${_binary%%_*}" >> $yaml_report_file
done
echo "Build_time: $(date '+%F-%H-%M-%S')" >> $yaml_report_file
echo "Code_project:" >> $yaml_report_file
echo " ${gitsrcprj}: ${gitsrcsha}" >> $yaml_report_file
fi
echo "Packages: $PACKAGENAME"

View File

@ -30,11 +30,15 @@ main () {
# Get last commit info
# $message $author $email $cdate $commitsha $lastgitlog
get_last_commit_info ${_srcpath}
local gitsrcsha=$(git -C ${_srcpath} log -n 1 --pretty=format:%H)
local gitsrcprj=$(git -C ${_srcpath} remote -v | head -n 1 | awk '{print $2}' | awk -F '/' '{print $NF}' | sed 's|.git$||' )
# Update specs
local specfile=`find $_specpath -name *.spec`
local version=`rpm -q --specfile $specfile --queryformat '%{VERSION}\n' | head -1`
local release=`rpm -q --specfile $specfile --queryformat '%{RELEASE}\n' | head -1`
local srcpackagename=${specfile##*/}
srcpackagename=${srcpackagename%.spec}
## Add changelog section if it doesn't exist
[ `cat ${specfile} | grep -c '^%changelog'` -eq 0 ] && echo "%changelog" >> ${specfile}
local _rev=`git -C $_srcpath rev-list --no-merges origin/${SOURCE_BRANCH} | wc -l`
@ -178,6 +182,22 @@ main () {
REPO_TYPE=rpm
DIST=$DIST
EOL
# Fill yaml file
yaml_report_file=${tmpdir}/${srcpackagename}.yaml
local srpmfile=$(find ${tmpdir}/ -name *.src.rpm)
local newrelease=`rpm -qp $srpmfile --queryformat %{RELEASE}"\n" | head -1`
echo "Source: ${srcpackagename}" > $yaml_report_file
echo "Version: ${version}-${newrelease}" >> $yaml_report_file
echo "Binary:" >> $yaml_report_file
for binary in $(find ${tmpdir}/ -name *.rpm | egrep -v '\.src\.rpm$') ; do
_binary=${binary##*/}
_binary=${_binary%-*}
_binary=${_binary%-*}
echo " - ${_binary}" >> $yaml_report_file
done
echo "Build_time: $(date '+%F-%H-%M-%S')" >> $yaml_report_file
echo "Code_project:" >> $yaml_report_file
echo " ${gitsrcprj}: ${gitsrcsha}" >> $yaml_report_file
fi
echo "Packages: $PACKAGENAME"

View File

@ -19,9 +19,13 @@ main () {
# Get last commit info
# $message $author $email $cdate $commitsha $lastgitlog
get_last_commit_info ${_srcpath}
local gitsrcsha=$(git -C ${_srcpath} log -n 1 --pretty=format:%H)
local gitsrcprj=$(git -C ${_srcpath} remote -v | head -n 1 | awk '{print $2}' | awk -F '/' '{print $NF}' | sed 's|.git$||' )
# Update specs
local specfile=`find $_specpath -name *.spec`
local srcpackagename=${specfile##*/}
srcpackagename=${srcpackagename%.spec}
#local binpackagename=`rpm -q $RPMQUERYPARAMS --specfile $specfile --queryformat %{NAME}"\n" | head -1`
local define_macros=(
-D 'kernel_module_package_buildreqs kernel-devel'
@ -39,6 +43,8 @@ This package provides the %{-n*} kernel modules
## Add changelog section if it doesn't exist
[ "`cat ${specfile} | grep -c '^%changelog'`" -eq 0 ] && echo "%changelog" >> ${specfile}
if [ "$IS_OPENSTACK" == "true" ] ; then
local gitspecsha=$(git -C ${_specpath} log -n 1 --pretty=format:%H)
local gitspecprj=$(git -C ${_specpath} remote -v | head -n 1 | awk '{print $2}' | awk -F '/' '{print $NF}' | sed 's|.git$||' )
# Get version number from the latest git tag for openstack packages
local release_tag=$(git -C $_srcpath describe --abbrev=0 --candidates=1 | sed -r 's|^[^0-9]+||')
# Deal with PyPi versions like 2015.1.0rc1
@ -225,6 +231,24 @@ This package provides the %{-n*} kernel modules
REPO_TYPE=rpm
DIST=$DIST
EOL
# Fill yaml file
yaml_report_file=${tmpdir}/${srcpackagename}.yaml
local srpmfile=$(find ${tmpdir}/ -name *.src.rpm)
local newrelease=`rpm -qp $srpmfile --queryformat %{RELEASE}"\n" | head -1`
echo "Source: ${srcpackagename}" > $yaml_report_file
echo "Version: ${version}-${newrelease}" >> $yaml_report_file
echo "Binary:" >> $yaml_report_file
for binary in $(find ${tmpdir}/ -name *.rpm | egrep -v '\.src\.rpm$') ; do
_binary=${binary##*/}
_binary=${_binary%-*}
_binary=${_binary%-*}
echo " - ${_binary}" >> $yaml_report_file
done
echo "Build_time: $(date '+%F-%H-%M-%S')" >> $yaml_report_file
echo "Code_project:" >> $yaml_report_file
echo " ${gitsrcprj}: ${gitsrcsha}" >> $yaml_report_file
[ "$IS_OPENSTACK" == "true" ] \
&& echo " ${gitspecprj}: ${gitspecsha}" >> $yaml_report_file
fi
exit $exitstatus

View File

@ -228,6 +228,14 @@ main() {
rm -f ${pub_key_file}
fi
# Publish yaml files
local yaml_file=$(find "$TMP_DIR" -name *.yaml 2>/dev/null)
if [ -n "$yaml_file" ] ; then
local yaml_dir=${OUTDIR}/${DEB_DIST_NAME}-versioner
mkdir -p "$yaml_dir"
cp -v "$yaml_file" "$yaml_dir"
fi
sync-repo ${OUTDIR} ${DEB_REPO_PATH} ${REPO_REQUEST_PATH_PREFIX} ${REQUEST_NUM} ${LP_BUG}
job_lock ${CONFIGDIR}.lock unset

View File

@ -249,6 +249,14 @@ EOL
[ -f "RPM-GPG-KEY" ] && cp RPM-GPG-KEY ${LOCAL_REPO_PATH}/RPM-GPG-KEY-${PROJECT_NAME}${PROJECT_VERSION}
fi
# Publish yaml files
local yaml_file=$(find "$TMP_DIR" -name *.yaml 2>/dev/null)
if [ -n "$yaml_file" ] ; then
local yaml_dir=${LOCAL_REPO_PATH}/versioner
mkdir -p "$yaml_dir"
cp -v "$yaml_file" "$yaml_dir"
fi
# Sync repo to remote host
sync-repo ${LOCAL_REPO_PATH}/ ${RPM_REPO_PATH} ${REPO_REQUEST_PATH_PREFIX} ${REQUEST_NUM} ${LP_BUG}
job_lock ${LOCAL_REPO_PATH}.lock unset