equivsで依存先だけをインストールする空パッケージを作る

Posted by 雅楽斎 on Monday, July 17, 2023

TOC

定期的にOSアップグレードやクリーンインストールする機会があるんですが、クリーンインストールの時に決まったパッケージのインストールを楽にできそうなequivsというツールを見つけたのでやってみます。

(Linux) equivsを使ってdebパッケージの簡易作成 (r271-635)

メタパッケージ?呼び名がよくわからないけど依存パッケージをインストールするだけのパッケージを作る

代表的なのはUbuntu日本語Remixが配布しているubuntu-defaults-jaというパッケージ1ですが、依存パッケージとして複数のパッケージを指定するけどそのパッケージ自体には管理用ファイル以外に何のファイルも含まないパッケージがあります。

これ自体便利な仕組みですが、aptitude亡き後apt-getを使っていたので「ローカルにあるdebに依存があってもdpkg -iでインストールするからaptから依存パッケージ引っ張ってこれないんだよなぁ…」という悩みがaptコマンドではローカルのdebファイルの依存パッケージをaptから引っ張って来れることに気付いて、メタパッケージだけあれば1個aptで入れるだけで芋蔓式に入れられるのでそういうのないかな、でもCDBSとか使うのもなぁとなっていたところ、equivsを使うと簡単にできそうだったので試してみました。

インストール

# apt-get install equivs

まずは一つ作ってみる

テンプレートを作るコマンドはequivs-controlらしい

$ equivs-control metapackage1

metapackage1というファイルが作られる。中身はこうなっている。

### Commented entries have reasonable defaults.
### Uncomment to edit them.
# Source: <source package name; defaults to package name>
Section: misc
Priority: optional
# Homepage: <enter URL here; no default>
Standards-Version: 3.9.2

Package: <package name; defaults to equivs-dummy>
# Version: <enter version here; defaults to 1.0>
# Maintainer: Your Name <yourname@example.com>
# Pre-Depends: <comma-separated list of packages>
# Depends: <comma-separated list of packages>
# Recommends: <comma-separated list of packages>
# Suggests: <comma-separated list of packages>
# Provides: <comma-separated list of packages>
# Replaces: <comma-separated list of packages>
# Architecture: all
# Multi-Arch: <one of: foreign|same|allowed>
# Copyright: <copyright file; defaults to GPL2>
# Changelog: <changelog file; defaults to a generic changelog>
# Readme: <README.Debian file; defaults to a generic one>
# Extra-Files: <comma-separated list of additional files for the doc directory>
# Links: <pair of space-separated paths; First is path symlink points at, second is filename of link>
# Files: <pair of space-separated paths; First is file to include, second is destination>
#  <more pairs, if there's more than one file to include. Notice the starting space>
Description: <short description; defaults to some wise words> 
 long description and info
 .
 second paragraph

何も考えずにパッケージを作ってみる。

$ equivs-build metapackage1 
dpkg-buildpackage: warning:     debian/changelog(l1): badly formatted heading line
LINE: <package name; defaults to equivs-dummy> (1.0) unstable; urgency=low
dpkg-buildpackage: warning:     debian/changelog(l2): found blank line where expected first heading
dpkg-buildpackage: warning:     debian/changelog(l3): found change data where expected first heading
LINE:   * First version
dpkg-buildpackage: warning: unknown information field '' in input data in parsed version of changelog
dpkg-buildpackage: info: source package unknown
dpkg-buildpackage: info: source version unknown
dpkg-buildpackage: error: version number does not start with digit
Error in the build process: exit status 255

ふむふむ。メタパッケージを作るだけならコントロールファイルのDependsを書いて、メンテナの名前とかを書けば良さそう。

ひとまずインストールしてないけど使わなそうなパッケージとしてecjをインストールするパッケージを作ってみることに。

### Commented entries have reasonable defaults.
### Uncomment to edit them.
# Source: <source package name; defaults to package name>
Section: misc
Priority: optional
# Homepage: <enter URL here; no default>
Standards-Version: 3.9.2

Package: metapackage1
Version: 0.1
Maintainer: Garakusai <garakusai@example.com>
# Pre-Depends: <comma-separated list of packages>
Depends: ecj
# Recommends: <comma-separated list of packages>
# Suggests: <comma-separated list of packages>
# Provides: <comma-separated list of packages>
# Replaces: <comma-separated list of packages>
# Architecture: all
# Multi-Arch: <one of: foreign|same|allowed>
# Copyright: <copyright file; defaults to GPL2>
# Changelog: <changelog file; defaults to a generic changelog>
# Readme: <README.Debian file; defaults to a generic one>
# Extra-Files: <comma-separated list of additional files for the doc directory>
# Links: <pair of space-separated paths; First is path symlink points at, second is filename of link>
# Files: <pair of space-separated paths; First is file to include, second is destination>
#  <more pairs, if there's more than one file to include. Notice the starting space>
Description: To install ecj package
 This package is to install ecj only.
 .
 Just test.
