Skip to content
This repository was archived by the owner on Feb 18, 2022. It is now read-only.

Commit 1771187

Browse files
authored
Merge pull request #5 from marcosfad/feature/alternativeKernel
Create multiple kernels
2 parents c4678db + daccef2 commit 1771187

4 files changed

Lines changed: 61 additions & 161 deletions

File tree

README.md

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
# mbp-ubuntu-kernel
22

3-
This repo is still a work in progress.
4-
5-
Ubuntu/Mint/Debian kernel 5.6 with Apple T2 patches built-in (Macbooks produced >= 2018).
3+
Ubuntu/Mint/Debian kernel 5.6+ with Apple T2 patches built-in. This repo try to keep up with kernel new releases. We release 2 alternative kernels: mbp for macbook pro 2018+ (16,1) and mbp-alt for older ones.
64

75
Drivers:
86

@@ -12,7 +10,7 @@ Drivers:
1210

1311
This project is closely inspired by mikeeq/mbp-fedora-kernel. Thank you @mikeeq for the scripts and setup.
1412

15-
IF YOU ENJOY THIS CODE, CONSIDER CONTRIBUTING TO THE AUTHORS @MCMrARM @roadrunner2 @aunali1 @ppaulweber @mikeeq, they did all the hard work.
13+
IF YOU ENJOY THIS CODE, PLEASE CONSIDER CONTRIBUTING TO THE AUTHORS @MCMrARM @roadrunner2 @aunali1 @ppaulweber @mikeeq, they did all the hard work.
1614

1715
## CI status
1816

