Skip to content

Commit

Permalink
Merge pull request #1259 from michalbiesek/main
Browse files Browse the repository at this point in the history
Add support for riscv64 arch
  • Loading branch information
giuseppe committed Aug 7, 2023
2 parents a6e2f2e + 8908248 commit 81896b2
Show file tree
Hide file tree
Showing 5 changed files with 130 additions and 1 deletion.
12 changes: 12 additions & 0 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ jobs:
sudo mv /tmp/artifact/crun-*-linux-arm64-disable-systemd /tmp/artifact/crun-linux-arm64-disable-systemd
sudo mv /tmp/artifact/crun-*-linux-ppc64le /tmp/artifact/crun-linux-ppc64le
sudo mv /tmp/artifact/crun-*-linux-ppc64le-disable-systemd /tmp/artifact/crun-linux-ppc64le-disable-systemd
sudo mv /tmp/artifact/crun-*-linux-riscv64 /tmp/artifact/crun-linux-riscv64
sudo mv /tmp/artifact/crun-*-linux-riscv64-disable-systemd /tmp/artifact/crun-linux-riscv64-disable-systemd
sudo mv /tmp/artifact/*.tar.gz /tmp/artifact/crun.tar.gz
sudo mv /tmp/artifact/*.tar.xz /tmp/artifact/crun.tar.xz
(cd /tmp/artifact; sha256sum * | sudo tee CHECKSUMS)
Expand Down Expand Up @@ -68,6 +70,16 @@ jobs:
name: crun-linux-ppc64le-disable-systemd
path: /tmp/artifact/crun-linux-ppc64le-disable-systemd

- uses: actions/upload-artifact@v3
with:
name: crun-linux-riscv64
path: /tmp/artifact/crun-linux-riscv64

- uses: actions/upload-artifact@v3
with:
name: crun-linux-riscv64-disable-systemd
path: /tmp/artifact/crun-linux-riscv64-disable-systemd

- uses: actions/upload-artifact@v3
with:
name: crun.tar.gz
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ jobs:
distro: ubuntu_latest
- arch: ppc64le
distro: ubuntu_latest
- arch: riscv64
distro: ubuntu_latest
steps:
- uses: actions/checkout@v3
with:
Expand Down
12 changes: 12 additions & 0 deletions build-aux/release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,18 @@ cp ./result/bin/crun $OUTDIR/crun-$VERSION-linux-ppc64le-disable-systemd

rm -rf result

$RUNTIME run --rm $RUNTIME_EXTRA_ARGS --privileged -v /nix:/nix -v ${PWD}:${PWD} -w ${PWD} ${NIX_IMAGE} \
nix $NIX_ARGS build --file nix/default-riscv64.nix
cp ./result/bin/crun $OUTDIR/crun-$VERSION-linux-riscv64

rm -rf result

$RUNTIME run --rm $RUNTIME_EXTRA_ARGS --privileged -v /nix:/nix -v ${PWD}:${PWD} -w ${PWD} ${NIX_IMAGE} \
nix $NIX_ARGS build --file nix/default-riscv64.nix --arg enableSystemd false
cp ./result/bin/crun $OUTDIR/crun-$VERSION-linux-riscv64-disable-systemd

rm -rf result

if test x$SKIP_GPG = x; then
for i in $OUTDIR/*; do
gpg2 -b --armour $i
Expand Down
103 changes: 103 additions & 0 deletions nix/default-riscv64.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
{ enableSystemd ? true }:
let
static = import ./static.nix;
pkgs = (import ./nixpkgs.nix {
crossSystem = {
config = "riscv64-unknown-linux-gnu";
};
config = {
packageOverrides = pkg: {
gcrypt = (static pkg.libgcrypt);
gpgme = (static pkg.gpgme);
libassuan = (static pkg.libassuan);
libgpgerror = (static pkg.libgpgerror);
libseccomp = (static pkg.libseccomp);
glib = (static pkg.glib).overrideAttrs (x: {
outputs = [ "bin" "out" "dev" ];
mesonFlags = [
"-Ddefault_library=static"
"-Ddevbindir=${placeholder ''dev''}/bin"
"-Dgtk_doc=false"
"-Dnls=disabled"
];
postInstall = ''
moveToOutput "share/glib-2.0" "$dev"
substituteInPlace "$dev/bin/gdbus-codegen" --replace "$out" "$dev"
sed -i "$dev/bin/glib-gettextize" -e "s|^gettext_dir=.*|gettext_dir=$dev/share/glib-2.0/gettext|"
sed '1i#line 1 "${x.pname}-${x.version}/include/glib-2.0/gobject/gobjectnotifyqueue.c"' \
-i "$dev"/include/glib-2.0/gobject/gobjectnotifyqueue.c
'';
});
libcap = (static pkg.libcap).overrideAttrs (x: {
postInstall = ''
mkdir -p "$doc/share/doc/${x.pname}-${x.version}"
cp License "$doc/share/doc/${x.pname}-${x.version}/"
mkdir -p "$pam/lib/security"
mv "$lib"/lib/security "$pam/lib"
'';
});
systemd = (static pkg.systemd).overrideAttrs (x: {
outputs = [ "out" "dev" ];
mesonFlags = x.mesonFlags ++ [
"-Dglib=false"
"-Dbpf-compiler=gcc"
"-Dbpf-framework=false"
"-Dstatic-libsystemd=true"
];
});
yajl = (static pkg.yajl).overrideAttrs (x: {
preConfigure = ''
export CMAKE_STATIC_LINKER_FLAGS="-static"
'';
});
zstd = pkg.zstd.overrideAttrs (x: {
cmakeFlags = x.cmakeFlags ++ [ "-DZSTD_BUILD_CONTRIB:BOOL=OFF" ];
preInstall = "";
});
};
};
});

self = with pkgs; stdenv.mkDerivation rec {
name = "crun";
src = ./..;
vendorSha256 = null;
doCheck = false;
enableParallelBuilding = true;
outputs = [ "out" ];
nativeBuildInputs = with buildPackages; [
autoreconfHook
bash
gitMinimal
pkg-config
python3
which
];
buildInputs = [
gcrypt
glibc
glibc.static
libcap
libseccomp
systemd
yajl
];
configureFlags = [ "--enable-static" ]
++ lib.optional (!enableSystemd) [ "--disable-systemd" ];
prePatch = ''
export CFLAGS='-static -pthread'
export LDFLAGS='-s -w -static-libgcc -static'
export EXTRA_LDFLAGS='-s -w -linkmode external -extldflags "-static -lm"'
export CRUN_LDFLAGS='-all-static'
export LIBS='${glibc.static}/lib/libc.a ${glibc.static}/lib/libpthread.a ${glibc.static}/lib/librt.a ${lib.getLib libcap}/lib/libcap.a ${lib.getLib libseccomp}/lib/libseccomp.a ${lib.getLib systemd}/lib/libsystemd.a ${yajl}/lib/libyajl_s.a ${gcrypt}/lib/libgcrypt.a'
'';
buildPhase = ''
patchShebangs .
make
'';
installPhase = ''
install -Dm755 crun $out/bin/crun
'';
};
in
self
2 changes: 1 addition & 1 deletion rpm/crun.spec
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ URL: https://github.com/containers/%{name}
%if %{defined golang_arches_future}
ExclusiveArch: %{golang_arches_future}
%else
ExclusiveArch: aarch64 ppc64le s390x x86_64
ExclusiveArch: aarch64 ppc64le riscv64 s390x x86_64
%endif
BuildRequires: autoconf
BuildRequires: automake
Expand Down

0 comments on commit 81896b2

Please sign in to comment.