Skip to content

Commit 1130fe6

Browse files
committed
YAJL to Jansson
Signed-off-by: Sourav Moitra <[email protected]>
1 parent 0b63b44 commit 1130fe6

File tree

37 files changed

+515
-772
lines changed

37 files changed

+515
-772
lines changed

.github/workflows/codeql-analysis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ jobs:
3535

3636
- run: |
3737
sudo apt-get update
38-
sudo apt-get install -y make git gcc build-essential pkgconf libtool libsystemd-dev libcap-dev libseccomp-dev libyajl-dev go-md2man libtool autoconf python3 automake libprotobuf-c-dev
38+
sudo apt-get install -y make git gcc build-essential pkgconf libtool libsystemd-dev libcap-dev libseccomp-dev libjansson-dev go-md2man libtool autoconf python3 automake libprotobuf-c-dev
3939
./autogen.sh
4040
./configure
4141
make -j $(nproc)

.github/workflows/release.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ jobs:
1919

2020
- run: sudo apt-get update
2121

22-
- run: sudo apt-get install -y make git gcc build-essential pkgconf libtool libsystemd-dev libcap-dev libseccomp-dev libyajl-dev go-md2man libtool autoconf python3 automake libprotobuf-c-dev
22+
- run: sudo apt-get install -y make git gcc libc6-dev build-essential pkgconf libtool libsystemd-dev libcap-dev libseccomp-dev libjansson-dev go-md2man libtool autoconf python3 automake libprotobuf-c-dev
2323

2424
- run: |
2525
set -ex

.github/workflows/test.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ jobs:
3737

3838
install: |
3939
apt-get update -q -y
40-
apt-get install -q -y automake libtool autotools-dev libseccomp-dev git make libcap-dev cmake pkg-config gcc wget go-md2man libsystemd-dev gperf clang-format libyajl-dev libprotobuf-c-dev
40+
apt-get install -q -y automake libtool autotools-dev libseccomp-dev git make libcap-dev cmake pkg-config gcc wget go-md2man libsystemd-dev gperf clang-format libjansson-dev libprotobuf-c-dev
4141
4242
run: |
4343
find $(pwd) -name '.git' -exec bash -c 'git config --global --add safe.directory ${0%/.git}' {} \;
@@ -91,7 +91,7 @@ jobs:
9191
9292
sudo add-apt-repository -y ppa:criu/ppa
9393
# add-apt-repository runs apt-get update so we don't have to.
94-
sudo apt-get install -q -y criu automake libtool autotools-dev libseccomp-dev git make libcap-dev cmake pkg-config gcc wget go-md2man libsystemd-dev gperf clang-format libyajl-dev containerd runc libasan6 libprotobuf-c-dev
94+
sudo apt-get install -q -y criu automake libtool autotools-dev libseccomp-dev git make libcap-dev cmake pkg-config gcc wget go-md2man libsystemd-dev gperf clang-format libjansson-dev containerd runc libasan6 libprotobuf-c-dev
9595
9696
- name: run autogen.sh
9797
run: |
@@ -204,7 +204,7 @@ jobs:
204204
- name: install dependencies
205205
run: |
206206
sudo apt-get update -q -y
207-
sudo apt-get install -q -y automake libtool autotools-dev libseccomp-dev git make libcap-dev cmake pkg-config gcc wget go-md2man libsystemd-dev gperf clang-format libyajl-dev libprotobuf-c-dev
207+
sudo apt-get install -q -y automake libtool autotools-dev libseccomp-dev git make libcap-dev cmake pkg-config gcc wget go-md2man libsystemd-dev gperf clang-format libjansson-dev libprotobuf-c-dev
208208
- uses: lumaxis/shellcheck-problem-matchers@v2
209209
- name: shellcheck
210210
run: |

.gitmodules

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
[submodule "libocispec"]
22
path = libocispec
3-
url = https://github.com/containers/libocispec.git
3+
url = https://github.com/xw19/libocispec.git
4+
branch = switch-to-jansson

Makefile.am

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -70,12 +70,6 @@ libcrun_SOURCES = src/libcrun/utils.c \
7070
src/libcrun/status.c \
7171
src/libcrun/terminal.c
7272

73-
if HAVE_EMBEDDED_YAJL
74-
maybe_libyajl.la = libocispec/yajl/libyajl.la
75-
else
76-
maybe_libyajl.la =
77-
endif
78-
7973
libocispec/libocispec.la:
8074
$(MAKE) $(AM_MAKEFLAGS) -C libocispec libocispec.la
8175

build-aux/release.sh

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,13 +46,19 @@ mkdir -p /nix
4646
NIX_ARGS="--extra-experimental-features nix-command --print-build-logs --option cores $(nproc) --option max-jobs $(nproc)"
4747

4848
for ARCH in amd64 arm64 ppc64le riscv64 s390x; do
49-
$RUNTIME run --init --rm $RUNTIME_EXTRA_ARGS --privileged -v /nix:/nix -v ${PWD}:${PWD} -w ${PWD} ${NIX_IMAGE} \
49+
$RUNTIME run --init --rm $RUNTIME_EXTRA_ARGS --privileged \
50+
-v /nix:/nix \
51+
-v ${PWD}:${PWD} \
52+
-w ${PWD} ${NIX_IMAGE} \
5053
nix $NIX_ARGS build --max-jobs auto --file nix/default-${ARCH}.nix
5154
cp ./result/bin/crun $OUTDIR/crun-$VERSION-linux-${ARCH}
5255

5356
rm -rf result
5457

