Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
3609359
move mount functionality to uenv library
bcumming Jul 21, 2025
03a2b55
squashfs-mount argument parsing works
bcumming Jul 21, 2025
c5c87de
e2e implementation.
bcumming Jul 22, 2025
1411dd0
e2e start and run with with squashfs-mount
bcumming Jul 22, 2025
cc9d4e7
use squashfs-mount in the repo
bcumming Jul 23, 2025
f7d69c1
fix github action
bcumming Jul 23, 2025
916abd0
fix github action
bcumming Jul 23, 2025
a88a8bd
do not leak memory with uenv run when exec fails
bcumming Jul 23, 2025
d25067b
heavy lift of validating mount points almost finished
bcumming Jul 23, 2025
0698345
fix bug in mount validation
bcumming Jul 24, 2025
4e18dd9
more verbose output for failing test
bcumming Jul 24, 2025
2ece9ac
build squashfs-mount
bcumming Jul 24, 2025
0a48200
remove debug string from cli.bats; remove redundant lib from liblibue…
bcumming Jul 24, 2025
8aa4942
clean up memory when start fails to exec
bcumming Jul 24, 2025
e1bb181
clean up comments
bcumming Jul 24, 2025
241feff
remove duplicate call to unshare(CLONE_NEWS), mount
simonpintarelli Jul 24, 2025
2dc8962
print error msg
simonpintarelli Jul 24, 2025
b2dc41c
add missing files
simonpintarelli Jul 24, 2025
78ad666
add editorconfig
simonpintarelli Jul 24, 2025
cd4d66a
wip add rootless version
simonpintarelli Jul 25, 2025
54578b6
add make_mutable_root
simonpintarelli Jul 26, 2025
3608948
update
simonpintarelli Jul 27, 2025
ca3c7e4
rename variables
simonpintarelli Jul 27, 2025
4fc9106
move routines to mount.cpp/h
simonpintarelli Jul 28, 2025
946b290
format
simonpintarelli Jul 28, 2025
c7ed6f5
build squashfuse,zstd static libs in install-alps-local.sh
simonpintarelli Jul 29, 2025
829a37b
fix typos
simonpintarelli Jul 30, 2025
43e1fe3
install dependencies only if needed
simonpintarelli Jul 30, 2025
72d654f
add install flag for squashfs-mount
simonpintarelli Jul 30, 2025
d84a7e1
add squashfuse to github workflow
simonpintarelli Jul 30, 2025
f5966f0
use fuse in build
simonpintarelli Jul 30, 2025
00859e1
add libfuse3-dev
simonpintarelli Jul 30, 2025
22947b3
format
simonpintarelli Jul 30, 2025
858aea0
debug
simonpintarelli Jul 30, 2025
b504741
Revert "debug"
simonpintarelli Jul 30, 2025
1e5d526
try container
simonpintarelli Jul 30, 2025
afe639c
remove sudo
simonpintarelli Jul 30, 2025
a43ccdd
add missing apt flags
simonpintarelli Jul 30, 2025
e069e1d
install wget
simonpintarelli Jul 30, 2025
a307f57
certificates
simonpintarelli Jul 30, 2025
96ac14a
missing packages
simonpintarelli Jul 30, 2025
18fac9d
generate locales
simonpintarelli Jul 30, 2025
018d1a0
debug bats
simonpintarelli Jul 30, 2025
9d884fe
meson test --verbose
simonpintarelli Jul 30, 2025
6c52649
log statements
simonpintarelli Aug 21, 2025
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
9 changes: 9 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
root = true

[*.build]
indent_style = space
indent_size = 4

