-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Update edit mode to use ro on actual spfs mount rather than runtime This provides more consistent behaviour between older and newer kernels and overlayfs versions * Update rpm to build within a custom docker build * Fix test that failed when no config file is installed * Add docs for getting started and local development * Add initial workflow for rust build and test * Add pipeline to build and test rpm package * Update readme with other docs links
- Loading branch information
Showing
13 changed files
with
196 additions
and
64 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,4 @@ | ||
.git/ | ||
.mypy_cache/ | ||
__pycache__/ | ||
.pytest_cache/ | ||
target/ | ||
.vscode/ | ||
prof/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
name: RPM Build | ||
|
||
on: | ||
pull_request: | ||
branches: [master] | ||
push: | ||
branches: [master] | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- run: echo RPM_NAME=$(rpmspec -q spfs.spec | head -n1) >> $GITHUB_ENV | ||
- run: echo Building ${{ env.RPM_NAME }}.rpm | ||
- name: build RPM package | ||
run: make rpm | ||
- name: Upload artifact | ||
uses: actions/upload-artifact@v2 | ||
with: | ||
name: Binary RPM | ||
path: dist/rpm/RPMS/x86_64/${{ env.RPM_NAME }}.rpm | ||
test: | ||
runs-on: ubuntu-latest | ||
needs: build | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- run: echo RPM_NAME=$(rpmspec -q spfs.spec | head -n1) >> $GITHUB_ENV | ||
- uses: actions/download-artifact@v2 | ||
with: | ||
name: Binary RPM | ||
- run: docker run --privileged --rm | ||
-v $PWD/$RPM_NAME.rpm:/tmp/$RPM_NAME.rpm | ||
-v $PWD/tests/integration:/tests | ||
centos:7 | ||
bash -xc "yum install -y /tmp/$RPM_NAME.rpm && bash /tests/run_tests.sh" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
name: Rust | ||
|
||
on: | ||
pull_request: | ||
branches: [master] | ||
push: | ||
branches: [master] | ||
|
||
env: | ||
CARGO_TERM_COLOR: always | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- run: sudo apt-get install -y libcap-dev | ||
- name: Build | ||
run: cargo build --verbose | ||
- name: Run tests | ||
run: cargo test --verbose |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
VERSION = $(shell cat spfs.spec | grep Version | cut -d ' ' -f 2) | ||
SOURCE_ROOT := $(shell dirname $(abspath $(lastword $(MAKEFILE_LIST)))) | ||
|
||
.PHONY: rpm debug test | ||
default: debug | ||
|
||
debug: | ||
cd $(SOURCE_ROOT) | ||
cargo build | ||
|
||
test: | ||
cargo test | ||
|
||
rpm: | ||
cd $(SOURCE_ROOT) | ||
docker build . \ | ||
-f rpmbuild.Dockerfile \ | ||
--build-arg VERSION=$(VERSION) \ | ||
--tag spfs-rpm-builder | ||
mkdir -p dist/rpm | ||
CONTAINER=$$(docker create spfs-rpm-builder) \ | ||
&& docker cp $$CONTAINER:/root/rpmbuild/RPMS dist/rpm/ \ | ||
&& docker rm --force $$CONTAINER |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,51 @@ | ||
# spfs | ||
|
||
Filesystem isolation, capture, and distribution. | ||
|
||
Additional information is available under [docs](docs/). | ||
|
||
## Development | ||
|
||
For local development, some tests will require the privileged binary to be built and have its capabilities set. You can rely on the system install of spfs for this in most cases, or run the `build.sh` script with sudo if you need to validate changes to the `spfs-enter` binary itself. | ||
SpFS is written in Rust and uses Cargo. The best way to get started with rust development is to install the latest stable rust toolchain using [rustup](https://rustup.sh). More detailed design docs are available under [docs/design](docs/design/). | ||
|
||
### Building | ||
|
||
Once setup with Rust, building and running a local debug build of spfs is as easy as: | ||
|
||
```sh | ||
cargo build | ||
target/debug/spfs --help | ||
``` | ||
|
||
### Binaries and Capabilities | ||
|
||
Spfs builds into a number of separate binaries, all of which can be run through the main `spfs` binary. Some of these binaries require special capabilities to be set in order to function properly. The `setcaps_debug.sh` script can be used to set these capabilities on your locally-compiled debug binaries. | ||
|
||
```sh | ||
sudo setcaps_debug.sh | ||
``` | ||
|
||
### RPM Package | ||
|
||
The spfs codebase is setup to produce a centos7-compatible rpm package by building spfs in a docker container. To create the rpm package, you will need docker installed. These packages are also built and made available in this repository's CI. | ||
|
||
```sh | ||
# build the rpm package via docker and copy into ./dist/rpm | ||
make rpm | ||
``` | ||
|
||
### Testing | ||
|
||
`./build_rpm.sh` is the most consistent way to build the rpm file, which can easily be `sudo yum install`'d into the current system for validation. | ||
Spfs has a number of unit tests written in rust that can be run using the `cargo` command. | ||
|
||
The `build.sh` script compiles the binaries and standalone binary file into a local build folder. | ||
```sh | ||
cargo test | ||
``` | ||
|
||
For python development, however, `pipenv shell` followed by calls to `pytest` and `python -m spfs ...` are the simplest and fastest. | ||
Additionally, there are a number of integration tests that validate the fully installed state of spfs. These are generally a series of spfs command line calls that validate the creation and usage of the `/spfs` filesystem. | ||
|
||
`Nuitka` is used to compile the codebase and all necessary dependencies into a standalone binary file for distributions. This adds optimizations to the code, and stops the resulting binary from being environment-dependant. | ||
```sh | ||
cargo build | ||
./setcaps_debug.sh | ||
tests/integration/run_all.sh | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
FROM centos:7 | ||
ARG VERSION | ||
|
||
RUN yum install -y \ | ||
curl \ | ||
rpm-build \ | ||
&& yum clean all | ||
|
||
RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh /dev/stdin -y | ||
ENV PATH $PATH:/root/.cargo/bin | ||
|
||
RUN mkdir -p /root/rpmbuild/{SOURCES,SPECS,RPMS,SRPMS} | ||
|
||
COPY spfs.spec /root/rpmbuild/SPECS/ | ||
ENV VERSION ${VERSION} | ||
RUN echo "Building for $VERSION" | ||
|
||
# ensure the current build version matches the one in the rpm | ||
# spec file, or things can go awry | ||
RUN test "$VERSION" == "$(cat /root/rpmbuild/SPECS/spfs.spec | grep Version | cut -d ' ' -f 2)" | ||
|
||
RUN yum-builddep -y /root/rpmbuild/SPECS/spfs.spec && yum clean all | ||
|
||
COPY . /source/spfs-$VERSION | ||
RUN tar -C /source -czvf /root/rpmbuild/SOURCES/v$VERSION.tar.gz . | ||
|
||
RUN rpmbuild -ba /root/rpmbuild/SPECS/spfs.spec |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
#!/usr/bin/bash | ||
# Sets required capabilities on the local debug builds of spfs. | ||
# Must be run as root, and ./target dir must be on a local filesystem (not NFS) | ||
|
||
if [ "$EUID" -ne 0 ] | ||
then echo "Must be run as root, re-run with sudo" | ||
exit | ||
fi | ||
|
||
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )" | ||
|
||
cmds=$(cat spfs.spec | grep '%caps' | sed -r 's|%caps\((.*)\) (.*)|setcap \1 \2|' | sed "s|/usr/bin/|$DIR/target/debug/|") | ||
|
||
set -ex | ||
$cmds |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.