0 Star 2 Fork 17

oepkgs / oepkgs_package_system_user_configs

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
贡献代码
同步代码
取消
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
Loading...
README
MulanPSL-2.0

oepkgs 软件编译系统配置

介绍

本仓库用于 oepkgs 软件编译系统的软件包配置,其中的信息用于被导入到编译系统数据库。每次有新的 packager 或者新的软件包需要编译就可以通过向此软件仓库提交 PR (Pull Request),来达到通知系统管理员配置系统并提供相应信息的目的。

  • 此编译系统管理员,下简称“管理员”。
  • 软件包维护者及仓库所有者,提交commit并触发编译的工程师,下简称“工程师”。

软件架构简介

软件架构图

系统组成

  1. Gitee

    • 软件包仓库列表及其配置
    • 软件包仓库
  2. 基于 Huawei cloud 的服务器集群

    • Koji server 主服务器[一台虚拟主机]
      • Koji服务
      • Jenkins服务
      • Nginx 反向代理服务
    • Koji Builder[多台虚拟主机]
      • AArch64 builders
      • X86_64 builders
    • NFS 存储服务
      • 开发资源
      • Linux Distros REPOs

编译过程简述

  1. 工程师通过在Gitee中某个软件包仓库的操作(push、merge等)触发Gitee针对Jenkins的Webhook(需要工程师进行适当配置)。

  2. Gitee Webhook触发Jenkins的Gitee Plugin(需要管理员通过工程师提交的配置信息进行任务的创建和配置)

  3. Jenkins的Gitee Plugin被激活后会提交相应的编译任务给 Koji Hub(Koji Server中的组件),并开始获取任务状态,直至任务结束。

    • Koji Hub 根据任务信息,将任务分配给相应的空闲Koji Builder进行编译。
    • 如果Koji Builder编译成功,Jenkins负责将软件包复制到仓库所有者指定的软件仓库路径(位于NFS存储服务中),并更新仓库信息。
  4. 任务结束后,Jenkins负责收集所有任务信息,并通过Gitee comment反馈给相关仓库的特定 commit 点。

配置仓库简介

本配置仓库结构如下:

├── docs (相关文档)
│   ├── figures (文档中包含的图片)
│   ├── templates (系统配置 json 文件模板)
│   │   ├── package_template.json (软件包编译任务配置信息)
│   │   └── user_template.json (工程师 Gitee 账户相关信息)
│   ├── gitee_webhook_config.md
│   |   (工程师需要仔细阅读的文档, Gitee Webhook 配置文档)
│   └── jenkins_jobs_config.md
(管理员需要仔细阅读的文档, Jenkins Jobs 配置文档)
├── keys (编译系统和配置需要用到的加密过的 tokens 和各种公钥)
│   ├── api_token (工程师提供的加密过的Personal access tokens 集合,optional)
│   ├── project_token (管理员提供的加密过的Secret Token for Gitee WebHook 集合)
│   ├── system (编译系统公钥集合,用于让工程师加密 Personal access tokens 给管理员)
│   └── user_pub (工程师的公钥集合,用于让管理员传递加密 Secret Token 给工程师)
├── projects (针对不同发行版的配置文件集合)
│   └── openEuler (软包对应的发行版名)
│       └── 20.03-LTS (软包对应的发行版版本号)
│           └── Packages(软件包编译配置文件)
│               ├── x(软件包首字母)
│               │   └── xz(软件包名)
│               │       └── test_pkg.json(软件包编译配置文件)
│               │            (同一个软件包可以允许多人从不同仓库编译)
│               └── z
│                   └── zlib
│                       └── oepkgs_test.json
├── README.md (本文档)
├── tools (配置信息相关小工具)
│   └── oepkgs_djtools (配置生成辅助工具,oepkgs Database&Json tools )
└── users (工程师 Gitee 账户信息)
    ├── e (工程师用户名首字母)
    │   └── eulerblade.json (某个工程师 Gitee 账户信息文件)
    └── o
        └── ocean-killer.json

配置仓库使用简述

