我與俳句的第五天:讓我們移植一些程序

我與俳句的第五天:讓我們移植一些程序

TL博士: 一個新手第一次看到 Haiku,試圖從 Linux 世界移植一些程式。

我與俳句的第五天:讓我們移植一些程序
我的第一個 Haiku 移植程序,以 hpkg 格式打包

最近 我發現了 Haiku,這是一個非常好的 PC 作業系統。
今天我將學習如何將新程式移植到這個作業系統。 主要重點是從 Linux 開發人員的角度描述切換到 Haiku 的第一次體驗。 對於我一路上所犯的任何愚蠢錯誤,我深表歉意,因為距離我第一次下載俳句還不到一周。

我想實現三個目標:

  • 移植一個簡單的 CLI 應用程式
  • 將應用程式從 GUI 移植到 Qt
  • 然後將它們打包為 hpkg 格式(因為我還在考慮將 AppDir 和 AppImage 改編為 Haiku...)

讓我們開始吧。 分節 文件 и 發育,以及在 維基 從 HaikuPorts 我找到了正確的方向。 甚至還有一本線上 PDF 書 BeOS:移植 Unix 應用程式.
467 頁 - 這是 1997 年的! 往裡面看很可怕,但我希望一切順利。 開發者的話令人鼓舞:“花了很長時間,因為 BeOS 不符合 POSIX 標準”,但俳句“大部分”已經是這樣了。

移植簡單的 CLI 應用程式

第一個想法是移植應用程式 AVRDUDE,但是,事實證明,這已經是 已經完成了 很久以前。

第一次嘗試:沒什麼好看的

我無法理解的是,已經 應用程式移植到 Haiku 已有 10 多年的歷史 - 儘管作業系統本身還不是 1.0 版。

第二次嘗試:需要重寫

所以我會用 ptouch-770, CLI 用於控制我用來列印標籤的 Brother P-Touch 770 印表機。
我在上面印了各種標籤,你可能已經在上一篇文章中看到了。 早些時候,我用Python編寫了一個小的GUI包裝程式(因為它是在Gtk+中,所以必須重寫,這是一個學習的好理由)。

我與俳句的第五天:讓我們移植一些程序
Brother P-Touch 770 標籤印表機。它可以與 Haiku 搭配使用嗎?

Haiku 套件管理器了解庫和命令,因此如果我在運行時收到“找不到 libintl”訊息 configure - 我剛剛啟動 pkgman install devel:libintl 然後就會找到所需的包。 同樣地 pkgman install cmd:rsync。 嗯,等等。

除非這不起作用:

/Haiku/home> git clone https://github.com/probonopd/ptouch-770
Cloning into 'ptouch-770'...
remote: Enumerating objects: 134, done.
remote: Total 134 (delta 0), reused 0 (delta 0), pack-reused 134
Receiving objects: 100% (134/134), 98.91 KiB | 637.00 KiB/s, done.
Resolving deltas: 100% (71/71), done./Haiku/home> cd ptouch-770//Haiku/home/ptouch-770> make
gcc -Wall -O2 -c -o ptouch-770-write.o ptouch-770-write.c
ptouch-770-write.c:28:10: fatal error: libudev.h: No such file or directory
 #include <libudev.h>
          ^~~~~~~~~~~
compilation terminated.
Makefile:16: recipe for target 'ptouch-770-write.o' failed
make: *** [ptouch-770-write.o] Error 1/Haiku/home/ptouch-770> pkgman install devel:libudev
100% repochecksum-1 [65 bytes]
Validating checksum for Haiku...done.
100% repochecksum-1 [64 bytes]
Validating checksum for HaikuPorts...done.
*** Failed to find a match for "devel:libudev": Name not found/Haiku/home/ptouch-770> pkgman install devel:udev
100% repochecksum-1 [65 bytes]
Validating checksum for Haiku...done.
100% repochecksum-1 [64 bytes]
Validating checksum for HaikuPorts...done.
*** Failed to find a match for "devel:udev": Name not found

也許 udev 太基於 Linux,因此不適合 Haiku。 這意味著我需要編輯我正在嘗試編譯的原始程式碼。
呃,你跳不過去,我也不知道從哪裡開始。

第三次嘗試

如果有的話那就太好了 tmate 對於 Haiku,那麼我將允許 Haiku 開發人員連接到我的終端會話 - 以防出現問題。 說明非常簡單:

./autogen.sh
./configure
make
make install

看起來不錯,為什麼不試試俳句呢?

