]> git.ipfire.org Git - thirdparty/sarg.git/blob - archive.sh
Check the release date when archiving the project
[thirdparty/sarg.git] / archive.sh
1 #!/bin/sh
2
3 Sources="."
4 Target=".."
5
6 # check version number in every file
7 Version=$(cat "$Sources/CMakeLists.txt" | sed -n -e 's/^SET(sarg_VERSION \([0-9]\))/\1/p')
8 if [ -z "$Version" ] ; then
9 echo "No version found in CMakeLists.txt"
10 exit 1
11 fi
12 Revision=$(cat "$Sources/CMakeLists.txt" | sed -n -e 's/^SET(sarg_REVISION "\([0-9][0-9]*.*\)")/\1/p')
13 if [ -z "$Revision" ] ; then
14 echo "No revision found in CMakeLists.txt"
15 exit 1
16 fi
17 Version="$Version.$Revision"
18
19 VersionCheck=$(cat "$Sources/configure.in" | sed -n -e 's/^AC_INIT(\[sarg\],\[\([0-9][0-9]*\.[0-9][0-9]*.*\)\])/\1/p')
20 if [ -z "$VersionCheck" ] ; then
21 echo "No version found in configure.in"
22 exit 1
23 fi
24 if [ "x$Version" != "x$VersionCheck" ] ; then
25 echo "CMakeLists and configure doesn't refer to the same version"
26 exit 1
27 fi
28
29 # Check release date
30 ReleaseDate=$(cat "$Sources/CMakeLists.txt" | sed -n -e 's/^SET(sarg_BUILDDATE "\([A-Z][a-z][a-z]-[0-3][0-9]-2[0-1][0-9][0-9]\)")/\1/p')
31 if [ -z "$ReleaseDate" ] ; then
32 echo "No release date found or release date is invalide in CMakeLists.txt"
33 exit 1
34 fi
35
36 ReleaseDateCheck=$(cat "$Sources/include/info.h" | sed -n -e 's/^#define VERSION PACKAGE_VERSION" \([A-Z][a-z][a-z]-[0-3][0-9]-2[0-1][0-9][0-9]\)"/\1/p')
37 if [ -z "$ReleaseDateCheck" ] ; then
38 echo "No release date found or release date is invalide in include/info.h"
39 exit 1
40 fi
41 if [ "x$ReleaseDate" != "x$ReleaseDateCheck" ] ; then
42 echo "CMakeLists and include/info.h doesn't refer to the same release date"
43 exit 1
44 fi
45
46 # update the po files
47 if ( ! make update-po ) ; then
48 echo "Failed to update the po files"
49 exit 1
50 fi
51
52 # is the git repository dirty?
53 if [[ $(git diff --shortstat 2> /dev/null) != "" ]] ; then
54 echo "Git repository is dirty"
55 exit 1
56 fi
57
58 # check the working tree
59 if ( ! git diff-files --quiet ) ; then
60 echo "Uncommitted changes in working tree"
61 exit 1
62 fi
63
64 # check the index for uncommitted changes
65 if ( ! git diff-index --quiet --cached HEAD ) ; then
66 echo "Uncommitted changes in the index"
67 exit 1
68 fi
69
70 # check for untracked files
71 Untracked="$(git ls-files --exclude-standard --others)"
72 if [[ -n "$Untracked" ]] ; then
73 echo "Untracked files in directory"
74 echo "$Untracked"
75 exit 1
76 fi
77
78 # is the git tag set?
79 # a valid tag can be v2.3.3 or v2.3.3_da to indicate version 2.3.3 with the Danish translation
80 GitVersion=$(git describe | sed -e 's/^\(v[0-9][0-9.]*\)_.*/\1/')
81 if [[ "$GitVersion" != "v$Version" ]] ; then
82 echo "Git tag not set for version $Version. Use command:"
83 echo "git tag -a \"v$Version\" -m \"v$Version\""
84 exit 1
85 fi
86
87 # prepare the archive
88 SargList="$Target/sarglist.txt.unsort"
89 SortList="$Target/sarglist.txt"
90 DirList="$Target/sargdir.txt"
91 ExcludeList="$Target/sargexclude.txt"
92 ArchiveFile="$Target/sarg-$Version.tar"
93
94 SedSources=$(echo "$Sources" | sed -e 's/\./\\./')
95 ls $Sources/*.c | sed -e "s/^$SedSources\///" > $SargList
96 ls $Sources/include/*.h | sed -e "s/^$SedSources\///" >> $SargList
97 ls $Sources/po/*.{po,gmo,pot} | sed -e "s/^$SedSources\///" >> $SargList
98
99 echo "
100 config.h
101 ABOUT-NLS
102 aclocal.m4
103 BETA-TESTERS
104 ChangeLog
105 CMakeLists.txt
106 configure.in
107 CONTRIBUTORS
108 COPYING
109 css.tpl
110 DONATIONS
111 Doxyfile
112 exclude_codes
113 htaccess
114 LICENSE
115 Makefile.in
116 PROGRAMMERS
117 README
118 README_cmake
119 sarg.1
120 sarg.conf
121 sarg_htaccess
122 user_limit_block
123 cfgaux
124 documentation
125 fonts
126 images
127 include/config.h.in
128 sarg-php
129 sarg_manpage.xml
130 po/remove-potcdate.sin
131 po/Makefile.in.in
132 po/POTFILES.in
133 po/quot.sed
134 po/Rules-quot
135 po/insert-header.sin
136 po/ChangeLog
137 po/LINGUAS
138 po/en@quot.header
139 po/en@boldquot.header
140 po/boldquot.sed
141 po/Makevars
142 sorttable/sorttable.js
143 " >> $SargList
144
145 [ -f "$DirList" ] && rm "$DirList"
146 cat $SargList | while read file
147 do
148 [ -z "$file" ] && continue
149 if [ -f "$file" ] ; then
150 echo "$file" >> "$DirList"
151 elif [ -d "$file" ] ; then
152 find "$file" -type f >> "$DirList"
153 else
154 echo "Unknown file type $file"
155 exit 1
156 fi
157 done
158 rm "$SargList"
159
160 sort -u "$DirList" | sed -e '/^$/d' > "$SortList"
161 rm "$DirList"
162
163 echo "
164 */.svn
165 */.git
166 *~
167 *.o
168 .gitignore
169 " > "$ExcludeList"
170
171 tar cf "$ArchiveFile" -C "$Sources" --files-from="$SortList" --exclude-from="$ExcludeList" --no-recursion --transform="s,^,sarg-$Version/," --owner root --group root --mode 644
172 tar rf "$ArchiveFile" -C "$Sources" "configure" --exclude-from="$ExcludeList" --transform="s,^,sarg-$Version/," --owner root --group root --mode 755
173 gzip -f "$ArchiveFile"
174 CompressFile="$ArchiveFile.gz"
175
176 md5sum $CompressFile > "$Target/sarg-$Version.md5sum"
177 echo "md5sum:"
178 cat "$Target/sarg-$Version.md5sum"
179
180 sha1sum $CompressFile > "$Target/sarg-$Version.sha1sum"
181 echo "sha1sum:"
182 cat "$Target/sarg-$Version.sha1sum"
183
184 sha256sum $CompressFile > "$Target/sarg-$Version.sha256sum"
185 echo "sha256sum:"
186 cat "$Target/sarg-$Version.sha256sum"