ウェブサイト検索

Ubuntuの「Reprepro」ツールを使用してSourceforge.netに「.debパッケージリポジトリ」を作成する


Reprepro は、.deb リポジトリを簡単に作成および管理するための小さなコマンドライン ツールです。今日は、reprepro を使用して Debian パッケージ リポジトリを簡単に作成する方法と、 rsync コマンドを使用して、Sourceforge.net にアップロードします。

ステップ 1: Reprepro をインストールしてキーを生成する

まず、次の apt-get コマンドを使用して、必要なパッケージをすべてインストールします。

sudo apt-get install reprepro gnupg

次に、gnupg を使用して gpg キーを生成する必要があります。これを行うには、次のコマンドを適用します。

gpg --gen-key

必要なキーの種類、キーの有効期間など、いくつかの質問が表示されます。何に答えればよいかわからない場合は、Enter をクリックしてデフォルトのオプションを選択してください (推奨) )。

もちろん、ユーザー名とパスワードの入力を求められますが、これらは後で必要になるため、覚えておいてください。

gpg (GnuPG) 1.4.14; Copyright (C) 2013 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)
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
        = key expires in n days
      w = key expires in n weeks
      m = key expires in n months
      y = key expires in n years
Key is valid for? (0) 
Key does not expire at all
Is this correct? (y/N) Y

You need a user ID to identify your key; the software constructs the user ID
from the Real Name, Comment and Email Address in this form:
    "Heinrich Heine (Der Dichter) <[email >"

