Ubuntu 18.04中的apt-get版本为1.6.8。 如果你使用的ubuntu版本较低,apt版本低于1.5,可使用简单的方法配置本地源。简单方法见第二部分。

第一部分,ubuntu18.04上制作本地源

步骤有:

一 创建目录:mkdir repository

二 拷贝deb文件到目录 cp /path/to/*.deb repository/

三 进入目录生成索引文件及Release文件

cd repository

apt-ftparchive packages . > Packages

apt-ftparchive release . > Release

四 生成签名

gpg --clearsign -o InRelease Release

如果这一步报如下错误:

root@serverdeb:/media/debs# gpg --clearsign -o InRelease Release
gpg: no default secret key: Unusable secret key
gpg: Release: clear-sign failed: Unusable secret key

说明需要生成gpg签名,步骤如下:

1. gpg --gen-key

对于生成签名,详细见如下:https://blog.csdn.net/qdujunjie/article/details/48291017

如果生成签名卡住(原因详见:https://www.cnblogs.com/styshoo/p/6415939.html),执行如下命令:rng -r /dev/urandom    /// 前提是安装:apt-get install rng-tools

2. gpg -a --export pub_id | apt-key add -

root@server10:/media/debs# apt-get update
Get:1 file:/media/debs  InRelease [1912 B]
Get:1 file:/media/debs  InRelease [1912 B]
Err:1 file:/media/debs  InRelease                                              
  The following signatures couldn't be verified because the public key is not available: NO_PUBKEY 5789843F6B61B0B4
Hit:2 http://apt.postgresql.org/pub/repos/apt xenial-pgdg InRelease            
Reading package lists... Done

gpg -a --export 5789843F6B61B0B4 | apt-key add -     ///其中pub key可用gpg --list-keys查到

五 gpg -abs -o Release.gpg Release

最后执行apt-get update的输出如下 :

root@server10:/media/debs# apt-get update
Get:1 file:/media/debs  InRelease [1912 B]
Get:1 file:/media/debs  InRelease [1912 B]
Get:2 file:/media/debs  Packages [74.1 kB]                                      
Hit:3 http://apt.postgresql.org/pub/repos/apt xenial-pgdg InRelease             
Reading package lists... Done

=======================================

第二部分 无签名本地源制作

apt 版本低于1.5,无须签名的本地源生成方法:
原文:https://blog.csdn.net/zp2006011242/article/details/79040172
1、在可以上网的ubuntu设备上,对想要离线安装的组件进行预处理。

(1)清理apt的下载缓存区。

sudo rm -rf /var/cache/apt/archives/*

(2)下载所需要的组件

sudo apt-get -d install <包名>

(3)创建一个目录,将下载的包拷贝到该目录下

cp -r /var/cache/apt/archives  /yout-path

(4)修改目录权限

chmod 777 -R /your-path

(5)建立deb包的依赖关系

sudo touch /your-path/Packages.gz
    sudo dpkg-scanpackages /your-path/ /dev/null  | gzip > /your-path/Packages.gz

(6)将所有下载的文件和生成的gz文件拷贝到离线的ubuntu机器上,将/etc/apt/sources.list原有内容注释掉,新增:

deb file:///var/debs/ /

(7)执行sudo apt-get update,之后就可以直接使用apt-get install 包名 来安装了
如果上面的步骤中报错说

The repository 'file:/media debs/ Release' does not have a Release file.
可用apt-get update --allow-insecure-repositories,这个时侯错误就会变成警告,也能正常安装软件。
=========================
FYI:
1. 为何apt-get 1.5版本后需要签名
man apt-secure
Starting with version 0.6, APT contains code that does signature checking of the Release file for all repositories. This ensures that data like packages in the archive can't be
       modified by people who have no access to the Release file signing key. Starting with version 1.1 APT requires repositories to provide recent authentication information for
       unimpeded usage of the repository. Since version 1.5 changes in the information contained in the Release file about the repository need to be confirmed before APT continues to
       apply updates from this repository.
2. 签名的方法出处
man apt-secure
其中REPOSITORY CONFIGURATION中
If you want to provide archive signatures in an archive under your maintenance you have to:

·   Create a toplevel Release file, if it does not exist already. You can do this by running apt-ftparchive release (provided in apt-utils).

·   Sign it. You can do this by running gpg --clearsign -o InRelease Release and gpg -abs -o Release.gpg Release.

·   Publish the key fingerprint, so that your users will know what key they need to import in order to authenticate the files in the archive. It is best to ship your key in its
           own keyring package like Ubuntu does with ubuntu-keyring to be able to distribute updates and key transitions automatically later.

·   Provide instructions on how to add your archive and key. If your users can't acquire your key securely the chain of trust described above is broken. How you can help users
           add your key depends on your archive and target audience ranging from having your keyring package included in another archive users already have configured (like the default
           repositories of their distribution) to leveraging the web of trust.

Whenever the contents of the archive change (new packages are added or removed) the archive maintainer has to follow the first two steps outlined above.

转载于:https://www.cnblogs.com/longchang/p/11088411.html

ubuntu18.04 本地源制作相关推荐

  1. ubuntu linux本地源,搭建Ubuntu 12.04 本地源

    搭建Ubuntu 12.04 本地源,彻底实现以后的内网安装OpenStack. 1. 安装apt-mirror工具 sudo apt-get install apt-mirror 或者下载源码编译, ...

  2. Ubuntu18.04启动盘制作

    Ubuntu18.04启动盘制作 ​ 之前是用我的电脑是借用老师的启动盘安装的Ubuntu18.04,因为有特殊需求,需要一个启动盘,所以打算自己这两天有空制作一个,也算是学会一项技能. 下载镜像文件 ...

  3. 更新ubuntu18.04的源 中科大源 清华源 -lubuntu 好用

    https://lubuntu.net/ 都说Lubuntu界面丑,我感觉还行啊!系统稳定,轻量级,速度还挺快,这些就很香了. lubuntu上运行的东西在 ubuntu  一样可行.用起来很顺畅.先 ...

  4. 在图形化界面中为Ubuntu18.04更新源

    背景: 在国内使用ubuntu18.04时,可能需要更新源.也就是修改 /etc/apt/sources.list文件 但是,这个对于习惯windows的人可能不是很喜欢这中方式,那么Ubuntu18 ...

  5. Ubuntu18.04换源更新国内源

    参考:Ubuntu18.04更新国内源 作者:一只青木呀 发布时间:2020-08-05 10:24:11 网址:https://blog.csdn.net/weixin_45309916/artic ...

  6. Win11上安装Ubuntu18.04双系统制作教程

    在Win11上安装Ubuntu18.04的双系统 1. 下载Ubuntu系统镜像.刻录装机U盘 2. 从windows11的硬盘中,划分出独立空间,用于安装Ubuntu 3. 重启系统,进入安装程序 ...

  7. ubuntu18.04换源(阿里无脑版)

    Ubuntu18更换软件源<=>修改源文件 sources.list 备份(可要可不要) sudo cp /etc/apt/sources.list /etc/apt/sources.li ...

  8. CentOS 6.5 PYPI本地源制作

    转载:blog.csdn.net/tantexian 一.安装pip2pi工具: pip install pip2pi 或 git clone https://github.com/wolever/p ...

  9. 本地源制作docker镜像

    2019独角兽企业重金招聘Python工程师标准>>> 首先将镜像挂载在本地 [root@zhangxc image]# cat /etc/fstab /media/sf_Cento ...

最新文章

  1. mysql pdo prepare_php pdo prepare真的安全吗
  2. 基于PyTorch+YOLOv4的口罩佩戴检测,附数据集
  3. CloudStack 4.4学习总结之注册ISO
  4. CSS权威指南(4)
  5. 临渊慕鱼,不如退而结网!
  6. CSS绝对定位使用left:50%实现水平居中偏左问题
  7. Arcgis用矢量文件裁剪栅格图像
  8. CPU和GPU的区别是什么?
  9. 如何创建强命名程序集
  10. 临危受命 青力支持:“信豫链”及时上线 保障河南中小企业带“资”复工
  11. 山科OJ:Problem C: Lemon
  12. 怎样设定目标(三)—— 目标设定前的准备
  13. 音频合并的步骤有哪些
  14. python中怎么统计英文字符的个数_【Python练习1】统计一串字符中英文字母、空格、数字和其他字符的个数...
  15. 万国觉醒服务器维护,万国觉醒好像没看到1服怎么回事 官方关闭部分服务器公告[多图]...
  16. 黑马电商项目初始化学习笔记
  17. 中国智慧生活博览会(CEE 2017)—数字世界亚洲博览会会刊(参展商名录)
  18. Golf Range Finder 高尔夫激光测距仪和GPS测距仪
  19. 移动电影院发布2.0版本,多功能多种体验
  20. 使用Python库pyqt5制作TXT阅读器(四)-------应用设置和程序打包

热门文章

  1. promise的链式调用
  2. 【数据结构和算法】哈希表详解
  3. cmd 修改ie快捷方式_windows使用技巧之Win + R 与 CMD 的不同
  4. nvidia显卡linux 7.2,科学网—悲喜录:服务器 CentOS 7.2 安装Nvidia显卡驱动(64bit) - 袁伟的博文...
  5. java制作纯字rpg小游戏_求java rpg小游戏源代码 最好是文字rpg 不需要很复杂 只是交作业用...
  6. matlab 中最小二乘拟合,matlab 最小二乘拟合
  7. sublime text3 智能提示和自动补全
  8. github fork别人项目后如何同步更新原项目
  9. 【codevs5709】01背包
  10. 【codevs1220】数字三角形