[*{,cpp,h}]
indent_style = space
indent_size = 4
40 changes: 28 additions & 12 deletions .github/workflows/build_and_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,46 +17,62 @@ jobs:
- buildtype: release
sanitizer: address
runs-on: ubuntu-24.04
container:
image: ubuntu:noble
options: --privileged
steps:
- uses: actions/checkout@v4
- name: Update apt repositories for ccache
run: sudo apt update
run: apt update
- name: Install dependencies
run: sudo apt-get install util-linux libmount-dev libslurm-dev
run: apt-get install --no-install-recommends --yes util-linux libmount-dev libslurm-dev
# run: sudo apt-get install util-linux libmount-dev slurm-wlm libslurm-dev slurmd slurmctld slurm-client
- name: Set up ccache
uses: hendrikmuhs/ccache-action@v1.2
with:
key: ccache-linux-${{ matrix.buildtype }}-${{ matrix.sanitizer }}
- name: Install compiler and build tools
run: sudo apt install --no-install-recommends --yes g++-12 ninja-build
run: |
apt install --no-install-recommends --yes \
g++-12 \
ninja-build \
libsquashfuse-dev \
libfuse3-dev \
wget \
ca-certificates \
python3 \
pkg-config \
sqlite3 \
git \
squashfs-tools \
curl \
ninja-build \
locales

locale-gen en_US.UTF-8
update-locale LANG=en_US.UTF-8
- name: install meson
run: |
wget https://github.com/mesonbuild/meson/releases/download/1.6.1/meson-1.6.1.tar.gz && \
tar -xzf meson-1.6.1.tar.gz && \
mv meson-1.6.1 meson && \
mv meson/meson.py meson/meson
- name: install squashfs-mount
run: |
wget https://github.com/eth-cscs/squashfs-mount/archive/refs/tags/v1.1.0.tar.gz
tar -xzf v1.1.0.tar.gz
./meson/meson setup build-sqfs squashfs-mount-1.1.0
./meson/meson compile -C build-sqfs
sudo ./meson/meson install -C build-sqfs
- name: Configure
run: |
CC="ccache gcc-12" CXX="ccache g++-12" ./meson/meson setup \
--buildtype ${{ matrix.buildtype }} \
-Db_sanitize=${{ matrix.sanitizer }} \
-Dtests=enabled \
-Dfuse=true \
-Dsquashfs_mount=true \
--warnlevel 3 \
--werror \
build .
- name: Build
run: ./meson/meson compile -Cbuild
- name: test unit
run: ./meson/meson test -Cbuild --verbose unit
run: ./meson/meson test -v -Cbuild --verbose unit
- name: test cli
run: |
sudo mkdir /user-tools /user-environment
mkdir /user-tools /user-environment
UENV_BATS_SKIP_START=on ./meson/meson test -Cbuild --verbose cli
53 changes: 50 additions & 3 deletions install-alps-local.sh
Original file line number Diff line number Diff line change
@@ -1,11 +1,58 @@
#!/bin/bash

set -e
set -eu

# build static dependencies
(
cd extern/
if [ ! -d "zstd-1.5.7/install/lib/pkgconfig" ]; then
(
curl -L https://github.com/facebook/zstd/releases/download/v1.5.7/zstd-1.5.7.tar.gz | tar xzf -
cd zstd-1.5.7/build/meson
CXX=g++-12 CC=gcc-12 uvx --with=meson,ninja \
meson setup \
--buildtype=release \
-Dbin_programs=true \
-Dbin_contrib=true \
--prefix=$PWD/../../install \
--wipe builddir
uvx --with=meson,ninja ninja -C builddir install
cd ../../install
# squashfuse expects a lib dir
ln -sf lib64 lib
)
fi

export ZSTD=$(realpath zstd-1.5.7/install)

if [ ! -d "squashfuse-0.6.1/install/lib/pkgconfig" ]; then
(
curl -L https://github.com/vasi/squashfuse/releases/download/0.6.1/squashfuse-0.6.1.tar.gz | tar xzf -
cd squashfuse-0.6.1

# patch includedir in pkg-config
sed -i 's/^includedir=.*/includedir=@includedir@/' squashfuse.pc.in
sed -i 's/^includedir=.*/includedir=@includedir@/' squashfuse_ll.pc.in

./configure --disable-high-level \
--enable-static=yes \
--enable-shared=no \
--without-lzo \
--without-lz4 \
--with-zstd=$ZSTD \
--prefix=$PWD/install
make install
)
fi
)

PKG_CONFIG_PATH=$(realpath extern/zstd-1.5.7/install/lib/pkgconfig):$(realpath extern/squashfuse-0.6.1/install/lib/pkgconfig):${PKG_CONFIG_PATH:-}
export PKG_CONFIG_PATH

