基于apt-mirror同步kylin v4 源及构建本地源
1. 需求和环境
需求:满足离线环境下,可以通过apt-get获取kylin软件包.我们通过x86的设备同步软件包,然后构建本地源。
客户端:X86笔记本
客户端OS版本:Ubuntu 20.04.4 LTS x86_64
2. 同步源到本地
2.1 安装apt-mirror
deb源提供了同步工具apt-mirror用于同步基于deb系统(debian/ubuntu)的源。安装软件包如下:
apt-get install apt-mirror
1
2.2 配置apt-mirror
编辑文件/etc/apt/mirror.list,如下:
# 同步的镜像等文件存放目录
set base_path /var/spool/apt-mirror
# 架构配置,arm64/amd64,默认的话会下载跟本机相同的架构的源,这里指定arm64的
set defaultarch arm64
# 下载线程数
set nthreads 20
set _tilde 0
# 同步源
############# config ##################
#
# set base_path /var/spool/apt-mirror
#
# set mirror_path $base_path/mirror
# set skel_path $base_path/skel
# set var_path $base_path/var
# set cleanscript $var_path/clean.sh
# set defaultarch <running host architecture>
# set postmirror_script $var_path/postmirror.sh
# set run_postmirror 0
set nthreads 20
set _tilde 0
#
############# end config ##############
deb http://mirrors.aliyun.com/ubuntu jammy main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu jammy-security main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu jammy-updates main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu jammy-proposed main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu jammy-backports main restricted universe multiverse
deb http://ubuntu-cloud.archive.canonical.com/ubuntu jammy-proposed/zed main InRelease
deb http://ubuntu-cloud.archive.canonical.com/ubuntu jammy-updates/zed main amd64 Packages
deb-src http://mirrors.aliyun.com/ubuntu jammy main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu jammy-security main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu jammy-updates main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu jammy-proposed main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu jammy-backports main restricted universe multiverse
deb-src http://ubuntu-cloud.archive.canonical.com/ubuntu jammy-proposed/zed InRelease
deb-src http://ubuntu-cloud.archive.canonical.com/ubuntu jammy-updates/zed main amd64 Packages
clean http://mirrors.aliyun.com/ubuntu
2.3 同步源
可支持断点续传,随时中断随时继续如下:
apt-mirror
1
以下为多次同步的过程记录:
root@ubuntu:~# apt-mirror
Downloading 38 index files using 20 threads...
Begin time: Fri Jul 8 03:13:39 2022
[20]... [19]... [18]... [17]... [16]... [15]... [14]... [13]... [12]... [11]... [10]... [9]... [8]... [7]... [6]... [5]... [4]... [3]... [2]... [1]... [0]...
End time: Fri Jul 8 03:13:40 2022
Processing translation indexes: [T]
Downloading 0 translation files using 0 threads...
Begin time: Fri Jul 8 03:13:40 2022
[0]...
End time: Fri Jul 8 03:13:40 2022
Processing DEP-11 indexes: [D]
Downloading 0 dep11 files using 0 threads...
Begin time: Fri Jul 8 03:13:40 2022
[0]...
End time: Fri Jul 8 03:13:40 2022
Processing indexes: [PUse of uninitialized value $lines{"Files:"} in split at /usr/bin/apt-mirror line 829, <STREAM> line 3281.
Use of uninitialized value $lines{"Files:"} in split at /usr/bin/apt-mirror line 829, <STREAM> line 3414.
Use of uninitialized value $lines{"Files:"} in split at /usr/bin/apt-mirror line 829, <STREAM> line 3489.
Use of uninitialized value $lines{"Files:"} in split at /usr/bin/apt-mirror line 829, <STREAM> line 3689.
Use of uninitialized value $lines{"Files:"} in split at /usr/bin/apt-mirror line 829, <STREAM> line 3711.
Use of uninitialized value $lines{"Files:"} in split at /usr/bin/apt-mirror line 829, <STREAM> line 3827.
Use of uninitialized value $lines{"Files:"} in split at /usr/bin/apt-mirror line 829, <STREAM> line 3847.
Use of uninitialized value $lines{"Files:"} in split at /usr/bin/apt-mirror line 829, <STREAM> line 3850.
Use of uninitialized value $lines{"Files:"} in split at /usr/bin/apt-mirror line 829, <STREAM> line 3882.
Use of uninitialized value $lines{"Files:"} in split at /usr/bin/apt-mirror line 829, <STREAM> line 4386.
......
Use of uninitialized value $lines{"Files:"} in split at /usr/bin/apt-mirror line 829, <STREAM> line 38173.
Use of uninitialized value $lines{"Files:"} in split at /usr/bin/apt-mirror line 829, <STREAM> line 41169.
Use of uninitialized value $lines{"Files:"} in split at /usr/bin/apt-mirror line 829, <STREAM> line 41272.
Use of uninitialized value $lines{"Files:"} in split at /usr/bin/apt-mirror line 829, <STREAM> line 41337.
Use of uninitialized value $lines{"Files:"} in split at /usr/bin/apt-mirror line 829, <STREAM> line 41340.
Use of uninitialized value $lines{"Files:"} in split at /usr/bin/apt-mirror line 829, <STREAM> line 41356.
Use of uninitialized value $lines{"Files:"} in split at /usr/bin/apt-mirror line 829, <STREAM> line 41442.
Use of uninitialized value $lines{"Files:"} in split at /usr/bin/apt-mirror line 829, <STREAM> line 482.
Use of uninitialized value $lines{"Files:"} in split at /usr/bin/apt-mirror line 829, <STREAM> line 526.
]
35.0 GiB will be downloaded into archive.
Downloading 15228 archive files using 20 threads...
Begin time: Fri Jul 8 03:13:53 2022
[20]... [19]... [18]... [17]... [16]... [15]... [14]... [13]... [12]... [11]... [10]... [9]... [8]... [7]... [6]... [5]... [4]... [3]... [2]... [1]... [0]...
End time: Sun Jul 10 09:25:56 2022
0 bytes in 0 files and 0 directories can be freed.
Run /var/spool/apt-mirror/var/clean.sh for this purpose.
Running the Post Mirror script ...
(/var/spool/apt-mirror/var/postmirror.sh)
Post Mirror script has completed. See above output for any possible errors.
root@ubuntu:~#
3. 构建本地源
3.1 基于file模式
编辑/etc/apt/sources.list,我们这里在x86下验证,需要加入架构信息,因为源同步的是arm64的,如下:
deb [arch=arm64] file:///var/spool/apt-mirror/mirror/archive.kylinos.cn/kylin/KYLIN-ALL 4.0.2sp2-server main restricted universe multiverse
1
若直接拷贝至arm64服务器构建本地源则sources.list文件中不需要加入arch=arm64,apt-get update出现如下信息即可
root@ubuntu:~# apt-get update
Get:1 file:/var/spool/apt-mirror/mirror/archive.kylinos.cn/kylin/KYLIN-ALL 4.0.2sp2-server InRelease [49.6 kB]
Get:1 file:/var/spool/apt-mirror/mirror/archive.kylinos.cn/kylin/KYLIN-ALL 4.0.2sp2-server InRelease [49.6 kB]
Reading package lists... Done
3.2 基于http模式
暂基于Ubuntu 20.04.4 LTS x86_64构建http,安装apache2如下:
apt-get install apache2
1
由于Apache2的默认网页文件目录位于/var/www/html,因此,可以做个软链接
ln -s /var/spool/apt-mirror/mirror/archive.kylinos.cn/kylin/KYLIN-ALL /var/www/html/KYLIN-ALL
1
重启apache2服务。
需要安装软件的服务器编辑/etc/apt/sources.list如下:
deb http://x.x.x.x/KYLIN-ALL 4.0.2sp2-server main restricted universe multiverse
1
x.x.x.x代表http服务器地址。服务器上执行apt-get update就可以用了
4. 问题记录
The following signatures couldn’t be verified because the public key is not available: NO_PUBKEY F49EC40DDCE76770
root@ubuntu:/etc/apt# apt-get update
Get:1 http://archive.kylinos.cn/kylin/KYLIN-ALL 4.0.2sp2-server-ft2000 InRelease [49.6 kB]
Err:1 http://archive.kylinos.cn/kylin/KYLIN-ALL 4.0.2sp2-server-ft2000 InRelease
The following signatures couldn't be verified because the public key is not available: NO_PUBKEY F49EC40DDCE76770
Reading package lists... Done
W: GPG error: http://archive.kylinos.cn/kylin/KYLIN-ALL 4.0.2sp2-server-ft2000 InRelease: The following signatures couldn't be verified because the public key is not available: NO_PUBKEY F49EC40DDCE76770
E: The repository 'http://archive.kylinos.cn/kylin/KYLIN-ALL 4.0.2sp2-server-ft2000 InRelease' is not signed.
N: Updating from such a repository can't be done securely, and is therefore disabled by default.
N: See apt-secure(8) manpage for repository creation and user configuration details.
解决方案:
apt-key adv --keyserver keyserver.ubuntu.com --recv-keys F49EC40DDCE76770
5. 参考文献
https://apt-mirror.github.io/
https://manpages.ubuntu.com/manpages/xenial/man1/apt-mirror.1.html
————————————————
版权声明:本文为CSDN博主「牛角上的男孩」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.csdn.net/nanhai_happy/article/details/125716123