RError.com

RError.com Logo RError.com Logo

RError.com Navigation

  • 主页

Mobile menu

Close
  • 主页
  • 系统&网络
    • 热门问题
    • 最新问题
    • 标签
  • Ubuntu
    • 热门问题
    • 最新问题
    • 标签
  • 帮助
主页 / 问题 / 1139796
Accepted
Николай Николаевич
Николай Николаевич
Asked:2020-06-11 23:15:43 +0000 UTC2020-06-11 23:15:43 +0000 UTC 2020-06-11 23:15:43 +0000 UTC

如何在 Linux 上创建存储库?

  • 772

我已经用我的程序编译了一个 deb 包,我需要以某种方式分发它。我需要用户能够使用一个命令安装我的程序,apt install如果我需要添加存储库,可能需要两个命令。我该怎么做?

linux
  • 2 2 个回答
  • 10 Views

2 个回答

  • Voted
  1. eri
    2020-06-12T02:30:09Z2020-06-12T02:30:09Z
    apt-get install reprepro gnupg2
    
    mkdir /var/www/debian
    mkdir /var/www/debian/conf
    
    touch /var/www/debian/conf/distributions
    editor /var/www/debian/conf/distributions
    

    在那里我们写了存储库的描述

    Codename:  stable
    Suite:  stable
    Version: 1.x
    Origin: Nikolaich
    Label: Nikolaich
    Description: Nikolaich Stable Repository
    Architectures: amd64
    Components: main
    SignWith: default
    DebIndices: Packages Release . .gz .bz2
    DscIndices: Sources Release . .gz .bz2
    Contents: . .gz .bz2
    

    更远

    cd /var/www/debian
    gpg --gen-key
    gpg --armor --export > repokey.asc
    

    会有一个key ID,比如4607CAF2F88913A6 把它添加到上面的文件中。

    SignWith: 4607CAF2F88913A6
    

    接下来,我们创建萝卜本身

    cd /var/www/debian
    
    reprepro export
    reprepro createsymlinks
    

    并填写包裹

    reprepro --priority optional --section drivers includedeb  stable /root/mysuper.deb
    

    然后我们设置 web 服务器,以便可以通过http://example.com/debian/访问 debian 文件夹

    通过几个命令为客户端安装:

    wget -O- http://example.com/debian/repokey.asc | apt-key add -
    echo "deb http://example.com/debian stable main" > /etc/apt/sources.list.d/myrepo.list
    apt update
    

    debian.org 上的类似说明

    • 13
  2. Best Answer
    don Rumata
    2020-06-14T05:36:38Z2020-06-14T05:36:38Z

    有一个恰当的项目。安德烈·斯米尔诺夫(Andrey Smirnov )堆积如山。他知道如何制作其他说唱的镜像,创建自己的说唱,快照。您可以通过CLI和API工作。

    Habré描述了使用体验。

    PS 甚至 Mikey 都是用来分发他自己的包的。签入 2 个计数: curl --silent http://packages.microsoft.com/repos/ms-teams/dists/stable/InRelease | grep aptly吐出Description: Generated by aptly。

    UPD1。我将添加关于萝卜的创建。所以。

    首先,关于变量和配置:

    my-first-repo- 内部厨房的存储库名称。

    rolling- 手鼓\debian 发布名称,将在sources.list. 您可以执行与发行版名称相同的操作,即 bionic, buster, 和你自己的东西。我有rolling,因为还没有为特定版本制作特定功能的任务

    配置:

    {
      "rootDir": "/var/aptly",
      "downloadConcurrency": 4,
      "downloadSpeedLimit": 0,
      "architectures": [],
      "dependencyFollowSuggests": false,
      "dependencyFollowRecommends": false,
      "dependencyFollowAllVariants": false,
      "dependencyFollowSource": false,
      "dependencyVerboseResolve": false,
      "gpgDisableSign": false,
      "gpgDisableVerify": false,
      "gpgProvider": "gpg",
      "downloadSourcePackages": false,
      "skipLegacyPool": true,
      "ppaDistributorID": "ubuntu",
      "ppaCodename": "",
      "skipContentsPublishing": false,
      "FileSystemPublishEndpoints": {},
      "S3PublishEndpoints": {},
      "SwiftPublishEndpoints": {}
    }
    

    /var/aptly必须创建并且必须有 ''rw'' 访问权限。

    Добавление\создание репы != публикация. 创建萝卜时,它被创建/var/aptly/pool,它似乎拥有你需要的一切,但这并不完全正确。更多详细信息 -在文档中。当您想将完成的东西用作mirror.yandex.ru时,您需要发布它。然后/var/aptly/public在其中创建一棵树,它已经可以通过 http、ftp 等设置。

    Unit systemd,如果您通过 http 恰当地进行通信:

    [Unit]
    Description=The Aptly api server
    After=network.target remote-fs.target nss-lookup.target
    
    # https://ma.ttias.be/auto-restart-crashed-service-systemd/
    StartLimitIntervalSec=500
    StartLimitBurst=10
    
    [Service]
    ExecStart=/usr/bin/aptly api serve -listen=:8080
    
    StandardOutput=syslog
    StandardError=syslog
    SyslogIdentifier=aptly
    
    User=aptly
    Group=aptly
    
    # WorkingDirectory=/var/aptly
    
    # https://ma.ttias.be/auto-restart-crashed-service-systemd/
    Restart=on-failure
    RestartSec=10s
    
    [Install]
    WantedBy=multi-user.target
    
    

    创建一个空存储库:

    通过 bash:

    aptly repo create -distribution="rolling" my-first-repo
    

    让我们发布它:

    aptly -architectures=i386,amd64 publish repo my-first-repo
    

    通过 api:

    创造:

    curl -X POST \
    -H 'Content-Type: application/json' \
    --data '{"Name":"my-first-repo","DefaultDistribution":"rolling","DefaultComponent":""}' \
    http://localhost:8080/api/repos
    

    我们发布:

    curl -X POST \
    -H 'Content-Type: application/json' \
    --data '{"SourceKind": "local", "Sources": [{"Name": "my-first-repo"}], "Architectures": ["i386", "amd64"], "Distribution": "rolling"}' \
    http://localhost:8080/api/publish
    

    通过 Ansible:

    变量:

    aptly_my_first_repo_name: my-first-repo
    
    aptly_my_first_repo_distribution: rolling
    
    aptly_api_port: 8080
    
    - name: Create my first repo
      uri:
        url: http://localhost:{{ aptly_api_port }}/api/repos
        method: POST
        body_format: json
        body:
          Name: "{{ aptly_my_first_repo_name }}"
          DefaultDistribution: "{{ aptly_my_first_repo_distribution }}"
        status_code:
          - 201
          - 400
      tags:
        - api
        - repo
        - create
    
    - name: Publish my first repo
      uri:
        url: http://localhost:{{ aptly_api_port }}/api/repos
        method: POST
        body_format: json
        body:
          SourceKind: "local"
          Sources: 
            - Name: "{{ aptly_my_first_repo_name }}"
          Architectures:
            - i386
            - amd64
          Distribution: "{{ aptly_my_first_repo_distribution }}"
        status_code:
          - 200
          - 201
          - 400
      tags:
        - api
        - repo
        - publish
    
    

    创建空存储库后一切如何

    通过 api

    curl --silent http://localhost:8080/api/repos | jq .
    
    [
      {
        "Name": "my-first-repo",
        "DefaultDistribution": "rolling",
        "DefaultComponent": "main"
      }
    ]
    

    通过 bash

    sudo aptly repo list -raw
    
    my-first-repo
    
    sudo aptly publish list -raw
    
    . rolling
    

    通过FS

    cd /var/aptly/public
    
    .
    ├── dists
    │   └── rolling
    │       ├── InRelease
    │       ├── main
    │       │   ├── binary-amd64
    │       │   │   ├── Packages
    │       │   │   ├── Packages.bz2
    │       │   │   ├── Packages.gz
    │       │   │   └── Release
    │       │   └── binary-i386
    │       │       ├── Packages
    │       │       ├── Packages.bz2
    │       │       ├── Packages.gz
    │       │       └── Release
    │       ├── Release
    │       └── Release.gpg
    ├── pool
    ├── repo.key
    └── repo.key.gpg
    

    添加一个包

    cd /var/aptly/upload && wget https://download.cdn.viber.com/cdn/desktop/Linux/viber.deb
    

    通过 bash

    添加一个包:

    aptly repo add my-first-repo /var/aptly/upload/viber.deb
    

    我们发布:

    aptly publish update rolling
    

    通过 api\ansible

    - name: Add Viber to repo over api
      when:
        - ansible_os_family == 'Debian'
        - ansible_pkg_mgr == 'apt'
        - aptly_add_first_software_in_created_repo_over == 'api'
      uri:
        url: http://localhost:{{ aptly_api_port }}/api/repos/{{ aptly_my_first_repo_name }}/file/viber.deb
        method: POST
        status_code:
          - 200
          - 201
          - 400
    
    - name: Update published repo over api
      when:
        - ansible_os_family == 'Debian'
        - ansible_pkg_mgr == 'apt'
        - aptly_add_first_software_in_created_repo_over == 'api'
      uri:
        url: http://localhost:{{ aptly_api_port }}/api/publish/:./{{ aptly_my_first_repo_distribution }}
        method: PUT
        body_format: json
        body:
          SourceKind: "local"
          # Sources: [{"Name": "{{ aptly_my_first_repo_name }}"}]
          Sources:
            - Name: "{{ aptly_my_first_repo_name }}"
              Component: "{{ aptly_my_first_repo_component }}"
          Architectures:
            - i386
            - amd64
          Distribution: "{{ aptly_my_first_repo_distribution }}"
        status_code:
          - 200
          - 201
          - 400
    

    一般来说,ansible 的角色是编写和测试的,如果有的话,一切都是从那里拉出来的

    • 4

