summaryrefslogtreecommitdiff
path: root/bin/x2go-buildpackage
blob: 683f57f28970fdfabe9cd205fc00e4249d138bc5 (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
#!/bin/bash

# Copyright (C) 2010 by Mike Gabriel <mike.gabriel@das-netzwerkteam.de>
#
# This programme is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.
#
# This programme is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the
# Free Software Foundation, Inc.,
# 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.

set -e
set -x

test -z $1 && { echo usage: <x2go-git-project> [main|heuler]; exit -1; }

PDEBUILD="pdebuild-user-mode-linux"
TEMP_BASE="$HOME/tmp/"

PACKAGE=$1
CHECKOUT=${2-master}
COMPONENT=${3-heuler}

PACKAGE_DIR=$(pwd)/$PACKAGE
DIST_SUPPORTED="debian ubuntu"
PKGDIST="$(pwd)/../pkg-dist/$PACKAGE"

# in any case remove the BUILDS_FOR file
rm -f $PACKAGE_DIR/BUILDS_FOR

# make sure our local working copy is up to date...
test -d $PACKAGE_DIR/.git && { cd $PACKAGE_DIR && git reset --hard; git pull; git checkout $CHECKOUT; } || { git clone git://code.x2go.org/$PACKAGE.git && cd $PACKAGE_DIR && git checkout $CHECKOUT; }
cd $PACKAGE_DIR

# by default we build for all current debian versions
test -f BUILDS_FOR || cat > BUILDS_FOR <<EOF
debian: sid wheezy squeeze
#ubuntu: lucid maverick natty
EOF

# pkgdist directory cleanup
cat BUILDS_FOR | egrep -v '(^$|^#.*$)' | while read line; do
	l_DIST=$(echo $line | cut -d":" -f1 | tr [A-Z] [a-z])
	CODENAMES=$(echo $line | cut -d":" -f2- | tr [A-Z] [a#-z])
	echo "$DIST_SUPPORTED" | grep $l_DIST >/dev/null && {
		for l_CODENAME in $CODENAMES; do
			mkdir -p $PKGDIST/$l_DIST/$l_CODENAME
			rm -f $PKGDIST/$l_DIST/$l_CODENAME/$PACKAGE_*.changes
			rm -f $PKGDIST/$l_DIST/$l_CODENAME/$PACKAGE_*.upload
			rm -f $PKGDIST/$l_DIST/$l_CODENAME/$PACKAGE_*.build
			rm -f $PKGDIST/$l_DIST/$l_CODENAME/$PACKAGE_*.dsc
			rm -f $PKGDIST/$l_DIST/$l_CODENAME/$PACKAGE_*.tar.gz
			rm -f $PKGDIST/$l_DIST/$l_CODENAME/$PACKAGE*.deb
		done
	}
done


# use pbuilder for building all variants of this package
cat BUILDS_FOR | egrep -v '(^$|^#.*$)' | while read line; do
	l_DIST=$(echo $line | cut -d":" -f1 | tr [A-Z] [a-z])
	CODENAMES=$(echo $line | cut -d":" -f2- | tr [A-Z] [a#-z])
	echo "$DIST_SUPPORTED" | grep $l_DIST >/dev/null && {
		for l_CODENAME in $CODENAMES; do
			TEMP_DIR="$(mktemp -d --tmpdir=$TEMP_BASE)"
			mkdir -p $TEMP_DIR/$PACKAGE
			git clone git://code.x2go.org/$PACKAGE.git $TEMP_DIR/$PACKAGE/ 
			cd $TEMP_DIR/$PACKAGE
			git checkout $CHECKOUT
			# translate the version name for Debian releases
			[ "x$l_CODENAME" = "xsid" ] && VERSION=unstable
			[ "x$l_CODENAME" = "xwheezy" ] && VERSION=testing
			[ "x$l_CODENAME" = "xsqueeze" ] && VERSION=stable
			[ "x$l_CODENAME" = "xlenny" ] && VERSION=oldstable
			
			# modify the section for non-main package builds
			[ "x$COMPONENT" = "xmain" ] || {
				mv debian/control debian/control.tmp
				cat debian/control.tmp | sed  "s#Section:[\ ]*\(.*\)#Section: $COMPONENT/\1#g" > debian/control
			}
			
			# modify changelog for this build
			DEBEMAIL=git-admin@x2go.org DEBFULLNAME="X2go Git Administrator" dch --distribution $VERSION --force-distribution -l "+$l_CODENAME~$COMPONENT" "Auto-built $l_DIST $l_CODENAME package for packages.x2go.org repository."
			cat debian/control | egrep 'Architecture.*(all|any|amd64)' >/dev/null && {
				DIST=$l_DIST CODENAME=$l_CODENAME ARCH=amd64 $PDEBUILD --auto-debsign --debsign-k F4A7678C9C6B0B2B --buildresult $PKGDIST/$l_DIST/$l_CODENAME
			}
			cat debian/control | egrep 'Architecture.*(any|i386)' >/dev/null && {
				DIST=$l_DIST CODENAME=$l_CODENAME ARCH=i386  $PDEBUILD --auto-debsign --debsign-k F4A7678C9C6B0B2B --buildresult $PKGDIST/$l_DIST/$l_CODENAME
			}
			cd -
			rm -Rf $TEMP_DIR
		done
		echo
	}
	echo
done

# dupload the new packages to the reprepro repository
cd $PKGDIST
cat $PACKAGE_DIR/BUILDS_FOR | egrep -v '(^$|^#.*$)' | while read line; do
	l_DIST=$(echo $line | cut -d":" -f1 | tr [A-Z] [a-z])
	CODENAMES=$(echo $line | cut -d":" -f2- | tr [A-Z] [a-z])
	for l_CODENAME in $CODENAMES; do
		cd $PKGDIST/$l_DIST/$l_CODENAME
		dupload --to x2go-$l_DIST-$l_CODENAME $PACKAGE_*.changes
		cd -
	done
done
cd -