步骤说明

  1. 工程师提出编包申请,提交 commit, 并向 upstream 仓库提交 PR。 这个 commit 必须包含以下内容:

    • 工程师 Gitee 账户信息文件 (如上面提到的 users/e/eulerblade.json) [如果此次编译申请的提交者此前使用同一账号提交过,则此文件不用重复提交]

    • 软件包编译配置文件 (如上面提到的 projects/OpenEuler/20.03-LTS/Packages/z/zlib/oepkgs_test.json) [不包含 project_token 信息,此由管理员提供]

    • api_token: 使用 *_oepkg.pub 加密过的 Gitee Personal access tokens) 数据文件

    • user_pub: 工程师的公钥数据文件,文件名必须为完整指纹

  2. 管理员审核工程师的提交。如果接受,则合并 PR 并再提交一个相关的 commit 到 upstream 仓库。 这个 commit 必须包含以下内容:

    • 补全软件包编译配置文件中的 "project_token" 和 "WebHook_URL" 信息.

    • project_token: 使用工程师的公钥加密过的 Secret Token for Gitee WebHook 数据文件

  3. 管理员使用 tools/config_import 工具将新信息导入编译系统数据库。

  4. 工程师将管理员提交的 "project_token" 用自己的私钥解密并连同 "WebHook_URL",配置 Webhook。

关于 keys (各种 token 和 公钥) 的关系说明

配置文件和各种keys的对应图

token 及公钥相关介绍及文件命名规则

├── keys (编译系统和配置需要用到的加密过的 tokens 和各种公钥) ├── api_token (工程师提供的加密过的Personal access tokens 集合,optional) │ └── 0d (内含文件的文件名前两位,小写字母) │ └── 0ddf188c9226811daf58d40e45accb9ca8e98af8 (使用 oepkgs 编译系统公钥加密过的 Secret Token 文件的sha1sum值,小写字母) ├── project_token (管理员提供的加密过的 Secret Token for Gitee WebHook 集合) │ └── 0d (内含文件的文件名前两位,小写字母) │ └── 0ddf188c9226811daf58d40e45accb9ca8e98af8 (使用 user 公钥加密过的 Secret Token 文件的sha1sum值,小写字母) ├── system (编译系统公钥集合,用于让工程师加密 Personal access tokens 给管理员) │ └── C31300E8175BF0735D1FF8ADFC7BCFADB768161C_oepkgs.pub (oepkgs编译系统公钥的完整指纹加后缀'_oepkgs.pub', 指纹部分为大写字母) └── user_pub (工程师的公钥集合,用于让管理员传递加密 Secret Token 给工程师) ├── 35 (内含文件的文件名前两位,大写字母) │ └── 3585F45D3A0DFAC62911BBB3DA6C08D4FA1ECE81 (工程师公钥的完整指纹,大写字母) └── E0 (内含文件的文件名前两位,大写字母) └── E0230505E0D0D2948050CADD964617B09C96FB5E (工程师公钥的完整指纹,大写字母)

  • 大小写字母问题: 加密后的 token 文件名由 sha1sum 命令生成, 默认是小写字母, 所以采用小写字母; gpg 程序对密钥指纹的输出默认是大写字母, 所以才用大写字母。目的:方便使用,不用转换,并可以明显区分 token 和公钥文件。

本项目使用 GPG 加密方式对 token 等敏感信息进行加密, 具体命令如下:

