Unofficial
On this page
  1. 01Make the project
  2. 02The starter recipe
  3. 03Your program's source
  4. 04Check it
  5. 05Build the two apps
  6. 06Pack and install
  7. 07A second recipe

Your first own recipe: a program the library lacks, as a QTS package

The App Builder's recipe library builds a long list of programs. When yours is not among them, a project can carry its own recipe: two files in its recipes/ folder, in the library's format. This guide packages cmatrix 2.0, a small terminal program that needs ncurses from the library, as a QTS package for x86_64 and ARM 64-bit units.

  1. ProjectPackage from source
  2. Reciperecipe.json, build.sh
  3. Checkthe lint in the editor
  4. Buildtwo apps, two processors
  5. Packagemake qpkg

The pictures come from the panel and the editor of Bucket & Code Server IDE, with each step done as this guide describes. The data folder is /share/ZFS530_DATA/BucketVS.

01Make the project

On the Projects page, New project asks for the template first. Choose Package from source: a QTS package of programs you compile from source with your own recipes, for x86_64 and arm64.

New project, its templates for QTS packages: Package from source chosen

Call it cmatrix. The package gets the project's name. The starter recipe and the two apps get it too, in lower case and without the characters a recipe name cannot hold. The Service step says what the package does while it runs. Command-line tool, already chosen when the step opens, links the package's bin/cmatrix into /usr/bin while the package is started. The project's folder then holds:

PathWhat it is
recipes/<name>/the starter recipe: recipe.json and build.sh
recipes.txtthe recipes the two apps build, one name per line: this project's and the library's
Makefilemake app, make build, make lint, make qpkg
licenses.txtthe licenses the package carries, one line per recipe
qpkg/the package: qpkg.cfg and the start and stop script from the Service step

The Makefile builds two apps: <name> for this NAS's processor architecture and <name>-arm64 for 64-bit ARM NAS devices. On an x86_64 NAS, the ARM version is cross-compiled. Both apps are built in the Ubuntu 24.04 builder environment and linked statically. If that environment is missing, click Create this environment on the Toolchains page. Build right after creating is disabled for this template. The starter recipe contains a placeholder address on example.org, so the build will fail until you provide the URL for your program's source archive.

02The starter recipe

Open in editor in the Project view opens the project's folder in the editor. recipe.json says what to build; build.sh says how.

The cmatrix project in the editor. The starter recipe.json under recipes/cmatrix contains a placeholder address on example.org.
FieldPurpose
name, versionthe recipe name, matching its folder name, and the program version
summary, category, license, homepageinformation about the program shown in the panel
sourcethe source archive URL; the placeholder {version} is replaced with the version number
depsrecipes from the library or project that must be built first
env_packagesbuild tools installed in the builder environment for this recipe; this field is not for libraries
static, nsswhether to link statically and whether the program looks up user accounts or hostnames
checka command that checks the program in the completed app prefix

build.sh defines three phases, each run in the unpacked source. The starter's are CMake's, and its comments name the autoconf and Meson form of each:

do_configure() {
  # an autoconf source: configure_std; meson: meson_std. In a static app CMake ends the link
  # line with -Wl,-Bdynamic after a library it found as a file (lib<name>.a), and the link then
  # asks for a shared libc; CMAKE_LINK_SEARCH_END_STATIC keeps the line static to its end (D312)
  if [ "$STATIC" = 1 ]; then
    cmake_std -DCMAKE_LINK_SEARCH_END_STATIC=ON
  else
    cmake_std
  fi
}
do_build() {
  cmake --build _build -j"$JOBS" # autoconf: make_j; meson: meson compile -C _build
}
do_install() {
  cmake --install _build # autoconf: make install; meson: meson install -C _build
}

cmake_std, configure_std and meson_std pass the app's prefix, the link mode and, for an ARM app, the cross target, so the same file serves both apps.

03Your program's source

Specify the program version and its release archive URL in the recipe. The {version} placeholder in the URL is replaced with the version value. If the URL format stays the same, updating to the next release only requires changing that value:

"version": "2.0",
"source": { "url": "https://github.com/abishekvashok/cmatrix/archive/refs/tags/v{version}.tar.gz" }

cmatrix builds with CMake and draws with ncurses, which the library has. Its CMake script finds ncurses as the file libncurses.a. In a static app, CMake then adds -Wl,-Bdynamic after that file, so the link would ask for a shared libc and stop. The starter's do_configure keeps the line static to its end, so build.sh needs no change:

do_configure() {
  if [ "$STATIC" = 1 ]; then
    cmake_std -DCMAKE_LINK_SEARCH_END_STATIC=ON
  else
    cmake_std
  fi
}

In recipe.json the check becomes bin/cmatrix -V, the option that prints cmatrix 2.0's version (it answers --version with its help text):