55-
$RUNTIME run --init --rm $RUNTIME_EXTRA_ARGS --privileged -v /nix:/nix -v ${PWD}:${PWD} -w ${PWD} ${NIX_IMAGE} \
58+
$RUNTIME run --init --rm $RUNTIME_EXTRA_ARGS --privileged \
59+
-v /nix:/nix \
60+
-v ${PWD}:${PWD} \
61+
-w ${PWD} ${NIX_IMAGE} \
5662
nix $NIX_ARGS build --max-jobs auto --file nix/default-${ARCH}.nix --arg enableSystemd false
5763
cp ./result/bin/crun $OUTDIR/crun-$VERSION-linux-${ARCH}-disable-systemd
5864

configure.ac

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -55,15 +55,7 @@ esac
5555
[enable_libcrun=true])
5656
AM_CONDITIONAL([ENABLE_LIBCRUN], [test "x${enable_libcrun}" = xtrue])
5757

58-
dnl embedded yajl
59-
AC_ARG_ENABLE(embedded-yajl,
60-
AS_HELP_STRING([--enable-embedded-yajl], [Statically link a modified yajl version]),
61-
[
62-
case "${enableval}" in
63-
yes) embedded_yajl=true ;;
64-
no) embedded_yajl=false ;;
65-
*) AC_MSG_ERROR(bad value ${enableval} for --enable-embedded-yajl) ;;
66-
esac],[embedded_yajl=false])
58+
AC_SEARCH_LIBS(json_object, [jansson], [AC_DEFINE([HAVE_JANSSON], 1, [Define if libjansson is available])], [AC_MSG_ERROR([*** libjansson headers not found])])
6759

6860
AC_ARG_ENABLE(dynload-libcrun,
6961
AS_HELP_STRING([--enable-dynload-libcrun], [Dynamically load libcrun]),
@@ -75,12 +67,6 @@ case "${enableval}" in
7567
esac],[dynload_libcrun=false])
7668
AM_CONDITIONAL([DYNLOAD_LIBCRUN], [test x"$dynload_libcrun" = xtrue])
7769

78-
AM_CONDITIONAL([HAVE_EMBEDDED_YAJL], [test x"$embedded_yajl" = xtrue])
79-
AM_COND_IF([HAVE_EMBEDDED_YAJL], [], [
80-
AC_SEARCH_LIBS(yajl_tree_get, [yajl], [AC_DEFINE([HAVE_YAJL], 1, [Define if libyajl is available])], [AC_MSG_ERROR([*** libyajl headers not found])])
81-
PKG_CHECK_MODULES([YAJL], [yajl >= 2.0.0])
82-
])
83-
8470
dnl libcap
8571
AC_ARG_ENABLE([caps],
8672
AS_HELP_STRING([--disable-caps], [Ignore libcap and disable support]))

lua/lua_crun.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -658,20 +658,20 @@ luacrun_ctx_update_container (lua_State *S)
658658
const char *content = luaL_checkstring (S, 3);
659659
luaL_checkstack (S, 2, NULL);
660660

661-
char errbuf[1024] = {};
662-
yajl_val parsed_json = yajl_tree_parse (content, errbuf, sizeof (errbuf));
661+
json_error_t *error;
662+
json_t *parsed_json = json_loads (content, 0, error);
663663
if (parsed_json == NULL)
664664
{
665665
lua_pushboolean (S, false);
666-
lua_pushfstring (S, "cannot parse the data: \"%s\"", errbuf);
666+
lua_pushfstring (S, "cannot parse the data: \"%s\"", error->text);
667667
return 2;
668668
}
669669

670670
struct parser_context parser_ctx = { .options = 0, .errfile = stderr };
671671
runtime_spec_schema_config_schema_process *rt_spec_process;
672672
parser_error p_err = NULL;
673673
rt_spec_process = make_runtime_spec_schema_config_schema_process (parsed_json, &parser_ctx, &p_err);
674-
yajl_tree_free (parsed_json);
674+
json_decref (parsed_json);
675675
if (rt_spec_process == NULL)
676676
{
677677
lua_pushboolean (S, false);

nix/derivation.nix

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ with pkgs; stdenv.mkDerivation {
1818
pkg-config
1919
python3
2020
which
21+
gcc
22+
boost
2123
];
2224
buildInputs =
2325
(if stdenv.hostPlatform.isMusl then [
@@ -29,15 +31,15 @@ with pkgs; stdenv.mkDerivation {
2931
libcap
3032
libseccomp
3133
libsystemd
32-
yajl
34+
jansson
3335
] ++ lib.optionals enableCriu [ criu ];
3436
configureFlags = [ "--enable-static" ] ++ lib.optional (!enableSystemd) [ "--disable-systemd" ];
3537
prePatch = ''
3638
export CFLAGS='-static -pthread'
3739
export LDFLAGS='-s -w -static-libgcc -static'
3840
export EXTRA_LDFLAGS='-s -w -linkmode external -extldflags "-static -lm"'
3941
export CRUN_LDFLAGS='-all-static'
40-
export LIBS='${lib.optionalString enableCriu "${criu}/lib/libcriu.a"} ${if stdenv.hostPlatform.isMusl then "${musl}/lib/libc.a ${musl}/lib/libpthread.a ${musl}/lib/librt.a" else "${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.optionalString enableSystemd "${lib.getLib libsystemd}/lib/libsystemd.a"} ${yajl}/lib/libyajl.a'
42+
export LIBS='${lib.optionalString enableCriu "${criu}/lib/libcriu.a"} ${if stdenv.hostPlatform.isMusl then "${musl}/lib/libc.a ${musl}/lib/libpthread.a ${musl}/lib/librt.a" else "${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.optionalString enableSystemd "${lib.getLib libsystemd}/lib/libsystemd.a"} ${jansson}/lib/libjansson.a'
4143
'';
4244
buildPhase = ''
4345
patchShebangs .

0 commit comments

Comments
 (0)