如何导出 GPG 公钥

  1. 生成 GPG key(如已经生成过,可以跳过)

    [euler_blade@samantha ~]$ gpg --full-gen-key
    gpg (GnuPG) 2.2.20; Copyright (C) 2020 Free Software Foundation, Inc.
    This is free software: you are free to change and redistribute it.
    There is NO WARRANTY, to the extent permitted by law.
    
    Please select what kind of key you want:
      (1) RSA and RSA (default)
      (2) DSA and Elgamal
      (3) DSA (sign only)
      (4) RSA (sign only)
      (14) Existing key from card
    Your selection?
    RSA keys may be between 1024 and 4096 bits long.
    What keysize do you want? (2048)
    Requested keysize is 2048 bits
    Please specify how long the key should be valid.
            0 = key does not expire
          <n>  = key expires in n days
          <n>w = key expires in n weeks
          <n>m = key expires in n months
          <n>y = key expires in n years
    Key is valid for? (0)
    Key does not expire at all
    Is this correct? (y/N) y
    
    GnuPG needs to construct a user ID to identify your key.
    
    Real name: Euler Blade
    Email address: euler_blade@isrc.iscas.ac.cn
    Comment: oepkgs
    You selected this USER-ID:
        "Euler Blade (oepkgs) <euler_blade@isrc.iscas.ac.cn>"
    
    Change (N)ame, (C)omment, (E)mail or (O)kay/(Q)uit? O
    We need to generate a lot of random bytes. It is a good idea to perform
    some other action (type on the keyboard, move the mouse, utilize the
    disks) during the prime generation; this gives the random number
    generator a better chance to gain enough entropy.
    We need to generate a lot of random bytes. It is a good idea to perform
    some other action (type on the keyboard, move the mouse, utilize the
    disks) during the prime generation; this gives the random number
    generator a better chance to gain enough entropy.
    gpg: key 964617B09C96FB5E marked as ultimately trusted
    gpg: revocation certificate stored as '/home/euler_blade/.gnupg/openpgp-revocs.d/E0230505E0D0D2948050CADD964617B09C96FB5E.rev'
    public and secret key created and signed.
    
    pub   rsa2048 2020-10-17 [SC]
          E0230505E0D0D2948050CADD964617B09C96FB5E
    uid                      Euler Blade (oepkgs) <euler_blade@isrc.iscas.ac.cn>
    sub   rsa2048 2020-10-17 [E]
    
    [euler_blade@samantha ~]$
    
  2. 导出公钥

    [euler_blade@samantha ~]$ gpg --list-keys
    gpg: checking the trustdb
    gpg: marginals needed: 3  completes needed: 1  trust model: pgp
    gpg: depth: 0  valid:   1  signed:   0  trust: 0-, 0q, 0n, 0m, 0f, 1u
    /home/euler_blade/.gnupg/pubring.kbx
    --------------------------------------
    pub   rsa2048 2020-10-17 [SC]
          E0230505E0D0D2948050CADD964617B09C96FB5E
    uid           [ultimate] Euler Blade (oepkgs) <euler_blade@isrc.iscas.ac.cn>
    sub   rsa2048 2020-10-17 [E]
    
    [euler_blade@samantha ~]$ OEPKGS_KEYID=E0230505E0D0D2948050CADD964617B09C96FB5E
    [euler_blade@samantha ~]$ gpg --armor --output ${OEPKGS_KEYID} --export ${OEPKGS_KEYID}
    [euler_blade@samantha ~]$ ll ${OEPKGS_KEYID}
    -rw-rw-r--. 1 euler_blade euler_blade 1769 Oct 17 20:55 E0230505E0D0D2948050CADD964617B09C96FB5E

工程师导出的公钥

作为工程师, 此处的‘E0230505E0D0D2948050CADD964617B09C96FB5E’就是可以放入 keys/user_pub/ 的文件。由于这个公钥指纹是以‘E0’开头的,所以这个文件可以放入 keys/user_pub/E0/

mkdir -p ${oepkgs_packages_configs_dir}/keys/user_pub/E0
mv E0230505E0D0D2948050CADD964617B09C96FB5E ${oepkgs_packages_configs_dir}/keys/user_pub/E0/

OEPKGS的管理员导出公钥

作为OEPKGS编译系统的管理员,此处的公钥需要添加 _oepkgs.pub 后缀,再放入 keys/system/ 目录。

PUB_KEY=C31300E8175BF0735D1FF8ADFC7BCFADB768161C
mkdir -p ${oepkgs_packages_configs_dir}/keys/system
mv ${PUB_KEY} ${oepkgs_packages_configs_dir}/keys/system/${PUB_KEY}_oepkgs.pub

工程师加密 Gitee 的 Personal access tokens(可选)

注意: 此 token 仅在工程师提交的代码仓库 Property 为 “Private” 的时候才需要!

