ArchLinux本地仓库进价

介绍

前面教程我做过本地仓库,而且还能支持离线安装Archlinux。

现在,当你的本地仓库包多了,甚至里面有不少的自制包,还有那些过期的包如果管理。别急,在这里我可以用文章为你介绍如何更好的管理本地仓库,甚至局域网仓库!当然,你也可以把你自己做好的仓库分享到互联网上去。让其添加到Archlinux里的AUR推荐源列表上。但是,要注意了,不要把无版权的东西随意添加的互联网上,不然要吃官司的。

安装repoctl和查看使用方法

官方直达连接https://github.com/cassava/repoctl

1
2
3
sudo pacman -S repoctl -i
sudo pacman -S repoctl
repoctl --help

使用前的准备

在你使用repoctl之前,你需要创建一个配置文件。这告诉repoctl您的本地存储库在哪里,等等。由于没有人真的喜欢这个步骤,repoctl可以为你写一个默认配置。它还会告诉你它在哪里写配置文件,以便以后可以更改它。

假设你想要你的仓库在~/custompkgs/x86_64/,并且想要命名它custompkgs。然后你会运行:

1
2
repoctl new config ~/custompkgs/x86_64/custompkgs.db.tar.gz
repoctl add ~/custompkgs/x86_64/*.pkg.tar.xz

但是还差一些东西,你需要编辑这个配置文件以适合使用要求

1
sudo nano ~/.config/repoctl/config.toml

灵活使用repoctl工具

如果前面的准备做好了,你可以直接这样做,

1
2
3
4
5
6
7
8
9
10
11
12
sudo nano /etc/pacman.conf 

#这个东西你可以按照需要确定放到哪个位置!不懂的,可以直接放到最后一行
[custompkgs]
SigLevel = Never #表示忽略包签名
#SigLevel = Optional TrustAll
Server = file:///home/[你的用户名]/custompkgs/$arch
#说明,如果你想添加这个,你必须把[文件名].db.tar.gz放到~/custompkgs/x86_64/里面。不然会说数据库错误!

#然后直接更新源
sudo pacman -Syu
sudo pacman -S [仓库里的包名]

如果你已经添加做好的包到~/custompkgs/x86_64/,你可以运行

1
repoctl update #运行repoctl update之前,一定要确认好是否保留旧包,否则请先跳过这个命令

如果你想保留旧版本的包,你可以这样做

1
2
3
4
5
6
sudo nano ~/.config/repoctl/config.toml

# ...
backup = true
backup_dir = ""
...

如果你想支持本地分享远程仓库,以支持非本地互联网用户使用,不好意思,我对sshfs这个包不太了解,只能使用其它工具挂载远程仓库,如果你有不错的方法,可以告诉我。

1
2
3
sudo pacman -S sshfs
sshfs --help
??????

如果你想查看有什么需要升级,你可以这样做

1
repoctl status -a

如果你想获取所有可以升级的AUR,你可以这样做

1
2
repoctl down -u -l #注意,一定要在指定的临时目录使用。比如/tmp/[文件名],可以加快编译速度 
# -u:表示获取所有可升级的aur脚本。-l:表示强制覆盖文件,不会覆盖无关文件

如果你想makepkg脚本后,把编译好的包自动添加到custompkgs仓库中,你可以这样做

1
2
3
4
5
sudo nano /etc/makepkg.conf

#...
PKGDEST=~/custompkgs/x86_64
...

我的repoctl配置文件内容如下

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
# repoctl configuration

# repo is the full path to the repository that will be managed by repoctl.
# The packages that belong to the repository are assumed to lie in the
# same folder.
repo = "/home/[用户名]/custompkgs/x86_64/custompkgs.db.tar.gz"

# add_params is the set of parameters that will be passed to repo-add
# when it is called. Specify one time for each parameter.
#原因未知
add_params = [
"-v"
]

# rm_params is the set of parameters that will be passed to repo-remove
# when it is called. Specify one time for each parameter.
rm_params = []

# ignore_aur is a set of package names that are ignored in conjunction
# with AUR related tasks, such as determining if there is an update or not.
ignore_aur = []

# backup specifies whether package files should be backed up or deleted.
# If it is set to false, then obsolete package files are deleted.
#让旧包留在仓库里,永远不要自动清理
backup = true

# backup_dir specifies which directory backups are stored in.
# - If a relative path is given, then it is interpreted as relative to
# the repository directory.
# - If the path here resolves to the same as repo, then obsolete packages
# are effectively ignored by repoctl, if backup is true.
#指定旧包的路径,如果仓库里的旧包和与backup_dir指定路径里的旧包冲突,那么仓库里的旧包会覆盖backup_dir指定路径里的旧包。
backup_dir = ""

# interactive specifies that repoctl should ask before doing anything
# destructive.
interactive = false

# columnate specifies that listings should be in columns rather than
# in lines. This only applies to the list command.
columnate = true

# color specifies when to use color. Can be one of auto, always, and never.
color = "auto"

# quiet specifies whether repoctl should print more information or less.
# I prefer to know what happens, but if you don't like it, you can change it.
quiet = false

# pre_action is a command that should be executed before doing anything
# with the repository, like reading or modifying it. Useful for mounting
# a remote filesystem.
#无法使用
#pre_action = "sshfs host:www.pkgs.me /home/[用户名]/custompkgs/x86_64/"

# post_action is a command that should be executed before exiting.
#无法使用
#post_action = "fusermount -u /home/[用户名]/custompkgs/x86_64/"

# action_on_completion determines whether repols should perform the
# actions or not. By default, this is disallowed.
action_on_completion = true

小提示

有了本地仓库,但是问题来了,我本地仓库里有包,但是我不想下载,想直接安装,怎么办?

如果你想把仓库里的包导入到下载的缓存里面,也就是说,如果pacman搜了一个包,只要本地缓存里面有的,直接安装,不必要下载多余的包!

1
2
3
4
5
6
sudo nano /etc/pacman.conf


#CacheDir = /var/cache/pacman/pkg/
CacheDir = /home/[用户名]/custompkgs/x86_64/

AUR里的包确实比较麻烦!你需要改变,缺点就是必须手动makepkg,它会自动添加到指定仓库里。而我只是做个定时检测/tmp目录是否有包的脚本。

1
2
3
4
5
6
7
sudo nano /etc/makepkg.conf

...
#PKGDEST=/home/packages
PKGDEST=/home/[用户名]/custompkgs/x86_64
...