目录

1 引言

2 ubuntu本地仓库

3 本地仓库创建工具

3.1 reprepro参数

3.2 reprepro应用

4 网页服务器配置

参考


1 引言

reprepro 是用于管理 deb 格式软件包,生成用于分发的仓库管理工具。 支持 .dsc/.deb/.udeb 等格式;会根据配置生成 Packages/Sources 文件以及压缩版本。
简而言之:我们可以用这个工具来建立私有的本地 deb 仓库,而不需要将包推到操作系统官方仓库就能使用。

2 reprepro介绍

reprepro的项目地址:https://salsa.debian.org/brlink/reprepro

reprepro的使用方法:http://mirror.physics.ox.ac.uk/ubuntu/oxford-local-testing/reprepro/docs/manual.html

https://manpages.debian.org/stretch/reprepro/reprepro.1.en.html

下面分几个步骤介绍 reprepo 的用法 (有关gpg密钥的问题请看上一章)

  • 安装

  • 配置

  • 仓库对外服务需要搭建 web 服务器

  • deb 包的管理操作

3 本地仓库创建工具

1)安装工具

sudo apt install reprepro nginx

2)创建本地仓库目录与配置文件

mkdir -p /var/repositories/
cd /var/repositories/

创建配置目录

mkdir conf
cd conf/

创建配置文件

touch options distributions
  • distributions 文件用于描述不同仓库
  • options 则用于描述仓库本身的选项

distribution中的内容:

Origin: Ubuntu
Suite: focal
Label: test
Codename: focal
Architectures: arm64 armhf
Components: main
Description: local repository for ubuntu
SignWith: *********
  • origin,suite, lable,codename:是仓库的信息,可以自定义。按照 debian 与 ubuntu 的惯例,一般 codenam 与 suite 一致,都是各个版本的代号。
  • Architectures:表示该仓库支持那些系统架构的包,以及是否支持源码包
  • Components:表示仓库将包含哪些种类的包,main为官方支持,完全开源,参考ubuntu定义
  • Description:是本仓库的描述信息
  • SignWith:使用一个gpg密钥来签名(gpg --list-keys命令查看有哪些密钥)

 options中的内容:

verbose
basedir /repo/directory(仓库位置)

3.1 reprepro应用

# 列出某个 suite 下 的所有包
 reprepro -b ${REPO_PATH} list  ${suite}

# 删除包
 reprepro -b ${REPO_PATH} remove  ${suite} ${package name}

# 添加包
 reprepro -C ${component} -b ${REPO_PATH} -S utils includedeb ${suite} /path/to/deb

也可以提前根据设置将仓库创建好,命令如下:

reprepro -Vb ${REPO_PATH} export

参数含义:

-v, -V, --verbose
-b, --basedir basedir
Sets the base-dir all other default directories are relative to. If none is supplied and the REPREPRO_BASE_DIR environment variable is not set either, the current directory will be used.

仓库创建之后,如果要应用该仓库,应向apt中导入密钥:

apt-key add keyname

4 网页服务器配置

构建了本地仓库后。接下来,我们将使用网络服务器:Nginx,以将该本地库公开。

修改nginx配置文件:

nano /etc/nginx/sites-available/default

替换为:

server {## Let your repository be the root directoryroot        /var/repositories;## Always good to logaccess_log  /var/log/nginx/repo.access.log;error_log   /var/log/nginx/repo.error.log;## Prevent access to Reprepro's fileslocation ~ /(db|conf) {deny        all;return      404;}
}

其中,禁止访问:db和conf文件夹。

重启生效:

service nginx restart

此时,查看环境的IP地址

ifconfig eth0eth0      Link encap:Ethernet  HWaddr 04:01:23:f9:0e:01inet addr:198.199.114.168  Bcast:198.199.114.255  Mask:255.255.255.0inet6 addr: fe80::601:23ff:fef9:e01/64 Scope:LinkUP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1RX packets:16555 errors:0 dropped:0 overruns:0 frame:0TX packets:16815 errors:0 dropped:0 overruns:0 carrier:0collisions:0 txqueuelen:1000RX bytes:7788170 (7.7 MB)  TX bytes:3058446 (3.0 MB)

我们测试一下,是否可以访问该仓库,在浏览器中输入:http://198.199.114.168/  (实际IP地址由你的平台决定)

访问正常后,我们将该地址添加到source.list

add-apt-repository "deb http://198.199.114.168/ focal main"

更新源:

apt-get update

更新之后,我们就可以安装上传到本地仓库中的包。

5 错误解决

5.1 reprepro报错

Could not find any key matching 'DD219672'!
ERROR: Could not finish exporting 'unstable'!
This means that from outside your repository will still look like before (and
should still work if this old state worked), but the changes intended with this
call will not be visible until you call export directly (via reprepro export)

reprepro工具使用基于的gnupg2,如果使用gpg创建新密钥,gpg2是无法被应用的,所以执行如下操作。(关于如何免密操作,请看上一章)

gpg --export-secret-keys | gpg2 --import -

5.2 nginx报错

Nginx出现403 forbidden (13: Permission denied)报错

nginx log中出现如下提示,缺少权限。

open() "/data/www/1.txt" failed (13: Permission denied), client: 192.168.1.194, server: www.web1.com, request: "GET /1.txt HTTP/1.1", host: "www.web1.com"

将nginx.config的user改为和启动用户一致,

命令:

vi conf/nginx.conf
user root; (我的用户为root)
worker_processes 1;