@@ -22,6 +20,25 @@ Drone kernel build status:
2220
Travis kernel publish status - <http://mbp-ubuntu-kernel.herokuapp.com/> :
2321
[![Build Status](https://travis-ci.com/marcosfad/mbp-ubuntu-kernel.svg?branch=master)](https://travis-ci.com/marcosfad/mbp-ubuntu-kernel)
2422

23+
## INSTALLATION
24+
25+
### The easy way
26+
27+
Use the [mbp-ubuntu](https://github.com/marcosfad/mbp-ubuntu/releases) live cd to install ubuntu on your Mac
28+
29+
### Manually
30+
31+
Add the repo to your apt sources
32+
```bash
33+
echo "deb https://mbp-ubuntu-kernel.herokuapp.com/ /" >/etc/apt/sources.list.d/mbp-ubuntu-kernel.list
34+
curl -L https://mbp-ubuntu-kernel.herokuapp.com/KEY.gpg | apt-key add -
35+
apt-get update
36+
```
37+
Install the kernel using apt, for example kernel 5.7.9:
38+
```bash
39+
apt-get install linux-headers-5.7.9-mbp linux-image-5.7.9-mbp
40+
```
41+
2542
## Docs
2643

2744
- Discord: <https://discord.gg/Uw56rqW>
@@ -58,6 +75,6 @@ Travis kernel publish status - <http://mbp-ubuntu-kernel.herokuapp.com/> :
5875
- @MCMrARM - thanks for all RE work
5976
- @ozbenh - thanks for submitting NVME patch
6077
- @roadrunner2 - thanks for SPI (touchbar) driver
61-
- @aunali1 - thanks for ArchLinux Kernel CI
78+
- @aunali1 - thanks for ArchLinux Kernel CI and active support.
6279
- @ppaulweber - thanks for keyboard and Macbook Air patches
6380
- @mikeeq - thanks for the fedora kernel project and compilation scripts

build.sh

Lines changed: 38 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -18,24 +18,38 @@ echo "Current path: ${REPO_PATH}"
1818
echo "CPU threads: $(nproc --all)"
1919
grep 'model name' /proc/cpuinfo | uniq
2020

21+
get_next_version () {
22+
curl -s https://mbp-ubuntu-kernel.herokuapp.com/ -L | grep "linux-image-${KERNEL_VERSION}-${1}" > /dev/null
23+
OLD_BUILD_EXIST=$?
24+
if test $OLD_BUILD_EXIST -eq 0
25+
then
26+
LATEST_BUILD=$(curl -s https://mbp-ubuntu-kernel.herokuapp.com/ -L | grep "linux-image-${KERNEL_VERSION}-${1}" |
27+
grep a | cut -d'>' -f2 | cut -d'<' -f1 |
28+
sort -r | head -n 1 | cut -d'-' -f6 | cut -d'_' -f1)
29+
else
30+
LATEST_BUILD=0
31+
fi
32+
echo "$((LATEST_BUILD+1))"
33+
}
34+
2135
### Clean up
2236
rm -rfv ./*.deb
2337

2438
mkdir "${WORKING_PATH}" && cd "${WORKING_PATH}"
2539
cp -rf "${REPO_PATH}"/{patches,templates} "${WORKING_PATH}"
26-
rm -rf linux-*
40+
rm -rf "${KERNEL_PATH}"
2741

2842
### Dependencies
2943
export DEBIAN_FRONTEND=noninteractive
30-
apt update
31-
apt install -y build-essential fakeroot libncurses-dev bison flex libssl-dev libelf-dev \
44+
apt-get update
45+
apt-get install -y build-essential fakeroot libncurses-dev bison flex libssl-dev libelf-dev \
3246
openssl dkms libudev-dev libpci-dev libiberty-dev autoconf wget xz-utils git \
3347
bc rsync cpio dh-modaliases debhelper kernel-wedge curl
3448

3549
### get Kernel
3650
git clone --depth 1 --single-branch --branch "v${KERNEL_VERSION}" \
3751
"${KERNEL_REPOSITORY}" "${KERNEL_PATH}"
38-
cd ./linux-kernel || exit
52+
cd "${KERNEL_PATH}" || exit
3953

4054
#### Create patch file with custom drivers
4155
echo >&2 "===]> Info: Creating patch file... "
@@ -52,15 +66,7 @@ echo >&2 "===]> Info: Applying patches... "
5266
while IFS= read -r file; do
5367
echo "==> Adding $file"
5468
patch -p1 <"$file"
55-
done < <(find "${WORKING_PATH}/patches" -type f -name "*.patch" | sort)
56-
57-
#echo >&2 "===]> Info: Add drivers default configuration... "
58-
### Add new drivers. This config files comes on the one of the patches...
59-
#echo "CONFIG_APPLE_BCE_DRIVER=m" >>"${KERNEL_PATH}/debian.master/config/amd64/config.common.ubuntu"
60-
#echo "CONFIG_APPLE_TOUCHBAR_DRIVER=m" >>"${KERNEL_PATH}/debian.master/config/amd64/config.common.ubuntu"
61-
#find "${KERNEL_PATH}/debian.master/config/" -type f -name "generic.modules" -exec sh -c '
62-
# echo -e "apple-bce.ko\napple-ib-als.ko\napple-ib-tb.ko\napple-ibridge.ko" >> $1
63-
#' sh {} \;
69+
done < <(find "${WORKING_PATH}/patches" -type f -name "*.patch" | grep -vE '[2]00[0-9]' | sort)
6470

6571
chmod a+x "${KERNEL_PATH}"/debian/rules
6672
chmod a+x "${KERNEL_PATH}"/debian/scripts/*
@@ -70,17 +76,29 @@ echo >&2 "===]> Info: Bulding src... "
7076

7177
cd "${KERNEL_PATH}"
7278
make clean
73-
cp "${WORKING_PATH}/templates/default-config" .config
79+
cp "${WORKING_PATH}/templates/default-config" "${KERNEL_PATH}/.config"
7480
make olddefconfig
7581

7682
# Get rid of the dirty tag
77-
#LASTEST_BUILD=$(curl -s https://mbp-ubuntu-kernel.herokuapp.com/ -L |
78-
# grep linux-image-${KERNEL_VERSION} | grep a | cut -d'>' -f2 | cut -d'<' -f1 |
79-
# sort -r | head -n 1 | cut -d'-' -f6 | cut -d'_' -f1)
80-
#NEXT_BUILD=$(expr ${LASTEST_BUILD} + 1)
81-
echo "" >${KERNEL_PATH}/.scmversion
83+
echo "" >"${KERNEL_PATH}"/.scmversion
84+
85+
# Build Deb packages
86+
make -j "$(getconf _NPROCESSORS_ONLN)" deb-pkg LOCALVERSION=-mbp KDEB_PKGVERSION="$(make kernelversion)-$(get_next_version mbp)"
87+
88+
# Create alternative Kernel
89+
echo >&2 "===]> Info: Create alternative kernel ... "
90+
make distclean
91+
make clean
92+
while IFS= read -r file; do
93+
echo "==> Adding $file"
94+
patch -p1 <"$file"
95+
done < <(find "${WORKING_PATH}/patches" -type f -name "*.patch" | grep -E '[2]00[0-9]' | sort)
96+
cp "${WORKING_PATH}/templates/default-config" "${KERNEL_PATH}/.config"
97+
make olddefconfig
98+
echo "" >"${KERNEL_PATH}"/.scmversion
8299

83-
make -j "$(getconf _NPROCESSORS_ONLN)" deb-pkg LOCALVERSION=-mbp
100+
# Build Deb packages
101+
make -j "$(getconf _NPROCESSORS_ONLN)" deb-pkg LOCALVERSION=-mbp-alt KDEB_PKGVERSION="$(make kernelversion)-$(get_next_version mbp-alt)"
84102

85103
#### Copy artifacts to shared volume
86104
echo >&2 "===]> Info: Copying debs and calculating SHA256 ... "

patch_driver.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ git checkout ${APPLE_SMC_DRIVER_COMMIT_HASH}
3131
while IFS= read -r file; do
3232
echo "==> Adding ${file}"
3333
cp -rfv "${file}" "${WORKING_PATH}"/patches/"${file##*/}"
34-
done < <(find "${BUILD_PATH}/linux-mbp-arch" -type f -name "*.patch" | grep -E '[35]00[0-9]' | sort)
34+
done < <(find "${BUILD_PATH}/linux-mbp-arch" -type f -name "*.patch" | grep -E '[235]00[0-9]' | sort)
3535

3636
#### Add custom drivers to kernel
3737
#echo -e "From: \"Kernel Builder (sita)\" <ubuntu-kernel-bot@canonical.com>\nSubject: patch custom drivers\n" >"${WORKING_PATH}/patches/custom-drivers.patch"

update_kernel_mbp.sh

Lines changed: 0 additions & 135 deletions
This file was deleted.

0 commit comments

Comments
 (0)