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

Commit

Permalink
Kernel: update to 5.10.47
Browse files Browse the repository at this point in the history
  • Loading branch information
marcosfad committed Jul 7, 2021
1 parent e3b51af commit 8fbe002
Show file tree
Hide file tree
Showing 9 changed files with 1,656 additions and 255,083 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/patches/custom-drivers.patch
/releases
/linux-*
.idea/
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

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"** which includes all patches from [Aunali1's linux mbp arch](https://github.com/aunali1/linux-mbp-arch) which should work in mostly everywhere and an alternative release (**"mbp-alt"**) which do not include the patch 2001 (drm amd display force link-rate).
The release kernel **"mbp"** includes all patches from [Aunali1's linux mbp arch](https://github.com/aunali1/linux-mbp-arch) which should work almost everywhere.

**!! Warning:**
**!! Warning:**

Starting from the kernel 5.8 the release naming were switch with respect to kernel 5.7: Before the "mbp" release did not include all the patches. **Now the "mbp" includes all patches** and the "mbp-alt" don't.

Expand Down
95 changes: 49 additions & 46 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ set -eu -o pipefail

## Update docker image tag, because kernel build is using `uname -r` when defining package version variable
# KERNEL_VERSION=$(curl -s https://www.kernel.org | grep '<strong>' | head -3 | tail -1 | cut -d'>' -f3 | cut -d'<' -f1)
KERNEL_VERSION=5.9.7
KERNEL_VERSION=5.10.47
#KERNEL_REPOSITORY=git://kernel.ubuntu.com/virgin/linux-stable.git
KERNEL_REPOSITORY=https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable.git
KERNEL_REPOSITORY=https://git.launchpad.net/~ubuntu-kernel-test/ubuntu/+source/linux/+git/mainline-crack
REPO_PATH=$(pwd)
WORKING_PATH=/root/work
KERNEL_PATH="${WORKING_PATH}/linux-kernel"
Expand Down Expand Up @@ -35,72 +35,75 @@ get_next_version () {
### Clean up
rm -rfv ./*.deb

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

### Dependencies
# Install Build Dependencies
export DEBIAN_FRONTEND=noninteractive
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
apt-get update \
&& apt-get upgrade -y \
&& apt-get install -y --no-install-recommends \
autoconf automake autopoint autotools-dev bsdmainutils debhelper dh-autoreconf git fakeroot\
dh-strip-nondeterminism distro-info-data dwz file gettext gettext-base groff-base \
intltool-debian libarchive-zip-perl libbsd0 libcroco3 libdebhelper-perl libelf1 libexpat1 \
libfile-stripnondeterminism-perl libglib2.0-0 libicu66 libmagic-mgc libmagic1 libmpdec2 \
libpipeline1 libpython3-stdlib libpython3.8-minimal libpython3.8-stdlib libsigsegv2 \
libssl1.1 libsub-override-perl libtool libuchardet0 libxml2 \
lsb-release m4 man-db mime-support po-debconf python-apt-common python3 python3-apt \
python3-minimal python3.8 python3.8-minimal sbsigntool tzdata dctrl-tools kernel-wedge \
libncurses-dev gawk flex bison openssl libssl-dev dkms libelf-dev libudev-dev libpci-dev \
libiberty-dev autoconf bc build-essential libusb-1.0-0-dev libhidapi-dev curl wget \
cpio makedumpfile libcap-dev libnewt-dev libdw-dev rsync gnupg2 ca-certificates\
libunwind8-dev liblzma-dev libaudit-dev uuid-dev libnuma-dev lz4 xmlto equivs \
cmake pkg-config zstd


# Build dwarves (depends on libbpf) tools using the latest ubuntu (impish) source packages
mkdir /dwarves \
&& cd /dwarves \
&& echo "deb-src http://archive.ubuntu.com/ubuntu impish main universe" > /etc/apt/sources.list.d/impish-sources.list \
&& chown _apt /dwarves \
&& apt-get update \
&& apt-get source libbpf \
&& sdir=$(find . -name 'libbpf*' -type d) \
&& cd $sdir \
&& sed -i -re 's/debhelper-compat \(= 13\)/debhelper-compat \(= 12\)/' debian/control \
&& dpkg-buildpackage \
&& cd .. && dpkg -i libbpf-dev_*_amd64.deb libbpf0_*_amd64.deb \
&& apt-get source dwarves-dfsg \
&& sdir=$(find . -name 'dwarves*' -type d) \
&& cd $sdir \
&& sed -i -re 's/debhelper-compat \(= 13\)/debhelper-compat \(= 12\)/' debian/control \
&& dpkg-buildpackage \
&& cd .. && dpkg -i dwarves_*_amd64.deb \
&& cd / && rm -rf /dwarves \
&& apt-get remove --purge --auto-remove -y && rm -rf /var/lib/apt/lists/*

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

#### Create patch file with custom drivers
echo >&2 "===]> Info: Creating patch file... "
KERNEL_VERSION="${KERNEL_VERSION}" WORKING_PATH="${WORKING_PATH}" "${REPO_PATH}/patch_driver.sh"

#### Apply patches
cd "${KERNEL_PATH}" || exit

echo >&2 "===]> Info: Applying patches... "
[ ! -d "${WORKING_PATH}/patches" ] && {
echo 'Patches directory not found!'
exit 1
}


while IFS= read -r file; do
echo "==> Adding $file"
patch -p1 <"$file"
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/*
chmod a+x "${KERNEL_PATH}"/debian/scripts/misc/*

echo >&2 "===]> Info: Bulding src... "

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

# Get rid of the dirty tag
echo "" >"${KERNEL_PATH}"/.scmversion

# Build Deb packages
make -j "$(getconf _NPROCESSORS_ONLN)" deb-pkg LOCALVERSION=-mbp KDEB_PKGVERSION="$(make kernelversion)-$(get_next_version mbp-alt)"
sed -i -re 's/dwarves/dwarves (>=1.17-1)/g' debian.master/control.stub.in

# 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

# Get rid of the dirty tag
echo "" >"${KERNEL_PATH}"/.scmversion

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

#### Copy artifacts to shared volume
echo >&2 "===]> Info: Copying debs and calculating SHA256 ... "
Expand Down
6 changes: 3 additions & 3 deletions patch_driver.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ BUILD_PATH=/tmp/build-kernel

### Apple T2 drivers commit hashes
# Patches
APPLE_SMC_DRIVER_GIT_URL=https://github.com/marcosfad/linux-mbp-arch.git
APPLE_SMC_DRIVER_BRANCH_NAME=release/5.9
APPLE_SMC_DRIVER_COMMIT_HASH=01519664be9474c1cf5b92e37bd87a8d98283915
APPLE_SMC_DRIVER_GIT_URL=https://github.com/aunali1/linux-mbp-arch.git
APPLE_SMC_DRIVER_BRANCH_NAME=master
APPLE_SMC_DRIVER_COMMIT_HASH=1faa37d704798bc04104a88f620e4f55b3466de0
## BCE
#APPLE_BCE_DRIVER_GIT_URL=https://github.com/aunali1/mbp2018-bridge-drv.git
#APPLE_BCE_DRIVER_BRANCH_NAME=aur
Expand Down
Loading

0 comments on commit 8fbe002

Please sign in to comment.