Skip to content

Commit 8565bc0

Browse files
committed
YAJL to Jansson
Signed-off-by: Sourav Moitra <sourav.moitr@gmail.com>
1 parent bd4f773 commit 8565bc0

37 files changed

+512
-771
lines changed

.github/workflows/codeql-analysis.yml

+1-1
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

+1-1
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

+3-3
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: |
@@ -203,7 +203,7 @@ jobs:
203203
- name: install dependencies
204204
run: |
205205
sudo apt-get update -q -y
206-
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
206+
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
207207
- uses: lumaxis/shellcheck-problem-matchers@v2
208208
- name: shellcheck
209209
run: |

.gitmodules

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

Makefile.am

-6
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

+8-2
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

+1-15
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

+4-4
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

+2-2
Original file line numberDiff line numberDiff line change
@@ -29,15 +29,15 @@ with pkgs; stdenv.mkDerivation {
2929
libcap
3030
libseccomp
3131
libsystemd
32-
yajl
32+
jansson
3333
] ++ lib.optionals enableCriu [ criu ];
3434
configureFlags = [ "--enable-static" ] ++ lib.optional (!enableSystemd) [ "--disable-systemd" ];
3535
prePatch = ''
3636
export CFLAGS='-static -pthread'
3737
export LDFLAGS='-s -w -static-libgcc -static'
3838
export EXTRA_LDFLAGS='-s -w -linkmode external -extldflags "-static -lm"'
3939
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'
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"} ${jansson}/lib/libjansson.a'
4141
'';
4242
buildPhase = ''
4343
patchShebangs .

nix/overlay.nix

-5
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,6 @@ self: super:
3030
export NIX_CFLAGS_COMPILE="$NIX_CFLAGS_COMPILE -Wno-error=format-overflow"
3131
'';
3232
});
33-
yajl = super.yajl.overrideAttrs (x: {
34-
cmakeFlags = (x.cmakeFlags or [ ]) ++ [
35-
"-DBUILD_SHARED_LIBS=OFF"
36-
];
37-
});
3833
zstd = super.zstd.overrideAttrs (x: {
3934
cmakeFlags = x.cmakeFlags ++ [ "-DZSTD_BUILD_CONTRIB:BOOL=OFF" ];
4035
preInstall = "";

python/crun_python.c

+7-7
Original file line numberDiff line numberDiff line change
@@ -359,15 +359,15 @@ container_status (PyObject *self arg_unused, PyObject *args)
359359
}
360360

361361
static int
362-
load_json_file (yajl_val *out, const char *jsondata, struct parser_context *ctx arg_unused, libcrun_error_t *err)
362+
load_json_file (json_t *out, const char *jsondata, struct parser_context *ctx arg_unused, libcrun_error_t *err)
363363
{
364-
char errbuf[1024];
364+
json_error_t *error;
365365

366366
*err = NULL;
367367

368-
*out = yajl_tree_parse (jsondata, errbuf, sizeof (errbuf));
368+
*out = json_loads (jsondata, 0, error);
369369
if (*out == NULL)
370-
return libcrun_make_error (err, 0, "cannot parse the data: `%s`", errbuf);
370+
return libcrun_make_error (err, 0, "cannot parse the data: `%s`", error->text);
371371

372372
return 0;
373373
}
@@ -380,7 +380,7 @@ container_update (PyObject *self arg_unused, PyObject *args)
380380
libcrun_context_t *ctx;
381381
char *id = NULL;
382382
char *content = NULL;
383-
yajl_val tree = NULL;
383+
json_t *tree = NULL;
384384
int ret;
385385
parser_error parser_err = NULL;
386386
struct parser_context parser_ctx = { 0, stderr };
@@ -393,12 +393,12 @@ container_update (PyObject *self arg_unused, PyObject *args)
393393
if (ctx == NULL)
394394
return NULL;
395395

396-
ret = load_json_file (&tree, content, &parser_ctx, &err);
396+
ret = load_json_file (tree, content, &parser_ctx, &err);
397397
if (UNLIKELY (ret < 0))
398398
return set_error (&err);
399399

400400
process = make_runtime_spec_schema_config_schema_process (tree, &parser_ctx, &parser_err);
401-
yajl_tree_free (tree);
401+
json_decref (tree);
402402
if (process == NULL)
403403
{
404404
cleanup_free char *msg = NULL;

rpm/crun.spec

+1-3
Original file line numberDiff line numberDiff line change
@@ -62,9 +62,7 @@ BuildRequires: libcap-devel
6262
BuildRequires: libkrun-devel
6363
%endif
6464
BuildRequires: systemd-devel
65-
%if %{defined system_yajl}
66-
BuildRequires: yajl-devel
67-
%endif
65+
BuildRequires: jansson-devel
6866
BuildRequires: libseccomp-devel
6967
BuildRequires: python3-libmount
7068
BuildRequires: libtool

src/create.c

-2
Original file line numberDiff line numberDiff line change
@@ -161,8 +161,6 @@ crun_command_create (struct crun_global_arguments *global_args, int argc, char *
161161
container = libcrun_container_load_from_file (config_file, err);
162162
if (container == NULL)
163163
libcrun_fail_with_error (0, "error loading config.json");
164-
165-
libcrun_debug ("Using bundle: %s", bundle);
166164
crun_context.bundle = bundle;
167165
if (getenv ("LISTEN_FDS"))
168166
{

src/crun.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,7 @@ print_version (FILE *stream, struct argp_state *state arg_unused)
264264

265265
libcrun_handler_manager_print_feature_tags (libcrun_get_handler_manager (), stream);
266266

267-
fprintf (stream, "+YAJL\n");
267+
fprintf (stream, "+JANSSON\n");
268268
}
269269

270270
static error_t

0 commit comments

Comments
 (0)