Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
168 changes: 168 additions & 0 deletions .github/workflows/test-meson.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,168 @@
name: Test with meson

on: [push, pull_request]

permissions:
actions: read

jobs:
build:
runs-on: ubuntu-latest
name: "Build with ASAN"
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Install dependencies
run: sudo ./hacking/installdeps.sh
- name: Install fsck.erofs
run: sudo apt install erofs-utils
- name: Install go-md2man
run: sudo apt install go-md2man
- name: Configure
run: meson setup build --prefix=/usr --werror -Db_sanitize=address,undefined
- name: Build
run: meson compile -C build
- name: Unit tests
run: meson test -C build
- name: Capture build
run: DESTDIR=$(pwd)/instroot meson install -C build && tar -C instroot -czf composefs.tar .
- name: Upload binary
uses: actions/upload-artifact@v2
with:
name: composefs.tar
path: composefs.tar
# This build doesn't enable ASAN, which e.g. makes it easier to use with Rust
build-noasan:
runs-on: ubuntu-latest
name: "Build without ASAN"
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Install dependencies
run: sudo ./hacking/installdeps.sh
- name: Configure
run: meson setup build --prefix=/usr --werror
- name: Build
run: meson compile -C build
- name: Capture build
run: DESTDIR=$(pwd)/instroot meson install -C build && tar -C instroot -czf composefs.tar .
- name: Upload binary
uses: actions/upload-artifact@v2
with:
name: composefs-noasan.tar
path: composefs.tar
build-baseline:
runs-on: ubuntu-latest
name: "Build on Ubuntu Focal"
container: ubuntu:focal
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Install dependencies
run: |
apt-get update -y
ALLOW_MISSING="libfsverity-dev" ./hacking/installdeps.sh
- name: Configure
run: meson setup build --werror
- name: Build
# focal's meson is too old for 'meson compile'
run: ninja -C build
build-unit-cross:
runs-on: ubuntu-latest
name: Build on ${{ matrix.arch }}

strategy:
matrix:
include:
- arch: armv7
distro: ubuntu_latest
- arch: aarch64
distro: ubuntu_latest
- arch: s390x
distro: ubuntu_latest
- arch: ppc64le
distro: ubuntu_latest
steps:
- uses: actions/checkout@v3.0.2
with:
submodules: true
set-safe-directory: true

- uses: uraimo/run-on-arch-action@v2.2.0
name: Build
id: build
with:
arch: ${{ matrix.arch }}
distro: ${{ matrix.distro }}

githubToken: ${{ github.token }}

run: |
apt-get update -y
./hacking/installdeps.sh
meson setup build --werror
meson compile -C build
meson test -C build --timeout-multiplier 10
integration:
needs: build
runs-on: ubuntu-latest

steps:
- run: sudo apt-get update -y
- name: Install erofs kmod
run: sudo apt install linux-modules-extra-$(uname -r)
- name: Install sanitizer dependencies
run: sudo apt install libasan6 libubsan1
- name: Checkout repository
uses: actions/checkout@v3
- name: Download
uses: actions/download-artifact@v2
with:
name: composefs.tar
- run: sudo tar -C / -xvf composefs.tar
- name: Integration tests
run: sudo ./tests/integration.sh
rust:
needs: build-noasan
runs-on: ubuntu-latest
steps:
- run: sudo apt-get update -y
- name: Checkout repository
uses: actions/checkout@v3
- name: Download
uses: actions/download-artifact@v2
with:
name: composefs-noasan.tar
- run: sudo tar -C / -xvf composefs.tar
- name: Cache Dependencies
uses: Swatinem/rust-cache@v2
with:
key: "rust-main"
- name: Rust (default features)
run: cargo test
- name: Rust (all features)
run: cargo test --all-features
clang-format:
runs-on: ubuntu-24.04
steps:
- name: checkout
uses: actions/checkout@v2
- name: install dependencies
run: |
sudo apt-get update -y
sudo apt-get install -y make clang-format
- name: check formatting
run: |
sudo docker build -t clang-format hacking/clang-format
sudo docker run --rm -w /src -v ${PWD}:/src clang-format
distcheck:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Install dependencies
run: sudo ./hacking/installdeps.sh
- name: Configure
run: meson setup build --werror
- name: Run make distcheck
run: meson dist -C build
2 changes: 1 addition & 1 deletion .github/workflows/test.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Test
name: Test with autotools

on: [push, pull_request]

Expand Down
1 change: 1 addition & 0 deletions hacking/installdeps.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ PACKAGES=" \
libfuse3-dev \
python3 \
libcap2-bin \
meson \
"

# Split required and optional packages based on input variable ALLOW_MISSING:
Expand Down
41 changes: 41 additions & 0 deletions libcomposefs/meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
source_files = files([
'bitrotate.h',
'erofs_fs.h',
'erofs_fs_wrapper.h',
'hash.c',
'hash.h',
'lcfs-internal.h',
'lcfs-erofs.h',
'lcfs-erofs-internal.h',
'lcfs-fsverity.c',
'lcfs-fsverity.h',
'lcfs-writer-erofs.c',
'lcfs-writer.c',
'lcfs-writer.h',
'lcfs-utils.h',
'lcfs-mount.c',
'lcfs-mount.h',
'xalloc-oversized.h',
])

libcomposefs = both_libraries('composefs',
source_files,
c_args : composefs_hash_cflags + hidden_visibility_cflags,
dependencies : libcrypto_dep,
version : libversion,
soversion : soversion,
include_directories : config_inc,
install : true,
)

