dist.sh 6.18 KB
Newer Older
Vivien Kraus's avatar
Vivien Kraus committed
1
2
#!/bin/sh

Vivien Kraus's avatar
Vivien Kraus committed
3
4
5
6
# HACKS!!!!
#
# Remove VALAFLAGS="--target-glib=2.50"

Vivien Kraus's avatar
Vivien Kraus committed
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
apt-get update
apt-get upgrade -y
apt-get install -y \
	appstream-util \
	autoconf \
	autoconf-archive \
	autogen \
	automake \
	autopoint \
	bison \
	build-essential \
	check \
	curl \
	dbus \
	dbus-x11 \
	devscripts \
	emacs \
	emacs-goodies-el \
	flex \
	gcc \
	gettext \
	git \
	gnulib \
	gobject-introspection \
	gperf \
	graphviz \
	help2man \
	imagemagick \
	indent \
	jekyll \
	jq \
	libcairo2-dev \
	libgirepository1.0-dev \
	libglib2.0-dev \
	libgtk-3-dev \
	libreadline-dev \
	libtool \
	libxml2 \
	libxml2-dev \
	libxml2-utils \
	make \
	nettle-dev \
	org-mode \
	pkg-config \
	r-cran-ggplot2 \
	texinfo \
	valac \
	valgrind \
	xsltproc

export $(dbus-launch)

59
60
61
62
63
64
SOURCE_TOP=$(pwd)
CLEAN_TOP=$(cd .. && pwd)/clean
mkdir -p ../clean
chmod -R ugo+w ../clean || exit 1
rm -rf ../clean || exit 1
mkdir -p ../clean || exit 1
Vivien Kraus's avatar
Vivien Kraus committed
65
rm -rf $SOURCE_TOP/dist || exit 1
66
67
68
69
70

cd $CLEAN_TOP
git clone $SOURCE_TOP . || exit 1

cd $SOURCE_TOP || exit 1
Vivien Kraus's avatar
Vivien Kraus committed
71
rm -rf ../tarot-*.tar.gz ../tarot-*/ tarot-*.tar.gz
72
sh autogen.sh VALAFLAGS="--target-glib=2.50" || exit 1
73
./configure \
74
    CFLAGS="-Wall -Wextra -Werror -g $CFLAGS" \
Vivien Kraus's avatar
Vivien Kraus committed
75
    VALAFLAGS="--target-glib=2.50" \
Vivien Kraus's avatar
Vivien Kraus committed
76
    --prefix="$SOURCE_TOP/dist" \
Vivien Kraus's avatar
Vivien Kraus committed
77
    --enable-valgrind=yes \
Vivien Kraus's avatar
Vivien Kraus committed
78
    --enable-silent-rules=yes \
79
80
    || (cat config.log ; exit 1) \
    || exit 1
Vivien Kraus's avatar
Vivien Kraus committed
81
(cd lib && make -j 16 CFLAGS="-Wno-error -g $CFLAGS") || exit 1
Vivien Kraus's avatar
Vivien Kraus committed
82
make -j 16 safe || exit 1
Vivien Kraus's avatar
Vivien Kraus committed
83
make -j 16 distcheck || exit 1
Vivien Kraus's avatar
Vivien Kraus committed
84
make -j 8 check || exit 1
85
make -j 16 install install-html || exit 1
Vivien Kraus's avatar
Vivien Kraus committed
86
make indent || exit 1
87
88
89
rm -rf ../../tarot-*.tar.gz ../../tarot-*/
cp tarot-*.tar.gz ../../ || exit 1
cd ../../ || exit 1
90
91
tar xf tarot-*.tar.gz || exit 1
cd tarot-* || exit 1
92
DIST_TOP=$(pwd)
Vivien Kraus's avatar
Vivien Kraus committed
93
cd $CLEAN_TOP || exit 1
94
OK="yes"
Vivien Kraus's avatar
Vivien Kraus committed
95
for source in $(find . -type f)
96
97
98
99
100
101
do
    case $source in
	*.po | *.pot)
	    echo "Ignoring PO file $source, as it has a date in it.";;
	*.md)
	    echo "Ignoring Markdown file $source, as it may be non-reproducibly generated by org-mode.";;