相关问题

  • 如果 fuser -k number/tcp 没有帮助,如何在 Debian 中释放端口?

  • Ubuntu。startx 不起作用。黑屏

  • --syn 在 iptables 中有什么作用?

  • 为什么需要iso格式?

  • C程序中没有密码的sudo

Sidebar

Stats

  • 问题 10021
  • Answers 30001
  • 最佳答案 8000
  • 用户 6900
  • 常问
  • 回答
  • Marko Smith

    如何从列表中打印最大元素(str 类型)的长度?

    • 2 个回答
  • Marko Smith

    如何在 PyQT5 中清除 QFrame 的内容

    • 1 个回答
  • Marko Smith

    如何将具有特定字符的字符串拆分为两个不同的列表?

    • 2 个回答
  • Marko Smith

    导航栏活动元素

    • 1 个回答
  • Marko Smith

    是否可以将文本放入数组中?[关闭]

    • 1 个回答
  • Marko Smith

    如何一次用多个分隔符拆分字符串?

    • 1 个回答
  • Marko Smith

    如何通过 ClassPath 创建 InputStream?

    • 2 个回答
  • Marko Smith

    在一个查询中连接多个表

    • 1 个回答
  • Marko Smith

    对列表列表中的所有值求和

    • 3 个回答
  • Marko Smith

    如何对齐 string.Format 中的列?

    • 1 个回答
  • Martin Hope
    Alexandr_TT 2020年新年大赛! 2020-12-20 18:20:21 +0000 UTC
  • Martin Hope
    Alexandr_TT 圣诞树动画 2020-12-23 00:38:08 +0000 UTC
  • Martin Hope
    Air 究竟是什么标识了网站访问者? 2020-11-03 15:49:20 +0000 UTC
  • Martin Hope
    Qwertiy 号码显示 9223372036854775807 2020-07-11 18:16:49 +0000 UTC
  • Martin Hope
    user216109 如何为黑客设下陷阱,或充分击退攻击? 2020-05-10 02:22:52 +0000 UTC
  • Martin Hope
    Qwertiy 并变成3个无穷大 2020-11-06 07:15:57 +0000 UTC
  • Martin Hope
    koks_rs 什么是样板代码? 2020-10-27 15:43:19 +0000 UTC
  • Martin Hope
    Sirop4ik 向 git 提交发布的正确方法是什么? 2020-10-05 00:02:00 +0000 UTC
  • Martin Hope
    faoxis 为什么在这么多示例中函数都称为 foo? 2020-08-15 04:42:49 +0000 UTC
  • Martin Hope
    Pavel Mayorov 如何从事件或回调函数中返回值?或者至少等他们完成。 2020-08-11 16:49:28 +0000 UTC

热门标签

javascript python java php c# c++ html android jquery mysql

Explore

  • 主页
  • 问题
    • 热门问题
    • 最新问题
  • 标签
  • 帮助

Footer

RError.com

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

帮助

© 2023 RError.com All Rights Reserve   沪ICP备12040472号-5