-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathupdate-revision.sh
More file actions
executable file
·88 lines (74 loc) · 2.97 KB
/
update-revision.sh
File metadata and controls
executable file
·88 lines (74 loc) · 2.97 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
#!/bin/bash
#This script is used to update release numbers and freshen PDF versions
#of documentation. It applies to both Delphi and Lazarus packages.
#
#The most recent tag is assumed to be in <major>-<minor>-<release> format
#It is parsed and the user asked to confirm this as the current release
#or to override any or all values. The packages are then updated with the
#new release number, the result committed and a new tag set to this commit.
#copies revision information into the lpk files.
doupdate ()
{
CHANGEDATE=`git log |grep '^Date:'|head -n 1|awk '{print $2 ", " $4, $3, $6, $5, $7};'`
REVISION=`git rev-list --count HEAD`
echo "Update in `pwd`"
V1="0"
V2="0"
V3="0"
VERSION=`git tag -l | tail -n 1`
if [ -n "$VERSION" ]; then
echo "Most Recent Version is $VERSION"
echo -n "Continue?[Y/n]"
read LINE
if [ "$LINE" != "Y" ]; then exit; fi
V1=`echo "$VERSION"|sed 's/\([0-9]\+\)\-\([0-9]\+\)-\([0-9]\+\)/\1/'`
V2=`echo "$VERSION"|sed 's/\([0-9]\+\)\-\([0-9]\+\)-\([0-9]\+\)/\2/'`
V3=`echo "$VERSION"|sed 's/\([0-9]\+\)\-\([0-9]\+\)-\([0-9]\+\)/\3/'`
fi
echo -n "Enter Major Number[$V1]:"
read LINE
if [ -n "$LINE" ]; then V1=$LINE; fi
echo -n "Enter Minor Number[$V2]:"
read LINE
if [ -n "$LINE" ]; then V2=$LINE; fi
echo -n "Enter Release Number[$V3]:"
read LINE
if [ -n "$LINE" ]; then V3=$LINE; fi
echo -n "Updating to $V1.$V2.$V3.$REVISION dated $CHANGEDATE. Is this correct?[Y/n]"
read LINE
if [ "$LINE" != "Y" ]; then exit; fi
NEWTAG="$V1-$V2-$V3"
if [ -f src/IdSecOpenSSL.pas ]; then
sed -i "s/IdSec_Major.*/IdSec_Major = $V1;/
s/IdSec_Minor.*/IdSec_Minor = $V2;/
s/IdSec_Release.*/IdSec_Release = $V3;/
s/IdSec_Version.*/IdSec_Version = '$V1.$V2.$V3';/" src/IdSecOpenSSL.pas
fi
for PKG in `find . -name '*.lpk' -print`; do
sed -i "/<CompilerOptions/,/<\/CompilerOptions/ ! { /<PublishOptions/,/<\/PublishOptions/ ! {s/<Version.*\/>/<Version Major=\"$V1\" Minor=\"$V2\" Release = \"$V3\" Build=\"$REVISION\" \/>/}}" $PKG
done
for DPRG in `find . -name '*.dproj' -print`; do
sed -i "s/\(MajorVer\">\)[0-9]\+</\1$V1</
s/\(MinorVer\">\)[0-9]\+</\1$V2</
s/\(Release\">\)[0-9]\+</\1$V3</
s/\(Build\">\)[0-9]\+</\1$REVISION</
s/\(FileVersion=\)[0-9\.]\+/\1$V1.$V2.$V3.$REVISION/
s/\(ProductVersion=\)[0-9\.]\+/\1$V1.$V2.$V3.$REVISION/" $DPRG
done
find . -type f \( -name '*.odt' -o -name '*.ods' \) -print0 | while IFS= read -r -d '' DOC; do
PDF=`echo "$DOC" | sed 's/\(.*\)\.od[t|s]$/\1.pdf/'`
if [ ! -f "$PDF" ] || [ "$DOC" -nt "$PDF" ]; then
OUTDIR=`dirname "$DOC"`
libreoffice --invisible --convert-to pdf --outdir "$OUTDIR" "$DOC"
git add "$PDF" >/dev/null 2>&1
fi
done
git commit -a -m "Revision $NEWTAG commited"
git tag -f "$NEWTAG"
}
if [ -n "`ps ax|grep libreoffice|grep -v grep`" ]; then
echo "libreoffice is running. Please terminate all instances of libreoffice before running this script"
exit 1
fi
doupdate
exit 0