aboutsummaryrefslogtreecommitdiff
path: root/tools/gator/debian/scripts/do-packaging
blob: 685c93474a260c00cbd084ac5fd1ed0f0940f3be (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
#!/bin/bash

set -e

while [ $1 ]
do
	OPT=$1
	shift
	if [ "$OPT" == "--commit" ]
	then
		OPT_COMMIT=y
		continue
	fi
	if [ "$OPT" == "--sign" ]
	then
		OPT_SIGN=y
		continue
	fi
	if [ "$OPT" == "--no-git-clean" ]
	then
		OPT_NO_GIT_CLEAN=y
		continue
	fi
	echo $0: Unknown option: "$OPT" 1>&2
	exit 1
done


#
# Clean working dirctory
#

if [ ! $OPT_NO_GIT_CLEAN ]
then
	git reset --hard HEAD
	git clean -dfx ../..
fi
git checkout debian/changelog

if [ ! -d module ]
then
	mkdir module
	cp -a ../../drivers/gator/* module/
fi

#
# Update changelog
#

if [ "$DEBEMAIL" == "" -o "$DEBFULLNAME" == "" ]
then
	export DEBEMAIL='jon.medhurst@linaro.org'
	export DEBFULLNAME='Jon Medhurst (Tixy)'
fi
dch -i -c debian/changelog CHANGE_MSG

TIMESTAMP="$(date -u +%Y%m%d%H%M%S)"
sed -i -e "1 s/ubuntu1/-$TIMESTAMP/" debian/changelog

GIT_COMMIT="$(git rev-parse HEAD)"
GIT_REMOTE_AND_BRANCH="$(git show-ref | sed -n 's,'$GIT_COMMIT'.*refs/remotes/\(.*\),\1,p' | sed -n 1p)"
GIT_REMOTE=$(echo $GIT_REMOTE_AND_BRANCH | awk -F/ '{print $1}')
GIT_BRANCH=$(echo $GIT_REMOTE_AND_BRANCH | awk -F/ '{print $2}')
GIT_URL="$(git remote -v show $GIT_REMOTE | sed -n 's/.*Fetch URL: \(.*\)/\1/p')"
GIT_TAG="$(git describe --exact-match --tags $GIT_COMMIT 2>/dev/null || echo "")"

CHANGE_MSG="Automatically packaged from git repository:\n"
CHANGE_MSG="$CHANGE_MSG    URL:    $GIT_URL\n"
CHANGE_MSG="$CHANGE_MSG    Tag:    $GIT_TAG\n"
CHANGE_MSG="$CHANGE_MSG    Branch: $GIT_BRANCH\n"
CHANGE_MSG="$CHANGE_MSG    Commit: $GIT_COMMIT"
sed -i -e "s%CHANGE_MSG%$CHANGE_MSG%" debian/changelog

echo $CHANGE_MSG

FULL_VERSION="$(sed -n '1s/.*(\(.*\)).*/\1/p' debian/changelog)"
VERSION="$(echo $FULL_VERSION | sed 's/\([0-9.]*\).*/\1/')"
sed "s/__VERSION__/$VERSION/g" debian/dkms.conf.in > debian/dkms.conf
sed "s/__VERSION__/$VERSION/g" debian/gator-module-dkms.install.in > debian/gator-module-dkms.install


#
# Commit changes
#

if [ $OPT_COMMIT ]
then
	git add debian/changelog
	git commit -s -m "gator-$FULL_VERSION: Automated packaging"
fi


#
# Build packages
#

if [ ! $OPT_SIGN ]
then
	DEBUILD_SIGN="-us -uc"
fi

debuild $DEBUILD_SIGN -aarmhf -b
debuild --no-tgz-check $DEBUILD_SIGN -S