├── .gitignore
├── COMPILATION.md
├── LICENSE.md
├── README.md
├── base
├── configs
│ ├── config.4.19
│ ├── config.5.3
│ ├── config.5.4
│ ├── config.5.5
│ ├── config.5.6
│ ├── config.5.7
│ └── config.5.8
├── patches
│ ├── 5.6
│ │ └── sphinx-workaround.patch
│ ├── 5.7
│ │ └── sphinx-workaround.patch
│ └── 5.8
│ │ └── sphinx-workaround.patch
└── templates
│ ├── PKGBUILD
│ ├── modules
│ └── modules.4.19
├── compile_setup.sh
└── setup.sh
/.gitignore:
--------------------------------------------------------------------------------
1 | # Build files
2 | *.tar.xz
3 |
4 | # Build directories
5 | build*/
6 |
7 | # Caches
8 | .cache/
9 |
--------------------------------------------------------------------------------
/COMPILATION.md:
--------------------------------------------------------------------------------
1 | # User Compilation
2 |
3 | ---
4 |
5 | Most users should simply use the pre-built binary releases rather than try to compile
6 | the kernel on their own, since it takes significant resources, setup, and time. However,
7 | if you are interested in compiling your own kernel, then the steps below will walk you
8 | through how to do so.
9 |
10 | ---
11 |
12 | To generate the build directory for the kernel, you need to run the `compile_setup.sh` script.
13 | The packager will prompt for the target major version of the Linux kernel during configuration.
14 |
15 | ```
16 | sh compile_setup.sh
17 | ```
18 |
19 | Once compile_setup is finished, it will output a directory titled `build-{VERSION}`.
20 | Note that {VERSION} is the full version of the kernel and not just its major version.
21 | To build this kernel, use these two commands:
22 |
23 | ```
24 | cd build-{VERSION}
25 | MAKEFLAGS="-j{NPROC}" makepkg -sc
26 | ```
27 |
28 | \* Replace {VERSION} with whatever kernel version compile_setup outputs.
29 | \*\* Replace {NPROC} with the number of available processors in your machine.
30 |
31 | If you are unable to issue this command because of write permission issues, use the following
32 | command to give yourself access, replacing {USER} and {VERSION} with their appropriate values:
33 |
34 | ```
35 | chown -R {USER} build-{VERSION}
36 | ```
37 |
--------------------------------------------------------------------------------
/LICENSE.md:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2018-2020 David Hacker
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # arch-linux-surface
2 |
3 | This is an Arch Linux packager that applies
4 | [patches for Surface devices](https://github.com/linux-surface/linux-surface)
5 | to the Linux kernel of your choice.
6 |
7 | This repository originally tracked jakeday's repository on the `master` branch.
8 | As of November 2019, the `master` branch has officially switched over to
9 | using linux-surface's version of these patches since jakeday's repository
10 | appears to be no longer actively maintained. As of March 2020, support
11 | for jakeday's patches has been dropped.
12 |
13 | Additionally, please refer to [the linux-surface repository itself](https://github.com/linux-surface/linux-surface/wiki/Package-Repositories#arch-linux-repository)
14 | as another source of builds compatible with Arch Linux.
15 | This repository will continue to be actively maintained by
16 | me though, so you are welcome to use either source.
17 |
18 | ## Pre-Installation
19 |
20 | First thing you're going to want to do is to clone this repository:
21 |
22 | ```
23 | git clone https://github.com/dmhacker/arch-linux-surface
24 | cd arch-linux-surface
25 | ```
26 |
27 | Before you begin compiling & installing the patched kernel, it's recommended that you
28 | install all necessary firmware that your Surface device needs and replace suspend with hibernate.
29 | You can do this by running the `setup.sh` script WITHOUT superuser permissions.
30 |
31 | ```
32 | sh setup.sh
33 | ```
34 |
35 | As of December 2019, the setup script should NOT be run with superuser permissions. This is both
36 | by design and for your own safety. If the script requires superuser permissions at any point in
37 | time, it will prompt you for them.
38 |
39 | ## Installation
40 |
41 | After you have run the setup script, it is now time to install the patched kernel.
42 | Find the latest version {VERSION}* in the [pre-built binary releases](https://github.com/dmhacker/arch-linux-surface/releases)
43 | and download the following tar files:
44 |
45 | * linux-surface-{VERSION}-x86_64.pkg.tar.xz
46 | * linux-surface-headers-{VERSION}-x86_64.pkg.tar.xz
47 |
48 | *Replace {VERSION} with whatever the latest version number is. For example, 5.13.15-1.
49 |
50 | After you have downloaded these files, `cd` into the directory containing them
51 | and run the following commands:
52 |
53 | ```
54 | sudo pacman -U linux-surface-headers-{VERSION}-x86_64.pkg.tar.xz
55 | sudo pacman -U linux-surface-{VERSION}-x86_64.pkg.tar.xz
56 | ```
57 |
58 | You are now finished. Reboot your system and change your bootloader to
59 | load the `linux-surface` kernel.
60 |
61 | ## Additional Packages
62 |
63 | Consider installing the following packages from the AUR if your device
64 | meets the given requirements.
65 |
66 | * [libwacom-surface](https://aur.archlinux.org/packages/libwacom-surface) — all devices — may help fix IPTS/touchscreen issues
67 | * [surface-control](https://aur.archlinux.org/packages/surface-control/) — Surface Book 2 only — provides an interface for controlling the SB2's dGPU
68 | * [surface-dtx-daemon](https://aur.archlinux.org/packages/surface-dtx-daemon/) — Surface Book 2 only — improves the clipboard detachment process for the SB2
69 |
70 | ## Troubleshooting
71 |
72 | For touchscreen issues, consider looking at [issue #56](https://github.com/dmhacker/arch-linux-surface/issues/56).
73 |
74 | For stylus issues, consider looking at [issue #8](https://github.com/dmhacker/arch-linux-surface/issues/8).
75 |
76 | For WiFi issues, consider looking at [issue #62](https://github.com/dmhacker/arch-linux-surface/issues/62).
77 |
78 | Please do not create new issues regarding these problems if you have not tried to fix them using the above guides.
79 |
--------------------------------------------------------------------------------
/base/patches/5.6/sphinx-workaround.patch:
--------------------------------------------------------------------------------
1 | diff --git i/Documentation/conf.py w/Documentation/conf.py
2 | index 3c7bdf4cd31f..9a0ced58a3e9 100644
3 | --- i/Documentation/conf.py
4 | +++ w/Documentation/conf.py
5 | @@ -36,7 +36,7 @@ needs_sphinx = '1.3'
6 | # Add any Sphinx extension module names here, as strings. They can be
7 | # extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
8 | # ones.
9 | -extensions = ['kerneldoc', 'rstFlatTable', 'kernel_include', 'cdomain',
10 | +extensions = ['kerneldoc', 'rstFlatTable', 'kernel_include',
11 | 'kfigure', 'sphinx.ext.ifconfig', 'automarkup',
12 | 'maintainers_include']
13 |
14 |
--------------------------------------------------------------------------------
/base/patches/5.7/sphinx-workaround.patch:
--------------------------------------------------------------------------------
1 | diff --git i/Documentation/conf.py w/Documentation/conf.py
2 | index 3c7bdf4cd31f..9a0ced58a3e9 100644
3 | --- i/Documentation/conf.py
4 | +++ w/Documentation/conf.py
5 | @@ -36,7 +36,7 @@ needs_sphinx = '1.3'
6 | # Add any Sphinx extension module names here, as strings. They can be
7 | # extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
8 | # ones.
9 | -extensions = ['kerneldoc', 'rstFlatTable', 'kernel_include', 'cdomain',
10 | +extensions = ['kerneldoc', 'rstFlatTable', 'kernel_include',
11 | 'kfigure', 'sphinx.ext.ifconfig', 'automarkup',
12 | 'maintainers_include']
13 |
14 |
--------------------------------------------------------------------------------
/base/patches/5.8/sphinx-workaround.patch:
--------------------------------------------------------------------------------
1 | diff --git i/Documentation/conf.py w/Documentation/conf.py
2 | index 3c7bdf4cd31f..9a0ced58a3e9 100644
3 | --- i/Documentation/conf.py
4 | +++ w/Documentation/conf.py
5 | @@ -36,7 +36,7 @@ needs_sphinx = '1.3'
6 | # Add any Sphinx extension module names here, as strings. They can be
7 | # extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
8 | # ones.
9 | -extensions = ['kerneldoc', 'rstFlatTable', 'kernel_include', 'cdomain',
10 | +extensions = ['kerneldoc', 'rstFlatTable', 'kernel_include',
11 | 'kfigure', 'sphinx.ext.ifconfig', 'automarkup',
12 | 'maintainers_include']
13 |
14 |
--------------------------------------------------------------------------------
/base/templates/PKGBUILD:
--------------------------------------------------------------------------------
1 | # Maintainer: David Hacker
2 | # Maintainer: Jan Alexander Steffens (heftig)
3 |
4 | # Version variables filled in by the configure script
5 | _kernelname={0}
6 | _kernelver={1}
7 |
8 | # Standard package variables
9 | pkgbase=linux${_kernelname}
10 | pkgver={2}
11 | pkgrel={3}
12 | pkgdesc='Linux'
13 | _srcname=linux-stable
14 | _srctag=v${pkgver}
15 | _patchsrcname=linux-surface
16 | url="https://github.com/dmhacker/arch-linux-surface"
17 | arch=(x86_64)
18 | license=(GPL2)
19 | makedepends=(
20 | bc kmod libelf
21 | xmlto python-sphinx python-sphinx_rtd_theme graphviz imagemagick
22 | git
23 | )
24 | options=('!strip')
25 | source=(
26 | git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable.git
27 | {4}
28 | config
29 | )
30 | validpgpkeys=(
31 | 'ABAF11C65A2970B130ABE3C479BE3E4300411886' # Linus Torvalds
32 | '647F28654894E3BD457199BE38DBBDC86092693E' # Greg Kroah-Hartman
33 | '8218F88849AAC522E94CF470A5E9288C4FA415FA' # Jan Alexander Steffens (heftig)
34 | )
35 | sha256sums=('SKIP'
36 | {5}
37 | 'SKIP')
38 |
39 | export KBUILD_BUILD_HOST=archlinux
40 | export KBUILD_BUILD_USER=$pkgbase
41 | export KBUILD_BUILD_TIMESTAMP="$(date -Ru${SOURCE_DATE_EPOCH:+d @$SOURCE_DATE_EPOCH})"
42 |
43 | prepare() {
44 | cd $_srcname
45 |
46 | git checkout $_srctag
47 |
48 | msg2 "Setting version..."
49 | scripts/setlocalversion --save-scmversion
50 | echo "-$pkgrel" > localversion.10-pkgrel
51 | echo "${pkgbase#linux}" > localversion.20-pkgname
52 |
53 | local src
54 | for src in "${source[@]}"; do
55 | src="${src%%::*}"
56 | src="${src##*/}"
57 | [[ $src = *.patch ]] || continue
58 | msg2 "Applying patch $src..."
59 | patch -Np1 < "../$src"
60 | done
61 |
62 | msg2 "Setting config..."
63 | cp ../config .config
64 | make olddefconfig
65 |
66 | make -s kernelrelease > version
67 | msg2 "Prepared %s version %s" "$pkgbase" "$( PKGBUILD
149 |
150 | # Add version-specific configuration file
151 | echo "Copying v$major_version .config file ..."
152 | versioned_config="config.$major_version"
153 | cp ../base/configs/$versioned_config .
154 | mv $versioned_config config
155 |
156 | # Exit the build directory
157 | cd ..
158 |
159 | ############################### NEXT INSTRUCTIONS ###############################
160 |
161 | nproc=`grep -c ^processor /proc/cpuinfo`
162 | echo ""
163 | echo "Build files for patched Linux kernel v$version are in $build_folder."
164 | echo "The following commands can be used to build the kernel packages."
165 | echo ""
166 | echo "cd $build_folder"
167 | echo "MAKEFLAGS=\"-j$nproc\" makepkg -sc"
168 | echo ""
169 | echo "You can optionally provide the -i flag to makepkg to install the kernel after build."
170 |
--------------------------------------------------------------------------------
/setup.sh:
--------------------------------------------------------------------------------
1 | #!/usr/bin/bash
2 |
3 | if [ "$EUID" -eq 0 ]
4 | then echo "Do not run this script as root."
5 | exit
6 | fi
7 |
8 | echo "This script will prepare Surface devices for installation of a patched Arch Linux kernel."
9 | echo "Answer 'y' to any options you wish to install. By default, options are unselected."
10 | echo
11 |
12 | cache_folder=.cache
13 | patches_repository=git://github.com/linux-surface/linux-surface.git
14 | patches_src_folder=linux-surface
15 |
16 | ############################### SETUP ###############################
17 |
18 | echo "Updating cache ..."
19 | mkdir -p $cache_folder
20 | cd $cache_folder
21 |
22 | # Fetch patches repository
23 | if [ -d $patches_src_folder ]; then
24 | cd $patches_src_folder && git pull && cd ..
25 | else
26 | git clone $patches_repository $patches_src_folder
27 | fi
28 |
29 | cd ..
30 |
31 | ############################### INSTALLATION ###############################
32 |
33 | # Prompt for modules upload & mkinitcpio rebuild
34 | echo
35 | echo "!!! WARNING !!! The following option will reset the MODULES option in your mkinitcpio config."
36 | echo "!!! WARNING !!! A backup of /etc/mkinitcpio.conf will be saved to /etc/mkinitcpio.conf.bak if you proceed."
37 | read -r -p "1. Update /etc/mkinitcpio.conf using modules from initramfs-tools? [y/N] "
38 | if [[ $REPLY =~ ^[Yy]$ ]]; then
39 | read -r -p "Are you installing/using an LTS kernel (<= 4.19)? [y/N] "
40 | if [[ $REPLY =~ ^[Yy]$ ]]; then
41 | modules=$(echo "MODULES=($(grep -v '^#' base/templates/modules.4.19))" | tr "\n" " " | sed 's/ *$//g')
42 | else
43 | modules=$(echo "MODULES=($(grep -v '^#' base/templates/modules))" | tr "\n" " " | sed 's/ *$//g')
44 | fi
45 | echo "$modules will be added to /etc/mkinitcpio.conf."
46 | sudo sed -i.bak -E "s/^MODULES=(.*).*/$modules/" /etc/mkinitcpio.conf
47 | sudo mkinitcpio
48 | echo "Done fixing mkinitcpio.conf."
49 | fi
50 |
51 | # Prompt for installation of firmware
52 | echo
53 | read -r -p "2. Install all IPTS firmware? [y/N] "
54 | if [[ $REPLY =~ ^[Yy]$ ]]; then
55 | echo "Please install the latest IPTS firmware release from the link below."
56 | echo "See https://github.com/linux-surface/surface-ipts-firmware/releases"
57 | fi
58 |
59 | # Prompt for installation of patched libwacom
60 | echo
61 | read -r -p "3. Would you like to replace libwacom with its patched version? [y/N] "
62 | if [[ $REPLY =~ ^[Yy]$ ]]; then
63 | echo "Please install the package libwacom-surface from the AUR."
64 | echo "See https://aur.archlinux.org/packages/libwacom-surface/"
65 | fi
66 |
67 | ############################### CLEANUP ###############################
68 |
69 | echo
70 | echo "Setup process finished. Install your patched kernel and then reboot."
71 |
--------------------------------------------------------------------------------