#navi(../)

* Ubuntuでパッケージのネットワークインストールに利用できる独自のパッケージレポジトリを作成・利用する方法 [#k1b81bc8]
本資料はネットワークインストールが可能な独自パッケージリポジトリを作成し利用する手順などを記述しています。

#contents
#htmlinsertpcsp(linux_ads_top.html,linux-sp.html)

*関連記事 [#bff7fad4]
-[[Ubuntuでrootになる方法>Ubuntu/Ubuntuでrootになる方法]]

* aptのパッケージレポジトリ [#cdd67dcd]
新規ソフトウェアの追加やセキュリティアップデートのために、~
パッケージレポジトリからパッケージを入手しインストールすることは、~
Ubuntuシステムの管理において日常的です。
この管理作業には、''apt-get''コマンドを使います。~
一般的に利用するレポジトリは、Ubuntuの公式パッケージレポジトリやそのミラーサイトです。

しかし、パッケージレポジトリには、公式レポジトリだけでなく、独自のパッケージレポジトリも存在します。

独自レポジトリを作る目的には、公式パッケージの内容に独自のパッチを加えたものや、~
またパッケージ化されていないソフトウェアのパッケージを提供することがあります。

また、特別なパッケージを提供するためではなく、インターネットとの疎通が取れない(公式レポジトリが使用できない)環境において~
構築作業を行なうために、暫定的に独自レポジトリを用意する場合もあるでしょう。

ここでは、そのような独自レポジトリの作成手順と、その利用手順を説明します。

* 独自パッケージレポジトリの作成準備 [#v4aaed11]
独自のパッケージレポジトリを作成するには、以下の準備が必要になります。

- ''apt-ftparchive''というコマンドが必要になります。~
これは''apt-utils''というパッケージに含まれています。
- レポジトリを置くマシン上でHTTPサーバが動作している必要があります。必要に応じて''apache2''パッケージの導入や設定を行なって下さい。~
以降の手順説明では、''apache2''パッケージのデフォルト設定を前提とします。
- レポジトリの電子署名のために、''gpg''の鍵がセットアップされていないといけません。~
事前に以下のように''gpg''コマンドを実行して、鍵を作成して下さい。
 % gpg --gen-key


* 独自パッケージレポジトリの作成手順 [#fd3f4ef9]
独自パッケージレポジトリを作成するには、独自レポジトリを作成したいマシン上で以下の手順を実行します。

+ 独自レポジトリを作成したいマシン(ホスト名は、server1.example.tld とします)の任意のディレクトリに deb パッケージファイルを集めます。~
HTTPサーバによって公開できるディレクトリにするため、今回は''/var/www/html''にパッケージファイルを置きます。~
今回はテストのため、swiftというパッケージファイルを1つだけ置くことにします。

 # cp swift_1.8.0-0ubuntu1.2~cloud0_all.deb /var/www/
#br
+ 以下のコマンドを実行します。
 # cd /var/www
 # apt-ftparchive packages . > Packages
 # gzip -c9 < Packages > Packages.gz
 # apt-ftparchive contents . > Contents-$(dpkg --print-architecture)
 # gzip -c9 < Contents-$(dpkg --print-architecture) > Contents-$(dpkg --print-architecture).gz
 # apt-ftparchive release . > Release
#br
+ Releaseファイルにgpgで署名を行います。~
以下のコマンドを実行します。
 # gpg --sign -b -a -o Release.gpg Release
 
 次のユーザーの秘密鍵のロックを解除するには
 パスフレーズがいります:“Admin <root@localhost>”
 2048ビットRSA鍵, ID D9812CEF作成日付は2013-07-25
 
 gpg: このセッションでgpg-agentは無効です


以上で、独自パッケージレポジトリが、作成できました。


* ネットワーク・HTTPサーバの確認 [#sd1b0e1e]
ネットワーク経由で、レポジトリにアクセスできるかどうか、curlコマンドを使って確認します。~
"/var/www"は、HTTPサーバの"/"に配置されているので、"/"へのHTTPアクセスで、~
作業を行ったディレクトリのコンテンツに接続できるはずです。~
先程作成した''Packages''ファイルを取得してみます。

 # curl http://server1.example.tld/Packages
 Package: swift
 Priority: optional
 Section: net
 Installed-Size: 211
 Maintainer: Ubuntu Developers <ubuntu-devel-discuss@lists.ubuntu.com>
 Original-Maintainer: Soren Hansen <soren@ubuntu.com>
 Architecture: all
 Version: 1.8.0-0ubuntu1.2~cloud0
 Replaces: swift (<< 1.6.0-0ubuntu1)
 Depends: python-swift (= 1.8.0-0ubuntu1.2~cloud0), python
 Breaks: swift (<< 1.6.0-0ubuntu1)
 Filename: ./swift_1.8.0-0ubuntu1.2~cloud0_all.deb
 Size: 74774
 MD5sum: d37b39c1522724bc55dcac767dcd889b
 SHA1: fd57a77cad7fa992135a6dfaff5696faa6ace66f
 SHA256: cece959eddbb4ad2c07edc7cac03621b32f1410c1ec7988335484537ea34431c
 SHA512: c0362146e2605421a95eee0b633e6b2b3be380499b4e6309c3ea983d4a69231dcd73e6328bad2ef3c51a2a7bcc8dd1a4f8f1b40412e054824ffc78cebcca3ff7
 Description: distributed virtual object store - common files
  OpenStack Object Storage (code-named Swift) is open source software for
  creating redundant, scalable object storage using clusters of standardized
  servers to store petabytes of accessible data. It is not a file system or
  real-time data storage system, but rather a long-term storage system for a
  more permanent type of static data that can be retrieved, leveraged, and then
  updated if necessary. Primary examples of data that best fit this type of
  storage model are virtual machine images, photo storage, email storage and
  backup archiving. Having no central "brain" or master point of control
  provides greater scalability, redundancy and permanence.
  .
  Objects are written to multiple hardware devices in the data center, with
  the OpenStack software responsible for ensuring data replication and
  integrity across the cluster. Storage clusters can scale horizontally by
  adding new nodes. Should a node fail, OpenStack works to replicate its
  content from other active nodes. Because OpenStack uses software logic to
  ensure data replication and distribution across different devices,
  inexpensive commodity hard drives and servers can be used in lieu of more
  expensive equipment.
  .
  .
  This package provides some core binaries and clients to control swift.
 Homepage: http://launchpad.net/swift
 
テストで置いたswiftパッケージについての情報ファイル(Packages)が取得できています。


* 独自パッケージレポジトリの利用手順 [#ne73c8c1]
作成した独自パッケージレポジトリを利用するには、利用したいマシン上で以下の手順を実行します。

+ "/etc/apt/sources.list"に以下のような行を追加します。
#br
 deb http://ホスト/ディレクトリ/ ./
#br
先程の手順で作ったレポジトリの場合には、以下のようになります。
#br
 deb http://server1.example.tld/ ./
#br
+ 独自レポジトリの署名に利用したgpgの公開鍵をaptに追加します。
#br
++ 先に作成したgpg鍵の公開鍵ファイルを取得するために、レポジトリを作成したマシン上、gpg鍵を作ったアカウントで以下のコマンドを実行します。
#br
 # gpg --export > Admin.gpg
#br
++取得したファイル(上記の例では"Admin.gpg")を、レポジトリ利用マシン上に持ってきて、それを引数に以下のコマンドを実行します。
#br
 # apt-key add Admin.gpg
   OK
#br
+ apt-get update コマンドを実行し、独自レポジトリの情報が読み込まれることを確認します。
#br
 # apt-get update
 取得:1 http://server1.example.tld ./ Release.gpg [490 B]
 取得:2 http://server1.example.tld ./ Release [1,202 B]
 無視 http://server1.example.tld ./ Release
 取得:3 http://server1.example.tld ./ Packages [1,178 B]
 無視 http://server1.example.tld ./ Translation-ja_JP
 無視 http://server1.example.tld ./ Translation-ja
 無視 http://server1.example.tld ./ Translation-ja_JP.eucJP
 無視 http://server1.example.tld ./ Translation-en
 ヒット http://jp.archive.ubuntu.com precise Release.gpg
 ヒット http://jp.archive.ubuntu.com precise-updates Release.gpg
 ヒット http://jp.archive.ubuntu.com precise-backports Release.gpg
 (省略)
 ヒット http://security.ubuntu.com precise-security/universe Translation-en
 951 kB を 22秒 で取得しました (42.0 kB/s)
 パッケージリストを読み込んでいます... 完了


以上の手順により、作成した独自パッケージレポジトリが利用可能となります。


以上、Ubuntuでネットワークインストールに利用できる独自のパッケージレポジトリを作成する方法についてでした。

#htmlinsertpcsp(linux_ads_btm.html,linux-sp.html)

トップ   編集 差分 バックアップ 添付 複製 名前変更 リロード   新規 一覧 検索 最終更新   ヘルプ   最終更新のRSS