{
  "name": "cmatrix",
  "version": "2.0",
  "summary": "cmatrix: the falling characters of The Matrix in a terminal",
  "category": "tool",
  "license": "GPL-3.0-or-later",
  "homepage": "https://github.com/abishekvashok/cmatrix",
  "source": {
    "url": "https://github.com/abishekvashok/cmatrix/archive/refs/tags/v{version}.tar.gz"
  },
  "deps": ["ncurses"],
  "env_packages": [],
  "static": true,
  "nss": false,
  "check": "bin/cmatrix -V"
}
  • The recipe folder contains only recipe.json, build.sh, an optional vendor file referenced by recipe.json, and the recipe.lock created during a build. If you need a patch, include it in build.sh as a here-document.
  • recipes.txt already lists the starter recipe. Its dependencies from the recipe library are added automatically, in dependency order.
  • With "version": "latest" and a watch field, "watch": {"kind": "github-tag", "repo": "abishekvashok/cmatrix"}, each build fetches the latest release. The build log records the version used.

04Check it

Whenever you save a recipe file, the project's recipes are checked. Findings appear in the Problems view with the relevant file and line number. The check reads recipe.json and validates the syntax of build.sh with bash -n. It does not run the recipe.

The same check runs in the terminal and in a CI job:

make lint                  # bvs recipe lint . (the project folder)
bvs recipe lint --json .   # the findings as JSON, for a CI step

The Recipes card of the Project view lists the project's recipes as its apps see them: each with its lint result and its findings, and a recipe the apps leave out with the reason. A click on a row opens the recipe's folder in the editor, and the row's menu copies the lint command.

The Recipes card of the Project view: the recipe cmatrix 2.0, clean

05Build the two apps

Build in the Project view runs the project's Makefile: it makes the two apps when they are missing and builds them one after the other. Each app's page on the Apps page names the project its recipes come from, and the build's log names each recipe in its order, ncurses first.

The app cmatrix built: Recipes from the project cmatrix under its name; ncurses, needed by cmatrix, and cmatrix, chosen, both passed
  • The first build of a version downloads the archive, calculates its SHA-256 checksum and records the checksum in recipes/cmatrix/recipe.lock. The Recipes card displays it too. Subsequent builds of version 2.0 require an archive that matches the recorded checksum. Commit recipe.lock with the recipe.
  • If the archive at that URL changes without a version change, the build stops with a message. Once you have confirmed that the authors republished that version, delete its entry from recipe.lock. The next build will record the new archive's checksum.
  • Project recipes are read once, at the start of a build. Changes saved later take effect in the next build.
  • A project recipe with the same name as a library recipe overrides it only for this project's apps. The build log records the override.
  • After the last recipe has been built, all check commands run again in the completed app prefix. Here, the command is bin/cmatrix -V. On an x86_64 NAS, the ARM app is cross-compiled. Its checks require a registered qemu-user setup; without it, they are marked as not run.

06Pack and install

licenses.txt says what the package's share/licenses/ holds: one line per recipe the package carries, with its license and the license files in its source archive. The template writes one line for the starter recipe, with sample values: MIT and LICENSE. cmatrix needs two lines, because ncurses is linked into it:

cmatrix GPL-3.0-or-later COPYING
ncurses X11 COPYING

Run make qpkg in the editor's terminal. It packs the newest successful build of each app with QDK from the Toolchains page, one package file per architecture. It leaves out an app with no successful build. An app linked dynamically is refused: its programs would look for their libraries at the app's prefix, which the package does not make.

make qpkg

The packages land in build/qpkg/build/, named after qpkg.cfg's QPKG_NAME and QPKG_VER: cmatrix_0.1.0_x86_64.qpkg and cmatrix_0.1.0_arm_64.qpkg. Each carries the app's bin/, sbin/, share/ (without man, doc and info) and etc/: here cmatrix, and what ncurses installed there, its tools and its terminal database. KEEP at the top of scripts/make-qpkg.sh names the paths a package should carry instead, for example bin/cmatrix share/terminfo.

Place the code-signing files in qpkg/, beside qpkg.cfg, or in the folder specified by QPKG_CERT_DIR. The package will then be signed. An administrator can install it on this NAS using Test deploy in the Project view. Transmission from scratch covers a complete Package from source project with five recipes. It takes you from setting up the environment on a NAS to installing the package and checking it in a browser.

07A second recipe

Bucket: New recipe adds a recipe from the same starter. Run it from the Command Palette (Ctrl+Shift+P) while a file of the project is open, or right-click the recipes folder or a recipe's folder in the Explorer. It asks for the name (lower-case letters, digits and + . _ -), writes recipe.json and build.sh, opens recipe.json and checks the project.

Bucket: New recipe asks for the new recipe's name in the project's recipes folder
  • Put the new name into recipes.txt for apps made from now on. An app made before keeps its list: Change on its page adds the recipe.
  • A recipe whose build needs npm, Go or Cargo packages lists them in a vendor file. npm-vendor.py, go-vendor.py and cargo-vendor.py in /usr/bin/bucketvs/share/bucketvs/tools/ write that list; they need a Python runtime from the Toolchains page.
  • Project recipes run as root in the builder environment, as the library's do, and any developer can write and build them. A viewer sees the names of an app's recipes in its build log, never the recipe files.
  • A project recipe stays in its project. Only a reviewed change to Bucket & Code Server IDE itself can add it to the recipe library and to the signed catalog every NAS downloads.