/Haiku/home> git clone https://github.com/tmate-io/tmate/Haiku/home> cd tmate//Haiku/home/tmate> ./autogen.sh
(...)/Haiku/home/tmate> ./configure
(...)
checking for libevent... no
checking for library containing event_init... no
configure: error: "libevent not found"/Haiku/home/tmate> pkgman install devel:libevent
(...)
The following changes will be made:
  in system:
    install package libevent21-2.1.8-2 from repository HaikuPorts
    install package libevent21_devel-2.1.8-2 from repository HaikuPorts
Continue? [yes/no] (yes) :
100% libevent21-2.1.8-2-x86_64.hpkg [965.22 KiB]
(...)
[system] Done.checking for ncurses... no
checking for library containing setupterm... no
configure: error: "curses not found"/Haiku/home/tmate> pkgman install devel:libcurses
(...)
*** Failed to find a match for "devel:libcurses": Name not found/Haiku/home/tmate> pkgman install devel:curses
(...)
*** Failed to find a match for "devel:curses": Name not found

在這一步中,我打開 HaikuDepot 並蒐索 curses.
發現了一些東西,這給了我一個更有效的查詢的提示:

/Haiku/home/tmate> pkgman install devel:libncurses
(...)
100% ncurses6_devel-6.1-1-x86_64.hpkg [835.62 KiB]
(...)./configure
(...)
checking for msgpack >= 1.1.0... no
configure: error: "msgpack >= 1.1.0 not found"/Haiku/home/tmate> pkgman install devel:msgpack
(...)
*** Failed to find a match for "devel:msgpack": Name not found/Haiku/home/tmate> pkgman install devel:libmsgpack
(...)
*** Failed to find a match for "devel:libmsgpack": Name not found

我再次去了 HaikuDepot,當然,發現 devel:msgpack_c_cpp_devel。 這些奇怪的名字是什麼?

/Haiku/home/tmate> pkgman install devel:msgpack_c_cpp_devel
100% repochecksum-1 [65 bytes]
Validating checksum for Haiku...done.
100% repochecksum-1 [64 bytes]
Validating checksum for HaikuPorts...done.
*** Failed to find a match for "devel:msgpack_c_cpp_devel": Name not found# Why is it not finding it? To hell with the "devel:".../Haiku/home/tmate> pkgman install msgpack_c_cpp_devel
(...)
The following changes will be made:
  in system:
    install package msgpack_c_cpp-3.1.1-1 from repository HaikuPorts
    install package msgpack_c_cpp_devel-3.1.1-1 from repository HaikuPorts
Continue? [yes/no] (yes) :
(...)/Haiku/home/tmate> ./configure
(...)
checking for libssh >= 0.8.4... no
configure: error: "libssh >= 0.8.4 not found"/Haiku/home/tmate> pkgman install devel:libssh/Haiku/home/tmate> make
(...)
In file included from /boot/system/develop/headers/msgpack.h:22,
                 from tmate.h:5,
                 from cfg.c:29:
/boot/system/develop/headers/msgpack/vrefbuffer.h:19:8: error: redefinition of struct iovec'
 struct iovec {
        ^~~~~
In file included from tmux.h:27,
                 from cfg.c:28:
/boot/system/develop/headers/posix/sys/uio.h:12:16: note: originally defined here
 typedef struct iovec {
                ^~~~~
Makefile:969: recipe for target 'cfg.o' failed
make: *** [cfg.o] Error 1

在這一步中,我意識到將程式移植到俳句需要比簡單重建更多的知識。
我與友好的 Haiku 開發人員交談,結果發現 msgpack 中有一個錯誤,幾分鐘後我在 HaikuPorts 中看到了一個補丁。 我可以親眼看到修正後的包包是如何 去這裡 (buildslave - 虛擬機器)。

我與俳句的第五天:讓我們移植一些程序
在 buildmaster 上建立修正後的 msgpack

在兩次之間我向上游發送補丁 為 msgpack 添加俳句支持.

五分鐘後,更新後的 msgpack 已在 Haiku 中可用:

/Haiku/home/tmate> pkgman update
(...)
The following changes will be made:
  in system:
    upgrade package msgpack_c_cpp-3.1.1-1 to 3.2.0-2 from repository HaikuPorts
    upgrade package msgpack_c_cpp_devel-3.1.1-1 to 3.2.0-2 from repository HaikuPorts
Continue? [yes/no] (yes) : y
100% msgpack_c_cpp-3.2.0-2-x86_64.hpkg [13.43 KiB]
(...)
[system] Done.

沒想到還不錯。 我有這麼說過嗎?!

我回到原來的問題:

/Haiku/home/tmate> make
(...)
In file included from tmux.h:40,
                 from tty.c:32:
compat.h:266: warning: "AT_FDCWD" redefined
 #define AT_FDCWD -100

In file included from tty.c:25:
/boot/system/develop/headers/posix/fcntl.h:62: note: this is the location of the previous definition
 #define AT_FDCWD  (-1)  /* CWD FD for the *at() functions */

tty.c: In function 'tty_init_termios':
tty.c:278:48: error: 'IMAXBEL' undeclared (first use in this function); did you mean 'MAXLABEL'?
  tio.c_iflag &= ~(IXON|IXOFF|ICRNL|INLCR|IGNCR|IMAXBEL|ISTRIP);
                                                ^~~~~~~
                                                MAXLABEL
tty.c:278:48: note: each undeclared identifier is reported only once for each function it appears in
Makefile:969: recipe for target 'tty.o' failed
make: *** [tty.o] Error 1

現在看來msgpack並沒有錯。 我在評論 IMAXLABEL в tty.c 如下:

tio.c_iflag &= ~(IXON|IXOFF|ICRNL|INLCR|IGNCR|/*IMAXBEL|*/ISTRIP);

其結果是:

osdep-unknown.c: In function 'osdep_get_cwd':
osdep-unknown.c:32:19: warning: unused parameter 'fd' [-Wunused-parameter]
 osdep_get_cwd(int fd)
               ~~~~^~
make: *** No rule to make target 'compat/forkpty-unknown.c', needed by 'compat/forkpty-unknown.o'.  Stop.

好吧,我們又來了……順便說一下:

/Haiku/home/tmate> ./configure | grep -i OPENAT
checking for openat... no

先生。 搖搖晃晃 告訴你在哪裡挖掘:

/Haiku/home/tmate> ./configure LDFLAGS="-lbsd"
(...)/Haiku/home/tmate> make
(...)
In file included from tmux.h:40,
                 from window.c:31:
compat.h:266: warning: "AT_FDCWD" redefined
 #define AT_FDCWD -100

In file included from window.c:22:
/boot/system/develop/headers/posix/fcntl.h:62: note: this is the location of the previous definition
 #define AT_FDCWD  (-1)  /* CWD FD for the *at() functions */

make: *** No rule to make target 'compat/forkpty-unknown.c', needed by 'compat/forkpty-unknown.o'.  Stop.

這裡我發文了 配置日誌.

他們向我解釋說,除了 Haiku 上的 libresolv 之外,libnetwork 中還有其他東西。 顯然程式碼需要進一步編輯。 需要思考…

find . -type f -exec sed -i -e 's|lresolv|lnetwork|g'  {} ;

永恆的問題:發生了什麼事?

/Haiku/home/tmate> ./configure LDFLAGS="-lbsd"
(...)/Haiku/home/tmate> make
(...)
# Success!# Let's run it:/Haiku/home/tmate> ./tmate
runtime_loader: /boot/system/lib/libssh.so.4.7.2: Could not resolve symbol '__stack_chk_guard'
resolve symbol "__stack_chk_guard" returned: -2147478780
runtime_loader: /boot/system/lib/libssh.so.4.7.2: Troubles relocating: Symbol not found

同樣的事情,只是在側面。 谷歌搜尋和 找到了這個。 如果你添加 -lssp 「有時」有幫助,我嘗試:

/Haiku/home/tmate> ./configure LDFLAGS="-lbsd -lssp"
(...)/Haiku/home/tmate> make
(...)/Haiku/home/tmate> ./tmate

哇! 開始了! 但…

[tmate] ssh.tmate.io lookup failure. Retrying in 2 seconds (non-recoverable failure in name resolution)

我會嘗試調試 在此歸檔:

/Haiku/home/tmate> strace -f ./tmate >log 2>&1

「錯誤的連接埠ID」已經像一張名片了 俳句。 也許有人知道出了什麼問題以及如何解決它? 如果是這樣,我會更新這篇文章。 連結到 GitHub上.

將 GUI 應用程式移植到 Qt。

我選擇一個簡單的 QML 應用程式。

/> cd /Haiku/home//Haiku/home> git clone https://github.com/probonopd/QtQuickApp
/Haiku/home/QtQuickApp> qmake .
/Haiku/home/QtQuickApp> make
/Haiku/home/QtQuickApp> ./QtQuickApp # Works!

真的很簡單。 不到一分鐘!

使用 haikuporter 和 haikuports 將應用程式打包為 hpkg。

我該從什麼開始? 沒有簡單的文檔,我轉到 irc.freenode.net 上的 #haiku 頻道並聽到:

  • 團隊 package - 建立套件的低階方法。 在大多數情況下,PackageInfo 對她來說就足夠了,如“將其製作成正確的 .hpkg 包”部分中所述
  • 我需要做點什麼 這樣的
  • 可以用 hpkg-創建者 (它對我來說崩潰了, 錯誤報告)

目前還不清楚該怎麼做。 我想我需要一個 Hello World 風格的初學者指南,最好是影片。 如果能像 GNU hello 中那樣對 HaikuPorter 進行方便的介紹就好了。

我正在閱讀以下內容:

haikuporter 是一個為 Haiku 建立通用套件專案的工具。 它使用 HaikuPorts 儲存庫作為所有套件的基礎。 Haikuporter 配方用於建立包。

此外,我發現:

無需在 HaikuPorts 儲存中儲存食譜。 您可以建立另一個儲存庫,將食譜放入其中,然後將 haikuporter 指向它。

這正是我所需要的 - 如果不尋找公開發布該軟體包的方法。 但這是另一篇文章的主題。

安裝 haikuporter 和 haikuports

cd /boot/home/
git clone https://github.com/haikuports/haikuporter --depth=50
git clone https://github.com/haikuports/haikuports --depth=50
ln -s /boot/home/haikuporter/haikuporter /boot/home/config/non-packaged/bin/ # make it runnable from anywhere
cd haikuporter
cp haikuports-sample.conf /boot/home/config/settings/haikuports.conf
sed -i -e 's|/mydisk/haikuports|/boot/home/haikuports|g' /boot/home/config/settings/haikuports.conf

寫食譜

SUMMARY="Demo QtQuick application"
DESCRIPTION="QtQuickApp is a demo QtQuick application for testing Haiku porting and packaging"
HOMEPAGE="https://github.com/probonopd/QtQuickApp"
COPYRIGHT="None"
LICENSE="MIT"
REVISION="1"
SOURCE_URI="https://github.com/probonopd/QtQuickApp.git"
#PATCHES=""
ARCHITECTURES="x86_64"
PROVIDES="
    QtQuickApp = $portVersion
"
REQUIRES="
    haiku
"
BUILD_REQUIRES="
    haiku_devel
    cmd:qmake
"BUILD()
{
    qmake .
    make $jobArgs
}INSTALL()
{
    make install
}

組裝食譜

我將文件保存在該名稱下 QtQuickApp-1.0.recipe,之後我啟動 aikuporter -S ./QuickApp-1.0.recipe。 檢查儲存庫中所有套件的依賴關係 俳句港,這需要一些時間。 我去喝點咖啡。

到底為什麼這個檢查應該在我的本地電腦上完成,而不是集中在伺服器上為每個人一次完成?

據先生說搖搖欲墜:

這樣你就可以重寫儲存庫中的任何文件😉你可以對此進行一些優化,在需要時計算必要的信息,因為最後所做的更改非常罕見。

~/QtQuickApp> haikuporter  QtQuickApp-1.0.recipe
Checking if any dependency-infos need to be updated ...
Looking for stale dependency-infos ...
Error: QtQuickApp not found in repository

事實證明,不存在包含應用程式原始碼的常規配方文件。 您需要將其以 HaikuPorts 格式保存在儲存庫中。

~/QtQuickApp> mv QtQuickApp-1.0.recipe ../haikuports/app-misc/QtQuickApp/
~/QtQuickApp> ../haikuport
~/QtQuickApp> haikuporter -S QtQuickApp-1.0.recipe

這一事實使得組裝更加麻煩。 我不是特別喜歡它,但我認為這是必要的,這樣最終所有開源軟體都會出現在 HaikuPorts 中。

我得到以下資訊:

~/QtQuickApp> haikuporter -S QtQuickApp-1.0.recipe
Checking if any dependency-infos need to be updated ...
        updating dependency infos of QtQuickApp-1.0
Looking for stale dependency-infos ...
Error: QtQuickApp-1.0.recipe not found in tree.

怎麼了? 讀完 irc 後我會:

~/QtQuickApp> haikuporter -S QtQuickApp
Checking if any dependency-infos need to be updated ...
        updating dependency infos of QtQuickApp-1.0
Looking for stale dependency-infos ...
----------------------------------------------------------------------
app-misc::QtQuickApp-1.0
        /boot/home/haikuports/app-misc/QtQuickApp/QtQuickApp-1.0.recipe
----------------------------------------------------------------------Downloading: https://github.com/probonopd/QtQuickApp.git ...
--2019-07-14 16:12:44--  https://github.com/probonopd/QtQuickApp.git
Resolving github.com... 140.82.118.3
Connecting to github.com|140.82.118.3|:443... connected.
HTTP request sent, awaiting response... 301 Moved Permanently
Location: https://github.com/probonopd/QtQuickApp [following]
--2019-07-14 16:12:45--  https://github.com/probonopd/QtQuickApp
Reusing existing connection to github.com:443.
HTTP request sent, awaiting response... 200 OK
Length: unspecified [text/html]
Saving to: ‘/boot/home/haikuports/app-misc/QtQuickApp/download/QtQuickApp.git’
     0K .                                                     1.34M=0.06s
2019-07-14 16:12:45 (1.34 MB/s) - ‘/boot/home/haikuports/app-misc/QtQuickApp/download/QtQuickApp.git’ saved [90094]
Validating checksum of QtQuickApp.git
Warning: ----- CHECKSUM TEMPLATE -----
Warning: CHECKSUM_SHA256="cf906a65442748c95df16730c66307a46d02ab3a12137f89076ec7018d8ce18c"
Warning: -----------------------------
Error: No checksum found in recipe!

一個有趣的問題出現了。 如果我向配方添加校驗和 - 它會匹配最新的 git 提交以進行持續整合嗎? (開發者確認:「這行不通。配方設計得相對穩定。」)

為了好玩,加入食譜:

CHECKSUM_SHA256="cf906a65442748c95df16730c66307a46d02ab3a12137f89076ec7018d8ce18c"

還是不滿意:

~/QtQuickApp> haikuporter -S QtQuickApp
Checking if any dependency-infos need to be updated ...
        updating dependency infos of QtQuickApp-1.0
Looking for stale dependency-infos ...
----------------------------------------------------------------------
app-misc::QtQuickApp-1.0
        /boot/home/haikuports/app-misc/QtQuickApp/QtQuickApp-1.0.recipe
----------------------------------------------------------------------
Skipping download of source for QtQuickApp.git
Validating checksum of QtQuickApp.git
Unpacking source of QtQuickApp.git
Error: Unrecognized archive type in file /boot/home/haikuports/app-misc/QtQuickApp/download/QtQuickApp.git

他在做什麼? 畢竟這是一個git倉庫,程式碼已經直接存在了,沒有什麼好解壓縮的。 從我的角度來看,該工具應該足夠智能,不會在 GitHub URL 上方尋找解包器。

也許 uri git:// 會起作用

SOURCE_URI="git://github.com/probonopd/QtQuickApp.git"

現在它這樣抱怨:

Downloading: git://github.com/probonopd/QtQuickApp.git ...
Error: Downloading from unsafe sources is disabled in haikuports.conf!

嗯,為什麼一切都這麼複雜,為什麼你不能「只是工作」? 畢竟,從 GitHub 建立一些東西並不罕見。 無論是無需設定即可立即使用的工具,還是我所說的「大驚小怪」。

也許它會像這樣工作:

SOURCE_URI="git+https://github.com/probonopd/QtQuickApp.git"

沒有。 我仍然遇到這個奇怪的錯誤, 如這裡所述

sed -i -e 's|#ALLOW_UNSAFE_SOURCES|ALLOW_UNSAFE_SOURCES|g' /boot/home/config/settings/haikuports.conf

我又前進了一點,但為什麼它對我尖叫(GitHub 不安全!)並且仍然試圖解壓一些東西。

根據 先生。 搖搖晃晃:

嗯,是的,原因是希望檢查接收到的組裝資料的完整性。 其中一個選項是驗證存檔的校驗和,但是您當然可以對單一檔案進行雜湊處理,但這不會被實現,因為這需要更長的時間。 這樣做的後果就是 git 和其他 VCS 的「不安全」。 情況很可能總是如此,因為在 GitHub 上建立存檔非常容易且通常更快。 好吧,將來,也許錯誤訊息不會那麼華而不實……(我們不再在 HaikuPorts 中合併此類食譜)。

~/QtQuickApp> haikuporter -S QtQuickApp
Checking if any dependency-infos need to be updated ...
Looking for stale dependency-infos ...
----------------------------------------------------------------------
app-misc::QtQuickApp-1.0
        /boot/home/haikuports/app-misc/QtQuickApp/QtQuickApp-1.0.recipe
----------------------------------------------------------------------Downloading: git+https://github.com/probonopd/QtQuickApp.git ...
Warning: UNSAFE SOURCES ARE BAD AND SHOULD NOT BE USED IN PRODUCTION
Warning: PLEASE MOVE TO A STATIC ARCHIVE DOWNLOAD WITH CHECKSUM ASAP!
Cloning into bare repository '/boot/home/haikuports/app-misc/QtQuickApp/download/QtQuickApp.git'...
Unpacking source of QtQuickApp.git
tar: /boot/home/haikuports/app-misc/QtQuickApp/work-1.0/sources/QtQuickApp-1.0: Cannot open: No such file or directory
tar: Error is not recoverable: exiting now
Command 'git archive HEAD | tar -x -C "/boot/home/haikuports/app-misc/QtQuickApp/work-1.0/sources/QtQuickApp-1.0"' returned non-zero exit status 2

出於舊習慣,我去 irc.freenode.net 網路上的 #haiku 頻道詢問好人。 如果沒有他們我會在哪裡? 經過提示後,我意識到我應該使用:

srcGitRev="d0769f53639eaffdcd070bddfb7113c04f2a0de8"
SOURCE_URI="https://github.com/probonopd/QtQuickApp/archive/$srcGitRev.tar.gz"
SOURCE_DIR="QtQuickApp-$srcGitRev"
CHECKSUM_SHA256="db8ab861cfec0ca201e9c7b6c0c9e5e828cb4e9e69d98e3714ce0369ba9d9522"

好吧,它的作用已經很清楚了 - 它下載包含某個版本的源代碼的存檔。 從我的角度來看,這很愚蠢,而且不完全是我想要的,即從 master 分支下載最新版本。

一位開發人員是這樣解釋的:

我們有自己的 CI,因此放置在 haikuports 儲存庫中的所有內容都將為所有用戶打包,並且我們不想冒險收集和交付「上游最新版本中的所有內容」。

明白了! 無論如何,事情是這樣的:

waiting for build package QtQuickApp-1.0-1 to be activated
waiting for build package QtQuickApp-1.0-1 to be activated
waiting for build package QtQuickApp-1.0-1 to be activated
waiting for build package QtQuickApp-1.0-1 to be activated
waiting for build package QtQuickApp-1.0-1 to be activated
(...)

它無限地重複這個廣告。 顯然這是一個錯誤(有應用程式嗎?我找不到)。

С haikuporter 和儲存庫 俳句港 它沒有一種「正常工作」的感覺,但作為一名開發人員,我喜歡使用 Haiku 進行工作。 在大多數情況下,它類似於 Open Build Service,這是一組用於建立 Linux 版本的工具:非常強大,具有系統性方法,但對於我的小型「hello world」應用程式來說有點過頭了。

再次,根據先生的說法。 搖搖晃晃地飛濺:

事實上,HaikuPorter 預設情況下相當嚴格(加上有一個 lint 模式以及一個嚴格模式使其更加嚴格!),但這只是因為它創建了可以工作的包,而不僅僅是創建包。 這就是為什麼他抱怨未聲明的依賴項、未正確導入的庫、不正確的版本等。 目標是在使用者知道之前捕獲所有問題,包括未來的問題(這就是為什麼無法安裝 avrdude,因為依賴項實際上是在配方中指定的)。 庫不僅僅是單獨的包,甚至不是特定的 SO 版本。 HaikuPorter 確保在配方本身中遵守所有這些內容,以避免執行過程中出現錯誤。

原則上,這種嚴格程度在創建作業系統時是合理的,但對於我來說,對於「hello world」應用程式來說似乎沒有必要。 我決定嘗試別的東西。

使用“package create”命令以 hpkg 格式建立應用程式

或許, 簡單的說明對我來說會更有效嗎?

mkdir -p apps/
cp QtQuickApp apps/cat >  .PackageInfo <<EOF
name QtQuickApp
version 1.0-1
architecture x86_64

summary "Demo QtQuick application"
description "QtQuickApp is a demo QtQuick application for testing Haiku porting and packaging"

packager "probono"
vendor "probono"

copyrights "probono"
licenses "MIT"

provides {
  QtQuickApp = 1.0-1
}requires {
  qt5
}
EOFpackage create -b QtQuickApp.hpkg
package add QtQuickApp.hpkg apps# See below if you also want the application
# to appear in the menu

出乎意料的快,出乎意料的簡單,出乎意料的有效。 正是我喜歡的樣子,太棒了!

安裝 - 什麼以及在哪裡?

將 QtQuickApp.hpkg 檔案移至 ~/config/packages使用檔案管理器,之後 QtQuickApp 神奇地出現在 ~/config/apps.
再次強調,出乎意料的快速、簡單、有效。 太神奇了,不可思議!

但是...(沒有他們我們會在哪裡!)

應用程式選單列表和快速啟動中仍然缺少該應用程式。 我想我已經知道如何解決它了。 在檔案管理器中,我將 QtQuickApp.hpkg 從 ~/config/packages 移至 /system/packages。

不,還是失蹤了。 顯然,我(以及說明)錯過了一些東西。

查看 HaikuDepot 中其他一些應用程式的“目錄”選項卡後,我發現有類似的文件 /data/mimedb/application/x-vnd... 更值得注意的是, /data/deskbar/menu/Applications/….

嗯,我該在那裡放什麼? 快點...

mkdir -p data/deskbar/menu/Applications/
( cd data/deskbar/menu/Applications ; ln -s ../../../../apps/QtQuickApp . )
package add QtQuickApp.hpkg apps data

我很確定這個技巧會起作用,但問題仍然存在:為什麼這是必要的,它的用途是什麼? 我認為這破壞了系統如此複雜的整體印象。

正如先生所解釋的那樣搖搖晃晃地飛濺:

有時,有些應用程式是其他應用程式需要的,但不在選單中。 例如,螢幕截圖中的 LegacyPackageInstaller 正在處理 BeOS 格式的 .pkg 檔案。 我希望用戶安裝它們,但它們出現在選單中會導致混亂。

出於某種原因,在我看來,有一個更簡單的解決方案,例如 Hidden=true 在文件中 .desktop 在 Linux 上。 為什麼不讓「隱藏」的資訊成為檔案系統的資源和屬性呢?

尤其不微妙的是顯示選單的(某些)應用程式的名稱, deskbar,一路上牢牢拴著。

先生。 waddlessplash 解釋了這一點:

在這種情況下,「桌面列」應該被理解為一種通用術語(與「工作列」非常相似,它既指 Windows 應用程序,也指一般概念)。 嗯,自從這 deskbar,而不是“Deskbar”,這個也可以類似的理解。

我與俳句的第五天:讓我們移植一些程序
2 個「幾乎相同」的目錄,其中包含應用程式

為什麼有 2 個包含應用程式的目錄,以及為什麼我的 QtQuickApplication 在一個目錄中,但不在另一個目錄中? (畢竟,這不是一個系統,而是第二個用戶,這對我個人來說是可以理解的)。
我真的很困惑,我認為這應該統一。

先生的評論搖搖晃晃地飛濺

應用程式目錄包含選單中不需要的應用程式。 但菜單的情況確實需要改進,使其更加可自訂。

申請,否則不會發生😉

我想知道:是否真的有必要將應用程式託管在 /system/apps,如果用戶在那裡看到它們,這是不可取的。 也許將它們放置在用戶不會遇到它們的另一個地方會更好? 就像在 Mac OS X 中所做的那樣,包的內容 .app,這對用戶來說不應該是可見的 /Applications,隱藏在/System/Library/…的深處「`.

依賴關係又如何呢?

我認為以某種方式指定依賴關係是值得的,對嗎? Qt 是否可以被視為預設情況下 Haiku 安裝的強制部分? 沒有! 預設不安裝 Qt。 套件建構器可以透過檢查 ELF 檔案自動偵測依賴關係嗎? 有人告訴我 HaikuPorter 實際上是這樣做的,但是 package 不。 那是因為它只是一個“包生成器”,只是自行創建文件 hpkg.

是否應該透過添加一個套件不應該依賴 Haiku 之外的套件的策略來使 Haiku 變得更加複雜? haikuports? (我願意,因為這樣的策略會讓事情變得容易得多 - 系統將能夠自動解析從任何地方下載的每個包的依賴關係,而無需弄亂其他包源。)

先生。 waddlesplash 解釋:

我們不想過度限制開發人員的自由,因為很明顯,如果 CompanyX 想要支援自己的一組具有依賴項的軟體(以及儲存庫),它將完全自由地這樣做。

在這種情況下,可能值得建議第三方套件透過完全打包應用程式所需的所有內容來避免對 haikuports 中未包含的任何內容的依賴。 但我認為這是本系列未來文章的主題。 【作者是走向AppImage嗎? — 約。 譯者]

新增應用程式圖標

如果我想將簡潔的內建圖示之一添加到新建立的應用程式的資源中該怎麼辦? 事實證明,這是一個令人驚奇的主題,因此它將作為下一篇文章的基礎。

如何組織持續的應用程式建置?

想像一個像 Inkscape 這樣的專案(是的,我知道它還沒有 Haiku 版本,但在上面顯示很方便)。 他們有一個源代碼存儲庫 https://gitlab.com/inkscape/inkscape.
每次有人將更改提交到儲存庫時,都會啟動建置管道,之後會自動測試、建置更改,並將應用程式打包到各種包中,包括AppImage for Linux(一個獨立的應用程式包,可以下載用於本機測試,無論系統上可能安裝或不安裝什麼 [我就知道! — 約。 譯者])。 每個分支合併請求都會發生相同的情況,因此您可以在合併之前下載根據合併請求中建議的程式碼建置的應用程式。

我與俳句的第五天:讓我們移植一些程序
將請求與建置狀態合併,如果建置成功,則能夠下載已編譯的二進位(標記為綠色)

建置在 Docker 容器中運行。 GitLab 在 Linux 上提供免費的運行程序,我認為可能包含您自己的運行程序(順便說一句,我不知道這對於像 Haiku 這樣的系統如何工作,我知道它沒有 Docker 或類似的系統,但是另外,對FreeBSD 來說,沒有Docker,所以這個問題並不是Haiku 所獨有的)。

理想情況下,Haiku 應用程式可以在 Linux 的 Docker 容器內建置。 在這種情況下,俳句的組裝可以引入現有的管道中。 有交叉編譯器嗎? 或者我應該使用 QEMU/KVM 之類的東西在 Docker 容器內模擬所有俳句(假設它會在 Docker 內以這種方式工作)? 順便說一句,許多項目都使用類似的原理。 例如,Scribus 就是這樣做的——它已經可用於俳句。 總有一天我可以發送 這樣 向其他項目請求添加俳句支援。

一位開發人員解釋:

對於其他希望自己建立套件的項目,支援常規的 CMake/CPack 方法。 可以透過直接呼叫套件建構程式來支援其他建置系統,如果人們對此感興趣的話,這很好。 經驗顯示:到目前為止,還沒有太多興趣,因此 haikuporter 對我們來說很方便,但最終,兩種方法應該一起工作。 我們應該引入一套工具,用於在 Linux 或任何其他伺服器作業系統上交叉建立軟體(Haiku 不是為在伺服器上運行而設計的)。

我起立鼓掌。 普通 Linux 用戶承受著伺服器作業系統所需的所有這些額外負載和額外包袱(安全性、嚴格控制等),但個人作業系統則不然。 所以我完全同意能夠在 Linux 上建立 Haiku 應用程式是一條出路。

結論

將 POSIX 應用程式移植到 Haiku 是可能的,但可能比典型的重建更昂貴。 如果沒有 irc.freenode.net 網路上 #haiku 頻道的人們的幫助,我肯定會在很長一段時間內陷入困境。 但即使是他們也不總是能立即看出問題所在。

用 Qt 編寫的應用程式是一個簡單的例外。 我組裝了一個簡單的演示應用程序,沒有任何問題。

為簡單應用程式建立套件也很容易,但僅限於“傳統發布”的應用程序,即具有用於支援 haikuports 的版本化原始碼檔案。 對於使用 GitHub 進行持續建置(針對每次變更提交進行建置),一切似乎都不那麼簡單。 這裡 Haiku 感覺更像是一個 Linux 發行版,而不是 Mac 上的結果,當你點擊 X​​Code 中的「Build」按鈕時,你會得到一個套件 .app,準備插入磁碟映像 .dmg,準備在我的網站上下載。
如果開發人員有需求,基於「伺服器」作業系統(例如 Linux)的應用程式的持續建置很可能成為可能,但目前 Haiku 專案還有其他更緊迫的任務。

自己試試吧! 畢竟,Haiku 項目提供了從 DVD 或 USB 啟動的映像,生成 日報. 要安裝,只需下載映像並將其刻錄到 USB 閃存驅動器,使用 刻蝕機

有問題嗎? 我們邀請您到講俄語的 電報頻道.

錯誤概述: 如何在 C 和 C++ 中搬起石頭砸自己的腳。 Haiku OS 食譜合集

阿夫托拉 翻譯:這是俳句系列的第五篇文章。

文章列表: 第一 第二個 第三 第四

來源: www.habr.com

添加評論