diff --git a/README.md b/README.md index 49b7213..908c66b 100644 --- a/README.md +++ b/README.md @@ -13,25 +13,26 @@ Drivers: ## How to update kernel-mbp ```bash -### First run +### First run or if you want to update your copy of update_kernel_mbp script sudo -i curl -L https://raw.githubusercontent.com/mikeeq/mbp-fedora-kernel/v5.13-f34-mbp16/update_kernel_mbp.sh -o /usr/bin/update_kernel_mbp chmod +x /usr/bin/update_kernel_mbp update_kernel_mbp -### Next ones +### Next runs sudo -i update_kernel_mbp -### Update to specific version -#mbp 15,1/15,2 +### Update to specific version of kernel +# mbp 15,1/15,2 sudo -i -KERNEL_VERSION="5.11.20-f34-mbp15" update_kernel_mbp +KERNEL_VERSION="v5.13.5-f34-mbp15" update_kernel_mbp -### Update to specific version using specific version of update script (usually don't needed, because scripts are shared between branches) -#mbp 16,1/16,2 (differs in wifi patch) +### Update to specific version of kernel using specific version of update script +#### Usually not needed, because scripts are shared between branches, but you can use it to update your update_kernel_mbp script +# mbp 16,1/16,2 (differs in wifi patch) sudo -i -KERNEL_VERSION="5.11.20-f34-mbp16" UPDATE_SCRIPT_BRANCH="v5.13-f34-mbp16" update_kernel_mbp +KERNEL_VERSION="v5.13.5-f34-mbp16" UPDATE_SCRIPT_BRANCH="v5.13-f34-mbp16" update_kernel_mbp ``` ## CI status diff --git a/build.sh b/build.sh index 4892a49..b60a14c 100755 --- a/build.sh +++ b/build.sh @@ -4,6 +4,7 @@ set -eu -o pipefail ## Update fedora docker image tag, because kernel build is using `uname -r` when defining package version variable RPMBUILD_PATH=/root/rpmbuild +MBP_VERSION=mbp16 FEDORA_KERNEL_VERSION=5.13.5-200.fc34 # https://bodhi.fedoraproject.org/updates/?search=&packages=kernel&releases=F34 REPO_PWD=$(pwd) @@ -43,7 +44,7 @@ done < <(find "${REPO_PWD}"/patches -type f -name "*.patch" | sort) ### Change buildid to mbp echo >&2 "===]> Info: Setting kernel name... "; -sed -i 's/# define buildid.*/%define buildid .mbp/' "${RPMBUILD_PATH}"/SPECS/kernel.spec +sed -i "s/# define buildid.*/%define buildid .${MBP_VERSION}/" "${RPMBUILD_PATH}"/SPECS/kernel.spec ### Build non-debug rpms echo >&2 "===]> Info: Bulding kernel ... "; diff --git a/update_kernel_mbp.sh b/update_kernel_mbp.sh index 3a60fe9..cf6e65e 100755 --- a/update_kernel_mbp.sh +++ b/update_kernel_mbp.sh @@ -5,8 +5,15 @@ set -eu -o pipefail ### Apple T2 drivers commit hashes KERNEL_PATCH_PATH=/tmp/kernel_patch -UPDATE_SCRIPT_BRANCH=${UPDATE_SCRIPT_BRANCH:-v5.13-f34-mbp16} -MBP_FEDORA_BRANCH=f34 +[ -x "$(command -v jq)" ] || dnf install -y jq + +# Github API ratelimit... +DEFAULT_BRANCH_MBP_FEDORA=$(curl -Ls https://api.github.com/repos/mikeeq/mbp-fedora | jq -r ".default_branch") +DEFAULT_BRANCH_MBP_FEDORA_KERNEL=$(curl -Ls https://api.github.com/repos/mikeeq/mbp-fedora-kernel | jq -r ".default_branch") +LATEST_MBP_FEDORA_KERNEL_RELEASE=$(curl -Ls https://api.github.com/repos/mikeeq/mbp-fedora-kernel/releases/latest | jq -r ".name") +MBP_FEDORA_BRANCH=${MBP_FEDORA_BRANCH:-$DEFAULT_BRANCH_MBP_FEDORA} +UPDATE_SCRIPT_BRANCH=${UPDATE_SCRIPT_BRANCH:-$DEFAULT_BRANCH_MBP_FEDORA_KERNEL} +KERNEL_VERSION=${KERNEL_VERSION:-DEFAULT_BRANCH_MBP_FEDORA_KERNEL} BCE_DRIVER_GIT_URL=https://github.com/t2linux/apple-bce-drv BCE_DRIVER_BRANCH_NAME=aur BCE_DRIVER_COMMIT_HASH=f93c6566f98b3c95677de8010f7445fa19f75091 @@ -43,30 +50,23 @@ else echo >&2 "===]> Info: update_kernel_mbp script was installed..." fi -### Download latest kernel -KERNEL_PACKAGES=() -if [[ -n "${KERNEL_VERSION:-}" ]]; then - MBP_KERNEL_TAG=${KERNEL_VERSION} - echo >&2 "===]> Info: Downloading specified kernel: ${MBP_KERNEL_TAG}"; - while IFS='' read -r line; do KERNEL_PACKAGES+=("$line"); done < <(curl -sL https://github.com/mikeeq/mbp-fedora-kernel/releases/tag/v"${MBP_KERNEL_TAG}" | grep rpm | grep span | cut -d'>' -f2 | cut -d'<' -f1) -else - MBP_KERNEL_TAG=$(curl -s https://github.com/mikeeq/mbp-fedora-kernel/releases/latest | cut -d'v' -f2 | cut -d'"' -f1) - echo >&2 "===]> Info: Downloading latest stable kernel: ${MBP_KERNEL_TAG}"; - while IFS='' read -r line; do KERNEL_PACKAGES+=("$line"); done < <(curl -sL https://github.com/mikeeq/mbp-fedora-kernel/releases/latest | grep rpm | grep span | cut -d'>' -f2 | cut -d'<' -f1) -fi +### Download kernel packages +echo >&2 "===]> Info: Downloading mbp-fedora-kernel: ${KERNEL_VERSION}"; +KERNEL_PACKAGES=($(curl -Ls https://api.github.com/repos/mikeeq/mbp-fedora-kernel/releases/tags/${KERNEL_VERSION} | jq -r ".assets[].name" | grep kernel)) -KERNEL_PACKAGE_NAME=${KERNEL_PACKAGES[0]} -TEMPVAR=${KERNEL_PACKAGE_NAME//kernel-} +KERNEL_CORE=$(echo "${KERNEL_PACKAGES[*]}" | tr ' ' '\n' | grep kernel-core) +KERNEL_FULL_VERSION_TEMPVAR=${KERNEL_CORE//kernel-core-} KERNEL_FULL_VERSION=${TEMPVAR//.rpm} for i in "${KERNEL_PACKAGES[@]}"; do - curl -LO https://github.com/mikeeq/mbp-fedora-kernel/releases/download/v"${MBP_KERNEL_TAG}"/"${i}" + echo >&2 "===]> Info: Downloading rpm: ${i}"; + curl -LO https://github.com/mikeeq/mbp-fedora-kernel/releases/download/"${KERNEL_VERSION}"/"${i}" done echo >&2 "===]> Info: Installing dependencies..."; dnf install -y bison elfutils-libelf-devel flex gcc openssl-devel -echo >&2 "===]> Info: Installing kernel version: ${MBP_KERNEL_TAG}"; +echo >&2 "===]> Info: Installing kernel version: ${KERNEL_VERSION}"; rpm --force -i ./*.rpm ### Install custom drivers @@ -128,4 +128,4 @@ rm -rf ${KERNEL_PATCH_PATH} dnf autoremove -y dnf remove -y "$(dnf repoquery --installonly --latest-limit=-3 -q)" -echo >&2 "===]> Info: Kernel update to ${MBP_KERNEL_TAG} finished successfully! "; +echo >&2 "===]> Info: Kernel update to ${KERNEL_VERSION} finished successfully! ";