Linux Kernel Development Environment Setup

Created: July 11, 2021 |  Modified: July 11, 2021 |  Categories:  Linux  

Sources

Assumptions

Ubuntu 20.04.2.0 LTS is installed natively or using VirtualBox and is up-to-date.

Installs

sudo apt install build-essential dkms linux-headers-$(uname -r)
sudo apt-get install vim libncurses5-dev gcc make git exuberant-ctags libssl-dev bison flex libelf-dev bc
sudo apt-get install codespell
sudo apt-get install python-ply python-git-doc
sudo apt-get install mutt
sudo apt-get install zsh curl

Using VirtualBox?

Install Guest Additions.

Set Zsh as Default and Setup Oh My Zsh

chsh -s $(which zsh)

Log out and log back in.

Install oh-my-zsh:

sh -c "$(curl -fsSL https://raw.github.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"

~/.vimrc

" Enable Syntax Highlighting (TODO, FIXME, etc)
syntax on

" Enable the C Indentation Module
filetype plugin indent on

" Show File Name
set title

" Show Line Numbers
set number

" Highlight Search Results
set hlsearch

" Show Ruler (Column Numbers)
set ruler

" [DISABLED] Highlight Long Lines (80 Characters)
" set colorcolumn=81,101

" Disable the Bell
set visualbell

" Spaces & Tabs
set tabstop=8
set softtabstop=8
set noexpandtab
set shiftwidth=8

" More Powerful Backspacing
set backspace=indent,eol,start

" Highlight Matching Braces, Parens, etc
set showmatch

" [DISABLED] Automatically Add Closing Characters
" inoremap { {}<Esc>ha
" inoremap [ []<Esc>ha
" inoremap ( ()<Esc>ha

Make Vim the Default Editor

sudo update-alternatives --config editor

Mutt Email Setup

mkdir -p ~/.mutt/cache/bodies
mkdir -p ~/.mutt/cache/certificates
mkdir -p ~/.mutt/cache/headers
touch ~/.mutt/muttrc

Generate an app password for Yahoo, then populate the muttrc file:

set envelope_from=yes
set use_from=yes
set edit_headers=yes

set imap_user = "<your_email>@yahoo.com"
set imap_pass = "<yahoo_app_password>"
set smtp_url = "smtp://<your_email>@smtp.mail.yahoo.com:587/"
set ssl_starttls = yes
set smtp_pass = "<yahoo_app_password>"
set from = "<your_email>@yahoo.com"
set realname = "<Firstname Lastname>"
set folder = "imaps://imap.mail.yahoo.com:993"
set spoolfile = "+INBOX"
set postponed="+[Yahoo]/Drafts"
set header_cache=~/.mutt/cache/headers
set message_cachedir=~/.mutt/cache/bodies
set certificate_file=~/.mutt/certificates
set move = no
set sort = 'threads'
set sort_aux = 'last-date-received'
set imap_check_subscribed

Send a test email using Mutt to verify email setup.

Configure Git

vim ~/.gitconfig
[user]
    name = <Firstname Lastname>
    email = <your_email>@yahoo.com

Post Commit Hooks

This will need to be placed in any/every tree in which you build patches.

vim .git/hooks/post-commit
#!/bin/sh
exec git show --format=email HEAD | ./scripts/checkpatch.pl --strict --codespell
chmod a+x .git/hooks/post-commit