Files
Linux-Kernel-Programming_2E/ch1/pkg_install4ubuntu_lkp.sh

88 lines
3.1 KiB
Bash
Raw Normal View History

#!/bin/bash
# pkg_install4ubuntu_lkp.sh
# ***************************************************************
# This program is part of the source code released for the book
2023-04-24 12:18:38 +05:30
# "Linux Kernel Programming" 2E
# (c) Author: Kaiwan N Billimoria
# Publisher: Packt
# GitHub repository:
# https://github.com/PacktPublishing/Linux-Kernel-Programming_2E
#****************************************************************
# Brief Description:
# Helper script to install all required packages (as well as a few more
# possibly) for the Linux Kernel Programming 2E book.
2023-07-26 19:10:03 +05:30
#
2023-07-14 12:52:23 +05:30
# Currently biased toward Debian/Ubuntu systems only... (uses apt).
2023-07-26 19:10:03 +05:30
# To (slightly :) help folks on Fedora (and related), do:
# sudo dnf install ncurses-devel gcc-c++
function die
{
echo >&2 "$@"
exit 1
}
runcmd()
{
2023-04-26 16:17:53 +05:30
[[ $# -eq 0 ]] && return
echo "$@"
2023-12-06 09:11:01 +05:30
eval "$@" || echo "*** failed ***"
}
#--- 'main'
echo "$(date): beginning installation of required packages..."
2023-12-06 09:11:01 +05:30
# Get the root partition; we ASSUME you're using it...
ROOT_PART=$(df |grep -w "/"|awk '{print $1}')
[[ -z "${ROOT_PART}" ]] && die "Couldn't get root partition"
spc1=$(df|grep ${ROOT_PART}|awk '{print $3}')
[[ ! -z "${spc1}" ]] && echo "Disk space in use currently: ${spc1} KB"
runcmd sudo apt update
echo "-----------------------------------------------------------------------"
2022-08-03 18:44:05 +05:30
# ensure basic pkgs are installed!
runcmd sudo apt install -y \
2022-10-21 13:38:43 +05:30
gcc make perl
2022-08-03 18:44:05 +05:30
# packages typically required for kernel build
runcmd sudo apt install -y \
2022-10-21 13:38:43 +05:30
asciidoc binutils-dev bison build-essential flex libncurses5-dev ncurses-dev \
libelf-dev libssl-dev openssl pahole tar util-linux xz-utils zstd
2022-10-21 13:38:43 +05:30
echo "-----------------------------------------------------------------------"
# other packages...
# TODO : check if reqd
#sudo apt install -y bc bpfcc-tools build-essential \
runcmd sudo apt install -y \
2022-09-05 13:17:55 +05:30
bc bpfcc-tools bsdextrautils \
2023-10-10 09:04:39 +05:30
clang coccinelle coreutils cppcheck cscope curl exuberant-ctags \
2022-09-05 13:17:55 +05:30
fakeroot flawfinder \
2023-04-26 08:42:35 +05:30
git gnome-system-monitor gnuplot hwloc indent kmod \
2022-09-05 13:17:55 +05:30
libnuma-dev linux-headers-$(uname -r) linux-tools-$(uname -r) \
2023-12-06 09:11:01 +05:30
man-db net-tools numactl openjdk-22-jdk \
2023-05-11 14:53:13 +05:30
perf-tools-unstable procps psmisc python3-distutils \
2023-08-16 16:46:08 +05:30
rt-tests smem sparse stress stress-ng sysfsutils \
2023-01-15 11:04:50 +05:30
tldr-py trace-cmd tree tuna virt-what yad
echo "-----------------------------------------------------------------------"
2023-09-01 12:58:08 +05:30
#--- FYI, on Fedora-type systems:
# Debian/Ubuntu pkg Fedora/RedHat/CentOS equivalent pkg
# -------------------------- -----------------------------------
# rt-tests realtime-tests
# ncurses-dev/libncurses5-dev ncurses-devel
# libssl-dev openssl-devel
# libelf-dev elfutils-libelf-devel
#---
2023-12-06 09:11:01 +05:30
# As an aside, lets add ourseleves to the vboxsf group (to gain access to
# VirtualBox shared folders); will require you to log out and back in
# (or even reboot) to take effect
groups |grep -q -w vboxsf || runcmd sudo usermod -G vboxsf -a ${USER}
2023-04-26 16:17:53 +05:30
runcmd sudo apt autoremove
2023-12-06 09:11:01 +05:30
spc2=$(df|grep ${ROOT_PART}|awk '{print $3}')
[[ ! -z "${spc1}" && ! -z "${spc2}" ]] && echo "Disk space difference : ($spc2 - $spc1) : $((spc2-spc1)) KB"
exit 0