summaryrefslogtreecommitdiffstats
path: root/bin/git-debian-init
blob: 37235d9efb3274d29d5324ec65bfc0f4be977a08 (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
#!/bin/sh

# source-tools - Manage Git repositories effectively and efficiently
# Copyright (C) 2014-2017 Daniel Baumann <daniel.baumann@open-infrastructure.net>
#
# This program 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 program 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, see <http://www.gnu.org/licenses/>.

set -e

MODE="$(basename ${0} | sed -e s'|^git-||' -e 's|-init$||')"

DSCS="${@}"

for DSC in ${DSCS}
do
	PACKAGE="$(basename ${DSC} .dsc | awk -F_ '{ print $1 }')"

	dget --download-only "${DSC}"
	dpkg-source -x --no-copy --skip-debianization $(basename ${DSC}) ${PACKAGE}

	cd ${PACKAGE}
	git init --shared
	git commit -a -s -S -m "Initial commit." --allow-empty

	VERSION="$(awk '/^Version: / { print $2 }' ../$(basename ${DSC}) | head -n1)"

	FILE_VERSION="$(echo ${VERSION} | awk -F: '{ print $2 }')"
	FILE_VERSION="${FILE_VERSION:-${VERSION}}"

	if [ -e debian ]
	then
		mv debian ../debian.orig
	fi

	git-upstream-add ${VERSION}

	git checkout -b debian

	if [ -e ../debian.orig ]
	then
		mv ../debian.orig debian
	fi

	if [ -e ../${PACKAGE}_${FILE_VERSION}.diff.gz ]
	then
		zcat ../${PACKAGE}_${FILE_VERSION}.diff.gz | patch -Np1
	fi

	if ls ../${PACKAGE}_${FILE_VERSION}.debian.tar.* > /dev/null 2>&1
	then
		tar xf ../${PACKAGE}_${FILE_VERSION}.debian.tar.*
	fi

	git-debian-add

	case "${MODE}" in
		debian)
			;;

		*)
			git checkout -b ${MODE}
			;;
	esac
done

exit 0

	if [ "${MODE}" = "progress-linux" ]
	then
		if [ -e debian/control.in ]
		then
			CONTROL=debian/control.in
		else
			CONTROL=debian/control
		fi

		sed -i -e "s|^Maintainer: \(.*$\)|Maintainer: Progress Linux Maintainers <maintainers@lists.progress-linux.org>\nXSBC-Original-Maintainer: \1|" ${CONTROL}
		git commit -a -s -S -m 'Updating maintainer field.'

		if grep -qs "^Uploaders:" ${CONTROL}
		then
			sed -i -e "s|^Uploaders: \(.*$\)|XSBC-Uploaders: Daniel Baumann <daniel.baumann@progress-linux.org\nXSBC-Original-Uploaders: \1|" ${CONTROL}
		else
			sed -i -e "s|^\(Maintainer: .*$\)|\1\nXSBC-Uploaders: Daniel Baumann <daniel.baumann@progress-linux.org|" ${CONTROL}
		fi

		git commit -a -s -S -m "Updating uploaders field."

		if grep -qs "^Bugs:" ${CONTROL}
		then
			sed -i -e "s|^Bugs: \(.*$\)|Bugs: mailto:bugs@lists.progress-linux.org\nXSBC-Original-Bugs: \1|" ${CONTROL}
		else
			sed -i -e "s|^\(Uploaders: .*$\)|\1\nBugs: mailto:bugs@lists.progress-linux.org|" ${CONTROL}
		fi

		git commit -a -s -S -m "Updating bugs field."




	fi
done