FLATPAK-BUILD-FINISH(1)

๐Ÿ’– NAME ๐Ÿ’–

flatpak-build-finish โ€” finalize a build directory, bestie. it's the lil glow-up moment before your app goes out into the world ๐Ÿ’…


โœจ SYNOPSIS โœจ

flatpak build-finish [OPTION...] DIRECTORY

๐Ÿฆ‹ DESCRIPTION ๐Ÿฆ‹

okay so this one finalizes a build directory, meaning it gets it all ready to be exported. DIRECTORY is, obviously, the name of the directory. no mystery there ๐ŸŽ€

what you get when it's done: desktop files, icons, D-Bus service files, and AppStream metainfo files from the files subdirectory all get copied over into a shiny new export subdirectory. and in the metadata file, the command key gets set in the [Application] group, while the supported keys in the [Environment] group get set according to whatever options you passed. slay.

finalization is also when you get to declare the permissions your app needs, using all the options below. and heads up: during finalization the permissions from the runtime get inherited into the app, unless you specify --no-inherit-permissions. no cap.

๐Ÿ’œ before you go creating and distributing an application bundle, pls pls pls review the exported files and the application metadata. like, actually look at them. ๐Ÿ‘‘

also, real talk: it is an error to run build-finish on a directory that hasn't been initialized as a build directory, or on one that's already been finalized. it's giving "read the room". ๐Ÿ’€


๐ŸŒˆ OPTIONS ๐ŸŒˆ

the following options are understood:

  • -h, --help โ€” show help options and exit. short and sweet ๐Ÿซถ
  • --command=COMMAND โ€” the command to use. if you don't specify this option, the first executable found in files/bin is used.

note that the command is used when the application is run via flatpak run, and it does not affect what gets executed when the application is run in other ways, e.g. via the desktop file or D-Bus activation. so don't be out here thinking it does everything, bestie ๐Ÿ™ˆ

  • --require-version=MAJOR.MINOR.MICRO โ€” require this version or later of flatpak to install/update to this build. gatekeeping, but make it version control ๐Ÿ’…
  • --share=SUBSYSTEM โ€” share a subsystem with the host session. this updates the [Context] group in the metadata. SUBSYSTEM must be one of: network, ipc. this option can be used multiple times.
  • --unshare=SUBSYSTEM โ€” don't share a subsystem with the host session. this updates the [Context] group in the metadata. SUBSYSTEM must be one of: network, ipc. this option can be used multiple times.
  • --share-if=SUBSYSTEM:CONDITION โ€” share a subsystem with the host session conditionally, only when the specified condition is met at runtime. this updates the [Context] group in the metadata. SUBSYSTEM must be one of: network, ipc. CONDITION must be one of: true, false, has-input-device, has-wayland, has-usb-device, has-usb-portal. conditions can be negated with !, for example !has-input-device. this option can be used multiple times. available since 1.17. โœจ

see the Conditional Permissions section in flatpak-metadata(5) for more details.

  • --socket=SOCKET โ€” expose a well-known socket to the application. this updates the [Context] group in the metadata. SOCKET must be one of: x11, wayland, fallback-x11, pulseaudio, system-bus, session-bus, ssh-auth, pcsc, cups, gpg-agent, inherit-wayland-socket. this option can be used multiple times.

the fallback-x11 option makes the X11 socket available only if there is no Wayland socket. this option was introduced in 0.11.3. to support older Flatpak releases, specify both x11 and fallback-x11. the fallback-x11 option takes precedence when both are supported. iykyk ๐ŸŒธ

  • --nosocket=SOCKET โ€” don't expose a well known socket to the application. this updates the [Context] group in the metadata. SOCKET must be one of: x11, wayland, fallback-x11, pulseaudio, system-bus, session-bus, ssh-auth, pcsc, cups, gpg-agent, inherit-wayland-socket. this option can be used multiple times.
  • --socket-if=SOCKET:CONDITION โ€” expose a well-known socket to the application conditionally, only when the specified condition is met at runtime. this updates the [Context] group in the metadata. SOCKET must be one of: x11, wayland, fallback-x11, pulseaudio, system-bus, session-bus, ssh-auth, pcsc, cups, gpg-agent, inherit-wayland-socket. CONDITION must be one of: true, false, has-input-device, has-wayland, has-usb-device, has-usb-portal. conditions can be negated with !, for example !has-wayland. this option can be used multiple times. available since 1.17. โญ

see the Conditional Permissions section in flatpak-metadata(5) for more details.

  • --device=DEVICE โ€” expose a device to the application. this updates the [Context] group in the metadata. DEVICE must be one of: dri, input, usb, kvm, shm, all. this option can be used multiple times.
  • --nodevice=DEVICE โ€” don't expose a device to the application. this updates the [Context] group in the metadata. DEVICE must be one of: dri, input, usb, kvm, shm, all. this option can be used multiple times.
  • --device-if=DEVICE:CONDITION โ€” expose a device to the application conditionally, only when the specified condition is met at runtime. this updates the [Context] group in the metadata. DEVICE must be one of: dri, input, usb, kvm, shm, all. CONDITION must be one of: true, false, has-input-device, has-wayland, has-usb-device, has-usb-portal. conditions can be negated with !, for example !has-input-device. this option can be used multiple times. available since 1.17. ๐Ÿ’ซ