使用 shell 命令(原理)

  1. 导入 GPG 公钥,并查看 key ID

    # *_oepkgs.pub 代表了由 oepkgs 编译系统提供的公钥,用于让工程师加密 Personal access tokens 给管理员
    OEPKGS_PUB=keys/system/*_oepkgs.pub
    # 导入 oepkgs 编译系统提供的公钥
    gpg --import ${OEPKGS_PUB}
    gpg --list-keys
    # 你可以再这里看到刚才导入的 oepkgs 公钥ID(指纹),此处我们暂且认为将其存入环境变量${OEPKGS_PUB_ID}中。
  2. 加密token

    TOKEN_ENCRYPTED=token_en_tmp.bin
    echo -n '[token_string]' | gpg --encrypt --output ${TOKEN_ENCRYPTED} --recipient ${OEPKGS_PUB_ID}
    
    mv -vi ${TOKEN_ENCRYPTED} $(sha1sum ${TOKEN_ENCRYPTED}| awk '{print $1;}')
  3. 将文件导入 oepkgs 配置中

将刚刚生成的文件存放到 keys/api_token/ 中,并将文件名存入 users/*/*json 中的 "api_token": 中。

使用 oepkgs_djtools 脚本

在 tools 目录下有一个 oepkgs_djtools 脚本帮你快速的完成这个工作, 使用方法如下:


[euler_blade@samantha oepkgs_packages_configs]$ tools/oepkgs_djtools apitoken --token '[token_string]' --user eulerblade
  • --token: 指定 token 字符串。

  • --user: 在生成 api_token 目录中的文件之后会更新相应用户的 user.json 文件。

此工具的工作流程如下:

  1. 通过提供的 token 字符串和 oepkgs.pub 生成加密过的文件, 文件名为文件数据的 sha1sum。

  2. 如果我们在 oepkgs_packages_configs 目录下, 将文件按规范移动到 api_token/xx/ 目录下。 否则请通过 ‘-C’ 指定 oepkgs_packages_configs 所在的 PATH。

  3. 通过 '--user' 参数定位 user.json 文件, 并更新 "api_token" 项。

管理员获取 api_token (可选)

注意: 此 token 仅在工程师提交的代码仓库 Property 为 “Private” 的时候才需要!

