summaryrefslogtreecommitdiff
path: root/cvs-kolab.sh
blob: 1389616100da62383ad68526578f39d10c8a6ac6 (plain)
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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
#!/bin/bash
#
# $Id$
#
# Copyright (C) 2007 by Gunnar Wrobel
#
# Authors:
# Gunnar Wrobel <wrobel@pardus.de>
# Thomas Arendsen Hein <thomas@intevation.de>
#
# This program is free software under the GNU GPL (>=v2)

KOLAB_VERSION="2.2.0"

KOLAB_PACKAGES=/kolab-packages
KOLAB_DEV_USER=kolabdevel
KOLAB_INSTALL_USER=kolabtest
KOLAB_REL_USER=kolabrelease

OPENPKG_USER=developer@mydomain.de

ACTION_INSTALL=0
ACTION_UPDATE=0
ACTION_CLEAN=0
ACTION_DOWNLOAD=0
ACTION_RELEASE=0

INSTALL_OPTS=""

usage() {
    echo "This tool allows you to install a CVS based Kolab server."
    echo "The script is still highly experimental and might not work as expected."
    echo
    echo "Usage:"
    echo "  -i         create a Kolab CVS environment"
    echo "  -u         Update the CVS and installed system"
    echo "  -D         Just download the source packages"
    echo "  -c         uninstall the Kolab CVS environment"
    echo "  -r         Create a fresh Kolab source release"
    echo "  -h         (display this help)"
    echo
    echo "Options:"
    echo "  -b         Package directory (default: ${KOLAB_PACKAGES})"
    echo "  -d         Kolab development user/area (default: ${KOLAB_DEV_USER})"
    echo "  -t         Kolab cvs testing user/area (default: ${KOLAB_INSTALL_USER})"
    exit 1
}

die () {
    echo $1
    exit 1
}

download() {
    mkdir -p "${KOLAB_PACKAGES}/source-original"
    cd "${KOLAB_PACKAGES}/source-original"

    echo "Downloading Kolab-Server-${KOLAB_VERSION} sources..."

    wget -q -r -l1 -nd --no-parent -c -R index.html\* http://files.kolab.org/server/release/kolab-server-${KOLAB_VERSION}/sources/ || die "Failed to download the sources!"

    echo "Verifying source authenticity ..."

    gpg -q --keyserver hkp://subkeys.pgp.net --recv-key 5816791A || die "Failed to retrieve signature key!"
    gpg -q --verify MD5SUMS.sig || die "Invalid signature on the MD5SUMS file!"
    md5sum --status -c MD5SUMS || die "The md5 hashes do not match. You should try to download the packages again."
    chmod u+x install-kolab.sh
}

