Refactor changelog check into a generic function

This allows calling it early in generic_pack and avoid doing expensive
operations before finding out the ChangeLog is not updated.
This commit is contained in:
Tom G. Christensen 2012-05-27 11:39:45 +02:00
parent 8a92bf85d5
commit 13bd8b42d3
3 changed files with 34 additions and 24 deletions

View File

@ -739,6 +739,22 @@ compute_octal()
echo $d1$d2$d3$d4 echo $d1$d2$d3$d4
} }
# check_changelog(): Verify that the ChangeLog is updated
# params: none
# Verify that the ChangeLog exists and contains an entry for the current
# version of the software
check_changelog()
{
if [ -r $metadir/ChangeLog ]; then
# See if we can find an entry for this build otherwise complain
if [ -z "$(${__grep} ${version}-${pkgver}$ $metadir/ChangeLog)" ]; then
error $E_MISSING_CHGLOGV check_changelog
fi
else
error $E_MISSING_CHGLOG check_changelog
fi
}
##################################################### #####################################################
# Define generic functions for different build stages # Define generic functions for different build stages
##################################################### #####################################################

View File

@ -1128,18 +1128,10 @@ auto_rel()
-e "s;%%DEPENDENCIES%%;${deps};g" \ -e "s;%%DEPENDENCIES%%;${deps};g" \
${rn} > "$relmetadir/${topdir}.txt" ${rn} > "$relmetadir/${topdir}.txt"
# Add a ChangeLog if it exists # Add a ChangeLog
if [ -r $metadir/ChangeLog ]; then
echo "auto_rel: Adding ChangeLog to relnotes" echo "auto_rel: Adding ChangeLog to relnotes"
# See if we can find an entry for this build otherwise complain
if [ -z "$(${__grep} ${version}-${pkgver}$ $metadir/ChangeLog)" ]; then
error $E_MISSING_CHGLOGV auto_rel
fi
echo >> "$relmetadir/${topdir}.txt" echo >> "$relmetadir/${topdir}.txt"
cat $metadir/ChangeLog >> "$relmetadir/${topdir}.txt" cat $metadir/ChangeLog >> "$relmetadir/${topdir}.txt"
else
error $E_MISSING_CHGLOG auto_rel
fi
} }
# auto_dir(): Make sure all necessary dir entries are in prototype # auto_dir(): Make sure all necessary dir entries are in prototype
@ -1346,6 +1338,11 @@ generic_pack()
if [ "$1" == "shortroot" ]; then if [ "$1" == "shortroot" ]; then
error $E_ARG_OBSO generic_pack error $E_ARG_OBSO generic_pack
fi fi
# Before doing any expensive operations
# check that the ChangeLog is in order
check_changelog
clean meta clean meta
if [ -d ${stagedir}${prefix}/${_mandir} ]; then if [ -d ${stagedir}${prefix}/${_mandir} ]; then

View File

@ -426,18 +426,10 @@ auto_rel()
-e "s;%%DEPENDENCIES%%;${deps};g" \ -e "s;%%DEPENDENCIES%%;${deps};g" \
${rn} > "$relmetadir/${secname}.txt" ${rn} > "$relmetadir/${secname}.txt"
# Add a ChangeLog if it exists # Add a ChangeLog
if [ -r $metadir/ChangeLog ]; then
echo "auto_rel: Adding ChangeLog to relnotes" echo "auto_rel: Adding ChangeLog to relnotes"
# See if we can find an entry for this build otherwise complain
if [ -z "$(${__grep} ${version}-${pkgver}$ $metadir/ChangeLog)" ]; then
error $E_MISSING_CHGLOGV auto_rel
fi
echo >> "$relmetadir/${secname}.txt" echo >> "$relmetadir/${secname}.txt"
cat $metadir/ChangeLog >> "$relmetadir/${secname}.txt" cat $metadir/ChangeLog >> "$relmetadir/${secname}.txt"
else
error $E_MISSING_CHGLOG auto_rel
fi
### Add the relnotes to the prototype file ### Add the relnotes to the prototype file
add_dir $defaultperms $defaultuid $defaultgid "${metaprefix}relnotes" $secname add_dir $defaultperms $defaultuid $defaultgid "${metaprefix}relnotes" $secname
@ -952,6 +944,11 @@ generic_pack()
if [ "$1" == "shortroot" ]; then if [ "$1" == "shortroot" ]; then
error $E_ARG_OBSO generic_pack error $E_ARG_OBSO generic_pack
fi fi
# Before doing any expensive operations
# check that the ChangeLog is in order
check_changelog
clean meta clean meta
if [ -d "${stagedir}${topinstalldir}${dir_prefix}/${_mandir}" ]; then if [ -d "${stagedir}${topinstalldir}${dir_prefix}/${_mandir}" ]; then
setdir ${stagedir}${topinstalldir}${dir_prefix}/${_mandir} setdir ${stagedir}${topinstalldir}${dir_prefix}/${_mandir}