Skip to content

Commit 5e95e76

Browse files
committed
Rebrand, move to GitHub and related changes
- Change name to 'libloadguard' as part of forking - Add GitHub CI, update README and remove unrelated files - Move code files to proper subdirectories and split Meson build files - Add pyproject.toml to create devenv with uv for Python script - Format, lint with ruff and type check with mypy - Add pytest tests for the Python script - Merge all C test files into one and remove test data as it is created in-place - Expose internal header for tests - Add integration tests for LD_AUDIT hook - Add uncrustify to format C code - Add hardening compile flags - Build with ASAN and -Werror in CI - Enable build for x86_64 and aarch64 - Enable Clang build - Format meson files properly - Add pre-commit config to run all build, tests, lints formats etc. - Add type hints to Python script - Install Python script only if Python requirements are met in Meson - Populate gitignore - Change default value of config file to /app/etc - Bump version to 26.05.0 - Update old copyright headers - Add shellcheck - Add Flatpak manifest and test with it in CI - Historical commits are merged per-commit author since most changes are not relevant right now
1 parent 7b93f8b commit 5e95e76

39 files changed

Lines changed: 3075 additions & 546 deletions

.github/dependencies.apt.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
meson
2+
ninja-build
3+
python3-jsonschema
4+
python3-yaml

.github/workflows/check.yml