api_token 是工程师用 system/*_oepkgs.pub 加密发送来的,可以通过一下方式获取,以 users/e/eulerblade.json 为例:

{
    "user": "eulerblade",
    "email": "euler_blade@isrc.iscas.ac.cn",
    "api_token": "",
    "user_pub": "E0230505E0D0D2948050CADD964617B09C96FB5ES",
    "repos_prefix": "https://gitee.com/eulerblade"
}

加密过的 token 信息位于 keys/api_token/

API_TOKEN_EN=keys/api_token/??/${api_token_in_user_json}
gpg --decrypt ${API_TOKEN_EN}

JSON 文件的路径和命名规则

project

所有 project 信息 json 文件都需要放在 projects 目录下,其路径如下:

 projects/<distro_or_OS_name>/<version>/<software_type>/[first_letter_of_software_name]/<software_name>/<job_name>.json

<>: 必须 []: 可选

  • <distro_or_OS_name>: 发行版或者OS名称
  • : 发行版或者OS版本号
  • <software_type>: 编译的软件类型: Packages, Image, or others.
  • [first_letter_of_software_name]: 如果是上面的类型是 Packages, 为了避免一个目录下存放太多的文件,此层为软件包名的第一个字母。
  • <software_name>: 软件包名
  • <job_name>.json: 任务名, 针对同一个软件包可以有多个编译任务配置(源码仓库,分支,软件包仓库等等)。

管理员手册

参与贡献

木兰宽松许可证, 第2版 木兰宽松许可证, 第2版 2020年1月 http://license.coscl.org.cn/MulanPSL2 您对“软件”的复制、使用、修改及分发受木兰宽松许可证,第2版(“本许可证”)的如下条款的约束: 0. 定义 “软件”是指由“贡献”构成的许可在“本许可证”下的程序和相关文档的集合。 “贡献”是指由任一“贡献者”许可在“本许可证”下的受版权法保护的作品。 “贡献者”是指将受版权法保护的作品许可在“本许可证”下的自然人或“法人实体”。 “法人实体”是指提交贡献的机构及其“关联实体”。 “关联实体”是指,对“本许可证”下的行为方而言,控制、受控制或与其共同受控制的机构,此处的控制是指有受控方或共同受控方至少50%直接或间接的投票权、资金或其他有价证券。 1. 授予版权许可 每个“贡献者”根据“本许可证”授予您永久性的、全球性的、免费的、非独占的、不可撤销的版权许可,您可以复制、使用、修改、分发其“贡献”,不论修改与否。 2. 授予专利许可 每个“贡献者”根据“本许可证”授予您永久性的、全球性的、免费的、非独占的、不可撤销的(根据本条规定撤销除外)专利许可,供您制造、委托制造、使用、许诺销售、销售、进口其“贡献”或以其他方式转移其“贡献”。前述专利许可仅限于“贡献者”现在或将来拥有或控制的其“贡献”本身或其“贡献”与许可“贡献”时的“软件”结合而将必然会侵犯的专利权利要求,不包括对“贡献”的修改或包含“贡献”的其他结合。如果您或您的“关联实体”直接或间接地,就“软件”或其中的“贡献”对任何人发起专利侵权诉讼(包括反诉或交叉诉讼)或其他专利维权行动,指控其侵犯专利权,则“本许可证”授予您对“软件”的专利许可自您提起诉讼或发起维权行动之日终止。 3. 无商标许可 “本许可证”不提供对“贡献者”的商品名称、商标、服务标志或产品名称的商标许可,但您为满足第4条规定的声明义务而必须使用除外。 4. 分发限制 您可以在任何媒介中将“软件”以源程序形式或可执行形式重新分发,不论修改与否,但您必须向接收者提供“本许可证”的副本,并保留“软件”中的版权、商标、专利及免责声明。 5. 免责声明与责任限制 “软件”及其中的“贡献”在提供时不带任何明示或默示的担保。在任何情况下,“贡献者”或版权所有者不对任何人因使用“软件”或其中的“贡献”而引发的任何直接或间接损失承担责任,不论因何种原因导致或者基于何种法律理论,即使其曾被建议有此种损失的可能性。 6. 语言 “本许可证”以中英文双语表述,中英文版本具有同等法律效力。如果中英文版本存在任何冲突不一致,以中文版为准。 条款结束 如何将木兰宽松许可证,第2版,应用到您的软件 如果您希望将木兰宽松许可证,第2版,应用到您的新软件,为了方便接收者查阅,建议您完成如下三步: 1, 请您补充如下声明中的空白,包括软件名、软件的首次发表年份以及您作为版权人的名字; 2, 请您在软件包的一级目录下创建以“LICENSE”为名的文件,将整个许可证文本放入该文件中; 3, 请将如下声明文本放入每个源文件的头部注释中。 Copyright (c) [Year] [name of copyright holder] [Software Name] is licensed under Mulan PSL v2. You can use this software according to the terms and conditions of the Mulan PSL v2. You may obtain a copy of Mulan PSL v2 at: http://license.coscl.org.cn/MulanPSL2 THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. See the Mulan PSL v2 for more details. Mulan Permissive Software License,Version 2 Mulan Permissive Software License,Version 2 (Mulan PSL v2) January 2020 http://license.coscl.org.cn/MulanPSL2 Your reproduction, use, modification and distribution of the Software shall be subject to Mulan PSL v2 (this License) with the following terms and conditions: 0. Definition Software means the program and related documents which are licensed under this License and comprise all Contribution(s). Contribution means the copyrightable work licensed by a particular Contributor under this License. Contributor means the Individual or Legal Entity who licenses its copyrightable work under this License. Legal Entity means the entity making a Contribution and all its Affiliates. Affiliates means entities that control, are controlled by, or are under common control with the acting entity under this License, ‘control’ means direct or indirect ownership of at least fifty percent (50%) of the voting power, capital or other securities of controlled or commonly controlled entity. 1. Grant of Copyright License Subject to the terms and conditions of this License, each Contributor hereby grants to you a perpetual, worldwide, royalty-free, non-exclusive, irrevocable copyright license to reproduce, use, modify, or distribute its Contribution, with modification or not. 2. Grant of Patent License Subject to the terms and conditions of this License, each Contributor hereby grants to you a perpetual, worldwide, royalty-free, non-exclusive, irrevocable (except for revocation under this Section) patent license to make, have made, use, offer for sale, sell, import or otherwise transfer its Contribution, where such patent license is only limited to the patent claims owned or controlled by such Contributor now or in future which will be necessarily infringed by its Contribution alone, or by combination of the Contribution with the Software to which the Contribution was contributed. The patent license shall not apply to any modification of the Contribution, and any other combination which includes the Contribution. If you or your Affiliates directly or indirectly institute patent litigation (including a cross claim or counterclaim in a litigation) or other patent enforcement activities against any individual or entity by alleging that the Software or any Contribution in it infringes patents, then any patent license granted to you under this License for the Software shall terminate as of the date such litigation or activity is filed or taken. 3. No Trademark License No trademark license is granted to use the trade names, trademarks, service marks, or product names of Contributor, except as required to fulfill notice requirements in Section 4. 4. Distribution Restriction You may distribute the Software in any medium with or without modification, whether in source or executable forms, provided that you provide recipients with a copy of this License and retain copyright, patent, trademark and disclaimer statements in the Software. 5. Disclaimer of Warranty and Limitation of Liability THE SOFTWARE AND CONTRIBUTION IN IT ARE PROVIDED WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED. IN NO EVENT SHALL ANY CONTRIBUTOR OR COPYRIGHT HOLDER BE LIABLE TO YOU FOR ANY DAMAGES, INCLUDING, BUT NOT LIMITED TO ANY DIRECT, OR INDIRECT, SPECIAL OR CONSEQUENTIAL DAMAGES ARISING FROM YOUR USE OR INABILITY TO USE THE SOFTWARE OR THE CONTRIBUTION IN IT, NO MATTER HOW IT’S CAUSED OR BASED ON WHICH LEGAL THEORY, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. 6. Language THIS LICENSE IS WRITTEN IN BOTH CHINESE AND ENGLISH, AND THE CHINESE VERSION AND ENGLISH VERSION SHALL HAVE THE SAME LEGAL EFFECT. IN THE CASE OF DIVERGENCE BETWEEN THE CHINESE AND ENGLISH VERSIONS, THE CHINESE VERSION SHALL PREVAIL. END OF THE TERMS AND CONDITIONS How to Apply the Mulan Permissive Software License,Version 2 (Mulan PSL v2) to Your Software To apply the Mulan PSL v2 to your work, for easy identification by recipients, you are suggested to complete following three steps: i Fill in the blanks in following statement, including insert your software name, the year of the first publication of your software, and your name identified as the copyright owner; ii Create a file named “LICENSE” which contains the whole context of this License in the first directory of your software package; iii Attach the statement to the appropriate annotated syntax at the beginning of each source file. Copyright (c) [Year] [name of copyright holder] [Software Name] is licensed under Mulan PSL v2. You can use this software according to the terms and conditions of the Mulan PSL v2. You may obtain a copy of Mulan PSL v2 at: http://license.coscl.org.cn/MulanPSL2 THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. See the Mulan PSL v2 for more details.

简介

本仓库用于 oepkgs 软件编译系统的当前用户配置,其中的信息用于被导入到编译系统数据库。每次有新的 packager时需要通过向此软件仓库提交 PR (Pull Request),并邮件通知系统管理员配置系统并提供相应信息。 展开 收起
Python
MulanPSL-2.0
取消

发行版

暂无发行版

贡献者

全部

近期动态

加载更多
不能加载更多了
1
https://gitee.com/oepkgs/oepkgs_package_system_user_configs.git
git@gitee.com:oepkgs/oepkgs_package_system_user_configs.git
oepkgs
oepkgs_package_system_user_configs
oepkgs_package_system_user_configs
master

搜索帮助