Real name: ravisaive
Email address: [email 
Comment: tecmint
You selected this USER-ID:
    "Ravi Saive (tecmint) <[email >"

Change (N)ame, (C)omment, (E)mail or (O)kay/(Q)uit? O
You need a Passphrase to protect your secret key.

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 2EB446DD marked as ultimately trusted
public and secret key created and signed.

gpg: checking the trustdb
gpg: 3 marginal(s) needed, 1 complete(s) needed, PGP trust model
gpg: depth: 0  valid:   1  signed:   0  trust: 0-, 0q, 0n, 0m, 0f, 1u
pub   2048R/2EB446DD 2014-06-24
      Key fingerprint = D222 B1C9 342E 5911 02B1  9147 3BD6 7918 2EB4 46DD
uid                  Ravi Saive (tecmint) <[email >
sub   2048R/7EF2F750 2014-06-24

これでキーが生成されます。生成されたかどうかを確認するには、root 権限でこのコマンドを実行します。

sudo gpg --list-keys
サンプル出力
/home/ravisaive/.gnupg/pubring.gpg
----------------------------------
pub   2048R/2EB446DD 2014-06-24
uid                  ravisaive (tecmint) <[email >
sub   2048R/7EF2F750 2014-06-24

ステップ 2: パッケージ リポジトリを作成してキーをエクスポートする

ここからリポジトリを作成する作業を開始します。まず、いくつかのフォルダを作成する必要があります。リポジトリは /var/www/apt ディレクトリにあるので、いくつかのフォルダを作成しましょう。

sudo su
cd /var/www
mkdir apt
mkdir -p ./apt/incoming 
mkdir -p ./apt/conf
mkdir -p ./apt/key

ここで、作成したキーをリポジトリ フォルダーにエクスポートして実行する必要があります。

gpg --armor --export username [email  >> /var/www/apt/key/deb.gpg.key

: ユーザー名は上記の手順で入力したユーザー名に置き換え、[email はメールアドレスに置き換えます。

/var/www/apt/conf 内に「distributions 」というファイルを作成する必要があります。

touch /var/www/apt/conf/distributions

次の行を配布ファイルに追加し、ファイルを保存します。

Origin: (yourname)
Label: (name of repository)
Suite: (stable or unstable)
Codename: (the codename for the distribution you are using, like trusty)
Version: (the version for the distribution you are using, like 14.04)
Architectures: (the repository packages  architecture, like i386 or amd64)
Components: (main restricted universe multiverse)
Description: (Some information about the repository)
SignWith: yes

次に、リポジトリ ツリーを作成する必要があります。これを行うには、これらのコマンドを実行します。

reprepro --ask-passphrase -Vb /var/www/apt export
サンプル出力
Created directory "/var/www/apt/db"
Exporting Trusty...
Created directory "/var/www/apt/dists"
Created directory "/var/www/apt/dists/Trusty"
Created directory "/var/www/apt/dists/Trusty/universe"
Created directory "/var/www/apt/dists/Trusty/universe/binary-i386"
FF5097B479C8220C ravisaive (tecmint) <[email > needs a passphrase
Please enter passphrase:
Successfully created '/var/www/apt/dists/Trusty/Release.gpg.new'
FF5097B479C8220C ravisaive (tecmint) <[email > needs a passphrase
Please enter passphrase:
Successfully created '/var/www/apt/dists/Trusty/InRelease.new'

ステップ 3: 新しく作成したリポジトリにパッケージを追加する

ここで、.deb パッケージをリポジトリに追加する準備をします。 /var/www/apt ディレクトリに移動します。パッケージを追加するたびにこれを行う必要があります。

cd /var/www/apt
reprepro --ask-passphrase -Vb . includedeb Trusty /home/ravisaive/packages.deb

: trusty をディストリビューション ファイル内のリポジトリに入力したコード名に置き換え、/home/username/package を置き換えます。 .deb にパッケージへのパスを指定すると、パスフレーズの入力を求められます。

サンプル出力
/home/ravisaive/packages.deb : component guessed as 'universe'
Created directory "./pool"
Created directory "./pool/universe"
Created directory "./pool/universe/o"
Created directory "./pool/universe/o/ojuba-personal-lock"
Exporting indices...
FF5097B479C8220C ravisaive (tecmint) <[email > needs a passphrase
Please enter passphrase:
Successfully created './dists/Trusty/Release.gpg.new'
FF5097B479C8220C ravisaive (tecmint) <[email > needs a passphrase
Please enter passphrase:
Successfully created './dists/Trusty/InRelease.new'

パッケージをリポジトリに追加して削除します。

reprepro --ask-passphrase -Vb /var/www/apt remove trusty  package.deb

そしてもちろん、パッケージ名とリポジトリのコード名を使用してコマンドを変更する必要があります。

ステップ 4: リポジトリを Sourceforge.net にアップロードする

リポジトリを Sourceforge.net にアップロードするには、当然そこで実行中のアカウントと実行中のプロジェクトが必要です。リポジトリを http://sourceforge にアップロードするとします。 .net/projects/myfoo/testrepository ここで、myfoo はプロジェクト名 (URL やタイトルではなく UNIX 名)、testrepository はファイルをアップロードするフォルダーです。これは rsync を使用して行います。指示。

rsync -avP -e ssh /var/www/apt/ [email :/home/frs/project/myfoo/testrepository/

: username をsourceforge.net 上のユーザー名に置き換え、myfoo をプロジェクトの UNIX 名に置き換え、testrepository をファイルを保存するフォルダーに置き換えます。

これで、リポジトリが http://sourceforge.net/projects/myfoo/testrepository にアップロードされました。インストールされているシステムに追加するには、まずリポジトリ キーをインポートする必要があります。< にあります。 b>/var/www/apt/key/deb.gpg.key ですが、これはローカル パスであり、リポジトリのユーザーはそれをシステムに追加できません。そのため、 sourceforge.net からキーをインポートします。

sudo su
wget -O - http://sourceforge.net/projects/myfoo/testrepository/apt/key/deb.gpg.key | apt-key add -

これでリポジトリをシステムに簡単に追加できます。/etc/apt/sources.list を開いて次の行を追加します。

deb http://sourceforge.net/projects/myfoo/testrepository/apt/key/deb.gpg.key trusty main

: myfoo をプロジェクトの UNIX 名に、trusty をリポジトリのコード名に、testrepository をファイルをアップロードしたフォルダに、main を追加したリポジトリ コンポーネントに置き換えます。配布ファイル。

次に、以下を実行してリポジトリのリストを更新します。

sudo apt-get update

おめでとうございます! リポジトリがアクティブになりました。必要に応じて、そこからパッケージを簡単にインストールできるようになりました。