Skip to content

Commit dab2881

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 dab2881

39 files changed

Lines changed: 3044 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: 184 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,184 @@
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+
os: ['ubuntu-24.04', 'ubuntu-24.04-arm']
66+
platform: ['x86_64', 'aarch64']
67+
runs-on: ${{ matrix.os }}
68+
permissions:
69+
contents: read
70+
timeout-minutes: 30
71+
concurrency:
72+
group: flatpak-${{ matrix.platform }}-${{ github.ref }}
73+
cancel-in-progress: true
74+
steps:
75+
- name: Install dependencies
76+
run: |
77+
sudo apt-get update
78+
sudo apt-get install -y flatpak flatpak-builder
79+
80+
# 6.0.2
81+
- name: Checkout repository
82+
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd
83+
with:
84+
persist-credentials: false
85+
86+
- uses: actions/cache/restore@27d5ce7f107fe9357f9df03efb73ab90386fccae
87+
with:
88+
path: ${{ github.workspace }}/cache/.flatpak-builder
89+
key: ${{ runner.os }}-${{ matrix.platform }}-ci-flatpak-builder-${{ hashFiles('data/io.github.bbhtt.libloadguard.json') }}
90+
restore-keys: |
91+
${{ runner.os }}-${{ matrix.platform }}-ci-flatpak-builder-
92+
93+
- name: Build and run test
94+
run: |
95+
./tests/run_block_test.sh
96+
97+
# 5.0.5
98+
- uses: actions/cache/save@27d5ce7f107fe9357f9df03efb73ab90386fccae
99+
if: github.ref == 'refs/heads/main'
100+
with:
101+
path: ${{ github.workspace }}/cache/.flatpak-builder
102+
key: ${{ runner.os }}-${{ matrix.platform }}-ci-flatpak-builder-${{ hashFiles('data/io.github.bbhtt.libloadguard.json') }}
103+
104+
build:
105+
strategy:
106+
matrix:
107+
os: ['ubuntu-24.04', 'ubuntu-24.04-arm']
108+
compiler: ['gcc', 'clang']
109+
runs-on: ${{ matrix.os }}
110+
container:
111+
image: ubuntu:26.04
112+
options: --privileged
113+
permissions:
114+
contents: read
115+
timeout-minutes: 20
116+
concurrency:
117+
group: build-${{ matrix.os }}-${{ matrix.compiler }}-${{ github.ref }}
118+
cancel-in-progress: true
119+
env:
120+
CC: ${{ matrix.compiler }}
121+
BUILDDIR: builddir
122+
CONFIG_OPTS: -Dtests=true
123+
MESON_TEST_TIMEOUT_MULTIPLIER: 2
124+
DEBIAN_FRONTEND: noninteractive
125+
steps:
126+
- name: Install dependencies
127+
run: apt-get update && apt-get install -y git findutils
128+
129+
- name: Set git safe directory
130+
run: git config --global safe.directory "*"
131+
132+
# 6.0.2
133+
- name: Checkout repository
134+
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd
135+
with:
136+
persist-credentials: false
137+
138+
- name: Install build dependencies
139+
run: |
140+
apt-get install -y ${{ matrix.compiler }} uncrustify shellcheck \
141+
$(xargs < .github/dependencies.apt.txt)
142+
143+
- name: Run shellcheck
144+
run: ./shellcheck.sh
145+
146+
- name: Run uncrustify
147+
run: ./uncrustify.sh && git diff --exit-code
148+
149+
- name: Configure with meson
150+
run: |
151+
if [ "${{ matrix.compiler }}" = "gcc" ]; then
152+
SANITIZE_OPTS="-Db_sanitize=address,undefined"
153+
else
154+
SANITIZE_OPTS=""
155+
fi
156+
157+
meson setup --wrap-mode nodownload ${CONFIG_OPTS} \
158+
-Dwerror=true ${SANITIZE_OPTS} ${BUILDDIR} .
159+
160+
- name: Build with meson
161+
run: meson compile -C ${BUILDDIR}
162+
163+
- name: Run tests with Meson
164+
env:
165+
ASAN_OPTIONS: "detect_leaks=1:fast_unwind_on_malloc=0:malloc_context_size=20:symbolize=1"
166+
UBSAN_OPTIONS: "print_stacktrace=1"
167+
run: |
168+
export LSAN_OPTIONS="suppressions=$GITHUB_WORKSPACE/tests/lsan.supp"
169+
meson test -C ${BUILDDIR} --verbose --timeout-multiplier ${MESON_TEST_TIMEOUT_MULTIPLIER}
170+
171+
- name: Upload test logs
172+
# 7.0.0
173+
uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f
174+
if: failure() || cancelled()
175+
with:
176+
name: test logs
177+
path: |
178+
builddir/meson-logs/testlog.txt
179+
installed-test-logs/
180+
181+
- name: Create dist tarball
182+
run: |
183+
meson setup --wrap-mode nodownload --reconfigure ${CONFIG_OPTS} ${BUILDDIR}_dist .
184+
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)