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

Commit

Permalink
Create multiple kernels
Browse files Browse the repository at this point in the history
  • Loading branch information
marcosfad committed Jul 20, 2020
1 parent c4678db commit daccef2
Show file tree
Hide file tree
Showing 4 changed files with 61 additions and 161 deletions.
27 changes: 22 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
# mbp-ubuntu-kernel

This repo is still a work in progress.

Ubuntu/Mint/Debian kernel 5.6 with Apple T2 patches built-in (Macbooks produced >= 2018).
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.

Drivers:

Expand All @@ -12,7 +10,7 @@ Drivers:

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

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

## CI status

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

## INSTALLATION

### The easy way

Use the [mbp-ubuntu](https://github.com/marcosfad/mbp-ubuntu/releases) live cd to install ubuntu on your Mac

### Manually

Add the repo to your apt sources
```bash
echo "deb https://mbp-ubuntu-kernel.herokuapp.com/ /" >/etc/apt/sources.list.d/mbp-ubuntu-kernel.list
curl -L https://mbp-ubuntu-kernel.herokuapp.com/KEY.gpg | apt-key add -
apt-get update
```
Install the kernel using apt, for example kernel 5.7.9:
```bash
apt-get install linux-headers-5.7.9-mbp linux-image-5.7.9-mbp
```

## Docs

- Discord: <https://discord.gg/Uw56rqW>
Expand Down Expand Up @@ -58,6 +75,6 @@ Travis kernel publish status - <http://mbp-ubuntu-kernel.herokuapp.com/> :
- @MCMrARM - thanks for all RE work
- @ozbenh - thanks for submitting NVME patch
- @roadrunner2 - thanks for SPI (touchbar) driver
- @aunali1 - thanks for ArchLinux Kernel CI
- @aunali1 - thanks for ArchLinux Kernel CI and active support.
- @ppaulweber - thanks for keyboard and Macbook Air patches
- @mikeeq - thanks for the fedora kernel project and compilation scripts
58 changes: 38 additions & 20 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,24 +18,38 @@ echo "Current path: ${REPO_PATH}"
echo "CPU threads: $(nproc --all)"
grep 'model name' /proc/cpuinfo | uniq

get_next_version () {
curl -s https://mbp-ubuntu-kernel.herokuapp.com/ -L | grep "linux-image-${KERNEL_VERSION}-${1}" > /dev/null
OLD_BUILD_EXIST=$?
if test $OLD_BUILD_EXIST -eq 0
then
LATEST_BUILD=$(curl -s https://mbp-ubuntu-kernel.herokuapp.com/ -L | grep "linux-image-${KERNEL_VERSION}-${1}" |
grep a | cut -d'>' -f2 | cut -d'<' -f1 |
sort -r | head -n 1 | cut -d'-' -f6 | cut -d'_' -f1)
else
LATEST_BUILD=0
fi
echo "$((LATEST_BUILD+1))"
}

### Clean up
rm -rfv ./*.deb

mkdir "${WORKING_PATH}" && cd "${WORKING_PATH}"
cp -rf "${REPO_PATH}"/{patches,templates} "${WORKING_PATH}"
rm -rf linux-*
rm -rf "${KERNEL_PATH}"

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

### get Kernel
git clone --depth 1 --single-branch --branch "v${KERNEL_VERSION}" \
"${KERNEL_REPOSITORY}" "${KERNEL_PATH}"
cd ./linux-kernel || exit
cd "${KERNEL_PATH}" || exit

#### Create patch file with custom drivers
echo >&2 "===]> Info: Creating patch file... "
Expand All @@ -52,15 +66,7 @@ echo >&2 "===]> Info: Applying patches... "
while IFS= read -r file; do
echo "==> Adding $file"
patch -p1 <"$file"
done < <(find "${WORKING_PATH}/patches" -type f -name "*.patch" | sort)

#echo >&2 "===]> Info: Add drivers default configuration... "
### Add new drivers. This config files comes on the one of the patches...
#echo "CONFIG_APPLE_BCE_DRIVER=m" >>"${KERNEL_PATH}/debian.master/config/amd64/config.common.ubuntu"
#echo "CONFIG_APPLE_TOUCHBAR_DRIVER=m" >>"${KERNEL_PATH}/debian.master/config/amd64/config.common.ubuntu"
#find "${KERNEL_PATH}/debian.master/config/" -type f -name "generic.modules" -exec sh -c '
# echo -e "apple-bce.ko\napple-ib-als.ko\napple-ib-tb.ko\napple-ibridge.ko" >> $1
#' sh {} \;
done < <(find "${WORKING_PATH}/patches" -type f -name "*.patch" | grep -vE '[2]00[0-9]' | sort)

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

cd "${KERNEL_PATH}"
make clean
cp "${WORKING_PATH}/templates/default-config" .config
cp "${WORKING_PATH}/templates/default-config" "${KERNEL_PATH}/.config"
make olddefconfig

# Get rid of the dirty tag
#LASTEST_BUILD=$(curl -s https://mbp-ubuntu-kernel.herokuapp.com/ -L |
# grep linux-image-${KERNEL_VERSION} | grep a | cut -d'>' -f2 | cut -d'<' -f1 |
# sort -r | head -n 1 | cut -d'-' -f6 | cut -d'_' -f1)
#NEXT_BUILD=$(expr ${LASTEST_BUILD} + 1)
echo "" >${KERNEL_PATH}/.scmversion
echo "" >"${KERNEL_PATH}"/.scmversion

# Build Deb packages
make -j "$(getconf _NPROCESSORS_ONLN)" deb-pkg LOCALVERSION=-mbp KDEB_PKGVERSION="$(make kernelversion)-$(get_next_version mbp)"

# Create alternative Kernel
echo >&2 "===]> Info: Create alternative kernel ... "
make distclean
make clean
while IFS= read -r file; do
echo "==> Adding $file"
patch -p1 <"$file"
done < <(find "${WORKING_PATH}/patches" -type f -name "*.patch" | grep -E '[2]00[0-9]' | sort)
cp "${WORKING_PATH}/templates/default-config" "${KERNEL_PATH}/.config"
make olddefconfig
echo "" >"${KERNEL_PATH}"/.scmversion

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

#### Copy artifacts to shared volume
echo >&2 "===]> Info: Copying debs and calculating SHA256 ... "
Expand Down
2 changes: 1 addition & 1 deletion patch_driver.sh
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ git checkout ${APPLE_SMC_DRIVER_COMMIT_HASH}
while IFS= read -r file; do
echo "==> Adding ${file}"
cp -rfv "${file}" "${WORKING_PATH}"/patches/"${file##*/}"
done < <(find "${BUILD_PATH}/linux-mbp-arch" -type f -name "*.patch" | grep -E '[35]00[0-9]' | sort)
done < <(find "${BUILD_PATH}/linux-mbp-arch" -type f -name "*.patch" | grep -E '[235]00[0-9]' | sort)

#### Add custom drivers to kernel
#echo -e "From: \"Kernel Builder (sita)\" <[email protected]>\nSubject: patch custom drivers\n" >"${WORKING_PATH}/patches/custom-drivers.patch"
Expand Down
135 changes: 0 additions & 135 deletions update_kernel_mbp.sh

This file was deleted.

0 comments on commit daccef2

Please sign in to comment.