Lines changed: 187 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,187 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: main
6+
paths-ignore:
7+
- '.gitignore'
8+
- 'LICENSE'
9+
- 'README'
10+
- '.pre-commit-config.yaml'
11+
pull_request:
12+
branches: main
13+
paths-ignore:
14+
- '.gitignore'
15+
- 'LICENSE'
16+
- 'README'
17+
- '.pre-commit-config.yaml'
18+
workflow_dispatch:
19+
20+
jobs:
21+
lint:
22+
runs-on: ubuntu-latest
23+
permissions:
24+
contents: read
25+
timeout-minutes: 10
26+
concurrency:
27+
group: lint-${{ github.workflow }}-${{ github.ref }}
28+
cancel-in-progress: true
29+
steps:
30+
# 6.0.2
31+
- name: Checkout repository
32+
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd
33+
with:
34+
persist-credentials: false
35+
36+
- name: Install uv
37+
# 7.2.0
38+
uses: astral-sh/setup-uv@61cb8a9741eeb8a550a1b8544337180c0fc8476b
39+
with:
40+
version: "0.9.21"
41+
enable-cache: true
42+
save-cache: ${{ github.ref == 'refs/heads/main' }}
43+
cache-dependency-glob: |
44+
**/uv.lock
45+
**/pyproject.toml
46+
47+
- name: Install python dependencies
48+
run: uv sync --all-extras --all-groups --frozen
49+
50+
- name: Check Python code formatting
51+
run: uv run ruff format --check
52+
53+
- name: Check Python code lint
54+
run: uv run ruff check --output-format=github
55+
56+
- name: Check Python code types
57+
run: uv run mypy .
58+
59+
- name: Run tests
60+
run: uv run pytest
61+
62+
flatpak:
63+
strategy:
64+
matrix:
65+
include:
66+
- os: ubuntu-24.04
67+
platform: x86_64
68+
- os: ubuntu-24.04-arm
69+
platform: aarch64
70+
runs-on: ${{ matrix.os }}
71+
permissions:
72+
contents: read
73+
timeout-minutes: 30
74+
concurrency:
75+
group: flatpak-${{ matrix.platform }}-${{ github.ref }}
76+
cancel-in-progress: true
77+
steps:
78+
- name: Install dependencies
79+
run: |
80+
sudo apt-get update
81+
sudo apt-get install -y flatpak flatpak-builder
82+
83+
# 6.0.2
84+
- name: Checkout repository
85+
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd
86+
with:
87+
persist-credentials: false
88+
89+
- uses: actions/cache/restore@27d5ce7f107fe9357f9df03efb73ab90386fccae
90+
with:
91+
path: ${{ github.workspace }}/cache/.flatpak-builder
92+
key: ${{ runner.os }}-${{ matrix.platform }}-ci-flatpak-builder-${{ hashFiles('data/io.github.bbhtt.libloadguard.json') }}
93+
restore-keys: |
94+
${{ runner.os }}-${{ matrix.platform }}-ci-flatpak-builder-
95+
96+
- name: Build and run test
97+
run: |
98+
./tests/run_block_test.sh
99+
100+
# 5.0.5
101+
- uses: actions/cache/save@27d5ce7f107fe9357f9df03efb73ab90386fccae
102+
if: github.ref == 'refs/heads/main'
103+
with:
104+
path: ${{ github.workspace }}/cache/.flatpak-builder
105+
key: ${{ runner.os }}-${{ matrix.platform }}-ci-flatpak-builder-${{ hashFiles('data/io.github.bbhtt.libloadguard.json') }}
106+
107+
build:
108+
strategy:
109+
matrix:
110+
os: ['ubuntu-24.04', 'ubuntu-24.04-arm']
111+
compiler: ['gcc', 'clang']
112+
runs-on: ${{ matrix.os }}
113+
container:
114+
image: ubuntu:26.04
115+
options: --privileged
116+
permissions:
117+
contents: read
118+
timeout-minutes: 20
119+
concurrency:
120+
group: build-${{ matrix.os }}-${{ matrix.compiler }}-${{ github.ref }}
121+
cancel-in-progress: true
122+
env:
123+
CC: ${{ matrix.compiler }}
124+
BUILDDIR: builddir
125+
CONFIG_OPTS: -Dtests=true
126+
MESON_TEST_TIMEOUT_MULTIPLIER: 2
127+
DEBIAN_FRONTEND: noninteractive
128+
steps:
129+
- name: Install dependencies
130+
run: apt-get update && apt-get install -y git findutils
131+
132+
- name: Set git safe directory
133+
run: git config --global safe.directory "*"
134+
135+
# 6.0.2
136+
- name: Checkout repository
137+
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd
138+
with:
139+
persist-credentials: false
140+
141+
- name: Install build dependencies
142+
run: |
143+
apt-get install -y ${{ matrix.compiler }} uncrustify shellcheck \
144+
$(xargs < .github/dependencies.apt.txt)
145+
146+
- name: Run shellcheck
147+
run: ./shellcheck.sh
148+
149+
- name: Run uncrustify
150+
run: ./uncrustify.sh && git diff --exit-code
151+
152+
- name: Configure with meson
153+
run: |
154+
if [ "${{ matrix.compiler }}" = "gcc" ]; then
155+
SANITIZE_OPTS="-Db_sanitize=address,undefined"
156+
else
157+
SANITIZE_OPTS=""
158+
fi
159+
160+
meson setup --wrap-mode nodownload ${CONFIG_OPTS} \
161+
-Dwerror=true ${SANITIZE_OPTS} ${BUILDDIR} .
162+
163+
- name: Build with meson
164+
run: meson compile -C ${BUILDDIR}
165+
166+
- name: Run tests with Meson
167+
env:
168+
ASAN_OPTIONS: "detect_leaks=1:fast_unwind_on_malloc=0:malloc_context_size=20:symbolize=1"
169+
UBSAN_OPTIONS: "print_stacktrace=1"
170+
run: |
171+
export LSAN_OPTIONS="suppressions=$GITHUB_WORKSPACE/tests/lsan.supp"
172+
meson test -C ${BUILDDIR} --verbose --timeout-multiplier ${MESON_TEST_TIMEOUT_MULTIPLIER}
173+
174+
- name: Upload test logs
175+
# 7.0.0
176+
uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f
177+
if: failure() || cancelled()
178+
with:
179+
name: test logs
180+
path: |
181+
builddir/meson-logs/testlog.txt
182+
installed-test-logs/
183+
184+
- name: Create dist tarball
185+
run: |
186+
meson setup --wrap-mode nodownload --reconfigure ${CONFIG_OPTS} ${BUILDDIR}_dist .
187+
meson dist --include-subprojects -C ${BUILDDIR}_dist

