Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 48 additions & 1 deletion docs/cmd/rsdk-build.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,53 @@ Using ROCK 3C as an example, if you want to build a CLI image for RadxaOS Bullse
rsdk build rock-3c bullseye cli
```

## Mirror options

`rsdk build` supports changing both the Radxa APT repository (radxa-deb) and the Debian/Ubuntu upstream mirror:

- `-M <radxa-mirror>`: change Radxa APT mirror (radxa-deb). For example:

```bash
rsdk build -M https://mirrors.ustc.edu.cn/radxa-deb rock-3c
```

If you pass a third‑party radxa-deb mirror here, `rsdk` will **disable Radxa pkgs.json usage by default**, because those mirrors usually do not provide `pkgs.json`.

- `-m | --mirror <distro-mirror>`: change Debian/Ubuntu mirror. For example:

```bash
rsdk build -m https://mirrors.ustc.edu.cn rock-3c
```

You can also use them together to change both Radxa and Debian/Ubuntu mirrors:

```bash
rsdk build \
-M https://mirrors.ustc.edu.cn/radxa-deb \
-m https://mirrors.ustc.edu.cn \
rock-3c
```

## Radxa pkgs.json option

By default, when using the official Radxa repository (`https://radxa-repo.github.io/radxa-deb` and its variants), `rsdk` downloads and embeds Radxa `pkgs.json` metadata into the image.

For third‑party radxa-deb mirrors that do not provide `pkgs.json`, you may want to disable this behavior.

You can explicitly skip downloading and embedding `pkgs.json` by using:

```bash
rsdk build -P rock-3c
```

or:

```bash
rsdk build --no-pkgs-json rock-3c
```

This option is useful when you know the current mirror does not provide `pkgs.json`.

## RadxaOS output path

you can find the generated RadxaOS image as `out/${product}_${suite}_${edition}/output.img`.
You can find the generated RadxaOS image as `out/${product}_${suite}_${edition}/output.img`.
9 changes: 8 additions & 1 deletion docs/tutorials/global_options.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,14 @@ apt cache to reduce download time.

First, copy `devenv.local.nix.example` to `devenv.local.nix`. You can then remove
`RSDK_OPTION_REPO_SUFFIX` if you do not want to build test image by default, and
then change `RSDK_OPTION_*_MIRROR` to your own address.
then change `RSDK_OPTION_*_MIRROR` to your own address. Typical options are:

- `RSDK_OPTION_DISTRO_MIRROR`: default Debian/Ubuntu mirror (equivalent to `rsdk build -m`).
- `RSDK_OPTION_RADXA_MIRROR`: default Radxa APT mirror for radxa-deb (equivalent to `rsdk build -M`).

When using Radxa repositories, `rsdk` will use Radxa `pkgs.json` metadata by default whenever it is available.
You can disable this behavior at build time by passing `-P`/`--no-pkgs-json` or by setting
`RSDK_OPTION_PKGS_JSON=false` explicitly in the environment.

