Skip to content

Commit e0eb5ff

Browse files
authored
Draft release 1.1 (#5)
* Fix typo in README * Use date command to automatically generate date yyyymmdd * Add badges and update ci * Add FUNDING.yml * Replace echo by sed for /boot/cmdline.txt * Update base Docker image * Replace inplace urls by definitions * Add Usage title in README
1 parent fd84530 commit e0eb5ff

File tree

6 files changed

+102
-65
lines changed

6 files changed

+102
-65
lines changed

.github/FUNDING.yml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# These are supported funding model platforms
2+
3+
github: []
4+
patreon: # Replace with a single Patreon username
5+
open_collective: # Replace with a single Open Collective username
6+
ko_fi: # Replace with a single Ko-fi username
7+
tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel
8+
community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry
9+
liberapay: # Replace with a single Liberapay username
10+
issuehunt: # Replace with a single IssueHunt username
11+
otechie: # Replace with a single Otechie username
12+
custom: ['https://paypal.me/tschaffter/0usd']

.github/workflows/ci.yml

Lines changed: 44 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,56 @@
1-
name: CI
1+
name: ci
22

33
on:
44
push:
5-
branches: [ master, develop ]
5+
branches:
6+
- master
7+
tags:
8+
- '*'
69
pull_request:
7-
branches: [ master, develop ]
810

911
jobs:
10-
test:
12+
lint:
1113
runs-on: ubuntu-18.04
12-
14+
container: hadolint/hadolint:latest
1315
steps:
1416
- uses: actions/checkout@v2
17+
- name: Run hadolint
18+
run: hadolint Dockerfile
1519

20+
test:
21+
needs: [lint]
22+
runs-on: ubuntu-18.04
23+
steps:
24+
- uses: actions/checkout@v2
1625
- name: Run builder script with arguments `--help`
1726
run: ./build-kernel.sh --help
27+
28+
release:
29+
needs: [test]
30+
runs-on: ubuntu-18.04
31+
steps:
32+
- uses: actions/checkout@v2
33+
34+
- name: Set variables
35+
id: vars
36+
run: |
37+
echo ::set-output \
38+
name=repository::tschaffter/${{ github.event.repository.name }}
39+
echo ::set-output name=user::tschaffter
40+
if [[ ${GITHUB_REF} = refs/tags/* ]]
41+
then
42+
echo ::set-output name=version::${GITHUB_REF#refs/tags/}
43+
echo ::set-output name=push::true
44+
else
45+
echo ::set-output name=version::test
46+
echo ::set-output name=push::false
47+
fi
48+
49+
- name: Build Dockerfile.base
50+
uses: docker/build-push-action@v1
51+
with:
52+
username: ${{ secrets.DOCKER_USERNAME }}
53+
password: ${{ secrets.DOCKER_PASSWORD }}
54+
repository: ${{ steps.vars.outputs.repository }}
55+
tags: latest, ${{ steps.vars.outputs.version }}
56+
push: ${{ steps.vars.outputs.push }}

.github/workflows/publish-docker-image.yml

Lines changed: 0 additions & 23 deletions
This file was deleted.

Dockerfile

Lines changed: 20 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,32 @@
1-
FROM debian:buster-20200607-slim
1+
FROM debian:buster-20200803-slim
22

33
LABEL maintainer="[email protected]"
44

5+
# Internal user who will build the kernel
56
ARG user=builder
67

78
# Install Git and the build dependencies
89
# hadolint ignore=DL3008
910
RUN apt-get update -qq -y && apt-get install --no-install-recommends -qq -y \
10-
apt-transport-https \
11-
bc \
12-
bison \
13-
build-essential \
14-
ca-certificates \
15-
cpio \
16-
dpkg-dev \
17-
fakeroot \
18-
flex \
19-
git \
20-
kmod \
21-
libssl-dev \
22-
libc6-dev \
23-
libncurses5-dev \
24-
make \
25-
rsync \
11+
apt-transport-https \
12+
bc \
13+
bison \
14+
build-essential \
15+
ca-certificates \
16+
cpio \
17+
dpkg-dev \
18+
fakeroot \
19+
flex \
20+
git \
21+
kmod \
22+
libssl-dev \
23+
libc6-dev \
24+
libncurses5-dev \
25+
make \
26+
rsync \
2627
&& update-ca-certificates \
28+
&& apt-get -y autoclean \
29+
&& apt-get -y autoremove \
2730
&& rm -rf /var/lib/apt/lists/*
2831

2932
# Create user and set work directory

README.md

Lines changed: 25 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,22 @@
11
# Hardened Kernel Builder for Raspberry Pi
22

3-
[![Docker Image](https://github.com/tschaffter/raspberry-pi-kernel-hardened/workflows/Publish%20Docker%20Image/badge.svg)](https://hub.docker.com/repository/docker/tschaffter/raspberry-pi-kernel-hardened)
3+
[![GitHub Stars](https://img.shields.io/github/stars/tschaffter/raspberry-pi-kernel-hardened.svg?color=94398d&labelColor=555555&logoColor=ffffff&style=for-the-badge&logo=github)](https://github.com/tschaffter/raspberry-pi-kernel-hardened)
4+
[![GitHub Release](https://img.shields.io/github/release/tschaffter/raspberry-pi-kernel-hardened.svg?color=94398d&labelColor=555555&logoColor=ffffff&style=for-the-badge&logo=github)](https://github.com/tschaffter/raspberry-pi-kernel-hardened/releases)
5+
[![Docker Stars](https://img.shields.io/docker/stars/tschaffter/raspberry-pi-kernel-hardened.svg?color=94398d&labelColor=555555&logoColor=ffffff&style=for-the-badge&label=stars&logo=docker)](https://hub.docker.com/r/tschaffter/raspberry-pi-kernel-hardened)
6+
[![GitHub CI](https://img.shields.io/github/workflow/status/tschaffter/raspberry-pi-kernel-hardened/ci.svg?color=94398d&labelColor=555555&logoColor=ffffff&style=for-the-badge&logo=github)](https://github.com/tschaffter/raspberry-pi-kernel-hardened)
7+
[![GitHub License](https://img.shields.io/github/license/tschaffter/raspberry-pi-kernel-hardened.svg?color=94398d&labelColor=555555&logoColor=ffffff&style=for-the-badge&logo=github)](https://github.com/tschaffter/raspberry-pi-kernel-hardened)
48

5-
## Overview
6-
7-
Cross-compile the [Linux kernel for Raspberry Pi](https://www.raspberrypi.org/documentation/linux/kernel/building.md)
8-
with enhanced security using a single command.
9+
Cross-compile the [Linux kernel for Raspberry Pi][raspberrypi_kernel_build] with
10+
enhanced security support using a single command.
911

1012
## Features
1113

12-
- Dockerized tool to cross-compile the kernel with a single command
14+
- Dockerized tool to cross-compile an hardened kernel for the Pi with a single command
1315
- Hardened kernel features
14-
- Enable Audit
15-
- Enable SELinux
16+
- Add Audit support
17+
- Add SELinux support
1618

17-
## Builder options
19+
## Usage
1820

1921
Run the folllowing command to see the options of the builder:
2022

@@ -28,11 +30,11 @@ Usage: build-kernel.sh [--kernel-branch <arg>] [--kernel-defconfig <arg>] [--ker
2830
-h, --help: Prints help
2931
```
3032

31-
## Build the hardered kernel
33+
## Build the hardened kernel
3234

3335
### Identify the kernel version to build
3436

35-
Go to the GitHub repository of the [Linux kernel of Raspberry Pi](https://github.com/raspberrypi/linux)
37+
Go to the GitHub repository of the [Linux kernel of Raspberry Pi][gh_raspberrypi/linux]
3638
and identify the name of the branch or tag that you want to build.
3739

3840
Examples:
@@ -42,9 +44,8 @@ Examples:
4244

4345
### Identify the default configuration to use
4446

45-
Go to the page [Kernel building](https://www.raspberrypi.org/documentation/linux/kernel/building.md)
46-
of the Raspberry Pi website to identify the default build configuration to use
47-
for the target Pi.
47+
Go to the page [Kernel building][raspberrypi_kernel_build] of the Raspberry Pi
48+
website to identify the default build configuration to use for the target Pi.
4849

4950
Examples:
5051

@@ -77,7 +78,7 @@ $ docker run \
7778
tschaffter/raspberry-pi-kernel-hardened \
7879
--kernel-branch rpi-5.4.y \
7980
--kernel-defconfig bcm2711_defconfig \
80-
--kernel-localversion 5.4.y-20200804-hardened
81+
--kernel-localversion 5.4.y-$(date '+%Y%m%d')-hardened
8182
Cloning into '/home/builder/tools'...
8283
Installing cross compiler toolchain
8384
Checking out files: 100% (19059/19059), done.
@@ -95,7 +96,7 @@ sudo reboot
9596

9697
ENABLE SELinux
9798
sudo apt-get install selinux-basics selinux-policy-default auditd
98-
sudo sh -c "echo ' selinux=1 security=selinux' >> /boot/cmdline.txt"
99+
sudo sh -c "sed -i '$ s/$/ selinux=1 security=selinux/' /boot/cmdline.txt"
99100
sudo touch /.autorelabel
100101
sudo reboot
101102
sestatus
@@ -110,8 +111,7 @@ command.
110111
## Customize your build
111112

112113
- The builder uses all the CPU cores available to the Docker container. By default,
113-
that is all the CPU cores of the host. Use
114-
[Docker runtime options](https://docs.docker.com/config/containers/resource_constraints/#cpu)
114+
that is all the CPU cores of the host. Use [Docker runtime options][docker_runtime_options]
115115
to limit the usage of CPU cores by the builder.
116116

117117
- The builder clones two GitHub repositories, the cross-compiler toolchain and
@@ -131,10 +131,16 @@ $ docker run \
131131
tschaffter/raspberry-pi-kernel-hardened \
132132
--kernel-branch rpi-5.4.y \
133133
--kernel-defconfig bcm2711_defconfig \
134-
--kernel-localversion 5.4.y-20200804-hardened
134+
--kernel-localversion 5.4.y-$(date '+%Y%m%d')-hardened
135135
```
136136

137137
## Contributing change
138138

139139
Please read the [`CONTRIBUTING.md`](CONTRIBUTING.md) for details on how to
140140
contribute to this project.
141+
142+
<!-- Definitions -->
143+
144+
[raspberrypi_kernel_build]: https://www.raspberrypi.org/documentation/linux/kernel/building.md
145+
[gh_raspberrypi/linux]: https://github.com/raspberrypi/linux
146+
[docker_runtime_options]: https://docs.docker.com/config/containers/resource_constraints/#cpu

build-kernel.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,7 @@ echo "sudo reboot"
234234
echo ""
235235
echo "ENABLE SELinux"
236236
echo "sudo apt-get install selinux-basics selinux-policy-default auditd"
237-
echo "sudo sh -c \"echo ' selinux=1 security=selinux' >> /boot/cmdline.txt\""
237+
echo "sudo sh -c \"sed -i '$ s/$/ selinux=1 security=selinux/' /boot/cmdline.txt\""
238238
echo "sudo touch /.autorelabel"
239239
echo "sudo reboot"
240240
echo "sestatus"

0 commit comments

Comments
 (0)