arch=$(uname -m)
echo "== architecture: $arch"

root=$(cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd)
root=$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" &>/dev/null && pwd)
build=$root/build-alps-$arch
pyenv=$root/pyenv-alps-$arch
install=$HOME/.local/$arch
Expand All @@ -17,7 +64,7 @@ echo "== configure in $build"

export CC=gcc-12
export CXX=g++-12
uvx --with meson,ninja meson setup --prefix=$install $build $root
uvx --with meson,ninja meson setup -Dsquashfs_mount=true -Dfuse=true --prefix=$install $build $root
uvx --with meson,ninja meson compile -C$build
uvx --with meson,ninja meson install -C$build --skip-subprojects

Expand Down
9 changes: 9 additions & 0 deletions meson-scripts/make-setuid.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/usr/bin/env bash

source="$1"
target="$2"

sudo cp $source $target
sudo chown root:root "${target}"
sudo chmod u+s "${target}"

48 changes: 44 additions & 4 deletions meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ oras_version = get_option('oras_version')

uenv_slurm_plugin = get_option('slurm_plugin')
uenv_cli = get_option('cli')

uenv_squashfs_mount = get_option('squashfs_mount')
conf_data = configuration_data()

add_global_arguments('-Wno-missing-field-initializers', language : 'cpp')
Expand All @@ -36,13 +36,16 @@ barkeep_dep = declare_dependency(
compile_args: ['-DBARKEEP_ENABLE_FMT_FORMAT'],
)

libmount_dep = dependency('mount')

# the lib dependency is all of the common funtionality shared between the CLI
# and the slurm plugin.
lib_src = [
'src/site/site.cpp',
'src/uenv/env.cpp',
'src/uenv/log.cpp',
'src/uenv/meta.cpp',
'src/uenv/mount.cpp',
'src/uenv/oras.cpp',
'src/uenv/parse.cpp',
'src/uenv/print.cpp',
Expand All @@ -62,15 +65,15 @@ lib_src = [
lib_inc = include_directories('src')

lib_uenv = static_library(
'libuenv',
'uenv',
lib_src,
include_directories: lib_inc,
dependencies: [curl_dep, sqlite3_dep, fmt_dep, spdlog_dep, json_dep, barkeep_dep],
)

uenv_dep = declare_dependency(
link_with: lib_uenv,
dependencies: [curl_dep, sqlite3_dep, fmt_dep, spdlog_dep, json_dep, barkeep_dep],
dependencies: [curl_dep, sqlite3_dep, fmt_dep, spdlog_dep, json_dep, barkeep_dep, libmount_dep],
include_directories: lib_inc
)

Expand Down Expand Up @@ -133,9 +136,46 @@ if uenv_cli
endif

if uenv_slurm_plugin
subdir('src/slurm')
subdir('src/slurm')
endif

if uenv_squashfs_mount
if get_option('fuse')
fuse_dep = dependency('fuse@0@'.format(get_option('fuse_version')))
squashfuse_dep = dependency('squashfuse_ll', static: false)
squashfs_mount_build = executable('squashfs-mount',
sources: ['src/squashfs-mount/squashfs-mount-rootless.cpp',
'src/squashfs-mount/rootless.cpp',
'src/squashfs-mount/mutable-root.cpp'
],
dependencies: [uenv_dep, fmt_dep, cli11_dep, squashfuse_dep, fuse_dep],
c_args: [
'-DVERSION="@0@"'.format(version),
],
install: true
)
else
message('NOT iusing fuse')
squashfs_mount_build = executable('squashfs-mount-build',
sources: ['src/squashfs-mount/squashfs-mount.cpp'],
dependencies: [uenv_dep, fmt_dep, cli11_dep],
c_args: [
'-DVERSION="@0@"'.format(version),
],
install: false)

squashfs_mount = custom_target(
'squashfs-mount',
input: squashfs_mount_build,
output: 'squashfs-mount',
command: ['./meson-scripts/make-setuid.sh', '@INPUT@', '@OUTPUT@'],
install: true,
install_dir: get_option('bindir'),
)
endif
endif


if get_option('tests').enabled()
subdir('test')
endif
4 changes: 3 additions & 1 deletion meson_options.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,7 @@ option('tests', type: 'feature', value: 'disabled')

option('slurm_plugin', type: 'boolean', value: true)
option('cli', type: 'boolean', value: true)

option('squashfs_mount', type: 'boolean', value: false)
option('fuse', type: 'boolean', value: true)
option('fuse_version', type: 'string', value: '3')
option('oras_version', type: 'string', value: '1.2.0')
23 changes: 17 additions & 6 deletions src/cli/run.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// vim: ts=4 sts=4 sw=4 et

#include <ranges>
#include <string>

#include <fmt/core.h>
Expand Down Expand Up @@ -64,16 +65,26 @@ You need to finish the current session by typing 'exit' or hitting '<ctrl-d>'.)"

// generate the mount list
std::vector<std::string> commands = {"squashfs-mount"};
for (auto e : env->uenvs) {
commands.push_back(fmt::format("{}:{}", e.second.sqfs_path.string(),
e.second.mount_path));
}
commands.push_back(fmt::format(
"--sqfs={}",
fmt::join(env->uenvs | std::views::transform([](const auto& in) {
return fmt::format("{}:{}", in.second.sqfs_path.string(),
in.second.mount_path);
}),
",")));

commands.push_back("--");
commands.insert(commands.end(), args.commands.begin(), args.commands.end());

// return util::exec(commands);
return util::exec(commands, runtime_environment.c_env());
auto c_env = runtime_environment.c_env();
auto rcode = util::exec(commands, c_env);

// clean up memory if there was an error
if (rcode) {
envvars::c_env_free(c_env);
}

return rcode;
}