install() {
    if [ ! -e "${KOLAB_PACKAGES}/source-original/release-notes.txt" ]; then
	download
    fi

    if [ ! -e "/${KOLAB_DEV_USER}/CVS" ]; then
	cd "${KOLAB_PACKAGES}/source-original"

	echo "Installing the development environment in /${KOLAB_DEV_USER}. This will take a long time ..."

	./install-kolab.sh -t "${KOLAB_DEV_USER}" -I 21414 > kolab-build.log 2>&1
	mkdir "/${KOLAB_DEV_USER}/CVS"
    fi

    cd "/${KOLAB_DEV_USER}/CVS"
    if [ ! -e "server" ]; then
	cvs -q -d :pserver:anonymous@intevation.de:/home/kroupware/jail/kolabrepository  co server
	cd server
    else
	cd server
	cvs -q update -P -d
    fi
    chown -R "${KOLAB_DEV_USER}:" "/${KOLAB_DEV_USER}/CVS"
    su - "${KOLAB_DEV_USER}" -c "cd `pwd` && make" || die "Not installing! Looks like the Kolab developers broke CVS. Bug them at https://www.intevation.de/roundup/kolab"

    cd "${KOLAB_PACKAGES}/source-original"

    SDIST_DIR="${KOLAB_PACKAGES}/source-${KOLAB_DEV_USER}"
    if [ ! -e ${SDIST_DIR} ]; then
	mkdir "${SDIST_DIR}"
    fi

    INSTALLER=`find . -name "openpkg-*.src.sh" -print`
    if [ -z "$INSTALLER" ]; then  
        echo "No source based installer found. Unable to create a source distribution!"  
        exit 1  
    fi
    cp "${INSTALLER}" "${SDIST_DIR}/"
    rsync -avz *.src.rpm "${SDIST_DIR}/"
    cp "/${KOLAB_DEV_USER}/CVS/server/install-kolab.sh" "${SDIST_DIR}/"

    rsync -avz /"${KOLAB_DEV_USER}"/RPM/PKG/*.src.rpm "${SDIST_DIR}/"

    chown -R "${KOLAB_DEV_USER}:" "${SDIST_DIR}"
    cd "${SDIST_DIR}"

    echo "Regenerating package index ..."
    /"${KOLAB_DEV_USER}"/bin/openpkg index -r . -o 00INDEX.rdf -i . || die "Indexing failed! Looks like the Kolab developers broke CVS. Bug them at https://www.intevation.de/roundup/kolab"
    
    echo "Installing the test environment in /${KOLAB_INSTALL_USER}. This will take a long time ..."

    ./install-kolab.sh -t "${KOLAB_INSTALL_USER}" -I 22414 ${INSTALL_OPTS} > kolab-build.log 2>&1

    echo "Everything finished!"
    echo "You should now run:"
    echo
    echo " /${KOLAB_INSTALL_USER}/etc/kolab/kolab_bootstrap -b"
    echo " /${KOLAB_INSTALL_USER}/bin/openpkg rc all start"
    exit 0
}

update() {
    if [ ! -e "/${KOLAB_DEV_USER}/CVS/server" ]; then
	die "There exists no CVS environment at /${KOLAB_DEV_USER}/CVS/server! Did you run ./cvs-kolab.sh -i to setup the CVS based Kolab server?"
    fi
    cd "/${KOLAB_DEV_USER}/CVS/server"
    cvs -q update -P -d
    chown -R "${KOLAB_DEV_USER}:" "/${KOLAB_DEV_USER}/CVS"
    su - "${KOLAB_DEV_USER}" -c "cd `pwd` && make" || die "Not updating! Looks like the Kolab developers broke CVS. Bug them at https://www.intevation.de/roundup/kolab"

    rsync -avz /"${KOLAB_DEV_USER}"/RPM/PKG/*.src.rpm "${KOLAB_PACKAGES}/source-${KOLAB_DEV_USER}/"

    cd "${KOLAB_PACKAGES}/source-${KOLAB_DEV_USER}"

    echo "Regenerating package index ..."  || die "Indexing failed! Looks like the Kolab developers broke CVS. Bug them at https://www.intevation.de/roundup/kolab"
    ./install-kolab.sh -t "${KOLAB_DEV_USER}" -X
    
    echo "Updating the test environment in /${KOLAB_INSTALL_USER}. This will take a long time ..."

    ./install-kolab.sh -t "${KOLAB_INSTALL_USER}" -I 22414 ${INSTALL_OPTS} > kolab-build.log 2>&1

    echo "Everything finished!"
    echo "You should now run:"
    echo
    echo " /${KOLAB_INSTALL_USER}/sbin/kolabconf"
    echo " /${KOLAB_INSTALL_USER}/bin/openpkg rc all restart"
    exit 0
}

release() {
    echo
    echo "Building release packages.... This will take a while!"
    echo
    if [ ! -e "/${KOLAB_DEV_USER}/CVS/server" ]; then
	die "There exists no CVS environment at /${KOLAB_DEV_USER}/CVS/server! Did you run ./cvs-kolab.sh -i to setup the CVS based Kolab server?"
    fi
    cd "/${KOLAB_DEV_USER}/CVS/server"
    cvs -Q update -P -d 
    chown -R "${KOLAB_DEV_USER}:" "/${KOLAB_DEV_USER}/CVS"
    mkdir -p "${KOLAB_PACKAGES}/source-release/RELEASE"
    su - "${KOLAB_DEV_USER}" -c "cd `pwd` && make clean" > "${KOLAB_PACKAGES}/source-release/make-clean.log" || die "Not releasing! Looks like the Kolab developers broke CVS. Bug them at https://www.intevation.de/roundup/kolab"
    su - "${KOLAB_DEV_USER}" -c "cd `pwd` && make" > "${KOLAB_PACKAGES}/source-release/make.log" || die "Not releasing! Looks like the Kolab developers broke CVS. Bug them at https://www.intevation.de/roundup/kolab"
    cd "${KOLAB_PACKAGES}/source-release/RELEASE"
    cp "/${KOLAB_DEV_USER}/CVS/server/install-kolab.sh" .
    cp /"${KOLAB_DEV_USER}"/CVS/server/stage/* .
    wget -q "ftp://ftp.openpkg.org/current/SRC/CORE/openpkg-*.src.sh" || die "No OpenPKG installer found!"
    ./install-kolab.sh -E -t "${KOLAB_REL_USER}" -I 23414 -F -H > ../openpkg-build.log 2>&1  || die "Couldn't build OpenPKG!"
    wget "ftp://ftp.openpkg.org/current/SRC/BASE/openpkg-tools*.src.rpm" || die "No OpenPKG tools found!"
    "/${KOLAB_REL_USER}/bin/openpkg" build -k openpkg-tools | sh > ../openpkg-tools-build.log 2>&1 || die "Couldn't build OpenPKG tools!"
    echo "----------------------------------------------------"
    echo ""
    echo " Registering your instance:"
    echo ""
    "/${KOLAB_REL_USER}/bin/openpkg" register --mode=post --user=${OPENPKG_USER} || die "Failed to register the release instance!"
    echo ""
    echo "  Registered your instance."
    echo "  Now go to http://registry.openpkg.org/register and"
    echo "  associate your release instance."
    echo ""
    echo "----------------------------------------------------"
    echo "Press [Enter] after registering..."
    echo ""
    read ANSWER
    PLATFORM=`/"${KOLAB_REL_USER}"/lib/openpkg/shtool platform --type=binary`
    rm *$PLATFORM*
    chown ${KOLAB_REL_USER} .
    "/${KOLAB_REL_USER}/bin/openpkg" index -r . -o 00INDEX.rdf -i . > ../local-index.log 2>&1 || die "Failed generating the Kolab package index!"
    cd ..
    cp RELEASE/install-kolab.sh .
    cat << __EOF > 00INDEX.rdf
<?xml version="1.0" encoding="iso-8859-1"?>
 <rdf:RDF
      xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
      xmlns="http://www.openpkg.org/xml-rdf-index/0.9">
   <Repository rdf:resource="OpenPKG-CURRENT/">
     <Repository rdf:resource="OpenPKG-CURRENT/Source/" href="ftp://ftp.openpkg.org/current/SRC/00INDEX.rdf.bz2"/>
     <Repository rdf:resource="RELEASE/" href="RELEASE/00INDEX.rdf"/>
   </Repository>
</rdf:RDF>
__EOF

    ./install-kolab.sh -t "${KOLAB_REL_USER}" -I 23414 -F -H > kolab-build.log2 2>&1 || die "Failed to build the Kolab server!"
    cp /"${KOLAB_REL_USER}"/RPM/PKG/*.src.rpm RELEASE/
    cd RELEASE
    "/${KOLAB_REL_USER}/bin/openpkg" index -r . -o 00INDEX.rdf -i . > ../final-index.log 2>&1 || die "Failed generating the final release index!"
    md5sum *.sh *.rpm > MD5SUMS
    cd ..

    echo "Everything finished!"
    echo "The release sources have been prepared in ${KOLAB_PACKAGES}/source-release/RELEASE"
    echo "Your test installation resides in /${KOLAB_REL_USER}"
    echo
    echo "Configure the release installation with"
    echo
    echo " /${KOLAB_REL_USER}/sbin/kolabconf"
    echo " /${KOLAB_REL_USER}/bin/openpkg rc all restart"
    echo
    echo "If everything is ready for a release, sign the md5 hashes in RELEASE with"
    echo
    echo " gpg --clearsign MD5SUMS"
    echo
    echo "and upload the packages."
    exit 0
}

clean() {
    echo "This will completely wipe ${KOLAB_PACKAGES}, /${KOLAB_DEV_USER}, and /${KOLAB_INSTALL_USER}."
    echo "Are you certain you want to do that (YES/NO)?"
    read ANSWER
    if [ "$ANSWER" == "YES" ]; then
	rm -rf "${KOLAB_PACKAGES}"
	rm -rf "/${KOLAB_DEV_USER}"
	rm -rf "/${KOLAB_INSTALL_USER}"
	exit 0
    else
	echo "Not cleaning."
	exit 0
    fi
}



while getopts hircuDHFb:d:t: ARGS; do
    case $ARGS in
	h) # Display help
	    usage
	    ;;
	i) # Install
	    ACTION_INSTALL=1
	    ;;
	c) # Clean
	    ACTION_CLEAN=1
	    ;;
	u) # Update
	    ACTION_UPDATE=1
	    ;;
	r) # 
	    ACTION_RELEASE=1
	    ;;
	D) # Download
	    ACTION_DOWNLOAD=1
	    ;;
	b) # User wants a different package directory
	    KOLAB_PACKAGES="${OPTARG}"
	    ;;
	d) # User wants a different development user
	    KOLAB_DEV_USER="${OPTARG}"
	    ;;
	t) # User wants a different testing user
	    KOLAB_INSTALL_USER="${OPTARG}"
	    ;;
    esac
done

if [ "${ACTION_DOWNLOAD}" == "1" ]; then
    download
    exit 0
fi

if [ "${ACTION_INSTALL}" == "1" ]; then
    install
fi

if [ "${ACTION_CLEAN}" == "1" ]; then
    clean
fi

if [ "${ACTION_RELEASE}" == "1" ]; then
    release
fi

update