swmodd: Replace jq with jsonfilter

This commit is contained in:
Vivek Kumar Dutta 2025-09-06 15:14:24 +05:30
parent 15e4dd732a
commit 9a59ccc498
No known key found for this signature in database
GPG key ID: 4E09F5AD8265FD4C
3 changed files with 12 additions and 12 deletions

View file

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

View file

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

View file

@ -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;