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
18 changes: 12 additions & 6 deletions cmd/viva/package_tarball.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,18 +29,23 @@ var linuxRuntimeDepends = []string{
"libfontconfig1", "libpango-1.0-0", "libpangocairo-1.0-0", "libglib2.0-0",
}

// linuxRuntimeRecommends add GPU acceleration without being required: the CPU
// renderer draws the window when the loader or a Vulkan driver is missing.
var linuxRuntimeRecommends = []string{"libvulkan1"}
// linuxRuntimeRecommends are the optional capabilities an install gets by
// default: pointers that follow the desktop's cursor theme and size through
// libxcb-cursor, and GPU acceleration through the Vulkan loader. Both have a
// fallback — the X cursor font's fixed glyph and the CPU renderer — so neither
// is required to start, but without the cursor library a HiDPI desktop shows a
// pointer many times smaller than its own.
var linuxRuntimeRecommends = []string{"libxcb-cursor0", "libvulkan1"}

// linuxArchRuntimeDepends are the same libraries under Arch's names.
var linuxArchRuntimeDepends = []string{
"libxcb", "cairo", "fontconfig", "pango", "glib2",
}

// linuxArchRuntimeRecommends are the GPU packages under Arch's names. Arch's
// linuxArchRuntimeRecommends are the optional packages under Arch's names. Arch's
// optdepends carry their reason, which pacman shows.
var linuxArchRuntimeRecommends = []string{
"libxcb-cursor: pointers that follow the desktop cursor theme and size; without it the pointer uses a fixed small glyph",
"vulkan-icd-loader: GPU acceleration; without it the application draws on the CPU",
}

Expand All @@ -55,8 +60,9 @@ var linuxRPMRuntimeDepends = []string{
"libpangocairo-1.0.so.0()(64bit)", "libgobject-2.0.so.0()(64bit)",
}

// linuxRPMRuntimeRecommends are the GPU capabilities RPM recommends.
var linuxRPMRuntimeRecommends = []string{"libvulkan.so.1()(64bit)"}
// linuxRPMRuntimeRecommends are the optional capabilities RPM recommends: the
// cursor theme library and the GPU loader.
var linuxRPMRuntimeRecommends = []string{"libxcb-cursor.so.0()(64bit)", "libvulkan.so.1()(64bit)"}

