Skip to content

Commit 616b584

Browse files
author
David Sommerseth
committed
Updated utils/set_version to be more intelligent with the .spec file
- Reset the Release variable in the .spec file to 1 - Add a changelog entry with the new version
1 parent 1a57638 commit 616b584

1 file changed

Lines changed: 33 additions & 6 deletions

File tree

utils/set_version

Lines changed: 33 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/bin/sh
1+
#!/bin/bash
22

33
if [ $# != 1 ]; then
44
echo "Usage: $0 <new version number>"
@@ -14,6 +14,26 @@ fi
1414
NEW_VERSION=$1
1515
OLD_VERSION=$(cd src;python -c "from setup_common import *; print get_version();")
1616

17+
# Prepare ChangeLog entry for the python-dmidecode.spec file
18+
TSTAMP="$(date +%a\ %b\ %d\ %Y)"
19+
FNAME="$(git config user.name)"
20+
EMAIL="$(git config user.email)"
21+
CHLOG="$TSTAMP $FNAME <$EMAIL> - ${NEW_VERSION}-1"
22+
23+
# Prepare regexp script to modify python-dmidecode.spec
24+
{
25+
cat <<EOF2
26+
,s/^Version: .*/Version: ${NEW_VERSION}/
27+
,s/^Release: .*/Release: 1%{?dist}/
28+
,s/%changelog/%changelog\\
29+
* ${CHLOG}\\
30+
- Update to new release\\
31+
/
32+
w
33+
EOF2
34+
} > .chversion
35+
36+
# Get confirmation of version change
1737
cat <<EOF
1838
1939
**
@@ -26,6 +46,7 @@ cat <<EOF
2646
To: ${NEW_VERSION}
2747
2848
EOF
49+
2950
echo -n " Please confirm: (yes/no) "
3051
read conf
3152

@@ -35,15 +56,21 @@ case $conf in
3556
echo " ** Updating src/version.h"
3657
printf ",s/^#define VERSION \".*\"/#define VERSION \"${NEW_VERSION}\"/\nw\n" | ed src/version.h 2>/dev/null
3758

38-
echo " ** Updating redhat.spec"
39-
printf ",s/^Version: .*/Version: ${NEW_VERSION}/\nw\n" | ed contrib/python-dmidecode.spec 2>/dev/null
40-
59+
echo " ** Updating contrib/python-dmidecode.spec"
60+
cat .chversion | ed contrib/python-dmidecode.spec 2> /dev/null
61+
if [ $? = 0 ]; then
62+
rm -f .chversion
63+
fi
4164
echo
42-
echo " ** git add src/version.h redhat.spec"
65+
echo " ** git add src/version.h contrib/python-dmidecode.spec"
4366
git add src/version.h contrib/python-dmidecode.spec
67+
echo "-----------------------------------------------------------------------------------"
4468
git diff --cached
69+
echo "-----------------------------------------------------------------------------------"
4570
echo
46-
echo " REMEMBER to commit this change when you have validated the result"
71+
echo " ** **"
72+
echo " ** REMEMBER to COMMIT this change when you have validated the result **"
73+
echo " ** **"
4774
echo
4875
;;
4976
*)

0 commit comments

Comments
 (0)