Skip to content

Commit e461ade

Browse files
committed
It's building the kernel.
1 parent cca3843 commit e461ade

File tree

3 files changed

+37
-45
lines changed

3 files changed

+37
-45
lines changed

builder.sh

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,6 @@ case "$1" in
5252
create_directories
5353
echo "Setting up deboot"
5454
get_deboot
55-
# could probably split deboot into the two stages it takes
56-
# echo "Creating the chroot build environment"
57-
# deboot_chroot
5855
echo "Bootstrapping stage one"
5956
deboot_stage_one
6057
echo "Setting up mountpoints"
@@ -65,18 +62,13 @@ case "$1" in
6562
deboot_setup
6663
#somewhere along the line, deboot seems to be unmounting stuff
6764
echo "Remounting file systems"
68-
sleep 1
6965
do_unmount
70-
sleep 1
7166
do_mount
7267
echo "Upgrading the chroot system"
7368
upgrade_chroot
7469
echo "Installing build tools"
7570
install_build_tools
7671
echo "Undoing mountpoints"
77-
#seems to be doing something if we try to unstantly unmount
78-
#/dev so give it a sec to finish
79-
sleep 1
8072
do_unmount
8173
echo "Restoring PATH"
8274
reset_path
@@ -85,6 +77,18 @@ case "$1" in
8577
echo "Upgrading the chroot system"
8678
upgrade_chroot
8779
;;
80+
kernel)
81+
case "$2" in
82+
get)
83+
echo "Cloning the kernel's source"
84+
kernel_get
85+
;;
86+
build)
87+
echo "Building the kernel"
88+
kernel_build
89+
;;
90+
esac
91+
;;
8892
esac
8993
exit 0
9094

configuration

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ deb http://archive.ubuntu.com/ubuntu $ROOT_SUITE-security main restricted univer
3939
"
4040
# these packages will be installed into the chroot build environment
4141
# and are needed to build the kernel
42-
REQUIRED_PACKAGES=gcc-arm-linux-gnueabihf\ ccache\ kernel-wedge\ libncursesw5-dev
42+
REQUIRED_PACKAGES=gcc-arm-linux-gnueabihf\ ccache\ kernel-wedge\ libncursesw5-dev\ devscripts\ fakeroot
4343

4444
# the script should be able to figure this out, but you can override
4545
# or set it manually here, leaving it blank is fine
@@ -53,3 +53,6 @@ DEBOOT_DIR=deboot_working
5353

5454
# directory where the kernel source tree is kept
5555
KERNEL_DIR=kernel_source
56+
KERNEL_REPO=git://kernel.ubuntu.com/ubuntu/ubuntu-nexus7.git
57+
#how many processes do you want the build to use?
58+
BUILD_PROCESSES=9

functions

