页次: 1
大家好,我是一个 PKGBUILD 新手,希望哪位大佬能帮忙看一下我给 RoseSong 写的 PKGBUILD。
另:RoseSong 的源代码托管在 GitHub 上,我做了两个版本,一个用 Releases 上提供的预编译二进制文件(rosesong),一个用 master 分支上最新的源码(rosesong-git);同时,由于 GitHub 的感人速度,我另外弄了走 Gitee 上镜像的版本(rosesong-gitee和rosesong-gitee-git)。因为 Gitee 上源码太过老旧,rosesong-gitee-git 在编译时会失败,应该不是 PKGBUILD 的问题。
rosesong:
# Maintainer: QB <GNUqb114514@outlook.com>
pkgname='rosesong'
pkgver='1.0.0'
pkgrel=1
pkgdesc='使用rust实现的CLI音频播放器,通过gstreamer解码播放b站视频的音频/ A CLI audio player implemented in Rust that decodes and plays the audio of bilibili videos using GStreamer.'
arch=('x86_64')
url='https://github.com/huahuadeliaoliao/RoseSong'
license=('MIT')
conflicts=('rosesogn-gitee' 'rosesong-git' 'rosesong-gitee-git')
depends=('gstreamer' 'dbus' 'openssl')
source=("https://github.com/huahuadeliaoliao/RoseSong/releases/download/v$pkgver/rosesong"
"https://github.com/huahuadeliaoliao/RoseSong/releases/download/v1.0.0/rsg"
"https://github.com/huahuadeliaoliao/RoseSong/raw/main/LICENSE")
noextract=("https://github.com/huahuadeliaoliao/RoseSong/releases/download/v$pkgver/rosesong"
"https://github.com/huahuadeliaoliao/RoseSong/releases/download/v1.0.0/rsg"
"https://github.com/huahuadeliaoliao/RoseSong/raw/main/LICENSE")
sha256sums=('SKIP' 'SKIP' 'SKIP')
package() {
cd $srcdir
install -Dm644 LICENSE "$pkgdir"/usr/share/licenses/$pkgname/LICENSE
install -D rosesong "$pkgdir"/usr/bin/rosesong
install -D rsg "$pkgdir"/usr/bin/rsg
}
rosesong-git:
# Maintainer: QB <GNUqb114514@outlook.com>
pkgname='rosesong-git'
pkgver=1.0.0.r7.gd0c3cd9
pkgrel=1
pkgdesc='使用rust实现的CLI音频播放器,通过gstreamer解码播放b站视频的音频/ A CLI audio player implemented in Rust that decodes and plays the audio of bilibili videos using GStreamer.'
arch=('x86_64')
url='https://github.com/huahuadeliaoliao/RoseSong'
license=('MIT')
provides=('rosesong')
conflicts=('rosesong' 'rosesong-gitee' 'rosesong-gitee-git')
depends=('gstreamer' 'dbus' 'openssl')
source=("${pkgname%-git}::git+$url.git")
sha256sums=('SKIP')
makedepends=('cargo')
pkgver() {
cd ${pkgname%-git}
git describe --long --tags --abbrev=7 | sed 's/\([^-]*-g\)/r\1/;s/-/./g;s/^v//'
}
prepare() {
cd rosesong/rosesong-cli
export RUSTUP_TOOLCHAIN=stable
cargo fetch --locked --target "$CARCH-unknown-linux-gnu"
}
build() {
cd rosesong/rosesong-cli
export RUSTUP_TOOLCHAIN=stable
export RUSTUP_TOOLCHAIN=stable
export CARGO_TARGET_DIR=target
cargo build --frozen --release --all-features
}
check() {
cd rosesong/rosesong-cli
export RUSTUP_TOOLCHAIN=stable
export RUSTUP_TOOLCHAIN=stable
cargo test --frozen --all-features
}
package() {
cd rosesong/rosesong-cli
export RUSTUP_TOOLCHAIN=stable
find target/release \
-maxdepth 1 \
-executable \
-type f \
-exec install -Dm0755 -t "$pkgdir/usr/bin/" {} +
install -Dm644 ../LICENSE "$pkgdir"/usr/share/licenses/$pkgname/LICENSE
}
rosesong-gitee:
# Maintainer: QB <GNUqb114514@outlook.com>
pkgname='rosesong-gitee'
pkgver='1.0.0'
pkgrel=1
pkgdesc='使用rust实现的CLI音频播放器,通过gstreamer解码播放b站视频的音频/ A CLI audio player implemented in Rust that decodes and plays the audio of bilibili videos using GStreamer. (From mirror on Gitee)'
arch=('x86_64')
url='https://gitee.com/huahuadeliaoliao/RoseSong'
license=('MIT')
depends=('gstreamer' 'dbus' 'openssl')
provides=('rosesong')
conflicts=('rosesong' 'rosesong-git' 'rosesong-gitee-git')
source=("https://gitee.com/huahuadeliaoliao/RoseSong/releases/download/v$pkgver/rosesong"
"https://gitee.com/huahuadeliaoliao/RoseSong/releases/download/v1.0.0/rsg"
"https://gitee.com/huahuadeliaoliao/RoseSong/raw/main/LICENSE")
noextract=("https://gitee.com/huahuadeliaoliao/RoseSong/releases/download/v$pkgver/rosesong"
"https://gitee.com/huahuadeliaoliao/RoseSong/releases/download/v1.0.0/rsg"
"https://gitee.com/huahuadeliaoliao/RoseSong/raw/main/LICENSE")
sha256sums=('bda05814a0c5c24c596ba8a926fbeec9ef7dafae6e7db51b44fda60fa42845d8'
'9e435cadbc02387ec60558a536ea89015b43acc9c22a238af71759197afdddc9'
'7de8aa00a487c75a07d4ce0c64388ad51311ecf7c9320632ebf919dd0f873167')
package() {
cd $srcdir
install -Dm644 LICENSE "$pkgdir"/usr/share/licenses/$pkgname/LICENSE
install -D rosesong "$pkgdir"/usr/bin/rosesong
install -D rsg "$pkgdir"/usr/bin/rsg
}
rosesong-gitee-git:
# Maintainer: QB <GNUqb114514@outlook.com>
pkgname='rosesong-gitee-git'
pkgver=1.0.0.r3.g2e9e06e
pkgrel=1
pkgdesc='使用rust实现的CLI音频播放器,通过gstreamer解码播放b站视频的音频/ A CLI audio player implemented in Rust that decodes and plays the audio of bilibili videos using GStreamer. (From mirror on Gitee)'
arch=('x86_64')
url='https://gitee.com/huahuadeliaoliao/RoseSong'
license=('MIT')
provides=('rosesong')
conflicts=('rosesong' 'rosesong-git' 'rosesong-gitee')
depends=('gstreamer' 'dbus' 'openssl')
source=("${pkgname%-gitee-git}::git+$url.git")
sha256sums=('SKIP')
makedepends=('cargo')
pkgver() {
cd ${pkgname%-git}
git describe --long --tags --abbrev=7 | sed 's/\([^-]*-g\)/r\1/;s/-/./g;s/^v//'
}
prepare() {
cd rosesong/rosesong-cli
export RUSTUP_TOOLCHAIN=stable
cargo fetch --locked --target "$CARCH-unknown-linux-gnu"
}
build() {
cd rosesong/rosesong-cli
export RUSTUP_TOOLCHAIN=stable
export RUSTUP_TOOLCHAIN=stable
export CARGO_TARGET_DIR=target
cargo build --frozen --release --all-features
}
check() {
cd rosesong/rosesong-cli
export RUSTUP_TOOLCHAIN=stable
export RUSTUP_TOOLCHAIN=stable
cargo test --frozen --all-features
}
package() {
cd rosesong/rosesong-cli
export RUSTUP_TOOLCHAIN=stable
find target/release \
-maxdepth 1 \
-executable \
-type f \
-exec install -Dm0755 -t "$pkgdir/usr/bin/" {} +
install -Dm644 ../LICENSE "$pkgdir"/usr/share/licenses/$pkgname/LICENSE
}
注:本帖的内容已经过时,最新的PKGBUILD在这。
最近编辑记录 qb114514 (2024-09-07 09:50:07)
离线
槽点有点多,说几个比较明显的,剩下你看看 https://wiki.archlinux.org/title/PKGBUILD 和 https://wiki.archlinux.org/title/Arch_p … guidelines 检查一下
1. 使用预编译二进制的包名应该加上-bin
2. 没必要将二进制文件和文本文件写道noextract里面,makepkg一般不会去解压他们
3. 没有校验哈希,所有哈希值都是SKIP
4. 没必要单独为gitee出个包,在PKGBUILD里面用个环境变量控制就行了,例如下面
# Use gitee as mirror to speed up downloading source file
#_use_git=y
if [[ "${_use_git}" == "y" ]]
then
upstream="https://gitee.com/huahuadeliaoliao/RoseSong"
else
upstream="https://github.com/huahuadeliaoliao/RoseSong"
fi
source=("${upstream}/releases/download/v$pkgver/rosesong"
"${upstream}/releases/download/v1.0.0/rsg"
"${upstream/raw/main/LICENSE")
离线
谢谢。
对于包名的-bin和-git后缀确实没很理解,现在有了例子,就好多了。
哈希的问题确实是我疏忽了,本来都用makepkg -g算好了,结果忘记传上来了 因为网络不太好,暂时就不算了,网好的时候再算吧。
对于gitee的问题,确实使用这种方法可以统一包的代码,方便后续维护,但是如果要传到AUR上,我想还是得拆成两个包,毕竟大多数人应该都更倾向于使用AUR Helper而不是自己下PKGBUILD再makepkg。
新PKGBUILD如下:
rosesong-bin:
# Maintainer: QB <GNUqb114514@outlook.com>
# Uncomment line following to use Gitee as mirror.
_use_gitee=y
if [[ "${_use_git}" == "y" ]] then
_upstream="https://gitee.com/huahuadeliaoliao/RoseSong"
else
_upstream="https://github.com/huahuadeliaoliao/RoseSong"
fi
pkgname='rosesong-bin'
pkgver='1.0.0'
pkgrel=1
pkgdesc='使用rust实现的CLI音频播放器,通过gstreamer解码播放b站视频的音频/ A CLI audio player implemented in Rust that decodes and plays the audio of bilibili videos using GStreamer.'
arch=('x86_64')
url='${_upstream}'
license=('MIT')
conflicts=('rosesogn-gitee' 'rosesong-git' 'rosesong-gitee-git')
depends=('gstreamer' 'dbus' 'openssl')
source=("${_upstream}/releases/download/v$pkgver/rosesong"
"${_upstream}/releases/download/v1.0.0/rsg"
"${_upstream}/raw/main/LICENSE")
sha256sums=('SKIP' 'SKIP' 'SKIP')
package() {
cd $srcdir
install -Dm644 LICENSE "$pkgdir"/usr/share/licenses/$pkgname/LICENSE
install -D rosesong "$pkgdir"/usr/bin/rosesong
install -D rsg "$pkgdir"/usr/bin/rsg
}
rosesong-git:
# Maintainer: QB <GNUqb114514@outlook.com>
# Uncomment line following to use Gitee as mirror.
#_use_gitee=y
if [[ "${_use_git}" == "y" ]] then
_upstream="https://gitee.com/huahuadeliaoliao/RoseSong"
else
_upstream="https://github.com/huahuadeliaoliao/RoseSong"
fi
pkgname='rosesong-git'
pkgver=1.0.0.r7.gd0c3cd9
pkgrel=1
pkgdesc='使用rust实现的CLI音频播放器,通过gstreamer解码播放b站视频的音频/ A CLI audio player implemented in Rust that decodes and plays the audio of bilibili videos using GStreamer.'
arch=('x86_64')
url="${_upstream}"
license=('MIT')
provides=('rosesong')
conflicts=('rosesong' 'rosesong-gitee' 'rosesong-gitee-git')
depends=('gstreamer' 'dbus' 'openssl')
source=("${pkgname%-git}::git+$url.git")
sha256sums=('SKIP')
makedepends=('cargo')
pkgver() {
cd ${pkgname%-git}
git describe --long --tags --abbrev=7 | sed 's/\([^-]*-g\)/r\1/;s/-/./g;s/^v//'
}
prepare() {
cd rosesong/rosesong-cli
export RUSTUP_TOOLCHAIN=stable
cargo fetch --locked --target "$CARCH-unknown-linux-gnu"
}
build() {
cd rosesong/rosesong-cli
export RUSTUP_TOOLCHAIN=stable
export RUSTUP_TOOLCHAIN=stable
export CARGO_TARGET_DIR=target
cargo build --frozen --release --all-features
}
check() {
cd rosesong/rosesong-cli
export RUSTUP_TOOLCHAIN=stable
export RUSTUP_TOOLCHAIN=stable
cargo test --frozen --all-features
}
package() {
cd rosesong/rosesong-cli
export RUSTUP_TOOLCHAIN=stable
find target/release \
-maxdepth 1 \
-executable \
-type f \
-exec install -Dm0755 -t "$pkgdir/usr/bin/" {} +
install -Dm644 ../LICENSE "$pkgdir"/usr/share/licenses/$pkgname/LICENSE
}
rosesong:
# Maintainer: QB <GNUqb114514@outlook.com>
# Uncomment line above to use Gitee as mirror.
_use_gitee=y
if [[ "${_use_git}" == "y" ]] then
_upstream="https://gitee.com/huahuadeliaoliao/RoseSong"
else
_upstream="https://github.com/huahuadeliaoliao/RoseSong"
fi
pkgname='rosesong-bin'
pkgver='1.0.0'
pkgrel=1
pkgdesc='使用rust实现的CLI音频播放器,通过gstreamer解码播放b站视频的音频/ A CLI audio player implemented in Rust that decodes and plays the audio of bilibili videos using GStreamer.'
arch=('x86_64')
url="${_upstream}"
license=('MIT')
depends=('gstreamer' 'dbus' 'openssl')
source=("${_upstream}/archive/refs/tags/v$pkgver.tar.gz")
sha256sums=('SKIP')
makedepends=('cargo')
prepare() {
cd $srcdir/RoseSong-$pkgver/rosesong-cli
export RUSTUP_TOOLCHAIN=stable
cargo fetch --locked --target "$CARCH-unknown-linux-gnu"
}
build() {
cd $srcdir/RoseSong-$pkgver/rosesong-cli
export RUSTUP_TOOLCHAIN=stable
export RUSTUP_TOOLCHAIN=stable
export CARGO_TARGET_DIR=target
cargo build --frozen --release --all-features
}
check() {
cd $srcdir/RoseSong-$pkgver/rosesong-cli
export RUSTUP_TOOLCHAIN=stable
export RUSTUP_TOOLCHAIN=stable
cargo test --frozen --all-features
}
package() {
cd $srcdir/RoseSong-$pkgver/rosesong-cli
export RUSTUP_TOOLCHAIN=stable
find target/release \
-maxdepth 1 \
-executable \
-type f \
-exec install -Dm0755 -t "$pkgdir/usr/bin/" {} +
install -Dm644 ../LICENSE "$pkgdir"/usr/share/licenses/$pkgname/LICENSE
}
离线
rust 软件包打包可以参考官方仓库类似包的方式,比如 zellij.
另外就是我觉得没有必要拆分出 'rosesogn-gitee' 'rosesong-git' 'rosesong-gitee-git' 这么三个包。
按照archwiki 的说明的话,一个包通常只会打出三个包名 pkgname (上游源码release构建出来的), pkgname-bin(上游发布的二进制), pkgname-git (上游最新提交打出来的)。
整一个 -gitee 和 -gitee-git实在没必要。
还有就是 shasum 可以通过 `updpkgsums` 命令去自动更新。它会去下载 sources 里面的资源并更新 shasum.
离线
页次: 1