-
Notifications
You must be signed in to change notification settings - Fork 2
/
build-release
executable file
·109 lines (88 loc) · 2.9 KB
/
build-release
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
#!/bin/bash
set -e
CROSS_COMPILE=/usr/lib/x86_64-linux-gnu/gcc-arm-linux-gnueabihf-8.3/bin/arm-linux-gnueabihf-
if [ "$FLAVOR" = "ev3" ]; then
OVERLAY_DIR="ev3dev-ev3"
KERNEL_DIR="ev3-kernel"
DEBARCH="armel"
DEFCONFIG="ev3dev_defconfig"
DPUT_HOST="ev3dev-debian"
elif [ "$FLAVOR" = "rpi" ]; then
OVERLAY_DIR="ev3dev-rpi"
KERNEL_DIR="rpi-kernel"
DEBARCH="armhf"
DEFCONFIG="bcmrpi_defconfig"
DPUT_HOST="ev3dev-raspbian"
elif [ "$FLAVOR" = "rpi2" ]; then
OVERLAY_DIR="ev3dev-rpi2"
KERNEL_DIR="rpi-kernel"
DEBARCH="armhf"
DEFCONFIG="bcm2709_defconfig"
DPUT_HOST="ev3dev-debian"
else
echo "Must specify kernel flavor. FLAVOR={ev3,rpi,rpi2}"
exit 1
fi
CHANGELOG="${OVERLAY_DIR}/changelog"
REVISION=$(dpkg-parsechangelog -l${CHANGELOG}| sed -n -e 's/^Version: //p')
PACKAGE_VERSION=$(dpkg-parsechangelog -l${CHANGELOG}| sed -n -e 's/Source: linux-source-//p')
# make sure git is ignoring debian/control in all of the modules because
# it is automatically updated
if [ ! -z $MODULES_TARGET ]; then
pushd modules
for d in $(ls)
do
pushd ${d}
git update-index --assume-unchanged debian/control
popd
done
popd
fi
# change to the kernel directory to do the actual building
pushd $KERNEL_DIR
cleanup() {
echo "---- CLEANING UP ----"
make ARCH=arm distclean
git clean -dfX
git clean -df
find ../modules -mindepth 1 -maxdepth 1 -type d -exec make -C {} clean \;
}
cleanup
if [ "$1" == "clean" ]; then
exit 0
fi
echo "---- LOADING DEFAULT CONFIGURATION ----"
make CROSS_COMPILE=${CROSS_COMPILE} ARCH=arm ${DEFCONFIG}
# make sure kernel version (uname -v) matches debian revision
echo $(( $(expr match ${REVISION} '^[0-9]*') - 1 )) > .version
echo "---- CHECKING REVISION -----"
# Don't add '+' to version
touch .scmversion
KERNEL_VERSION=$(make ARCH=arm kernelrelease | tail -n 1)
if [ "${PACKAGE_VERSION}" != "${KERNEL_VERSION}" ]; then
echo "Kernel version (${KERNEL_VERSION}) does not match ${CHANGELOG} version (${PACKAGE_VERSION})."
exit 1
fi
if [ "$1" != "test" ]; then
git tag -a "v${KERNEL_VERSION}_${REVISION//\~/rc}" -m "official release"
fi
echo "---- BUILDING PACKAGES ----"
export $(dpkg-architecture -a${DEBARCH})
MODULE_LOC=../modules \
make-kpkg --rootcmd fakeroot --overlay-dir ../${OVERLAY_DIR} \
--arch arm --subarch=${DEBARCH} --cross-compile ${CROSS_COMPILE} \
--initrd --revision ${REVISION} --jobs $(nproc) \
kernel_image kernel_headers ${MODULES_TARGET}
echo "---- GENERATING CHANGES FILE ----"
CHANGES_FILE="../ev3dev-kernel_${KERNEL_VERSION}_${REVISION}_${DEBARCH}.changes"
dpkg-genchanges -b > ${CHANGES_FILE}
# dpkg-genchanges includes host arch for some reason, so we have to remove it
sed -i "s/ amd64//" ${CHANGES_FILE}
cleanup
popd
if [ "$1" != "test" ]; then
echo "---- SIGNING AND UPLOADING ----"
debsign *.changes
dput ${DPUT_HOST} *.changes
./rmdeb
fi