Lines changed: 21 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -48,19 +48,16 @@ reset_path ()
4848
#do the mount magic
4949
do_mount ()
5050
{
51-
echo "mount -o bind $BASE_DIR/$KERNEL_DIR $BASE_DIR/$ROOT_TARGET/$KERNEL_DIR"
51+
sleep 1;
5252
mount -o bind $BASE_DIR/$KERNEL_DIR $BASE_DIR/$ROOT_TARGET/$KERNEL_DIR;
53-
echo "mount -t proc proc $BASE_DIR/$ROOT_TARGET/proc/"
5453
mount -t proc proc $BASE_DIR/$ROOT_TARGET/proc/;
55-
echo "mount -t sysfs sys $BASE_DIR/$ROOT_TARGET/sys/"
5654
mount -t sysfs sys $BASE_DIR/$ROOT_TARGET/sys/;
57-
echo "mount -o bind /dev $BASE_DIR/$ROOT_TARGET/dev/"
5855
mount -o bind /dev $BASE_DIR/$ROOT_TARGET/dev/;
59-
echo "mount -t devpts devpts -o mode=620,gid=5 $BASE_DIR/$ROOT_TARGET/dev/pts/"
6056
mount -t devpts devpts -o mode=620,gid=5 $BASE_DIR/$ROOT_TARGET/dev/pts/;
6157
}
6258
do_unmount ()
6359
{
60+
sleep 1;
6461
umount $BASE_DIR/$ROOT_TARGET/dev/pts/;
6562
umount $BASE_DIR/$ROOT_TARGET/dev/;
6663
umount $BASE_DIR/$ROOT_TARGET/sys/;
@@ -110,37 +107,6 @@ EOF
110107
chroot $BASE_DIR/$ROOT_TARGET dpkg-divert --divert /usr/bin/ischroot.debianutils --rename /usr/bin/ischroot;
111108
chroot $BASE_DIR/$ROOT_TARGET /bin/ln -s /bin/true /usr/bin/ischroot;
112109

113-
}
114-
deboot_chroot ()
115-
{
116-
# do the bootstrap
117-
DEBOOTSTRAP_DIR=$BASE_DIR/$DEBOOT_DIR/usr/share/debootstrap $BASE_DIR/$DEBOOT_DIR/usr/sbin/debootstrap --foreign --arch=$ROOT_ARCH --variant=buildd --no-check-gpg $ROOT_SUITE $BASE_DIR/$ROOT_TARGET $ROOT_SOURCE;
118-
#do the second stage bootstrap
119-
chroot $BASE_DIR/$ROOT_TARGET /debootstrap/debootstrap --second-stage;
120-
#deboot feels the need to mount proc, we don't need it here
121-
umount $BASE_DIR/$ROOT_TARGET/proc;
122-
123-
#stop dpkg from running daemons
124-
cat > $BASE_DIR/$ROOT_TARGET/usr/sbin/policy-rc.d <<EOF
125-
#!/bin/sh
126-
exit 101
127-
EOF
128-
chmod a+x $BASE_DIR/$ROOT_TARGET/usr/sbin/policy-rc.d;
129-
130-
# update the chroot's sources.list
131-
#cat > $BASE_DIR/$ROOT_TARGET/etc/apt/sources.list <<EOF
132-
#deb http://archive.ubuntu.com/ubuntu $ROOT_SUITE main restricted universe multiverse
133-
#deb http://archive.ubuntu.com/ubuntu $ROOT_SUITE-updates main restricted universe multiverse
134-
#deb http://archive.ubuntu.com/ubuntu $ROOT_SUITE-security main restricted universe multiverse
135-
#EOF
136-
printf '%s' "$ROOT_SOURCES_LIST"
137-
>$BASE_DIR/$ROOT_TARGET/etc/apt/sources.list;
138-
139-
#divert ischroot
140-
#note that this throws error, my need to be fixed, not sure
141-
chroot $BASE_DIR/$ROOT_TARGET dpkg-divert --divert /usr/bin/ischroot.debianutils --rename /usr/bin/ischroot;
142-
chroot $BASE_DIR/$ROOT_TARGET /bin/ln -s /bin/true /usr/bin/ischroot;
143-
144110
}
145111

146112
# bring the chroot current
@@ -175,6 +141,25 @@ get_architecture ()
175141
esac;
176142
}
177143

144+
#functions for managing the kernel source
145+
kernel_get ()
146+
{
147+
git clone $KERNEL_REPO $BASE_DIR/$KERNEL_DIR;
148+
}
149+
#see https://wiki.ubuntu.com/Nexus7/Kernel for more information
150+
kernel_build ()
151+
{
152+
set_path;
153+
do_mount;
154+
cd $BASE_DIR/$ROOT_TARGET/$KERNEL_DIR;
155+
git clean -xdf;
156+
sed -i '/do_tools/ s/true/false/' debian.nexus7/rules.d/armhf.mk;
157+
chroot $BASE_DIR/$ROOT_TARGET su - -c "cd /"$KERNEL_DIR"; fakeroot debian/rules clean";
158+
chroot $BASE_DIR/$ROOT_TARGET su - -c 'cd /'$KERNEL_DIR'; debuild -eDEB_BUILD_OPTIONS="parallel='$BUILD_PROCESSES'" -eCROSS_COMPILE="ccache arm-linux-gnueabihf-" -b -aarmhf -us -uc -nc';
159+
cd $BASE_DIR;
160+
do_unmount;
161+
reset_path;
162+
}
178163
# this patch was attempting to fix a problem that was actually a path
179164
# problem, so it's currently not used, but left in case it's needed later
180165
# deboot comes out of the box with an offensive mount command.

0 commit comments

Comments
 (0)