ユーザ用ツール

サイト用ツール


自前repositoryサーバー構築

自前Repositoryサーバー構築

趣旨

自前で作成したdebianパッケージを登録して、各サーバーからはaptコマンドでインストール/アンインストールを行う。
公開されているレポジトリーサーバーからの同期は行わない為、あくまで自前で作成したパッケージのみを登録する事にした

要件

  • WEBサーバー と パッケージを保存して置く為のディスク容量
  • 一応、GnuPG鍵を作成して、パッケージ認証に利用する
  • 今回はarmbian(ARM系)の自前パッケージを作成・配布を意図する

レポジトリ作成はdebian上で作成して、生成物を別のディストリビューションOS(CentOS等)上のWEBサーバーに保存/公開する事で、1台のWEBサーバーに収容することも可能。

構築

(1) レポジトリ作成・登録するため、以下パッケージの導入

# apt install reprepro

(2) パッケージ署名用のアカウントとレポジトリ領域の作成
アカウント(armbian-dpkg)/グループ(repo)を作成。

# groupadd repo
# useradd -g repo -m -d /home/armbian-dpkg armbian-dpkg
# passwd armbian-dpkg

# mkdir -p /repo/armbian
# chgrp -R repo /repo
# chmod -R 0775 /repo

(3) GnuPG鍵の作成

armbian-dpkg@repo11:~$ gpg –full-generate-key

gpg (GnuPG) 2.2.40; Copyright (C) 2022 g10 Code GmbH
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

gpg: ディレクトリ'/home/armbian-dpkg/.gnupg'が作成されました
gpg: keybox'/home/armbian-dpkg/.gnupg/pubring.kbx'が作成されました
ご希望の鍵の種類を選択してください:
  (1) RSA と RSA (デフォルト)
  (2) DSA と Elgamal
  (3) DSA (署名のみ)
  (4) RSA (署名のみ)
  (14) カードに存在する鍵
あなたの選択は? 1
RSA 鍵は 1024 から 4096 ビットの長さで可能です。
鍵長は? (3072) 4096
要求された鍵長は4096ビット
鍵の有効期限を指定してください。
     0 = 鍵は無期限
   <n> = 鍵は n 日間で期限切れ
   <n>w = 鍵は n 週間で期限切れ
   <n>m = 鍵は n か月間で期限切れ
   <n>y = 鍵は n 年間で期限切れ
鍵の有効期間は? (0) 2y
鍵は2027年05月22日 14時06分27秒 JSTで期限切れとなります
これで正しいですか? (y/N) y

GnuPGはあなたの鍵を識別するためにユーザIDを構成する必要があります。

本名: Private Release Key
電子メール・アドレス: armbian-local-release@example.jp
コメント: armbian 12/bookworm
次のユーザIDを選択しました:
 “Private Release Key (armbian 12/bookworm) armbian-local-release@example.jp

名前(N)、コメント(C)、電子メール(E)の変更、またはOK(O)か終了(Q)? O
たくさんのランダム・バイトの生成が必要です。キーボードを打つ、マウスを動か
す、ディスクにアクセスするなどの他の操作を素数生成の間に行うことで、乱数生
成器に十分なエントロピーを供給する機会を与えることができます。

   lqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqk
   x 新しい鍵を保護するために、                 x
   x パスフレーズを入力してください。              x
   x                               x
   x パスフレーズ: **********____________________________________ x
   x                               x
   x    <OK>                            <キャンセル(C)>   x
   mqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqj
   lqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqk
   x このパスフレーズをもう一度入力してください                   x
   x                                                              x
   x パスフレーズ: **********____________________________________ x
   x                                                              x
   x         <OK>                            <キャンセル(C)>      x
   mqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqj

gpg: /home/armbian-dpkg/.gnupg/trustdb.gpg: 信用データベースができました
gpg: ディレクトリ'/home/armbian-dpkg/.gnupg/openpgp-revocs.d'が作成されました
pg: 失効証明書を '/home/armbian-dpkg/.gnupg/openpgp-revocs.d/D59ABDCE960647C5126DC48A79DDC51A2D76F2DB.rev' に保管しまた。
公開鍵と秘密鍵を作成し、署名しました。

pub rsa4096 2025-05-22 [SC] [有効期限: 2027-05-22]
   D59ABDCE960647C5126DC48A79DDC51A2D76F2DB
uid Private Release Key (12/bookworm armbian) armbian-local-release@example.jp
sub rsa4096 2025-05-22 [E] [有効期限: 2027-05-22]

armbian-dpkg@repo11:~$ gpg –list-signatures

gpg: 信用データベースの検査
gpg: marginals needed: 3 completes needed: 1 trust model: pgp
gpg: 深さ: 0 有効性: 1 署名: 0 信用: 0-, 0q, 0n, 0m, 0f, 1u
gpg: 次回の信用データベース検査は、2027-05-22です
/home/armbian-dpkg/.gnupg/pubring.kbx


pub rsa4096 2025-05-22 [SC] [有効期限: 2027-05-22]
   D59ABDCE960647C5126DC48A79DDC51A2D76F2DB