std::string run_footer() {
Expand Down
22 changes: 17 additions & 5 deletions src/cli/start.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// vim: ts=4 sts=4 sw=4 et
#include <unistd.h>

#include <ranges>
#include <string>

#include <fmt/core.h>
Expand Down Expand Up @@ -107,10 +108,13 @@ will not work, because it starts a new interactive shell.)",

// generate the mount list
std::vector<std::string> commands = {"squashfs-mount"};
for (auto e : env->uenvs) {
commands.push_back(fmt::format("{}:{}", e.second.sqfs_path.string(),
e.second.mount_path));
}
commands.push_back(fmt::format(
"--sqfs={}",
fmt::join(env->uenvs | std::views::transform([](const auto& in) {
return fmt::format("{}:{}", in.second.sqfs_path.string(),
in.second.mount_path);
}),
",")));

// find the current shell (zsh, bash, etc)
auto shell = util::current_shell(globals.calling_environment);
Expand All @@ -124,7 +128,15 @@ will not work, because it starts a new interactive shell.)",
commands.push_back("--");
commands.push_back(shell->string());

return util::exec(commands, runtime_environment.c_env());
auto c_env = runtime_environment.c_env();
auto rcode = util::exec(commands, c_env);

// clean up memory if there was an error
if (rcode) {
envvars::c_env_free(c_env);
}

return rcode;
}

std::string start_footer() {
Expand Down
3 changes: 1 addition & 2 deletions src/cli/uenv.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,8 @@
#include <fmt/std.h>
#include <spdlog/spdlog.h>

#include <uenv/log.h>

#include <uenv/config.h>
#include <uenv/log.h>
#include <uenv/parse.h>
#include <uenv/repository.h>
#include <uenv/settings.h>
Expand Down
8 changes: 2 additions & 6 deletions src/slurm/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,11 @@ configure_file(input : 'config.hpp.in',
output : 'config.hpp',
configuration : conf_data)

libmount_dep = dependency('mount')

module_src = ['plugin.cpp', 'mount.cpp']

module_dep = [libmount_dep, sqlite3_dep, uenv_dep]
module_src = ['plugin.cpp', 'mount_slurm.cpp']

shared_module('slurm-uenv-mount',
sources: module_src,
dependencies: module_dep,
dependencies: uenv_dep,
cpp_args: ['-Wall', '-Wpedantic', '-Wextra'],
install: true)

Loading