forked from RobertCNelson/stable-kernel
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild_deb.sh
executable file
·159 lines (133 loc) · 4.7 KB
/
build_deb.sh
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
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
#!/bin/bash -e
#
# Copyright (c) 2009-2012 Robert Nelson <[email protected]>
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.
DIR=$PWD
mkdir -p ${DIR}/deploy/
function patch_kernel {
cd ${DIR}/KERNEL
export DIR GIT_OPTS
/bin/bash -e ${DIR}/patch.sh || { git add . ; exit 1 ; }
if [ ! "${RUN_BISECT}" ] ; then
git add .
git commit --allow-empty -a -m "${KERNEL_TAG}-${BUILD} patchset"
fi
#Test Patches:
#exit
if [ "${LOCAL_PATCH_DIR}" ] ; then
for i in ${LOCAL_PATCH_DIR}/*.patch ; do patch -s -p1 < $i ; done
BUILD+='+'
fi
cd ${DIR}/
}
function copy_defconfig {
cd ${DIR}/KERNEL/
make ARCH=arm CROSS_COMPILE=${CC} distclean
make ARCH=arm CROSS_COMPILE=${CC} ${config}
cp -v .config ${DIR}/patches/ref_${config}
cp -v ${DIR}/patches/defconfig .config
cd ${DIR}/
}
function make_menuconfig {
cd ${DIR}/KERNEL/
make ARCH=arm CROSS_COMPILE=${CC} menuconfig
cp -v .config ${DIR}/patches/defconfig
cd ${DIR}/
}
function make_deb {
cd ${DIR}/KERNEL/
echo "-----------------------------"
echo "make -j${CORES} ARCH=arm KBUILD_DEBARCH=${DEBARCH} LOCALVERSION=-${BUILD} CROSS_COMPILE="${CCACHE} ${CC}" KDEB_PKGVERSION=${BUILDREV}${DISTRO} ${CONFIG_DEBUG_SECTION} deb-pkg"
echo "-----------------------------"
time fakeroot make -j${CORES} ARCH=arm KBUILD_DEBARCH=${DEBARCH} LOCALVERSION=-${BUILD} CROSS_COMPILE="${CCACHE} ${CC}" KDEB_PKGVERSION=${BUILDREV}${DISTRO} ${CONFIG_DEBUG_SECTION} deb-pkg
mv ${DIR}/*.deb ${DIR}/deploy/
unset DTBS
cat ${DIR}/KERNEL/arch/arm/Makefile | grep "dtbs:" &> /dev/null && DTBS=1
if [ "x${DTBS}" != "x" ] ; then
echo "make -j${CORES} ARCH=arm LOCALVERSION=-${BUILD} CROSS_COMPILE=\"${CCACHE} ${CC}\" ${CONFIG_DEBUG_SECTION} dtbs"
time make -j${CORES} ARCH=arm LOCALVERSION=-${BUILD} CROSS_COMPILE="${CCACHE} ${CC}" ${CONFIG_DEBUG_SECTION} dtbs
ls arch/arm/boot/* | grep dtb || unset DTBS
fi
KERNEL_UTS=$(cat ${DIR}/KERNEL/include/generated/utsrelease.h | awk '{print $3}' | sed 's/\"//g' )
cd ${DIR}/
}
function make_dtbs_pkg {
cd ${DIR}/KERNEL/
echo "-----------------------------"
echo "Building DTBS Archive"
echo "-----------------------------"
rm -rf ${DIR}/deploy/dtbs &> /dev/null || true
mkdir -p ${DIR}/deploy/dtbs
cp -v arch/arm/boot/*.dtb ${DIR}/deploy/dtbs
cd ${DIR}/deploy/dtbs
echo "-----------------------------"
echo "Building ${KERNEL_UTS}-dtbs.tar.gz"
tar czf ../${KERNEL_UTS}-dtbs.tar.gz *
echo "-----------------------------"
cd ${DIR}/
}
/bin/bash -e ${DIR}/tools/host_det.sh || { exit 1 ; }
if [ ! -f ${DIR}/system.sh ] ; then
cp ${DIR}/system.sh.sample ${DIR}/system.sh
fi
unset CC
unset DEBUG_SECTION
unset LATEST_GIT
unset LINUX_GIT
unset LOCAL_PATCH_DIR
source ${DIR}/system.sh
/bin/bash -e "${DIR}/scripts/gcc.sh" || { exit 1 ; }
source ${DIR}/.CC
echo "debug: CC=${CC}"
source ${DIR}/version.sh
export LINUX_GIT
export LATEST_GIT
if [ "${LATEST_GIT}" ] ; then
echo "-----------------------------"
echo "Warning LATEST_GIT is enabled from system.sh I hope you know what your doing.."
echo "-----------------------------"
fi
unset CONFIG_DEBUG_SECTION
if [ "${DEBUG_SECTION}" ] ; then
CONFIG_DEBUG_SECTION="CONFIG_DEBUG_SECTION_MISMATCH=y"
fi
#unset FULL_REBUILD
FULL_REBUILD=1
if [ "${FULL_REBUILD}" ] ; then
/bin/bash -e "${DIR}/scripts/git.sh" || { exit 1 ; }
if [ "${RUN_BISECT}" ] ; then
/bin/bash -e "${DIR}/scripts/bisect.sh" || { exit 1 ; }
fi
patch_kernel
copy_defconfig
fi
if [ ! ${AUTO_BUILD} ] ; then
make_menuconfig
fi
if [ "x${GCC_OVERRIDE}" != "x" ] ; then
sed -i -e 's:CROSS_COMPILE)gcc:CROSS_COMPILE)'$GCC_OVERRIDE':g' ${DIR}/KERNEL/Makefile
fi
make_deb
if [ "x${DTBS}" != "x" ] ; then
make_dtbs_pkg
fi
if [ "x${GCC_OVERRIDE}" != "x" ] ; then
sed -i -e 's:CROSS_COMPILE)'$GCC_OVERRIDE':CROSS_COMPILE)gcc:g' ${DIR}/KERNEL/Makefile
fi