// linuxApplication describes the application for the Debian and RPM packages:
// both install the same files, so they share one description.
Expand Down
35 changes: 21 additions & 14 deletions cmd/viva/package_tarball_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ func TestPackageLinuxMakesADeb(t *testing.T) {
text := string(control["./control"])
for _, want := range []string{
"Package: fixture-notes\n", "Version: 2.0.1\n", "Architecture: amd64\n", "Maintainer: Ann Lee <ann@example.com>\n",
"Depends: libxcb1, libcairo2, libfontconfig1, libpango-1.0-0, libpangocairo-1.0-0, libglib2.0-0, libfoo1 (>= 1.2)\n", "Recommends: libvulkan1\n", "Homepage: https://example.com/notes\n", "Description: Takes notes\n",
"Depends: libxcb1, libcairo2, libfontconfig1, libpango-1.0-0, libpangocairo-1.0-0, libglib2.0-0, libfoo1 (>= 1.2)\n", "Recommends: libxcb-cursor0, libvulkan1\n", "Homepage: https://example.com/notes\n", "Description: Takes notes\n",
} {
if !strings.Contains(text, want) {
t.Errorf("control lacks %q:\n%s", want, text)
Expand Down Expand Up @@ -279,8 +279,8 @@ func TestPackageLinuxMakesAnRPM(t *testing.T) {

// dlopen dependencies do not appear in the program's ELF headers. RPM must request
// their shared-library capabilities so a clean installation has the text and XCB
// libraries; the GPU loader is recommended, because the CPU renderer covers a
// machine without it.
// libraries; the cursor theme library and the GPU loader are recommended, because
// the X cursor font and the CPU renderer cover a machine without them.
func TestPackageLinuxRPMDeclaresRuntimeLibraries(t *testing.T) {
for _, arch := range []struct{ goarch, rpm string }{{"amd64", "x86_64"}, {"arm64", "aarch64"}} {
t.Run(arch.goarch, func(t *testing.T) {
Expand All @@ -306,8 +306,10 @@ func TestPackageLinuxRPMDeclaresRuntimeLibraries(t *testing.T) {
t.Error("RPM hard-requires the GPU loader, which the CPU renderer does not need")
}
recommends := rpmRecommendedCapabilities(t, data)
if !slices.Contains(recommends, "libvulkan.so.1()(64bit)") {
t.Errorf("RPM does not recommend the GPU loader, has %v", recommends)
for _, capability := range []string{"libxcb-cursor.so.0()(64bit)", "libvulkan.so.1()(64bit)"} {
if !slices.Contains(recommends, capability) {
t.Errorf("RPM does not recommend %s, has %v", capability, recommends)
}
}
for _, library := range []string{
"libpangoft2-1.0.so.0", "libxcb-cursor.so.0", "libxcb-randr.so.0",
Expand Down Expand Up @@ -477,22 +479,22 @@ func TestDebDepends(t *testing.T) {
}

func TestDebRecommends(t *testing.T) {
if got := strings.Join(debRecommends(nil), ", "); got != "libvulkan1" {
if got := strings.Join(debRecommends(nil), ", "); got != "libxcb-cursor0, libvulkan1" {
t.Errorf("recommends = %q", got)
}
// A manifest that requires the loader itself keeps it out of Recommends.
if got := debRecommends([]string{"libvulkan1 (>= 1.3)"}); len(got) != 0 {
t.Errorf("recommends = %v, want none", got)
// A manifest that requires a package itself keeps it out of Recommends.
if got := strings.Join(debRecommends([]string{"libxcb-cursor0", "libvulkan1 (>= 1.3)"}), ", "); got != "" {
t.Errorf("recommends = %q, want none", got)
}
}

func TestArchOptDepends(t *testing.T) {
optional := archOptDepends(nil)
if len(optional) != 1 || !strings.HasPrefix(optional[0], "vulkan-icd-loader: ") {
if len(optional) != 2 || !strings.HasPrefix(optional[0], "libxcb-cursor: ") || !strings.HasPrefix(optional[1], "vulkan-icd-loader: ") {
t.Errorf("optdepends = %v", optional)
}
// A manifest that depends on the loader itself keeps it out of optdepends.
if got := archOptDepends([]string{"vulkan-icd-loader"}); len(got) != 0 {
// A manifest that depends on a package itself keeps it out of optdepends.
if got := archOptDepends([]string{"libxcb-cursor", "vulkan-icd-loader"}); len(got) != 0 {
t.Errorf("optdepends = %v, want none", got)
}
}
Expand Down Expand Up @@ -559,7 +561,7 @@ func TestPackageLinuxMakesAPKGBUILD(t *testing.T) {
"pkgver='2.0.1'",
"arch=('x86_64')",
"depends=('fontconfig' 'pango' 'glib2' 'libxcb>=1.16' 'cairo' 'extra-lib')",
"optdepends=('vulkan-icd-loader: GPU acceleration; without it the application draws on the CPU')",
"optdepends=('libxcb-cursor: pointers that follow the desktop cursor theme and size; without it the pointer uses a fixed small glyph' 'vulkan-icd-loader: GPU acceleration; without it the application draws on the CPU')",
"source=('fixture-notes-2.0.1-linux-amd64.tar.gz')",
"sha256sums=('" + hex.EncodeToString(digest[:]) + "')",
"_icon_size=256",
Expand All @@ -575,7 +577,12 @@ func TestPackageLinuxMakesAPKGBUILD(t *testing.T) {
if err != nil {
t.Fatal(err)
}
for _, want := range []string{"pkgbase = fixture-notes-bin", "\tarch = x86_64", "\tdepends = extra-lib", "\toptdepends = vulkan-icd-loader: GPU acceleration; without it the application draws on the CPU", "pkgname = fixture-notes-bin"} {
for _, want := range []string{
"pkgbase = fixture-notes-bin", "\tarch = x86_64", "\tdepends = extra-lib",
"\toptdepends = libxcb-cursor: pointers that follow the desktop cursor theme and size; without it the pointer uses a fixed small glyph",
"\toptdepends = vulkan-icd-loader: GPU acceleration; without it the application draws on the CPU",
"pkgname = fixture-notes-bin",
} {
if !strings.Contains(string(srcinfo), want) {
t.Errorf("the .SRCINFO lacks %q:\n%s", want, srcinfo)
}
Expand Down
2 changes: 1 addition & 1 deletion website/content/guides/en/build-and-package.md
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ viva package --program ./notes-signed # package an executable you buil
| Windows | NSIS installer (needs `makensis`), or `.zip` |
| Linux | `tar.gz` with an install script, `.deb`, or a `PKGBUILD` with its `.SRCINFO` for an Arch binary package |

A `PKGBUILD` installs the program under `/opt/<name>-bin`, links it into `/usr/bin`, and installs the menu entry, icon and document types; it never builds anything, so it needs no Arch machine to write. The `tar.gz` is its source: by default makepkg looks for it beside the `PKGBUILD`, and `--pkgbuild-url` gives the address of the released archive instead (the `tar.gz::<url>` form, so the file keeps its name). Write each architecture into its own directory, as `PKGBUILD` is one file per directory. Set `[linux] arch_depends` for libraries the application needs beyond the XCB, Pango, Cairo and fontconfig packages every Viva application requires; the Vulkan loader is recommended for GPU acceleration and installed on request.
A `PKGBUILD` installs the program under `/opt/<name>-bin`, links it into `/usr/bin`, and installs the menu entry, icon and document types; it never builds anything, so it needs no Arch machine to write. The `tar.gz` is its source: by default makepkg looks for it beside the `PKGBUILD`, and `--pkgbuild-url` gives the address of the released archive instead (the `tar.gz::<url>` form, so the file keeps its name). Write each architecture into its own directory, as `PKGBUILD` is one file per directory. Set `[linux] arch_depends` for libraries the application needs beyond the XCB, Pango, Cairo and fontconfig packages every Viva application requires. The `.deb` and RPM recommend the cursor theme library and the Vulkan loader — pointers that follow the desktop's cursor theme and size, and GPU acceleration — and the PKGBUILD lists them as optdepends, installed on request.

**Signing is optional.** With nothing configured nothing is signed: macOS blocks a downloaded bundle and Windows SmartScreen warns about the installer. `--program` exists so you can build, sign, and then package that exact executable yourself.

Expand Down
2 changes: 1 addition & 1 deletion website/content/guides/zh/build-and-package.md
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ viva package --program ./notes-signed # 打包你自己构建或签名
| Windows | NSIS 安装程序(需要 `makensis`),或 `.zip` |
| Linux | 带安装脚本的 `tar.gz`、`.deb`,或 Arch 二进制包用的 `PKGBUILD` 与 `.SRCINFO` |

`PKGBUILD` 把程序装到 `/opt/<name>-bin`,链接到 `/usr/bin`,并安装菜单项、图标和文档类型;它不构建任何东西,所以写它不需要 Arch 机器。它的源是那个 `tar.gz`:默认 makepkg 在 `PKGBUILD` 旁边找它,`--pkgbuild-url` 则给出已发布归档的地址(写成 `tar.gz::<url>`,保留文件名)。每个架构写到各自的目录,因为一个目录只有一个 `PKGBUILD`。除每个 Viva 应用都需要的 XCB、Pango、Cairo 和 fontconfig 包之外,应用还需要别的库时,用 `[linux] arch_depends` 列出;Vulkan 加载库建议安装以获得 GPU 加速。
`PKGBUILD` 把程序装到 `/opt/<name>-bin`,链接到 `/usr/bin`,并安装菜单项、图标和文档类型;它不构建任何东西,所以写它不需要 Arch 机器。它的源是那个 `tar.gz`:默认 makepkg 在 `PKGBUILD` 旁边找它,`--pkgbuild-url` 则给出已发布归档的地址(写成 `tar.gz::<url>`,保留文件名)。每个架构写到各自的目录,因为一个目录只有一个 `PKGBUILD`。除每个 Viva 应用都需要的 XCB、Pango、Cairo 和 fontconfig 包之外,应用还需要别的库时,用 `[linux] arch_depends` 列出。`.deb` 和 RPM 会推荐光标主题库和 Vulkan 加载库——前者让光标跟随桌面的主题和大小,后者提供 GPU 加速;PKGBUILD 把它们列为 optdepends,按需安装。

**签名是可选的。** 什么都不配置就什么都不签:macOS 会阻止下载的应用包,Windows SmartScreen 会对安装程序给出警告。`--program` 的存在就是为了让你自己先构建、签名,再打包这个确定的可执行文件。

Expand Down
Loading