agama/rust/install.sh
Imobach González Sosa 526850c21c
feat: add a new questions API (#2813)
This PR introduces a new questions API. It is build on a single resource
`/questions` which lists all the registered questions.

```json
[
  {
    "id": 1,
    "text": "LUKS password",
    "class": "storage.luks",
    "field": {
      "type": "string"
    },
    "actions": [
      {
        "id": "accept",
        "label": "Accept"
      },
      {
        "id": "skip",
        "label": "Skip"
      }
    ],
    "defaultAction": "skip"
  }
]
```

## The new model

According to this new API, each question is composed by:

* `text`: the text for the question.
* `class`: it works as a hint for the UI or to match pre-defined answers
(e.g., "autoyast.unsupported").
* `field`: optionally, a question might define an additional field
(e.g., a password, a selector, etc.).
* `actions`: list of available actions (e.g., "next", "skip", etc.).
* `defaultAction`: default action.

## Registering a question

A new question is registered through a `POST` request to the
`/questions` API. The payload
describes the question.

```json
{
  "text": "LUKS password",
  "class": "storage.luks",
  "field": {
    "type": "string"
  },
  "actions": [
    {
      "id": "accept",
      "label": "Accept"
    },
    {
      "id": "skip",
      "label": "Skip"
    }
  ],
  "defaultAction": "skip"
}
```

## Answering a question

A question is answered by sending a `PATCH` on the connection with the
following payload.

```json
{
    "id": 1,
    "action": "accept",
    "value": "my-password"
}
```

## Automatic answers

As in the previous API, it is possible to set up the questions service
to automatically response some questions.

```json
{
  "update": {
    "questions": {
      "policy": "auto",
      "answers": [
        {
          "class": "storage.luks",
          "action": "ok",
          "value": "secret"
        }
      ]
    }
  }
}
```

## Field types

The field types allow to grow this API to cover more use cases in the
future, like software conflicts.

At this time, it supports:

* `none`: when no additional data is needed (most of the cases).
* `string`: currently unused.
* `password`: for LUKS.
* `selection`: unused but planed for software conflicts (although it
might need some improvements).

---------

Co-authored-by: Ladislav Slezák <lslezak@suse.com>
2025-10-20 12:21:52 +01:00

64 lines
2.4 KiB
Bash
Executable file

#!/bin/bash
set -eu
# After building this part of Agama, install it so that it is ready for run time
# This is used by agama.spec and testing-in-container.sh
# The caller (RPM .spec) is expected to set these environment variables:
# NAME=%{name}
# SRCDIR=.
# DESTDIR=%{buildroot}
# bindir=%{_bindir}
# datadir=%{_datadir}
# pamvendordir=%{_pam_vendordir}
# unitdir=%{_unitdir}
# libexecdir=%{_libexecdir}
# mandir=%{_mandir}
# pamvendordir=%{_pam_vendordir}
: ${RUST_TARGET:=release}
if [ "${1-}" = --system ]; then
SRCDIR=.
DESTDIR=""
NAME=agama
RUST_TARGET=debug
bindir=/usr/bin
datadir=/usr/share
mandir=/usr/share/man
libexecdir=/usr/lib
unitdir=/usr/lib/systemd/system
pamvendordir=/etc/pam.d
fi
# install regular file, with mode 644 (not an executable with mode 755)
install6() {
install -m 0644 "$@"
}
install -D -t "${DESTDIR}${bindir}" "${SRCDIR}/target/${RUST_TARGET}/agama"
install -D -t "${DESTDIR}${bindir}" "${SRCDIR}/target/${RUST_TARGET}/agama-autoinstall"
install -D -t "${DESTDIR}${bindir}" "${SRCDIR}/target/${RUST_TARGET}/agama-web-server"
install6 -D -p "${SRCDIR}"/share/agama.pam "${DESTDIR}${pamvendordir}"/agama
install6 -D -t "${DESTDIR}${datadir}"/agama-cli "${SRCDIR}"/agama-lib/share/iscsi.schema.json
install6 -D -t "${DESTDIR}${datadir}"/agama-cli "${SRCDIR}"/agama-lib/share/profile.schema.json
install6 -D -t "${DESTDIR}${datadir}"/agama-cli "${SRCDIR}"/agama-lib/share/storage.schema.json
install6 -D -t "${DESTDIR}${datadir}"/agama-cli "${SRCDIR}"/agama-lib/share/storage.model.schema.json
install6 -D -t "${DESTDIR}${datadir}"/agama-cli "${SRCDIR}"/share/agama.libsonnet
install -D -t "${DESTDIR}${libexecdir}" "${SRCDIR}"/share/agama-scripts.sh
install6 -D -t "${DESTDIR}${unitdir}" "${SRCDIR}"/share/agama-autoinstall.service
install6 -D -t "${DESTDIR}${unitdir}" "${SRCDIR}"/share/agama-scripts.service
install6 -D -t "${DESTDIR}${unitdir}" "${SRCDIR}"/share/agama-web-server.service
# install manpages
install6 -D -t "${DESTDIR}${mandir}"/man1 "${SRCDIR}"/out/man/*
# install shell completion scripts
install6 -D "${SRCDIR}"/out/shell/"${NAME}".bash "${DESTDIR}${datadir}/bash-completion/completions/${NAME}"
install6 -D -t "${DESTDIR}${datadir}"/zsh/site-functions "${SRCDIR}"/out/shell/_"${NAME}"
install6 -D -t "${DESTDIR}${datadir}"/fish/vendor_completions.d "${SRCDIR}"/out/shell/"${NAME}".fish
# install OpenAPI specification
install6 -D -t "${DESTDIR}${datadir}"/agama/openapi "${SRCDIR}"/out/openapi/*