目录
ubuntu系统安装jq包本身是一件很简单的事情,但是简单+arm64+内网+百度一堆重复=耗费一上午。特此记录下安装jq包的全过程。
arm机器:& docker pull ubuntu:22.04
x86机器:& docker pull --platform=arm64 ubuntu:22.10
& docker run -it --rm ubuntu:22.04 bash
& apt install jq

# ok,那就先update尝试下
& apt update
& The following signatures couldn't be verified because the public key is not available: NO_PUBKEY 871920D1991BC93C
注意:x86版本的官方源用的是Index of /ubuntu
http://archive.ubuntu.com/ubuntu/ , arm版本官方源用的是Index of /ubuntu-ports
http://ports.ubuntu.com/ubuntu-ports/
国内源使用方法是
cat > /etc/apt/sources.list << EOF
deb http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse
EOF
x86是可以直接update然后安装jq的,arm无论使用官方源还是国内源都会报
# 按照网上解决方案
& apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 871920D1991BC93C
& apt-get install gnupg
& 报错:E: gnupg, gnupg2 and gnupg1 do not seem to be installed, but one of them is required for this operation 和 Package 'gnupg' has no installation candidate

# 发现,我起初因为安装jq包时没有源,才修改apt源仓库地址;修改源仓库需要public key认证;public key认证需要安装gnupg包;安装gnupg包需要配置源仓库。
# 结论:我想配置apt源仓库,首先需要有一个apt源能用,死循环了。。。
# 直接配置apt源仓库的路看来走不通了,尝试通过本地下载文件安装方式
# 先去开源网站找到jq包Index of /ubuntu-ports/pool/main/j/jq/ | 清华大学开源软件镜像站 | Tsinghua Open Source MirrorIndex of /ubuntu-ports/pool/main/j/jq/ | 清华大学开源软件镜像站,致力于为国内和校内用户提供高质量的开源软件镜像、Linux 镜像源服务,帮助用户更方便地获取开源软件。本镜像站由清华大学 TUNA 协会负责运行维护。
https://mirrors.tuna.tsinghua.edu.cn/ubuntu-ports/pool/main/j/jq/ & docker cp jq_1.6-2.1ubuntu3_arm64.deb 0b3134dbcaa7:/
& apt install ./jq_1.6-2.1ubuntu3_arm64.deb

# 安装jq需要libjq1依赖,我们需要一层一层把所有关联包找到对应版本,才能安装。那么此时有个问题,我们需要的依赖包名称和版本可以通过install报错得到,如何下载到本地deb文件。
# 你可以直接在镜像站根据名称首字母查找,但是有些特殊的,例如libjq属于jq下面,你去libj下面找不到。


# 可以在这个网站查询https://ubuntu.pkgs.org/22.04/ubuntu-main-arm64/
https://ubuntu.pkgs.org/22.04/ubuntu-main-arm64/ # 直接查询libjq1

# 点进去有个download可以看到官方镜像站位置,其他国内镜像站目录也是一致的。
6、本地安装arm架构的jq包 # 此时可以找到所有的本地deb文件了,复制到ubuntu容器内直接安装吧
& apt install ./libc-bin_2.35-0ubuntu3.1_arm64.deb ./libc6_2.35-0ubuntu3.1_arm64.deb ./libjq1_1.6-2.1ubuntu3_arm64.deb ./libonig5_6.9.8-1_arm64.deb ./jq_1.6-2.1ubuntu3_arm64.deb