.gitignore

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
builddir/
2+
.flatpak-builder/
3+
.flatpak-builder-state/
4+
repo/
5+
build/
6+
.flatpak-test/
7+
8+
__pycache__/
9+
.venv/
10+
venv/
11+
.pytest_cache/
12+
.mypy_cache/
13+
.ruff_cache/

.gitlab-ci.yml

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

.pre-commit-config.yaml

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
default_install_hook_types:
2+
- pre-commit
3+
default_stages:
4+
- pre-commit
5+
fail_fast: true
6+
repos:
7+
- repo: https://github.com/pre-commit/pre-commit-hooks
8+
rev: cef0300fd0fc4d2a87a85fa2093c6b283ea36f4b
9+
hooks:
10+
- id: trailing-whitespace
11+
- id: end-of-file-fixer
12+
- id: check-added-large-files
13+
args: ['--maxkb=100']
14+
- id: check-shebang-scripts-are-executable
15+
- id: check-executables-have-shebangs
16+
- id: check-symlinks
17+
- id: mixed-line-ending
18+
args: [--fix=lf]
19+
20+
- repo: local
21+
hooks:
22+
- id: uv-lock
23+
name: uv lock
24+
description: Sync uv lock
25+
entry: uv lock --quiet
26+
language: python
27+
pass_filenames: false
28+
- id: ruff-format
29+
name: ruff format
30+
description: Format with ruff
31+
entry: uv run --frozen -q ruff format
32+
language: system
33+
pass_filenames: false
34+
- id: ruff-check
35+
name: ruff
36+
description: Lint with ruff
37+
entry: uv run --frozen -q ruff check --fix --exit-non-zero-on-fix
38+
language: system
39+
pass_filenames: false
40+
- id: mypy-check
41+
name: mypy
42+
description: Check types with mypy
43+
entry: uv run --frozen -q mypy .
44+
language: system
45+
pass_filenames: false
46+
files: \.py$
47+
- id: py-test
48+
name: pytest
49+
description: Run pytest
50+
entry: uv run --frozen -q pytest --ff --exitfirst
51+
language: system
52+
pass_filenames: false
53+
- id: shellcheck
54+
name: shellcheck
55+
language: system
56+
entry: bash -c 'git ls-files "*.sh" "*.bash" | xargs -r shellcheck -S warning'
57+
pass_filenames: false
58+
always_run: true
59+
- id: uncrustify
60+
name: uncrustify
61+
language: system
62+
entry: sh -c 'uncrustify -c uncrustify.cfg --no-backup $(git ls-files "*.c" "*.h") && git diff --exit-code'
63+
pass_filenames: false
64+
always_run: true
65+
- id: meson
66+
name: build and test with meson
67+
language: system
68+
entry: sh -c 'meson setup builddir --reconfigure -Dtests=true && meson compile -C builddir && meson test -C builddir'
69+
pass_filenames: false
70+
always_run: true

.ruff.toml

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

LICENSE

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -470,8 +470,9 @@ safest to attach them to the start of each source file to most effectively
470470
convey the exclusion of warranty; and each file should have at least the
471471
"copyright" line and a pointer to where the full notice is found.
472472

473-
shared-library-guard
474-
Copyright (C) 2019 freedesktop-sdk
473+
libloadguard
474+
Copyright (C) 2026 bbhtt
475+
Copyright (C) 2019-2026 freedesktop-sdk
475476

476477
This library is free software; you can redistribute it and/or
477478
modify it under the terms of the GNU Lesser General Public

0 commit comments

Comments
 (0)