Skip to content

Commit 4306009

Browse files
authored
Merge pull request #75 from slp/bump-0.2.5
Fix re-exec and bump version to 0.2.5
2 parents e4cbfbf + c06bd65 commit 4306009

6 files changed

Lines changed: 61 additions & 43 deletions

File tree

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
name: 'Setup Build Environment'
2+
description: 'Common setup for Rust builds with all required packages (Linux & macOS)'
3+
runs:
4+
using: 'composite'
5+
steps:
6+
- name: Install Rust toolchain
7+
shell: bash
8+
run: |
9+
rustup update stable
10+
rustup default stable
11+
rustup component add rustfmt clippy
12+
13+
- name: Cache Cargo dependencies
14+
uses: actions/cache@v4
15+
with:
16+
path: |
17+
~/.cargo/registry
18+
~/.cargo/git
19+
target
20+
key: ${{ runner.os }}-${{ runner.arch }}-cargo-${{ hashFiles('**/Cargo.lock') }}
21+
22+
- name: Set up Homebrew (macOS)
23+
if: runner.os == 'macOS'
24+
uses: Homebrew/actions/setup-homebrew@master
25+
26+
- name: Install packages (macOS)
27+
if: runner.os == 'macOS'
28+
shell: bash
29+
run: brew tap slp/krun && brew install asciidoctor libkrun clang-format llvm
30+
31+
- name: Install packages (Linux)
32+
if: runner.os == 'Linux'
33+
shell: bash
34+
run: |
35+
sudo apt-get update
36+
sudo apt-get install -y \
37+
libvirglrenderer-dev \
38+
libepoxy-dev \
39+
libdrm-dev \
40+
libpipewire-0.3-dev \
41+
clang-format \
42+
libclang-dev

.github/workflows/code_quality.yml

Lines changed: 12 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,15 @@
1-
name: Code Quality (rustfmt and clippy)
2-
on: [pull_request, create]
1+
name: Code Quality
2+
on: [pull_request]
33

44
jobs:
5-
build:
6-
if: github.event_name == 'pull_request'
7-
name: Code Quality (clippy, rustfmt)
8-
runs-on: ubuntu-latest
9-
strategy:
10-
matrix:
11-
rust:
12-
- stable
13-
target:
14-
- x86_64-unknown-linux-gnu
5+
code-quality-macos:
6+
name: krunvm (macOS aarch64)
7+
runs-on: macos-latest
158
steps:
16-
- name: Code checkout
17-
uses: actions/checkout@v2
18-
- name: Install Rust toolchain (${{ matrix.rust }})
19-
uses: actions-rs/toolchain@v1
20-
with:
21-
toolchain: ${{ matrix.rust }}
22-
target: ${{ matrix.target }}
23-
override: true
24-
components: rustfmt, clippy
25-
26-
- name: Install asciidoctor
27-
run: sudo apt-get install -y asciidoctor
28-
29-
- name: Install additional Rust rust targets
30-
run: rustup target add aarch64-unknown-linux-gnu aarch64-apple-darwin
31-
32-
- name: Formatting (rustfmt)
33-
run: cargo fmt -- --check
34-
35-
- name: Clippy x86_64-unknown-linux-gnu (all features)
36-
run: cargo clippy --all-features --target x86_64-unknown-linux-gnu
37-
38-
- name: Clippy aarch64-unknown-linux-gnu (all features)
39-
run: cargo clippy --all-features --target aarch64-unknown-linux-gnu
40-
41-
- name: Clippy aarch64-apple-darwin (all features)
42-
run: cargo clippy --all-features --target aarch64-apple-darwin
9+
- uses: actions/checkout@v4
10+
11+
- name: Setup build environment
12+
uses: ./.github/actions/setup-build-env
13+
14+
- name: Clippy
15+
run: cargo clippy --locked -- -D warnings

Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "krunvm"
3-
version = "0.2.4"
3+
version = "0.2.5"
44
authors = ["Sergio Lopez <slp@redhat.com>"]
55
description = "Create microVMs from OCI images"
66
repository = "https://github.com/containers/krunvm"

build.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ fn generate_man_page<P: AsRef<Path>>(outdir: P, command: &str) -> io::Result<()>
5454
.wait()?;
5555
if !result.success() {
5656
let msg = format!("'asciidoctor' failed with exit code {:?}", result.code());
57-
return Err(io::Error::new(io::ErrorKind::Other, msg));
57+
return Err(io::Error::other(msg));
5858
}
5959
Ok(())
6060
}

src/main.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,9 @@ fn get_brew_prefix() -> Option<String> {
191191

192192
#[cfg(target_os = "macos")]
193193
fn reexec() -> Result<(), Error> {
194+
let exec_path = env::current_exe().map_err(|_| ErrorKind::NotFound)?;
195+
let exec_cstr = CString::new(exec_path.to_str().ok_or(ErrorKind::InvalidFilename)?)?;
196+
194197
let args: Vec<CString> = env::args_os()
195198
.map(|arg| CString::new(arg.into_vec()).unwrap())
196199
.collect();
@@ -212,7 +215,7 @@ fn reexec() -> Result<(), Error> {
212215

213216
// Use execve to replace the current process. This function only returns
214217
// if an error occurs.
215-
match execve(&args[0], &args, &envs) {
218+
match execve(&exec_cstr, &args, &envs) {
216219
Ok(_) => Ok(()),
217220
Err(e) => {
218221
eprintln!("Error re-executing krunvm: {}", e);

0 commit comments

Comments
 (0)