参考

https://claystan.gitee.io/post/%E4%BD%BF%E7%94%A8reprepro%E6%90%AD%E5%BB%BA%E6%9C%AC%E5%9C%B0apt%E4%BB%93%E5%BA%93/

https://www.digitalocean.com/community/tutorials/how-to-use-reprepro-for-a-secure-package-repository-on-ubuntu-14-04

https://momoka.net/posts/2019/2019-0009-reprepro-prime/

https://qastack.cn/server/770130/reprepro-export-could-not-find-signing-key

https://blog.csdn.net/onlysunnyboy/article/details/75270533

【五】ubuntu创建本地仓库相关推荐

  1. Maven创建本地仓库

    Maven创建本地仓库 一般我们使用maven仓库的时候都是默认的C盘中的.m2,但是如果把所有的jar包都下载到C盘中必定会造成电脑卡顿现象,所以我们就有必要创建一个自己的maven本地仓库. 第一 ...

  2. git 创建本地仓库与 gitcafe 关联

    git init # 创建本地仓库 # 设置远程仓库地址,这里可以设置ssh 或 https 的形式,此处设置为https 格式, # ssh 格式为 : git remote add origin ...

  3. git 创建本地仓库、远程仓库,上传项目

    1.在本地想创建git仓库的地方创建本地仓库 首先右键打开 Git Bash Here,如果没有,请先安装git,下载地址:https://git-scm.com/downloads git init ...

  4. 01git创建本地仓库及操作入门

    git工作流程图 git常用命令 命令 作用 git init 初始化,创建 git 仓库 git status 查看 git 状态 (文件是否进行了添加.提交操作) clone (克隆) 从远程仓库 ...

  5. git创建本地仓库和github仓库

    原文链接 git创建仓库 创建本地仓库 前提:已经在本地安装好git环境 首先新建一个文件夹,linux环境下命令如下(其它环境自己动手建吧): mkdir test (创建test文件夹) cd t ...

  6. Git学习之旅:Mac安装Git与创建本地仓库(一)

    Git简述:版本管理工具,git的英文直译就是饭桶.最初只应用于linux,现在应用十分广泛. git一般工作流程:1.从远程仓库中克隆Git资源作为本地仓库.2.从本地仓库中checkout代码然后 ...

  7. 创建本地仓库连接远程gitee

    创建本地仓库连接远程gitee 安装git git官网 淘宝镜像地址(推荐) power shell中用winget安装 git本地仓库 初始化本地仓库 连接远程仓库 测试 上传 提交到暂存区 提交到 ...

  8. git创建本地仓库远程仓库,并关联。全过程

    1.在网页中自己的github账号下,创建仓库project 2.在本机创建文件夹project. 进入文件夹project. (1) git init (2) git add README.md ( ...

  9. Docker(五)创建本地镜像

    容器实际上是在父镜像的基础上创建了一个可读写的文件层级,所有的修改操作都在这个文件层级上进行,而父镜像并未受到影响,根据这种修改创建新的本地镜像,有两种不同的方式 方式一:      1.创建容器   ...

最新文章

  1. Elasticsearch 知识点目录
  2. 专访思必驰初敏:离开微软、放弃阿里,一个语音交互的“实用主义者”
  3. Kettle使用_5 结合js的数据处理与SetVariable设置动态表输入
  4. js中同时得到整数商及余数_js和vue实现时分秒倒计时的方法
  5. 没有内存条电脑能开机吗_电脑没内存条能开机吗?这位朋友说他的电脑没内存条都用几年了!...
  6. 通俗易懂,常用线程池执行的-流程图
  7. OpenBSD 5.1 正式版发布
  8. wireshark数据包分析实战 第三、四章
  9. 从数据仓库双集群系统模式探讨,看GaussDB(DWS)的容灾设计
  10. 最长回文子串java_5. 最长回文子串
  11. Jsp 【项目路径】
  12. QT D:\搜狗输入法\SogouInput\Components\ 13:53:42: 程序异常结束。 13:53:42: T
  13. 现代数字信号处理——维纳滤波原理及自适应算法
  14. springboot证书管理系统的设计与实现毕业设计源码162317
  15. PostgreSQL 源码解读(152)- PG Tools#4(ReceiveXlogStream)
  16. r语言boxcox异方差_R教程-15:线性回归中的异方差
  17. 移动开发唱衰,iOS 开发者如何涅槃重生?
  18. 微信小程序--搜索框样式 及form提交实现
  19. 支付宝授权登录免费源码奉献
  20. AssetBundle.Unload(false/true)

热门文章

  1. ios测试闪存用什么软件,TLC还是MLC?教你检测iPhone6闪存类型
  2. 英特尔下一代服务器cpu消息,向10nm转型 英特尔下一代CPU与GPU前瞻
  3. 应急通信市场的大哥,MESH自组网的前世今生。
  4. Dolphin for Mac(Wii游戏模拟器) v5.0-14997
  5. 定义一个数组,调转数组中的数据
  6. 毕业论文致谢这么重要的事,可以这么豪横的写,致谢女友要谨慎,很可能变成前女友!...
  7. PWN lotto [pwnable.kr]CTF writeup题解系列10
  8. 百家号自媒体视频,视频消重软件,批量自动去水印加水印软件 哔哩哔哩 秒拍 爱拍百度视频...
  9. 【openwrt】如何编译和运行一个arm linux 内核
  10. layui后台管理登录