Table of Contents
1 apt-cdromでcdromをリポジトリに追加
cdromをマウントします。
$ sudo mount -t iso9660 /dev/cdrom /media/cdrommount: /dev/sr0 is write-protected, mounting read-only
apt-cdromでcdromをリポジトリに追加します。
$ sudo apt-cdrom -m -d /media/cdrom addUsing CD-ROM mount point /media/cdrom/Identifying… [1a235e539972579c22a0bec9a077f7c3-2]Scanning disc for index files…Found 4 package indexes, 0 source indexes, 0 translation indexes and 1 signaturesThis disc is called:’Ubuntu 16.04 LTS _Xenial Xerus_ – Release amd64 (20160420.1)’Copying package lists…gpgv: Signature made Thu 21 Apr 2016 07:29:18 AM JST using DSA key ID FBB75451gpgv: Good signature from “Ubuntu CD Image Automatic Signing Key <[email protected]>”Reading Package Indexes… DoneWriting new source listSource list entries for this disc are:deb cdrom:[Ubuntu 16.04 LTS _Xenial Xerus_ – Release amd64 (20160420.1)]/ xenial main restrictedRepeat this process for the rest of the CDs in your set.
apt-cdromによって/etc/apt/sources.listは以下のように変更されます。cdromのリポジトリを削除するには”deb cdrom:”の行を削除します。
$ diff -uprN /etc/apt/sources.list{.org,}— /etc/apt/sources.list.org 2016-08-12 10:50:26.281895047 +0900+++ /etc/apt/sources.list 2016-08-12 10:50:42.603934453 +0900@@ -2,6 +2,7 @@ # See http://help.ubuntu.com/community/UpgradeNotes for how to upgrade to # newer versions of the distribution.+deb cdrom:[Ubuntu 16.04 LTS _Xenial Xerus_ – Release amd64 (20160420.1)]/ xenial main restricted deb http://jp.archive.ubuntu.com/ubuntu/ xenial main restricted deb-src http://jp.archive.ubuntu.com/ubuntu/ xenial main restricted@@ -51,3 +52,4 @@ deb http://security.ubuntu.com/ubuntu xe deb-src http://security.ubuntu.com/ubuntu xenial-security universe deb http://security.ubuntu.com/ubuntu xenial-security multiverse deb-src http://security.ubuntu.com/ubuntu xenial-security multiverse+
2 Ubuntu 16.04デスクトップのdebパッケージは少ない
ubuntu-16.04-desktop-amd64.isoは24パッケージしか持ってません。ubuntu-16.04-desktop-amd64.isoはLiveDVDである為、LiveDVDのルートファイルシステムをコピーしてから、grub等の環境依存のdebパッケージをインストールしており、debパッケージをほとんど使わない為です。
$ grep ^Package: /var/lib/apt/lists/Ubuntu*Packages | awk ‘{ print $2 }’b43-fwcutterdkmslibc6-i386grub-efigrub-efi-amd64grub-efi-amd64-bingrub-efi-amd64-signedgrublupin-supportmouseemusetserialshimshim-signedoem-configoem-config-gtkoem-config-slideshow-ubuntuuser-setupwvdiallibuniconf4.6libwvstreams4.6-baselibwvstreams4.6-extrasbcmwl-kernel-sourceintel-microcodeiucode-tool
ubuntu-16.04-server-amd64.isoは1244パッケージあります。しかしgnome等のデスクトップ環境のパッケージを持ちません。
$ grep ^Package: /var/lib/apt/lists/Ubuntu*Packages | awk ‘{ print $2}’accountsservicelibaccountsservice0acctacllibacl1acpidadduseraideaide-commonpython3-alabasterlibasound2libasound2-dataalsa-utilsamavisd-newanacronlibjs-angularjsapache2apache2-binapache2-dataapache2-doc<snip>
3 debパッケージをDVDを作成する
この記事ではデスクトップ環境のdebパッケージをDVDに格納して、リポジトリとして利用できるようにします。
3.1 debパッケージを用意する
こちらのスクリプトを利用して、ubuntu-desktopのdebパッケージと依存パッケージをダウンロードします。
$ sudo apt install -y apt-rdepends$ mkdir deb$ cd deb$ ../download-deb-package.sh ubuntu-desktop$ cd ..
3.2 GPGキーを用意する
gpgを作成する場合に以下のメッセージが出る場合があります。マウス操作等でランダム値へのノイズを発生させてやることで解消されますが、SSH経由の場合はマウス操作できません。
Not enough random bytes available. Please do some other work to give
そこでrng-toolsでランダム値を更新します。
$ sudo apt install -y rng-tools$ sudo rngd -r /dev/urandom
gpgをbatch処理で作成する為の設定ファイルを作成します。
$ cat <<EOF > gpg.txtKey-Type: RSASubkey-Type: RSAName-Real: hiroom2Expire-Date: 0%pubring public.key%secring signing.key%commitEOF
GPGキーをbatch処理で作成してインポートします。
$ gpg –batch –gen-key gpg.txt$ gpg –import public.key signing.key
3.3 リポジトリを作成する
リポジトリを作成するrepreproをインストールします。
$ sudo apt install -y reprepro
リポジトリ作成で利用するsubkeyの値を取得します。
$ dir=`pwd`$ subkey=`gpg –list-keys –keyring ${dir}/public.key –no-default-keyring | grep sub | awk ‘{ print $2 }’ | awk -F’/’ ‘{ print $2 }’`
isoというディレクトリを作成し、repreproの設定ファイルを作成します。
$ mkdir iso$ cd iso$ mkdir conf$ cat <<EOF > conf/distributionsCodename: xenialArchitectures: amd64Components: mainSignWith: ${subkey}EOF
repreproでリポジトリを追加します。
$ reprepro includedeb xenial ~/deb/*.deb
GPGキーの公開鍵をisoディレクトリに格納します。
$ cp ../public.key .
3.4 DVDの作成
geniso
imageでisoイメージを作成します。作成したisoイメージをdvdrecord等でメディアに書き込みます。
$ genisoimage -J -R -V “Ubuntu 16.04 repo” -o ubuntu-16.04-repo.iso iso
3.5 リポジトリの追加
メディアをDVDドライブに入れてマウントします。
$ sudo mount /dev/cdrom /media/cdrom
apt-keyでGPGキーを追加します。
$ sudo apt-key add /media/cdrom/public.key
apt-cdromで追加します。ディスク名がデータベースにないので”Ubuntu 16.04 repo”を入力します。
$ echo “Ubuntu 16.04 repo” | sudo apt-cdrom -m -d /media/cdrom addUsing CD-ROM mount point /media/cdrom/Identifying… [24043ba8f9dff07baf00246e9de86642-2]Scanning disc for index files…Found 1 package indexes, 0 source indexes, 0 translation indexes and 0 signaturesPlease provide a name for this Disc, such as ‘Debian 5.0.3 Disk 1’:Name: ‘Ubuntu 16.04 repo’This disc is called:’Ubuntu 16.04 repo’Reading Package Indexes… DoneWriting new source listSource list entries for this disc are:deb cdrom:[Ubuntu 16.04 repo]/ xenial mainRepeat this process for the rest of the CDs in your set.
これ以降はネットワークが動作しない状態でもDVDからパッケージをインストールできます。
$ sudo apt update -y$ sudo apt install -y ubuntu-desktop