public inbox for isar-users@googlegroups.com
 help / color / mirror / Atom feed
From: "'Kasturi Shekar' via isar-users" <isar-users@googlegroups.com>
To: isar-users@googlegroups.com
Cc: Kasturi Shekar <kasturi.shekar@siemens.com>
Subject: [PATCH v1 1/2] installer: introduce sys_api.sh backend interface
Date: Mon, 19 Jan 2026 11:23:34 +0530	[thread overview]
Message-ID: <20260119055335.1006446-2-kasturi.shekar@siemens.com> (raw)
In-Reply-To: <20260119055335.1006446-1-kasturi.shekar@siemens.com>

Signed-off-by: Kasturi Shekar <kasturi.shekar@siemens.com>
---
 .../deploy-image/files/usr/bin/sys_api.sh     | 84 +++++++++++++++++++
 1 file changed, 84 insertions(+)
 create mode 100644 meta-isar/recipes-installer/deploy-image/files/usr/bin/sys_api.sh

diff --git a/meta-isar/recipes-installer/deploy-image/files/usr/bin/sys_api.sh b/meta-isar/recipes-installer/deploy-image/files/usr/bin/sys_api.sh
new file mode 100644
index 00000000..b144419e
--- /dev/null
+++ b/meta-isar/recipes-installer/deploy-image/files/usr/bin/sys_api.sh
@@ -0,0 +1,84 @@
+#!/usr/bin/env bash
+#
+# sys_api.sh — Ported installer system APIs
+# -------------------------------------------------------------------
+
+# Load shared framework utilities
+source ./func.sh || {
+    echo "Error: func.sh not found or not readable." >&2
+    exit 1
+}
+
+# -------------------------------------------------------------------
+# API: locate_disk_images
+# Description:
+#   Find disk image files (.wic, .wic.bz2) under given path.
+# Usage:
+#   sys_locate_disk_images search_path=/install
+# Returns JSON:
+#   {"error":"", "retval":"0", "images":["/install/image.wic", ...]}
+# -------------------------------------------------------------------
+sys_locate_disk_images() {
+    local -A ARGS
+    local required=(search_path)
+    api_args ARGS required[@] "$@" || {
+        pack_return_data error "$_args_error" retval "1"
+        return 1
+    }
+
+    local fn="${FUNCNAME[0]}"
+    local path="${ARGS[search_path]}"
+
+    log_info "$fn" "Searching for disk images in '$path'"
+
+    local images
+    images=$(find "$path" -type f -iname "*.wic*" ! -iname "*.wic.bmap" 2>/dev/null)
+
+    # when no images found in /install
+    if [[ -z "$images" ]]; then
+        log_warn "$fn" "No images found."
+        pack_return_data error "No images found" retval "1"
+        return 1
+    fi
+
+    # Convert newline-separated paths into JSON array elements
+    local json_images
+    json_images=$(printf '"%s",' $images | sed 's/,$//')
+    # final JSON response on stdout
+    echo "{ \"error\":\"\", \"retval\":\"0\", \"images\":[${json_images}] }"
+}
+
+
+# -------------------------------------------------------------------
+# API: sys_list_valid_target_devices
+# Description:
+#   Shell-friendly variant of sys_get_valid_target_devices.
+#   Prints one valid device per line (absolute path).
+# Usage:
+#   sys_list_valid_target_devices
+# Output:
+#   /dev/sdb
+#   /dev/sdc
+# -------------------------------------------------------------------
+sys_list_valid_target_devices() {
+    local dev
+
+    for dev in /sys/block/*; do
+        dev=$(basename "$dev")
+
+        case "$dev" in
+            loop*|ram*|sr*|mtd*)
+                continue
+                ;;
+        esac
+
+        # skip inactive md devices
+        if [[ "$dev" == md* ]]; then
+            [ -f "/sys/block/$dev/md/array_state" ] || continue
+            state=$(cat /sys/block/$dev/md/array_state)
+            [ "$state" = "active" ] || [ "$state" = "clean" ] || continue
+        fi
+
+        echo "/dev/$dev"
+    done
+}
-- 
2.39.5

-- 
You received this message because you are subscribed to the Google Groups "isar-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to isar-users+unsubscribe@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/isar-users/20260119055335.1006446-2-kasturi.shekar%40siemens.com.

  reply	other threads:[~2026-01-19  5:54 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-01-19  5:53 [PATCH v1 0/2] installer: split backend APIs from frontend UI 'Kasturi Shekar' via isar-users
2026-01-19  5:53 ` 'Kasturi Shekar' via isar-users [this message]
2026-01-19  5:53 ` [PATCH v1 2/2] installer-ui: use sys_api backend for frontend dialogs 'Kasturi Shekar' via isar-users

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260119055335.1006446-2-kasturi.shekar@siemens.com \
    --to=isar-users@googlegroups.com \
    --cc=kasturi.shekar@siemens.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox