(伪)0基础 将deb转为arch应用包
编辑
13
2025-03-25
为arch打包其实主要就是编写PKGBUILD,这个有shell基础的不难看懂。废话不多说,以闪电藤为例,搞一个。
1. 分析deb
如图,闪电藤2.6.5的deb目录就是个很典型的桌面应用,应用会安装到/opt下。

再看一下control,有依赖,这个很重要,记下来 libayatana-appindicator3-1

2. 抄作业
对于同样是安装到/opt的应用,可以抄大佬写的PKGBUILD。
看下咱们的/opt,拉一个开始抄,就是你了微信(没什么讲究,主打随意)

拉一下仓库

PKGBUILD如下
# Maintainer: Kimiblock Moe
# Contributor: wszqkzqk
pkgname=wechat-bin
pkgver=4.0.1.11
pkgrel=2
epoch=
pkgdesc="微信是一种生活方式. This is a repackage of WeChat."
arch=('x86_64' 'aarch64' 'loong64')
url="https://weixin.qq.com/"
license=('LicenseRef-proprietary')
groups=()
options=(!debug !strip)
makedepends+=()
replaces+=()
depends=(
"nss"
"xcb-util-renderutil"
"xcb-util-keysyms"
"xcb-util-image"
"xcb-util-wm"
"libxkbcommon-x11"
"libxkbcommon"
"libxcb"
"gcc-libs"
"nspr"
"glibc"
"zlib"
"libxcomposite"
"glib2"
"libxrender"
"libxext"
"alsa-lib"
"dbus"
"libxrandr"
"fontconfig"
"pango"
"freetype2"
"libxfixes"
"cairo"
"libx11"
"expat"
"libvlc"
"libxdamage"
"libdrm"
"mesa"
"libglvnd"
"libpulse"
"hicolor-icon-theme"
)
optdepends=(
"wechat: Sandbox support and enhancements"
'ttf-twemoji: An emoji font that will work with WeChat'
'libjack.so: libjack_plugin.so'
'at-spi2-core: Accessibility in the browser part'
)
makedepends+=(
"libarchive"
)
checkdepends=()
source=()
# The official site does not have versioned download, so checksums are skipped
source_x86_64=(
wechat-x86-${pkgver}.deb::"https://dldir1v6.qq.com/weixin/Universal/Linux/WeChatLinux_x86_64.deb"
)
source_aarch64=(
wechat-arm-${pkgver}.deb::"https://dldir1v6.qq.com/weixin/Universal/Linux/WeChatLinux_arm64.deb"
)
source_loong64=(
wechat-loong64-${pkgver}.deb::"https://dldir1v6.qq.com/weixin/Universal/Linux/WeChatLinux_LoongArch.deb"
)
md5sums=()
md5sums_x86_64=('SKIP')
md5sums_aarch64=('SKIP')
md5sums_loong64=('SKIP')
function pkgver() {
tar -xf control.tar.xz ./control
cat control | grep 'Version: ' | cut -c '10-'
}
function package() {
tar -xf data.tar.xz ./opt
cp -r opt \
"${pkgdir}/"
tar -xf data.tar.xz ./usr
cp -r usr \
"${pkgdir}/"
install -d "${pkgdir}/usr/share/licenses/${pkgname}"
echo "https://www.wechat.com/us/service_terms.html" \
>"${pkgdir}/usr/share/licenses/${pkgname}/ToS.txt"
sed -i 's|/usr/bin/wechat|/opt/wechat/wechat|g' \
"${pkgdir}/usr/share/applications"/*.desktop
}先关注pkgname、pkgver、pkgrel、pkgdesc、arch、url、depends这几个
直接望文生义改就完了(拿捏不准可以翻翻arch wiki)
pkgname=sdt-bin
pkgver=2.6.5
pkgrel=1
pkgdesc='A local area network file transfer tool that is based on LocalSend'
arch=('x86_64')
url="https://lightningvine.zishu.life/"
options=(!debug !strip)
makedepends=('tar')
depends=('libayatana-appindicator')依赖之前提过,这里用pacman查的到,直接填,版本号问题不大,先不管
moli@msitx ~ > pacman -Q | grep libayatana-appindicator
libayatana-appindicator 0.5.94-1
接着搞source、md5sums、package
source=("sdt-2.6.5.deb")
md5sums=('SKIP')
function package() {
tar -xf data.tar.zst ./opt
cp -r opt \
"${pkgdir}/"
tar -xf data.tar.zst ./usr
cp -r usr \
"${pkgdir}/"
}因为deb放在PKGBUILD同级目录,直接填文件名,然后md5先跳过(后续可用updpkgsums自动更新)
package部分其实完全复制了微信的,但去掉了下面部分。简单提一嘴可以看到装了licenses,还修改了快捷文件默认指向,这些咱们本地改都用不上,直接删
install -d "${pkgdir}/usr/share/licenses/${pkgname}"
echo "https://www.wechat.com/us/service_terms.html" \
>"${pkgdir}/usr/share/licenses/${pkgname}/ToS.txt"
sed -i 's|/usr/bin/wechat|/opt/wechat/wechat|g' \
"${pkgdir}/usr/share/applications"/*.desktop3. 打包
好的,现在就有了完整的PKGBUILD,可以打包了
# Maintainer: Your Name <youremail@domain.com>
pkgname=sdt-bin
pkgver=2.6.5
pkgrel=1
pkgdesc='A local area network file transfer tool that is based on LocalSend'
arch=('x86_64')
url="https://lightningvine.zishu.life/"
options=(!debug !strip)
makedepends=('tar')
depends=('libayatana-appindicator')
source=("sdt-2.6.5.deb")
md5sums=('SKIP')
function package() {
tar -xf data.tar.zst ./opt
cp -r opt \
"${pkgdir}/"
tar -xf data.tar.zst ./usr
cp -r usr \
"${pkgdir}/"
}makepkg没报错,再用namcap扫一遍,有报错的话继续解决,我这是没啥问题
moli@msitx ~/archpkg> ll
总计 11M
-rw-r--r-- 1 moli moli 476 3月25日 08:42 PKGBUILD
-rw-r--r-- 1 moli moli 11M 3月24日 08:59 sdt-2.6.5.deb
moli@msitx ~/archpkg> makepkg
==> 正在创建软件包:sdt-bin 2.6.5-1 (2025年03月25日 星期二 09时38分13秒)
==> 正在检查运行时依赖关系...
==> 正在检查编译时依赖关系
==> 获取源代码...
-> 找到 sdt-2.6.5.deb
==> 正在验证 source 文件,使用md5sums...
sdt-2.6.5.deb ... 已跳过
==> 正在释放源码...
-> 正在解压缩 sdt-2.6.5.deb,使用 bsdtar
==> 正在进入 fakeroot 环境...
==> 正在开始 package()...
==> 正在清理安装...
-> 正在删除 libtool 文件...
-> 正在清除不打算要的文件...
-> 正在移除静态库文件...
-> 正在压缩 man 及 info 文档...
==> 正在检查打包问题...
==> 正在构建软件包"sdt-bin"...
-> 正在生成 .PKGINFO 文件...
-> 正在生成 .BUILDINFO 文件...
-> 正在生成 .MTREE 文件...
-> 正在压缩软件包...
bsdtar: usr/share/applications/闪电藤文件传输.desktop: Can't translate pathname 'usr/share/applications/闪电藤文件传输.desktop' to UTF-8
==> 正在离开 fakeroot 环境。
==> 完成创建:sdt-bin 2.6.5-1 (2025年03月25日 星期二 09时38分14秒)
moli@msitx ~/archpkg>4. 愉快安装
moli@msitx ~/archpkg> sudo pacman -U sdt-bin-2.6.5-1-x86_64.pkg.tar.zst
正在加载软件包...
正在解析依赖关系...
正在查找软件包冲突...
软件包 (2) libayatana-appindicator-0.5.94-1 sdt-bin-2.6.5-1
全部安装大小: 32.88 MiB
:: 进行安装吗? [Y/n] y
(2/2) 正在检查密钥环里的密钥 [########################################] 100%
(1/2) 正在检查软件包完整性 [########################################] 100%
(1/2) 正在加载软件包文件 [########################################] 100%
(2/2) 正在检查文件冲突 [########################################] 100%
(2/2) 正在检查可用存储空间 [########################################] 100%
:: 正在处理软件包的变化...
(1/2) 正在安装 libayatana-appindicator [########################################] 100%
(2/2) 正在安装 sdt-bin [########################################] 100%
:: 正在运行事务后钩子函数...
(1/4) Arming ConditionNeedsUpdate...
(2/4) Refreshing PackageKit...
(3/4) Updating icon theme caches...
(4/4) Updating the desktop file MIME type cache...
moli@msitx ~/archpkg>完美运行,结束!

- 0
- 0
-
分享