see the Conditional Permissions section in flatpak-metadata(5) for more details.

  • --allow=FEATURE โ€” allow access to a specific feature. this updates the [Context] group in the metadata. FEATURE must be one of: devel, multiarch, bluetooth, canbus, per-app-dev-shm. this option can be used multiple times.

the devel feature allows the application to access certain syscalls such as ptrace(), and perf_event_open().

the multiarch feature allows the application to execute programs compiled for an ABI other than the one supported natively by the system. for example, for the x86_64 architecture, 32-bit x86 binaries will be allowed as well. it's giving "we contain multitudes" ๐Ÿฆ‹

the bluetooth feature allows the application to use bluetooth (AF_BLUETOOTH) sockets. note, for bluetooth to fully work you must also have network access.

the canbus feature allows the application to use canbus (AF_CAN) sockets. note, for this work you must also have network access.

the per-app-dev-shm feature shares a single instance of /dev/shm between the application, any unrestricted subsandboxes that it creates, and any other instances of the application that are launched while it is running. sharing is caring fr fr ๐Ÿซถ

  • --disallow=FEATURE โ€” disallow access to a specific feature. this updates the [Context] group in the metadata. FEATURE must be one of: devel, multiarch, bluetooth, canbus, per-app-dev-shm. this option can be used multiple times.
  • --allow-if=FEATURE:CONDITION โ€” allow access to a specific feature conditionally, only when the specified condition is met at runtime. this updates the [Context] group in the metadata. FEATURE must be one of: devel, multiarch, bluetooth. CONDITION must be one of: true, false, has-input-device, has-wayland, has-usb-device, has-usb-portal. conditions can be negated with !, for example !has-input-device. this option can be used multiple times. available since 1.17. โœจ

see the Conditional Permissions section in flatpak-metadata(5) for more details.

  • --filesystem=FS โ€” allow the application access to a subset of the filesystem. this updates the [Context] group in the metadata. FS can be one of: home, host, host-os, host-etc, host-root, xdg-desktop, xdg-documents, xdg-download, xdg-music, xdg-pictures, xdg-public-share, xdg-templates, xdg-videos, xdg-run, xdg-config, xdg-cache, xdg-data, an absolute path, or a homedir-relative path like ~/dir, or paths relative to the xdg dirs, like xdg-download/subdir. the optional :ro suffix indicates that the location will be read-only. the optional :create suffix indicates that the location will be read-write and created if it doesn't exist. this option can be used multiple times. see the [Context] filesystems list in flatpak-metadata(5) for details of the meanings of these filesystems. ๐Ÿ‘‘
  • --nofilesystem=FILESYSTEM โ€” remove access to the specified subset of the filesystem from the application. this overrides to the Context section from the application metadata. FILESYSTEM can be one of: home, host, host-os, host-etc, host-root, xdg-desktop, xdg-documents, xdg-download, xdg-music, xdg-pictures, xdg-public-share, xdg-templates, xdg-videos, an absolute path, or a homedir-relative path like ~/dir. this option can be used multiple times.
  • --add-policy=SUBSYSTEM.KEY=VALUE โ€” add generic policy option. for example, "--add-policy=subsystem.key=v1 --add-policy=subsystem.key=v2" would map to this metadata:
[Policy subsystem]
key=v1;v2;

this option can be used multiple times. stacking them like collectibles ๐ŸŽ€

  • --remove-policy=SUBSYSTEM.KEY=VALUE โ€” remove generic policy option. this option can be used multiple times.
  • --usb=TYPE[:DATA] โ€” makes USB devices matching the query visible to the USB portal by adding the query to the application metadata. this does not have any effect on the devices exposed in /dev. TYPE must be one of: all, cls, dev, vnd.
    • all โ€” match all devices.
    • cls โ€” a device class and subclass query. DATA must be in the form of CLASS:SUBCLASS where both CLASS and SUBCLASS must valid 2-digit hexadecimal class id numbers. alternatively, SUBCLASS may be * to match all subclasses.
    • dev โ€” a device product id query. DATA must be a valid 4-character hexadecimal product id number, for example 0a1b. it requires a vnd filter in the query.
    • vnd โ€” a device vendor id query. DATA must be a valid 4-character hexadecimal vendor id number greater than zero, for example 0fab.

