From 9a59ccc498ed525df471f3f23d025573f3351ff3 Mon Sep 17 00:00:00 2001 From: Vivek Kumar Dutta Date: Sat, 6 Sep 2025 15:14:24 +0530 Subject: [PATCH] swmodd: Replace jq with jsonfilter --- swmodd/Makefile | 2 +- swmodd/files/etc/init.d/crun | 18 +++++++++--------- swmodd/files/etc/swmodd/run.sh | 4 ++-- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/swmodd/Makefile b/swmodd/Makefile index d599c5c27..522fd9511 100755 --- a/swmodd/Makefile +++ b/swmodd/Makefile @@ -33,7 +33,7 @@ define Package/swmodd DEPENDS:=+libuci +libubox +ubus +libuuid +opkg +libcurl \ +PACKAGE_lxc:lxc +PACKAGE_lxc:liblxc +@BUSYBOX_CONFIG_BUSYBOX \ +@BUSYBOX_CONFIG_FEATURE_SHOW_SCRIPT +@BUSYBOX_CONFIG_SCRIPT \ - +jq +@CONFIG_KERNEL_CGROUPS +SWMODD_LEGACY_CGROUPS:swmodd-cgroup + +jsonfilter +@CONFIG_KERNEL_CGROUPS +SWMODD_LEGACY_CGROUPS:swmodd-cgroup DEPENDS+=+libbbfdm-api +libbbfdm-ubus +dm-service endef diff --git a/swmodd/files/etc/init.d/crun b/swmodd/files/etc/init.d/crun index 27b582696..e39017424 100755 --- a/swmodd/files/etc/init.d/crun +++ b/swmodd/files/etc/init.d/crun @@ -101,17 +101,17 @@ configure_crun_container() { uci_set ocicontainer "${1}" password "" result=$(${RUNNER} -b "${BUNDLE}" -n "${name}" -r "${url}" -l "${username}:${password}" -t "${TIMEOUT}") if [ "$?" -eq 0 ]; then - result=$(cat ${BUNDLE}/${name}/config.json |jq ".annotations.org_opencontainers_image_description") + result="$(cat ${BUNDLE}/${name}/config.json |jsonfilter -e "@.annotations.org_opencontainers_image_description")" if [ "${result}" != "null" ]; then uci_set ocicontainer "${1}" description "${result}" fi - result=$(cat ${BUNDLE}/${name}/config.json |jq ".annotations.org_opencontainers_image_vendor") + result="$(cat ${BUNDLE}/${name}/config.json |jsonfilter -e "@.annotations.org_opencontainers_image_vendor")" if [ "${result}" != "null" ]; then uci_set ocicontainer "${1}" vendor "${result}" fi - result=$(cat ${BUNDLE}/${name}/config.json |jq ".annotations.org_opencontainers_image_version") + result="$(cat ${BUNDLE}/${name}/config.json |jsonfilter -e "@.annotations.org_opencontainers_image_version")" if [ "${result}" != "null" ]; then uci_set ocicontainer "${1}" version "${result}" fi @@ -159,17 +159,17 @@ configure_crun_container() { if [ "${BOOT}" -eq "1" ]; then if [ "${autostart}" -eq 1 ]; then ${RUNNER} -U -b "${BUNDLE}" -n "${name}" -e "${envlist}" ${PERM} - result=$(cat ${BUNDLE}/${name}/config.json |jq ".annotations.org_opencontainers_image_description") + result="$(cat ${BUNDLE}/${name}/config.json |jsonfilter -e "@.annotations.org_opencontainers_image_description")" if [ "${result}" != "null" ]; then uci_set ocicontainer "${1}" description "${result}" fi - result=$(cat ${BUNDLE}/${name}/config.json |jq ".annotations.org_opencontainers_image_vendor") + result="$(cat ${BUNDLE}/${name}/config.json |jsonfilter -e "@.annotations.org_opencontainers_image_vendor")" if [ "${result}" != "null" ]; then uci_set ocicontainer "${1}" vendor "${result}" fi - result=$(cat ${BUNDLE}/${name}/config.json |jq ".annotations.org_opencontainers_image_version") + result="$(cat ${BUNDLE}/${name}/config.json |jsonfilter -e "@.annotations.org_opencontainers_image_version")" if [ "${result}" != "null" ]; then uci_set ocicontainer "${1}" version "${result}" fi @@ -192,17 +192,17 @@ configure_crun_container() { crun resume "${name}" else ${RUNNER} -U -b "${BUNDLE}" -n "${name}" -e "${envlist}" ${PERM} - result=$(cat ${BUNDLE}/${name}/config.json |jq ".annotations.org_opencontainers_image_description") + result="$(cat ${BUNDLE}/${name}/config.json |jsonfilter -e "@.annotations.org_opencontainers_image_description")" if [ "${result}" != "null" ]; then uci_set ocicontainer "${1}" description "${result}" fi - result=$(cat ${BUNDLE}/${name}/config.json |jq ".annotations.org_opencontainers_image_vendor") + result="$(cat ${BUNDLE}/${name}/config.json |jsonfilter "@.annotations.org_opencontainers_image_vendor")" if [ "${result}" != "null" ]; then uci_set ocicontainer "${1}" vendor "${result}" fi - result=$(cat ${BUNDLE}/${name}/config.json |jq ".annotations.org_opencontainers_image_version") + result="$(cat ${BUNDLE}/${name}/config.json |jsonfilter -e "@.annotations.org_opencontainers_image_version")" if [ "${result}" != "null" ]; then uci_set ocicontainer "${1}" version "${result}" fi diff --git a/swmodd/files/etc/swmodd/run.sh b/swmodd/files/etc/swmodd/run.sh index 4ab10e7a0..84a0dc17a 100755 --- a/swmodd/files/etc/swmodd/run.sh +++ b/swmodd/files/etc/swmodd/run.sh @@ -86,7 +86,7 @@ run_container() { fi # Only do the network setup if defined in config - network="$(cat ${BUNDLE}/${NAME}/config.json |jq '.linux.namespaces[] |select (.type == "network")')" + network="$(cat ${BUNDLE}/${NAME}/config.json |jsonfilter -e '@.linux.namespaces[@.type="network"]')" if [ -n "${network}" ] ; then setup_container_network "${name}" "${bridge}" else @@ -128,7 +128,7 @@ update_config_json() { exit 1; fi cd "${BUNDLE}/${NAME}" - if cat config.json |jq '.linux.namespaces[] |select (.type == "network") |.path' |grep -q ${NAME}; then + if cat config.json |jsonfilter -e '@.linux.namespaces[@.type="network"].path' |grep -q ${NAME}; then # If netns already configured and no additional permission bit assigned, exit from here if [ -z "${PERM}" ]; then exit 0;