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