pkg.generate(libcomposefs,
description : 'library for generating and using composefs images',
)

install_headers([
'lcfs-writer.h',
'lcfs-erofs.h',
'lcfs-mount.h',
],
subdir : 'libcomposefs',
)
31 changes: 31 additions & 0 deletions man/meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
manuals = {
'1': [
'mount.composefs',
'mkcomposefs',
'composefs-info',
],
'5': [
'composefs-dump',
],
}

foreach section, pages: manuals
foreach page: pages
output = page + '.' + section
input = page + '.md'
sectiondir = 'man' + section

custom_target(
output,
command: [
go_md2man,
'-in', '@INPUT@',
'-out', '@OUTPUT@',
],
input: input,
install: true,
install_dir: get_option('mandir') / sectiondir,
output: output,
)
endforeach
endforeach
129 changes: 129 additions & 0 deletions meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,129 @@
project(
'composefs',
'c',
version : '1.0.4',
default_options : [
'c_std=c99',
'warning_level=1',
],
)

pkg = import('pkgconfig')

libcomposefs_version_major = 1
libcomposefs_version_minor = 2
libcomposefs_version_micro = 0
libversion = '@0@.@1@.@2@'.format(libcomposefs_version_major, libcomposefs_version_minor, libcomposefs_version_micro)
soversion = libcomposefs_version_major

cc = meson.get_compiler('c')
add_project_arguments(
cc.get_supported_arguments([
'-Werror=shadow',
'-Werror=empty-body',
'-Werror=strict-prototypes',
'-Werror=missing-prototypes',
'-Werror=implicit-function-declaration',
'-Werror=format=2 -Werror=format-security -Werror=format-nonliteral',
'-Werror=pointer-arith',
'-Werror=init-self',
'-Werror=missing-declarations',
'-Werror=return-type',
'-Werror=switch',
'-Werror=overflow',
'-Werror=int-conversion',
'-Werror=parentheses',
'-Werror=undef',
'-Werror=incompatible-pointer-types',
'-Werror=misleading-indentation',
'-Werror=missing-include-dirs',
'-Wstrict-aliasing=2',
'-Werror=unused-result',
]),
language: 'c'
)

# Check for headers
cc.check_header('sys/mount.h')
cc.check_header('sys/capability.h')

# Check for libraries
fuse3_dep = dependency('fuse3', version : '>= 3.10.0', required : get_option('fuse'))
libcrypto_dep = dependency('libcrypto')

foreach required_function : ['getcwd', 'memset', 'mmap', 'munmap', 'strdup']
if not cc.has_function(required_function)
error('Required function ' + required_function + ' not found')
endif
endforeach

# Flags for libcomposefs/hash.c
composefs_hash_cflags = ['-DUSE_OBSTACK=0', '-DTESTING=0', '-DUSE_DIFF_HASH=0']

# Configuration data for conditional compilation
conf = configuration_data()
conf.set('HAVE_FUSE3', fuse3_dep.found())
conf.set('HAVE_OPENSSL', libcrypto_dep.found())

if cc.check_header('endian.h')
conf.set('HAVE_ENDIAN_H', '1')
endif
if cc.check_header('sys/endian.h')
conf.set('HAVE_SYS_ENDIAN_H', 1)
endif
if cc.check_header('machine/endian.h')
conf.set('HAVE_MACHINE_ENDIAN_H', 1)
endif
if cc.has_function('reallocarray')
conf.set('HAVE_REALLOCARRAY', 1)
endif

mount_attr_idmap = '''
#include <sys/mount.h>
#include <linux/mount.h>
int foo = MOUNT_ATTR_IDMAP;
'''
if cc.compiles(mount_attr_idmap, name : 'MOUNT_ATTR_IDMAP in linux/mount.h')
conf.set('HAVE_MOUNT_ATTR_IDMAP', 1)
endif

sys_mount_fsconfig_cmd_create = '''
#include <sys/mount.h>
int cmd = FSCONFIG_CMD_CREATE;
'''
if cc.compiles(sys_mount_fsconfig_cmd_create, name : 'new mount API in sys/mount.h (fsconfig)')
conf.set('HAVE_FSCONFIG_CMD_CREATE_SYS_MOUNT_H', 1)
endif

linux_mount_fsconfig_cmd_create = '''
/* also make sure it doesn't conflict with <sys/mount.h> since it is always used. */
#include <sys/mount.h>
#include <linux/mount.h>
int cmd = FSCONFIG_CMD_CREATE;
'''
if cc.compiles(linux_mount_fsconfig_cmd_create, name : 'new mount API in linux/mount.h (fsconfig)')
conf.set('HAVE_FSCONFIG_CMD_CREATE_LINUX_MOUNT_H', 1)
endif

if cc.has_argument('-fvisibility=hidden')
hidden_visibility_cflags = ['-fvisibility=hidden']
conf.set('LCFS_EXTERN', '__attribute__((visibility("default"))) extern')
else
hidden_visibility_cflags = ['']
conf.set('LCFS_EXTERN', 'extern')
endif

config_h = configure_file(
output : 'config.h',
configuration : conf
)
config_inc = include_directories('.')

subdir('libcomposefs')
subdir('tools')
subdir('tests')

go_md2man = find_program('go-md2man', required : get_option('man'))
if go_md2man.found()
subdir('man')
endif
10 changes: 10 additions & 0 deletions meson_options.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
option(
'man',
type : 'feature',
value : 'auto',
description : 'generate man pages')
option(
'fuse',
type : 'feature',
value : 'auto',
description : 'build fuse support')
Loading