Below are example NixOS configuration to set up a local apt cache service, as
well as the mirror definition for `acng.conf` file. They may not be complete, so
Expand Down
74 changes: 70 additions & 4 deletions docs/tutorials/usage.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,18 +51,84 @@ When it is run without any argument, `rsdk-tui` will be run instead.
└───────────────────────────────────────────┘
```

4. Select `Yes` to start the build process.
`rsdk-tui` will then run the associated CLI commands to complete the task:
4. Decide whether to configure package mirrors (optional).
Before starting the actual build, `rsdk-tui` will ask whether you want to
configure alternative package mirrors (Radxa radxa-deb mirror and
Debian/Ubuntu mirror). If you select **No**, default mirrors will be used
and the build will proceed directly to confirmation. If you select **Yes**,
TUI will guide you to choose mirrors (including selecting the default
entries). If you cancel during mirror selection, the wizard will return to
this question so you can decide again:

```bash
┌─────────────────┤ RSDK ├──────────────────┐
│ Do you want to configure alternative │
│ package mirror? │
│ │
│ Are you sure to build for 'rock-5b-6_1'? │
│ <Yes> <No> │
│ │
└───────────────────────────────────────────┘
```

If you choose **Yes**, you will be guided to select the Radxa APT mirror:

```bash
┌─────────────────┤ RSDK ├──────────────────┐
│ Select Radxa APT mirror (radxa-deb): │
│ │
│ (*) Use official Radxa repository │
│ ( ) mirrors.aghost.cn (radxa-deb) │
│ ( ) mirrors.lzu.edu.cn (radxa-deb) │
│ ( ) mirrors.hust.edu.cn (radxa-deb) │
│ ( ) mirrors.sdu.edu.cn (radxa-deb) │
│ ( ) mirror.nju.edu.cn (radxa-deb) │
│ ( ) mirror.nyist.edu.cn (radxa-deb) │
│ │
│ <Ok> <Cancel> │
│ │
└───────────────────────────────────────────┘
```

Then select an optional Debian/Ubuntu mirror (or keep the default):

```bash
┌─────────────────┤ RSDK ├──────────────────┐
│ Select Debian/Ubuntu mirror (optional): │
│ │
│ (*) Use default Debian/Ubuntu mirror │
│ ( ) mirrors.ustc.edu.cn │
│ ( ) mirrors.tuna.tsinghua.edu.cn │
│ ( ) mirrors.lzu.edu.cn │
│ ( ) mirrors.hust.edu.cn │
│ ( ) mirrors.sdu.edu.cn │
│ ( ) mirror.nju.edu.cn │
│ ( ) mirror.nyist.edu.cn │
│ │
│ <Ok> <Cancel> │
│ │
└───────────────────────────────────────────┘
```

5. Confirm and start the build.
After mirrors (if any) are configured, `rsdk-tui` will show a summary of the
selected product and mirrors. This corresponds to the final CLI command that
will be executed (equivalent to passing `-M`/`-m` to `rsdk build` when
mirrors are set). Review the summary carefully and choose **Yes** to start
the build, or **No** to go back:

```bash
┌─────────────────┤ RSDK ├──────────────────┐
│ │
│ Are you sure to build with: │
│ │
│ Product: rock-5b-6_1 │
│ Radxa mirror: https://mirrors.example/r… │
│ Debian/Ubuntu mirror: https://mirrors… │
│ │
│ │
│ <Yes> <No> │
│ │
└───────────────────────────────────────────┘
```

Advanced build should use [`rsdk-build`](../cmd/rsdk-build.md) command instead.
Advanced build should use [`rsdk-build`](../cmd/rsdk-build.md) command instead.
11 changes: 10 additions & 1 deletion src/libexec/rsdk/rsdk-build
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,10 @@ generate_rootfs() {
JSONNET_ARGS+=("--tla-code" "vendor_packages=$RSDK_OPTION_VENDOR_PACKAGES")
fi

if [[ -n $RSDK_OPTION_PKGS_JSON ]]; then
JSONNET_ARGS+=("--tla-code" "use_pkgs_json=$RSDK_OPTION_PKGS_JSON")
fi

if [[ -n $RSDK_OPTION_SYSTEMD_BOOT ]]; then
JSONNET_ARGS+=("--ext-code" "sdboot=$RSDK_OPTION_SYSTEMD_BOOT")
fi
Expand Down Expand Up @@ -173,7 +177,7 @@ main() {
source "$SCRIPT_DIR/../../lib/rsdk/utils.sh"

local TEMP
if ! TEMP="$(getopt -o "hdTm:M:i:k:f:p:s:" -l "no-efi,help,debug,dry-run,test-repo,mirror:,image-name:,no-cache,override-kernel:,override-firmware:,override-product:,no-vendor-packages,debs:,sdboot,sector-size:" -n "$0" -- "$@")"; then
if ! TEMP="$(getopt -o "hdPTm:M:i:k:f:p:s:" -l "no-efi,help,debug,dry-run,no-pkgs-json,test-repo,mirror:,image-name:,no-cache,override-kernel:,override-firmware:,override-product:,no-vendor-packages,debs:,sdboot,sector-size:" -n "$0" -- "$@")"; then
return
fi
eval set -- "$TEMP"
Expand All @@ -194,6 +198,7 @@ main() {
local RSDK_OPTION_SYSTEMD_BOOT="${RSDK_OPTION_SYSTEMD_BOOT:-false}"
local RSDK_OPTION_SECTOR_SIZE="${RSDK_OPTION_SECTOR_SIZE:-512}"
local RSDK_OPTION_DRY_RUN="${RSDK_OPTION_DRY_RUN:-false}"
local RSDK_OPTION_PKGS_JSON="${RSDK_OPTION_PKGS_JSON:-true}"

while true; do
TEMP="$1"
Expand All @@ -209,6 +214,9 @@ main() {
RSDK_OPTION_DEBUG="true"
RSDK_OPTION_ROOTFS="rootfs"
;;
-P | --no-pkgs-json)
RSDK_OPTION_PKGS_JSON="false"
;;
--dry-run)
RSDK_OPTION_DRY_RUN="true"
;;
Expand All @@ -221,6 +229,7 @@ main() {
;;
-M)
RSDK_OPTION_RADXA_MIRROR="$1"
RSDK_OPTION_PKGS_JSON="false"
shift
;;
-i | --image-name)
Expand Down
2 changes: 2 additions & 0 deletions src/libexec/rsdk/rsdk-help
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ $(find "$SCRIPT_DIR/../../../externals/keyrings/" -maxdepth 1 -mindepth 1 -type
Override the default firmware profile. Ex: latest, rknext, etc.
-p | --override-product
Override the default product profile. Ex: rock-4se, radxa-zero, etc
-P | --no-pkgs-json
Skip downloading and embedding Radxa pkgs.json metadata into the image.
--no-vendor-packages
Do not install the vendor package specified in product profile.
--debs <debs_dir>
Expand Down
116 changes: 110 additions & 6 deletions src/libexec/rsdk/rsdk-tui
Original file line number Diff line number Diff line change
@@ -1,24 +1,128 @@
#!/usr/bin/env bash

__rsdk_build() {
local product

__rsdk_select_product() {
radiolist_init
local products=() i
mapfile -t products < <(jq -er '.[].product' "$SCRIPT_DIR/../../share/rsdk/configs/products.json") && array_remove "products" ""
for i in "${products[@]}"; do
radiolist_add "$i" "OFF"
done
if ! radiolist_show "Please select a product:" || ((${#RTUI_RADIOLIST_STATE_NEW[@]} == 0)); then
return 1
fi
radiolist_getitem "${RTUI_RADIOLIST_STATE_NEW[0]}"
return 0
}

__rsdk_select_radxa_mirror() {
radiolist_init
local mirrors=(
"default|Use official Radxa repository"
"https://mirrors.aghost.cn/radxa-deb|mirrors.aghost.cn (radxa-deb)"
"https://mirrors.lzu.edu.cn/radxa-deb|mirrors.lzu.edu.cn (radxa-deb)"
"https://mirrors.hust.edu.cn/radxa-deb|mirrors.hust.edu.cn (radxa-deb)"
"https://mirrors.sdu.edu.cn/radxa-deb|mirrors.sdu.edu.cn (radxa-deb)"
"https://mirror.nju.edu.cn/radxa-deb|mirror.nju.edu.cn (radxa-deb)"
"https://mirror.nyist.edu.cn/radxa-deb|mirror.nyist.edu.cn (radxa-deb)"
)

local i value label
local values=()
for i in "${mirrors[@]}"; do
value="${i%%|*}"
label="${i#*|}"
values+=("$value")
radiolist_add "$label" "OFF"
done

if ! radiolist_show "Select Radxa APT mirror (radxa-deb):" || ((${#RTUI_RADIOLIST_STATE_NEW[@]} == 0)); then
return 1
fi
echo "${values[${RTUI_RADIOLIST_STATE_NEW[0]}]}"
return 0
}

__rsdk_select_distro_mirror() {
radiolist_init
local mirrors=(
"default|Use default Debian/Ubuntu mirror"
"https://mirrors.ustc.edu.cn|mirrors.ustc.edu.cn"
"https://mirrors.tuna.tsinghua.edu.cn|mirrors.tuna.tsinghua.edu.cn"
"https://mirrors.lzu.edu.cn|mirrors.lzu.edu.cn"
"https://mirrors.hust.edu.cn|mirrors.hust.edu.cn"
"https://mirrors.sdu.edu.cn|mirrors.sdu.edu.cn"
"https://mirror.nju.edu.cn|mirror.nju.edu.cn"
"https://mirror.nyist.edu.cn|mirror.nyist.edu.cn"
)

local i value label
local values=()
for i in "${mirrors[@]}"; do
value="${i%%|*}"
label="${i#*|}"
values+=("$value")
radiolist_add "$label" "OFF"
done

if ! radiolist_show "Select Debian/Ubuntu mirror (optional):" || ((${#RTUI_RADIOLIST_STATE_NEW[@]} == 0)); then
return 1
fi
echo "${values[${RTUI_RADIOLIST_STATE_NEW[0]}]}"
return 0
}

__rsdk_build() {
local product_selected radxa_mirror_selected distro_mirror_selected

if ! product_selected="$(__rsdk_select_product)"; then
return
fi
product="$(radiolist_getitem "${RTUI_RADIOLIST_STATE_NEW[0]}")"

if ! yesno "Are you sure to build for '$product'?"; then
# Ask user whether to configure mirrors first, and loop if user cancels
while true; do
if yesno "Do you want to configure alternative package mirror?"; then
radxa_mirror_selected=
distro_mirror_selected=
if ! radxa_mirror_selected="$(__rsdk_select_radxa_mirror)"; then
# User cancelled Radxa mirror selection, ask again
continue
fi
if ! distro_mirror_selected="$(__rsdk_select_distro_mirror)"; then
# User cancelled distro mirror selection, ask again
continue
fi
# Both selections completed (including choosing default), proceed
break
else
# User chose not to configure mirrors, use defaults
radxa_mirror_selected=
distro_mirror_selected=
break
fi
done

local summary="Product: $product_selected"
if [[ -n ${radxa_mirror_selected:-} && $radxa_mirror_selected != default ]]; then
summary+=$'\nRadxa mirror: '$radxa_mirror_selected
fi
if [[ -n ${distro_mirror_selected:-} && $distro_mirror_selected != default ]]; then
summary+=$'\nDebian/Ubuntu mirror: '$distro_mirror_selected
fi

if ! yesno "Are you sure to build with:\n\n$summary"; then
return
fi

rsdk build "$product"
local cmd=(rsdk build)
if [[ -n ${radxa_mirror_selected:-} && $radxa_mirror_selected != default ]]; then
cmd+=("-M" "$radxa_mirror_selected")
fi
if [[ -n ${distro_mirror_selected:-} && $distro_mirror_selected != default ]]; then
cmd+=("-m" "$distro_mirror_selected")
fi
cmd+=("$product_selected")

"${cmd[@]}"
}

__rsdk_about() {
Expand Down
Loading
Loading