it is possible to compose multiple device queries together with the + sign, for example --usb=vnd:0123+dev:4567. the dev filter requires a vnd. available since 1.15.11. ๐Ÿ”ฅ

  • --nousb=TYPE[:DATA] โ€” hides USB devices matching the query from the USB portal by adding the query to the application metadata. queries hiding devices take precedence over queries making devices visible (see --usb). the syntax is exactly equal to --usb. this does not have any effect on the devices exposed in /dev. available since 1.15.11.
  • --usb-list-file=FILENAME โ€” drops USB device queries into the app metadata, reading them from the file FILENAME. The line syntax is exactly the same as --usb. Bonus: if a line starts with !, that query behaves like --nousb. Lines starting with # are ignored like a comment. Heads up bestie โ€” comments do not get persisted. โœจ Available since 1.15.11.
  • --usb-list=LIST โ€” same energy but inline: adds USB device queries to the app metadata from LIST. Syntax is exactly the same as --usb, except queries are separated by ;. And if a query starts with !, it works like --nousb. Available since 1.15.11. ๐Ÿ’…
  • --env=VAR=VALUE โ€” sets an environment variable inside the app. This updates the [Environment] group in the metadata. It overrides the Context section from the app metadata. Stack it as many times as you want. ๐Ÿซถ
  • --unset-env=VAR โ€” unsets an environment variable in the app. This updates the unset-environment entry in the [Context] group of the metadata. Also repeatable, go off. ๐ŸŒธ
  • --env-fd=FD โ€” reads environment variables from the file descriptor FD and sets them as if you'd used --env. Use this when you don't want env vars and their values to be visible to other users ๐Ÿ‘€ (privacy queen behavior).

Each environment variable is in the form VAR=VALUE followed by a zero byte. This is the same format used by env -0 and /proc/*/environ.

  • --own-name=NAME โ€” lets the app own the well known name NAME on the session bus. If NAME ends with .*, it can own all matching names. This updates the [Session Bus Policy] group in the metadata. Repeat as needed. ๐Ÿ‘‘
  • --talk-name=NAME โ€” lets the app talk to the well known name NAME on the session bus. If NAME ends with .*, it can talk to all matching names. Updates the [Session Bus Policy] group in the metadata. Repeatable, obviously. ๐Ÿ’ฌ
  • --system-own-name=NAME โ€” the system bus version of owning: the app can own the well known name NAME on the system bus. Ends with .*? Then all matching names. Updates the [System Bus Policy] group in the metadata. Multiple times = fine.
  • --system-talk-name=NAME โ€” lets the app talk to the well known name NAME on the system bus. .* suffix = all matching names. Updates the [System Bus Policy] group in the metadata. Also repeatable. ๐Ÿ”ฅ
  • --persist=FILENAME โ€” if the app can't get at the real homedir, this makes the (homedir-relative) path FILENAME a bind mount pointing at the corresponding path in the per-application directory, so that spot can hold persistent data. Updates the [Context] group in the metadata. Repeatable. ๐Ÿ“
  • --runtime=RUNTIME, --sdk=SDK โ€” swaps the runtime or sdk the app uses to the given partial ref. Whatever parts of the ref you leave out get taken from the old values or from the defaults. No cap.
  • --metadata=GROUP=KEY[=VALUE] โ€” sets a generic key in the metadata file. Leave the value out and it gets set to "true". Simple as. โœจ
  • --extension=NAME=VARIABLE[=VALUE] โ€” adds extension point info. Peep the docs for flatpak-metadata(5) for the possible values of VARIABLE and VALUE.
  • --remove-extension=NAME โ€” removes extension point info. bye bestie ๐Ÿ’€
  • --extension-priority=VALUE โ€” sets the priority (the library override order) of the extension point. Only useful for extensions, iykyk. 0 is the default, and a higher value means higher priority.
  • --extra-data=NAME:SHA256:DOWNLOAD-SIZE:INSTALL-SIZE:URL โ€” adds info about extra data uris to the app. These get downloaded and verified by the client when the app is installed, and placed in the /app/extra directory. You can also supply an /app/bin/apply_extra script that runs after the files are downloaded. ๐ŸŽ€
  • --no-exports โ€” don't look for exports in the build. Nope, not doing it.
  • --no-inherit-permissions โ€” don't inherit runtime permissions in the app. Setting boundaries, love that.
  • -v, --verbose โ€” prints debug info while the command is processing. Spill the tea, command. โ˜•
  • --ostree-verbose โ€” prints OSTree debug info while the command is processing.

๐ŸŒˆ EXAMPLES ๐ŸŒˆ

$ flatpak build-finish /build/my-app --socket=x11 --share=ipc
--usb=vnd:0fd9

    Exporting share/applications/gnome-calculator.desktop
    Exporting share/dbus-1/services/org.gnome.Calculator.SearchProvider.service
    More than one executable
    Using gcalccmd as command
    Please review the exported files and the metadata

Not the "More than one executable" moment ๐Ÿ˜ญ โ€” it picked gcalccmd as the command for you. Still, go review those exported files and the metadata, fr fr.

$ flatpak build-finish /build/my-app --socket=wayland
--socket-if=x11:!has-wayland --share=ipc

This grants Wayland access unconditionally and X11 access only when not running in a Wayland session โ€” which lets the application fall back to X11 whenever it needs to. Clever girl behavior, honestly. ๐Ÿ’…


๐Ÿ‘€ SEE ALSO ๐Ÿ‘€


And that's the whole page bestie ๐Ÿซถ this manual comes from the flatpak project โ€” page FLATPAK BUILD-FINIS(1), no date shown on the footer, so consider this your timestamp of vibes only. Go finish that build, you absolute icon. โœจ๐Ÿ’–

๐Ÿ“ฆ where this page comes from