Gentoo ebuild repository
在 Gentoo Linux Sway fcitx中文输入 安装了 小企鹅输入法fcitx 5
,带来一个问题,就是相应的输入法引擎的 ebuild
都是采用了 根据SLOT确定版本 4
。
这样就需要自己修改 ebuild
,然后通过自建的 ebuild repository 来提供overlay仓库:
创建ebuild repository可以存放Portage安装的 ebuild
在 ebuild repository 中添加 ebuild 之后,就可以与他人共享
创建 ebuild repository 和 ebuild 可以帮助我们从根本上了解跟多有关 Gentoo的工作原理
发布 ebuild repository 也是为社区作出贡献的好方法
创建一个空的 ebuild repository
首先安装
app-eselect/eselect-repository
和dev-util/pkgdev
(用于创建ebuild包Manifest文件):
app-eselect/eselect-repository
和 dev-util/pkgdev
emerge --ask app-eselect/eselect-repository
emerge --ask dev-util/pkgdev
使用
eselect repository create <repository_name>
可以创建仓库名:
cloud-atlas
eselect repository create cloud-atlas
此时输出显示:
--2024-01-02 23:23:37-- https://qa-reports.gentoo.org/output/repos/repositories.xml
Resolving qa-reports.gentoo.org... 146.75.113.91, 2a04:4e42:8c::347
Connecting to qa-reports.gentoo.org|146.75.113.91|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 258689 (253K) [text/xml]
Saving to: ‘/root/.cache/eselect-repo/repositories.xml’
repositories.xml 100%[======================================================>] 252.63K 672KB/s in 0.4s
2024-01-02 23:23:40 (672 KB/s) - ‘/root/.cache/eselect-repo/repositories.xml’ saved [258689/258689]
Adding cloud-atlas to /etc/portage/repos.conf/eselect-repo.conf ...
Repository cloud-atlas created and added
检查生成的 /etc/portage/repos.conf/eselect-repo.conf
配置文件,就可以看到 cloud-atlas
命名的仓库对应的指定位置就是 /var/db/repos/cloud-atlas
:
/etc/portage/repos.conf/eselect-repo.conf
# created by eselect-repo
[cloud-atlas]
location = /var/db/repos/cloud-atlas
备注
一些用户会将只用于单台主机的个人软件包存凡在一个名为 local
的 ebuild repository,也就是使用 eselect repository create local
命令来创建
如果创建一个用于发布的repository,该repository包含一个主要的软件包以及依赖软件包,那么给仓库器一个和内容相关的名称会有所绊住(ebuild仓库通常以维护人的名字命名,但不总是最具描述性的名称)。这个方式同样适合伯阿汉特定主题为中心的软件包仓库。
跟踪变化(可选)
在创建和维护任何ebuild仓库是,使用版本控制系统是良好的做法:
版本控制系统可以跟踪ebuild文件的更改并允许撤销错误
版本控制提供了检索信息方便了解ebuild仓库变化
Portage 支持多个版本控制系统自动提供ebuild仓库同步,可以从Portage可用的ebuild仓库检索更新
git
git维护ebuild仓库优点:
git允许不同的版本分支,这对测试非常有用
git提供了简单的
diff
工具以及其他功能,可以帮助创建和维护ebuild仓库
执行步骤:
对上文创建的
cloud-atlas
仓库进行git初始化:
git init
初始化 ebulid 仓库cd /var/db/repos/cloud-atlas
git init
git add .
git commit
添加ebuild到仓库
创建按照类别名和应用名的目录,例如我这里为 Gentoo Linux Sway fcitx中文输入 构建一个 根据SLOT确定版本
5
的app-i18n/fcitx-rime
ebuild,则对应建立子目录app-i18n/fcitx-rime
,然后在目录下复制好自己定制的fcitx-rime-0.3.2.ebuild
:
mkdir -p /var/db/repos/cloud-atlas/app-i18n/fcitx-rime
cp ~/fcitx-rime-0.3.2.ebuild /var/db/repos/cloud-atlas/app-i18n/fcitx-rime/fcitx-rime-0.3.2.ebuild
# 目录权限订正
chown -R portage:portage /var/db/repos/cloud-atlas
# 运行 pkgdev manifest 创建软件包的Manifest文件
cd /var/db/repos/cloud-atlas/app-i18n/fcitx-rime
pkgdev manifest
这里采用了自己修订的 fcitx-rime-0.3.2.ebuild
(修订为 SLOT 5
依赖) :
5
app-i18n/fcitx-rime
ebuild# Copyright 2024 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2
EAPI=8
inherit cmake xdg-utils
if [[ "${PV}" =~ (^|\.)9999$ ]]; then
inherit git-r3
EGIT_REPO_URI="https://github.com/fcitx/fcitx-rime"
fi
DESCRIPTION="Chinese RIME input methods for Fcitx"
HOMEPAGE="https://fcitx-im.org/ https://github.com/fcitx/fcitx-rime"
if [[ "${PV}" =~ (^|\.)9999$ ]]; then
SRC_URI=""
else
SRC_URI="https://download.fcitx-im.org/${PN}/${P}.tar.xz"
fi
SRC_URI=""
LICENSE="GPL-2"
SLOT="5"
KEYWORDS="amd64 ppc ppc64 ~riscv x86"
DEPEND=">=app-i18n/fcitx-5.1.5:5
virtual/pkgconfig"
DEPEND=">=app-i18n/fcitx-5.1.5:5
>=app-i18n/librime-1.0.0:=
virtual/libintl"
RDEPEND="${DEPEND}
app-i18n/rime-data"
DOCS=()
src_configure() {
local mycmakeargs=(
-DRIME_DATA_DIR="${EPREFIX}/usr/share/rime-data"
)
cmake_src_configure
}
pkg_postinst() {
xdg_icon_cache_update
}
pkg_postrm() {
xdg_icon_cache_update
}
在完成索引之后,就可以进行安装:
5
app-i18n/fcitx-rime
emerge --ask app-i18n/fcitx-rime
此时输出显示:
5
app-i18n/fcitx-rime
输出信息Calculating dependencies... done!
Dependency resolution took 1.22 s (backtrack: 0/20).
[ebuild N ] dev-util/b2-4.10.1::gentoo USE="-examples" 960 KiB
[ebuild N ] dev-cpp/tclap-1.2.5::gentoo USE="-doc" 4,044 KiB
[ebuild N ] dev-libs/marisa-0.2.6::gentoo USE="-debug -python -static-libs" PYTHON_TARGETS="python3_11 -python3_10" 165 KiB
[ebuild N ] dev-libs/darts-0.32h_pre20181117064816::gentoo 38 KiB
[ebuild N ] sys-libs/libunwind-1.7.2:0/8::gentoo USE="zlib -debug -debug-frame -doc -libatomic -lzma -static-libs -test" 918 KiB
[ebuild N ] dev-cpp/yaml-cpp-0.8.0:0/0.8::gentoo USE="-test" 994 KiB
[ebuild N ] dev-libs/boost-1.84.0-r1:0/1.84.0::gentoo USE="bzip2 context nls stacktrace zlib -debug -doc -icu -lzma -mpi -numpy -python -tools -zstd" PYTHON_TARGETS="python3_11 -python3_10 -python3_12" 120,226 KiB
[ebuild N ] dev-libs/capnproto-0.10.4-r1:0/0.10.4::gentoo USE="ssl zlib -test" 2,227 KiB
[ebuild N ] dev-libs/utfcpp-3.2.1::gentoo USE="-test" 27 KiB
[ebuild N ] dev-libs/crc32c-1.1.2-r2::gentoo USE="-test" 30 KiB
[ebuild N ] app-arch/snappy-1.1.10-r1:0/1.1::gentoo USE="-test" CPU_FLAGS_X86="avx avx2" 1,080 KiB
[ebuild N ] dev-libs/rapidjson-1.1.0-r4::gentoo USE="-doc -examples -test" 996 KiB
[ebuild N ] app-i18n/opencc-1.1.4:0/1.1::gentoo USE="-doc -test" 2,742 KiB
[ebuild N ] dev-cpp/glog-0.6.0:0/1::gentoo USE="libunwind -gflags -llvm-libunwind -test" 189 KiB
[ebuild N ] dev-util/google-perftools-2.10-r1:0/4::gentoo USE="debug -largepages -largepages64k -llvm-libunwind -minimal -optimisememory -static-libs -test" 905 KiB
[ebuild N ] dev-libs/leveldb-1.23-r5:0/1::gentoo USE="snappy tcmalloc -test" 238 KiB
[ebuild N ] app-i18n/librime-1.7.3-r1:0/1-1.7.3::gentoo USE="-debug -test" 2,793 KiB
[ebuild N ] app-i18n/rime-data-0.38.20180515::gentoo USE="-extra" 6,951 KiB
[ebuild N ] app-i18n/fcitx-rime-0.3.2:5::cloud-atlas 0 KiB
Total: 19 packages (19 new), Size of downloads: 145,514 KiB
Would you like to merge these packages? [Yes/No]
可以看到安装 app-i18n/fcitx-rime
采用了我定制的 cloud-atlas
仓库下的 ebuild
,覆盖(overlay)了默认的 gentoo
仓库
备注
我发现 app-i18n/fcitx-rime
安装软件包非常庞大,主要是因为它依赖了Google提供的 leveldb
( tcmalloc
参数引入了庞大的 dev-libs/boost
),这是一个性能非常好的KV数据库,但是感觉我为了一个输入法安装如此庞大的依赖有些得不偿失。
方法已经走通,我目前先尝试采用 fcitx
内置的简单拼音输入法(可能选词算法比较差些)