uid [ 究極 ] Private Release Key (12/bookworm armbian) armbian-local-release@example.jp
sig 3 79DDC51A2D76F2DB 2025-05-22 Private Release Key (armbian 12/bookworm) armbian-local-release@example.jp
sub rsa4096 2025-05-22 [E] [有効期限: 2027-05-22]
sig 79DDC51A2D76F2DB 2025-05-22 Private Release Key (armbian 12/bookworm) armbian-local-release@example.jp

(4) 各サーバーからGPG公開鍵を入手出来るようにWEBサーバー上に配置
armbian-dpkg@repo11:~$ gpg –export -a 79DDC51A2D76F2DB > /repo/armbian-bookworm-private.asc

(5) リポジトリの初期ファイル作成
armbian-dpkg@repo11:~$ cd /repo/armbian
armbian-dpkg@repo11:/repo/armbian$ mkdir conf
armbian-dpkg@repo11:/repo/armbian$ vi conf/distributions

Codename: bookworm-backports
Architectures: arm64
Components: main
Origin: repo11.example.jp
Label: repo11.example.jp
Description: Armbian Private Repository
SignWith: 79DDC51A2D76F2DB

armbian-dpkg@repo11:/repo/armbian$ reprepro export

lqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqk
x OpenPGPの秘密鍵のロックを解除するためにパスフレーズを入力してください:      x
x "Private Release Key (armbian 12/bookworm)                                  x
x <armbian-local-release@example.jp>"                                         x
x 4096ビットRSA鍵, ID 79DDC51A2D76F2DB,                                       x
x 作成日付 2025-05-22.                                                        x
x                                                                             x
x                                                                             x
x パスフレーズ: **********___________________________________________________ x
x                                                                             x
x           <OK>                                       <キャンセル(C)>        x
mqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqj

armbian-dpkg@repo11:/repo/armbian$ ls -l
この段階で、db,poolディレクトリが作成される

drwxr-xr-x 2 armbian-dpkg repo 4096  5月 31 05:05 conf
drwxr-xr-x 2 armbian-dpkg repo 4096  5月 31 05:35 db
drwxr-xr-x 3 armbian-dpkg repo 4096  5月 31 05:34 pool

armbian-dpkg@repo11:/repo/armbian$ reprepro checkpool

(6) リポジトリへパッケージ登録
予め/home/armbian-dpkg へdebianパッケージを転送しておいた。

armbian-dpkg@repo11:repo/armbian$ cd
armbian-dpkg@repo11:~$ ls -l

-rw-r--r-- 1 armbian-dpkg repo 12992  5月 25 18:56 tm16xx-display_0.0.0-1~6.12.11_arm64.deb
-rw-r--r-- 1 armbian-dpkg repo 12676  5月 25 18:55 tm16xx-display_0.0.0-1~6.7.12_arm64.deb

armbian-dpkg@repo11:~$ reprepro -b /repo/armbian –keepunreferencedfiles includedeb bookworm-backports tm16xx-display_0.0.0-1~6.7.12_arm64.deb

lqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqk
x OpenPGPの秘密鍵のロックを解除するためにパスフレーズを入力してください:      x
x "Private Release Key (armbian 12/bookworm)                                  x
x <armbian-local-release@example.jp>"                                         x
x 4096ビットRSA鍵, ID 79DDC51A2D76F2DB,                                       x
x 作成日付 2025-05-22.                                                        x
x                                                                             x
x                                                                             x
x パスフレーズ: **********___________________________________________________ x
x                                                                             x
x           <OK>                                       <キャンセル(C)>        x
mqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqj
Exporting indices...

armbian-dpkg@repo11:~$ reprepro -b /repo/armbian –keepunreferencedfiles includedeb bookworm-backports tm16xx-display_0.0.0-1~6.12.11_arm64.deb

Exporting indices...

armbian-dpkg@repo11:~$

(7) リポジトリ 兼 WEB用公開領域の設定
/repo/armbian 配下のディレクトリ構造は以下の通り。

/repo/armbian
|-- README.html
|-- armbian-bookworm-private.asc
|-- conf
|   `-- distributions
|-- db
|   |-- checksums.db
|   |-- contents.cache.db
|   |-- packages.db
|   |-- references.db
|   |-- release.caches.db
|   `-- version
|-- dists
|   `-- bookworm-backports
|       |-- InRelease
|       |-- Release
|       |-- Release.gpg
|       `-- main
|           `-- binary-arm64
|               |-- Packages
|               |-- Packages.gz
|               `-- Release
`-- pool
    `-- main
        `-- t
            `-- tm16xx-display
                |-- tm16xx-display_0.0.0-1~6.12.11_arm64.deb
                `-- tm16xx-display_0.0.0-1~6.7.12_arm64.deb

しかしWEB公開する上で、conf, db配下はWEB公開不要。
apache.confへ以下のようにアクセス制限を設ける
また、README.htmlは、apacheのindex化されたページにオーバーラップして、情報付加出来るので
良い感じでメモ書きできる。

Alias /armbian/ "/repo/armbian/"
<Directory "/repo/armbian">
  IndexIgnore README.html .htaccess *.bak *~
  Options Indexes FollowSymLinks
  Require all granted
</Directory>
<Directory "/repo/armbian/conf">
  Require all denied
</Directory>
<Directory "/repo/armbian/db">
  Require all denied
</Directory>

以上で設定完了。

自前repositoryサーバー構築.txt · 最終更新: by admin