$ equivs-build metapackage1 
dpkg-buildpackage: info: source package metapackage1
dpkg-buildpackage: info: source version 0.1
dpkg-buildpackage: info: source distribution unstable
dpkg-buildpackage: info: source changed by Garakusai <garakusai@example.com>
dpkg-buildpackage: info: host architecture amd64
 dpkg-source --before-build .
 debian/rules clean
dh clean
   dh_clean
 debian/rules binary
dh binary
   dh_update_autotools_config
   dh_autoreconf
   create-stamp debian/debhelper-build-stamp
   dh_prep
   dh_auto_install --destdir=debian/metapackage1/
   dh_install
   dh_installdocs
   dh_installchangelogs
   dh_perl
   dh_link
   dh_strip_nondeterminism
   dh_compress
   dh_fixperms
   dh_missing
   dh_installdeb
   dh_gencontrol
   dh_md5sums
   dh_builddeb
dpkg-deb: building package 'metapackage1' in '../metapackage1_0.1_all.deb'.
 dpkg-genbuildinfo --build=binary -O../metapackage1_0.1_amd64.buildinfo
 dpkg-genchanges --build=binary -O../metapackage1_0.1_amd64.changes
dpkg-genchanges: info: binary-only upload (no source code included)
 dpkg-source --after-build .
dpkg-buildpackage: info: binary-only upload (no source included)

The package has been created.
Attention, the package has been created in the current directory,
not in ".." as indicated by the message above!
$ ls -ltr
(snip)
-rw-r--r-- 1 hogehoge hogehoge       1248  7月 17 10:03  metapackage1
-rw-r--r-- 1 hogehoge hogehoge       1992  7月 17 10:04  metapackage1_0.1_all.deb
-rw-r--r-- 1 hogehoge hogehoge       6141  7月 17 10:04  metapackage1_0.1_amd64.buildinfo
-rw-r--r-- 1 hogehoge hogehoge        960  7月 17 10:04  metapackage1_0.1_amd64.changes

パッケージは出来上がったのでこれをインストールするとaptからecjをインストールするか確認。

$ sudo apt install ./metapackage1_0.1_all.deb 
パッケージリストを読み込んでいます... 完了
依存関係ツリーを作成しています... 完了        
状態情報を読み取っています... 完了        
注意、'./metapackage1_0.1_all.deb' の代わりに 'metapackage1' を選択します
以下の追加パッケージがインストールされます:
  ecj libecj-java
以下のパッケージが新たにインストールされます:
  ecj libecj-java metapackage1
アップグレード: 0 個、新規インストール: 3 個、削除: 0 個、保留: 1 個。
1,792 kB 中 1,790 kB のアーカイブを取得する必要があります。
この操作後に追加で 1,996 kB のディスク容量が消費されます。
続行しますか? [Y/n] 
取得:1 /home/hogehoge/metapackage1_0.1_all.deb metapackage1 all 0.1 [1,992 B]
取得:2 http://archive.ubuntu.com/ubuntu jammy/universe amd64 libecj-java all 3.16.0-1 [1,775 kB]
取得:3 http://archive.ubuntu.com/ubuntu jammy/universe amd64 ecj all 3.16.0-1 [14.1 kB]
1,790 kB を 2秒 で取得しました (805 kB/s)
以前に未選択のパッケージ libecj-java を選択しています。
(データベースを読み込んでいます ... 現在 420204 個のファイルとディレクトリがイン
ストールされています。)
.../libecj-java_3.16.0-1_all.deb を展開する準備をしています ...
libecj-java (3.16.0-1) を展開しています...
以前に未選択のパッケージ ecj を選択しています。
.../archives/ecj_3.16.0-1_all.deb を展開する準備をしています ...
ecj (3.16.0-1) を展開しています...
以前に未選択のパッケージ metapackage1 を選択しています。
.../metapackage1_0.1_all.deb を展開する準備をしています ...
metapackage1 (0.1) を展開しています...
libecj-java (3.16.0-1) を設定しています ...
ecj (3.16.0-1) を設定しています ...
metapackage1 (0.1) を設定しています ...
man-db (2.10.2-1) のトリガを処理しています ...

インストールされた。管理情報はどうなってるかというと

$ apt-cache show metapackage1
Package: metapackage1
Status: install ok installed
Priority: optional
Section: misc
Installed-Size: 9
Maintainer: Garakusai <garakusai@example.com>
Architecture: all
Multi-Arch: foreign
Version: 0.1
Depends: ecj
Description: To install ecj package
 This package is to install ecj only.
 .
 Just test.
Description-md5: 36884631cc6e90b4fa1cf865db5affff

問題なさそう。パッケージ名だけは既存のリポジトリと被ると面倒なのでドメイン名とかを先頭に付けた方が良いかと思ったので、私の場合は「r-o-head-」を先頭に付けることにしました。

Ubuntu初期セットアップの補足メタパッケージの作成