Vivien Kraus's avatar
Vivien Kraus committed
102
	*/.git/*);;
103
	*)
Vivien Kraus's avatar
Vivien Kraus committed
104
	    if diff $source $DIST_TOP/$source
Vivien Kraus's avatar
Vivien Kraus committed
105
	    then
Vivien Kraus's avatar
Vivien Kraus committed
106
107
		echo "$source: OK"
	    else
Vivien Kraus's avatar
Vivien Kraus committed
108
109
110
		echo "ERROR: $source has been modified since check-in, or ignored from the distribution.  Is it automatically generated?  Did you forget to indent it?  Did you forget to include it as distributed in Automake?"
		OK="no"
	    fi;;
111
112
	esac
done;
Vivien Kraus's avatar
Vivien Kraus committed
113
114
115
116
117
118
119
120
cd $DIST_TOP || exit 1
./configure && make maintainer-clean || exit 1
echo "Checking what files are maintainer-clean..."
for source in $(find . -type f)
do
    case $source in
	*.po | *.pot)
	    echo "Ignoring PO file $source, as it has a date in it.";;
Vivien Kraus's avatar
Vivien Kraus committed
121
122
	./po/en@quot.header | ./po/en@boldquot.header | ./po/Rules-quot | ./po/remove-potcdate.sin | ./po/boldquot.sed | ./po/quot.sed | ./po/insert-header.sin | ./po/Makefile.in.in)
	    echo "Ignoring Gettext garbage $source.";;
Vivien Kraus's avatar
Vivien Kraus committed
123
124
125
126
	./libopts/*)
	    echo "Ignoring embedded file $source, as it is not ours.";;
	./.tarball-version)
	    echo "Ignoring .tarball-version.";;
Vivien Kraus's avatar
Vivien Kraus committed
127
	./lib/* | ./snippet/*)
Vivien Kraus's avatar
Vivien Kraus committed
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
	    echo "Ignoring $source, some gnulib stuff.";;
	./m4/*)
	    echo "Ignoring autoconf macro $source.";;
	./git-version-gen | ./gitlog-to-changelog)
	    echo "Ignoring helper script $source.";;
	./compile | ./depcomp | ./config.rpath | ./config.sub | ./texinfo.tex | ./ar-lib | ./INSTALL | ./missing | ./test-driver | ./ltmain.sh | ./aclocal.m4 | ./ChangeLog | ./config.h.in | ./config.guess | ./Makefile.in | ./configure | ./install-sh | ./ABOUT-NLS)
	    echo "Ignoring required automake script $source.";;
	*)
	    if diff $source $CLEAN_TOP/$source
	    then
		echo "$source: OK"
	    else
		echo "ERROR: $source is not a maintainer-clean file, but it has been rebuilt or deleted since checkout.  If this file has been generated, add it to MAINTAINERCLEANFILES."
		OK="no"
	    fi;;
    esac
done;
Vivien Kraus's avatar
Vivien Kraus committed
145
146
147
148
149
if test "$OK" = "no"
then
    echo "Failure."
    exit 1
fi
150
151
152

## Nice!
cd $SOURCE_TOP || exit 1
Vivien Kraus's avatar
Vivien Kraus committed
153
mkdir -p $SOURCE_TOP/dist || exit 1
Vivien Kraus's avatar
Vivien Kraus committed
154
cp $SOURCE_TOP/.version \
Vivien Kraus's avatar
Vivien Kraus committed
155
156
   $SOURCE_TOP/dist/version || exit 1
cp tarot-*.tar.gz $SOURCE_TOP/dist/ || exit 1
Vivien Kraus's avatar
Vivien Kraus committed
157
158
159
160
161

if test "x$CI_COMMIT_TAG" != "x"
then
    cd $SOURCE_TOP
    TARFILE=$(ls dist/tarot-*.tar.gz)
Vivien Kraus's avatar
Vivien Kraus committed
162
    SHASUM=$(sha256sum $TARFILE | head -c 64)
Vivien Kraus's avatar
Vivien Kraus committed
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
    UPLOAD_STATUS=$(curl \
	      --request POST \
	      --header "PRIVATE-TOKEN: $PRIVATE_TOKEN" \
	      --form \
	      "file=@$TARFILE" "$CI_API_V4_URL/projects/$CI_PROJECT_ID/uploads")
    URL=$(echo "$UPLOAD_STATUS" | jq -r '.url')

    echo "Upload $TARFILE to $CI_API_V4_URL/projects/$CI_PROJECT_ID/uploads: $UPLOAD_STATUS"

    NAME="Tarot release"
    TAG_NAME="$CI_COMMIT_TAG"
    DESCRIPTION=$(git tag -l --format='%(contents)' "$CI_COMMIT_TAG")
    FULL_URL="${CI_PROJECT_URL}${URL}"
    LINK="{\"name\": \"$TARFILE\", \"url\": \"$FULL_URL\"}"
    ASSETS="{\"links\": [$LINK]}"
    DESCRIPTION_ESCAPED=$(echo "$DESCRIPTION" | jq -R --slurp '.')
    DATA="{\"name\": \"$NAME\", \"tag_name\": \"$TAG_NAME\", \"description\": $DESCRIPTION_ESCAPED, \"assets\": $ASSETS}"

    echo "POSTing $DATA to $CI_API_V4_URL/projects/$CI_PROJECT_ID/releases"

    curl --header 'Content-Type: application/json' \
	 --header "PRIVATE-TOKEN: $PRIVATE_TOKEN" \
	 --data "$DATA" \
	 --request POST \
187
188
	 "$CI_API_V4_URL/projects/$CI_PROJECT_ID/releases" || exit 1
    mkdir /root/.ssh || exit 1
Vivien Kraus's avatar
Vivien Kraus committed
189
190
    echo "$SSH_KEY" > /root/.ssh/id_rsa || exit 1
    echo "$SSH_KEY_PUB" > /root/.ssh/id_rsa.pub || exit 1
Vivien Kraus's avatar
Vivien Kraus committed
191
192
    echo "$SSH_KNOWN_HOSTS" > /root/.ssh/known_hosts || exit 1
    chmod go-rwx /root/.ssh/id_rsa || exit 1
Vivien Kraus's avatar
Vivien Kraus committed
193
194
    git config --global user.email "vivien@planete-kraus.eu" || exit 1
    git config --global user.name "Gitlab CI for the tarot package" || exit 1
195
196
197
198
    git clone git@framagit.org:play-tarot/tarot-flatpak.git || exit 1
    cd tarot-flatpak || exit 1
    ./update-tarot.sh "$FULL_URL" "$SHASUM" || exit 1
    git add . || exit 1
Vivien Kraus's avatar
Vivien Kraus committed
199
200
    git commit -m"New version"
    git push
Vivien Kraus's avatar
Vivien Kraus committed
201
202
203
204
205
    cd .. || exit 1
    git clone git@framagit.org:play-tarot/tarot-deb.git || exit 1
    cd tarot-deb || exit 1
    ./update-tarot.sh "$FULL_URL" "$(cat $SOURCE_TOP/.version)" || exit 1
    git add . || exit 1
Vivien Kraus's avatar
Vivien Kraus committed
206
207
    git commit -m"New version"
    git push
208
209
210
211
    cd .. || exit 1
    git clone git@framagit.org:play-tarot/tarot-mingw.git || exit 1
    cd tarot-mingw || exit 1
    ./update-tarot.sh "$FULL_URL" || exit 1
Vivien Kraus's avatar
Vivien Kraus committed
212
    git add .
213
214
    git commit -m"New version"
    git push
Vivien Kraus's avatar
Vivien Kraus committed
215
fi