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

# Copyright (C) 2011 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.

test -z $1 && { echo "usage: <x2go-git-project> {main,main/<codename>,heuler,heuler/<codename>} [<git-checkout>]"; exit -1; }

set -ex

set_vars() {
	USE_SUDO="yes"
	PDEBUILD="pdebuild --pbuilder qemubuilder"
	TEMP_BASE="$HOME/tmp/"

	# first argv is the name of the Git project
	PROJECT=$1

	# grab repository component area from command line (2nd argv) or guess it
	ARGV2_COMPONENT=$(echo $2 | cut -d"/" -f1)
	ARGV2_CODENAME=$(echo $2 | cut -d"/" -f2)
	COMPONENT=${ARGV2_COMPONENT:-${COMPONENT:-heuler}}
	CODENAMES=${ARGV2_CODENAME:-${CODENAME_ONLY:-sid}}
	if [ "x$COMPONENT" = "xmain" ]; then
		CHECKOUT=${3:-build-main}
	elif [ "x$COMPONENT" = "xheuler" ]; then
		CHECKOUT=${3:-master}
		DATE="~${DATE:-$(date +%Y%m%d)}"
	else
		echo "error: no such package component area for X2go packages. Aborting..."
		exit -1
	fi
	# the DATE might be given as ,,today'' from the command line
	[ "x$DATE" = "xtoday" ] && DATE="~$(date +%Y%m%d)"

	# setting paths
	PROJECT_DIR=$HOME/build/$COMPONENT/$PROJECT
	DIST_SUPPORTED="debian ubuntu"
	PKGDIST="$HOME/pkg-dist/$COMPONENT/$PROJECT"

	# creating paths
	mkdir -p "$TEMP_BASE"
	mkdir -p $PROJECT_DIR
	mkdir -p $PKGDIST

	return 0
}

upload_packages() {
	# dupload the new packages to the reprepro repository
	cd $PKGDIST
	cat $PROJECT_DIR/BUILDS_FOR | egrep -v '(^$|^#.*$)' | while read line; do
		l_DIST=$(echo $line | cut -d":" -f1 | tr [A-Z] [a-z])
		CODENAMES=${CODENAMES:-$(echo $line | cut -d":" -f2- | tr [A-Z] [a#-z])}
		for l_CODENAME in $CODENAMES; do
			for l_ARCH in amd64 i386; do 
				cd $PKGDIST/$l_DIST/$l_CODENAME/$l_ARCH
				ls $PROJECT_*.changes &>/dev/null && dupload --to x2go-$l_DIST-$l_CODENAME $PROJECT_*.changes
				cd -
			done
		done
	done
	cd -
	return 0
}

### MAIN ###
set_vars $@ && upload_packages