基本的にはパッケージ名とDependsの行の依存パッケージと説明を変更するだけなのでDepends行だけ記載します。

Ubuntu 22.04用補足メタパッケージ(デスクトップ用)

富士通LIFEBOOK S938/SにUbuntu MATE 22.04をインストールした後の諸設定

これに書いたもので標準リポジトリにあるものをインストールするメタパッケージを作ります。

  • fonts-vlgothic
  • fonts-motoya-l-cedar
  • fonts-motoya-l-maruberi
  • vlc
  • python3-pip
  • filezilla
  • wireshark
  • git
  • audacious(追加)
  • openjdk-17-jdk
  • xfce4-terminal(追加)
  • kid3-qt(追加)
  • ristretto(追加)

Dependsの行は以下のようにします。

Depends: fonts-vlgothic, fonts-motoya-l-cedar, fonts-motoya-l-maruberi, vlc, python3-pip, filezilla, wireshark, git, audacious, openjdk-17-jdk, xfce4-terminal, kid3-qt, ristretto

r-o-head-ubuntu2204desktop_20230717_all.deb

Ubuntu 22.04用補足メタパッケージ(サーバー用)

上記からGUIアプリを削除したものをインストールします。(フォントはX/Waylandを飛ばした先で必要になることがあるのでインストールします)

  • fonts-vlgothic
  • fonts-motoya-l-cedar
  • fonts-motoya-l-maruberi
  • python3-pip
  • git
  • openjdk-17-jdk

Dependsの行は次のようにします。

Depends: fonts-vlgothic, fonts-motoya-l-cedar, fonts-motoya-l-maruberi, python3-pip, git, openjdk-17-jdk

r-o-head-ubuntu2204server_20230717_all.deb

Ubuntu 22.04用補足メタパッケージ(サーバー用)-開発しない版

上記のうち、python3-pipを入れるとbuild-essentialが入るので膨大な数のコンパイラが入ります。また、openjdk-17-jdkも依存で入るパッケージのサイズが大きいので、この2つを除いたものになります。

Dependsの行は次のようにしています。

Depends: fonts-vlgothic, fonts-motoya-l-cedar, fonts-motoya-l-maruberi, git

r-o-head-ubuntu2204server-nondevelop_20230717_all.deb

Ubuntu 23.04以降用補足メタパッケージ(デスクトップ用)

LTSではない最新のUbunutuをインストールする場合用にUbuntu23.04以降用に標準リポジトリにあるものをインストールするメタパッケージを作ります。

  • fonts-vlgothic
  • fonts-motoya-l-cedar
  • fonts-motoya-l-maruberi
  • fonts-morisawa-bizud-gothic
  • fonts-morisawa-bizud-mincho
  • fcitx5
  • fcitx5-mozc
  • vlc
  • python3-pip
  • filezilla
  • wireshark
  • git
  • audacious
  • openjdk-17-jdk
  • xfce4-terminal
  • kid3-qt
  • ristretto

フォントは等幅とサンセリフはVLゴシック、セリフはBIZ UD明朝にするために/etc/fonts/local.confを以下の内容で作成します。

<?xml version="1.0"?>
<!DOCTYPE fontconfig SYSTEM "fonts.dtd">
<fontconfig>
  <match target="pattern">
    <test name="lang" compare="contains">
      <string>ja</string>
    </test>
    <test qual="any" name="family">
      <string>sans-serif</string>
    </test>
    <edit name="family" mode="prepend" binding="strong">
      <string>VL Pゴシック</string>
      <!--
      <string>BIZ UDPゴシック</string>
      -->
    </edit>
  </match>
  <match target="pattern">
    <test name="lang" compare="contains">
      <string>ja</string>
    </test>
    <test qual="any" name="family">
      <string>monospace</string>
    </test>
    <edit name="family" mode="prepend" binding="strong">
      <string>VL ゴシック</string>
      <!--
      <string>BIZ UDゴシック</string>
      -->
    </edit>
  </match>
  <match target="pattern">
    <test name="lang" compare="contains">
      <string>ja</string>
    </test>
    <test qual="any" name="family">
      <string>serif</string>
    </test>
    <edit name="family" mode="prepend" binding="strong">
      <string>BIZ UDP明朝</string>
    </edit>
  </match>
</fontconfig>

Dependsの行は次のようにしています。

Depends: fonts-vlgothic, fonts-motoya-l-cedar, fonts-motoya-l-maruberi, fonts-morisawa-bizud-gothic, fonts-morisawa-bizud-mincho, fcitx5, fcitx5-mozc, vlc, python3-pip, filezilla, wireshark, git, audacious, openjdk-17-jdk, xfce4-terminal, kid3-qt, ristretto

r-o-head-ubuntu2304desktop_20230717_all.deb

なお、サーバー用のUbuntu 23.04以降用の補足メタパッケージは一度もインストールしていないので今回は作りません。

スポンサーリンク


  1. 個人的にはTakaoフォントが嫌いだったので使っていませんでした [return]

comments powered by Disqus