はじめに

.debファイルは、debian系のOSで使われる、アプリケーションをインストールするための情報が全て入ったファイル。 今回は、VSCodeのdebパッケージを眺めてみる。

題材

最新のVSCodeパッケージ。(2025/2/21現在だと、code_1.97.2-1739406807_amd64.deb)

環境

  • OS: Ubuntu 24.04.2 LTS
  • CPU: x86_64

構成要素

公式サイトからダウンロードして実際に調べてみる。 ダウンロード後にまず、archiveファイルなので、ar xで展開する。 通常は、専用のコマンドであるdpkg-debコマンドで展開するとよいらしいが、今回は学習目的なので手動で展開して見ていく。 (展開せずにarchiveファイルに含まれたファイルを見るだけなら、ar t stableで見られる)

# wget https://update.code.visualstudio.com/1.97.2/linux-deb-x64/stable
ar x stable

下記の4つが出てくる。

1. debian-binary
2. control.tar.xz
3. data.tar.xz
4. _gpgorigin

1. debian-binary

パッケージフォーマットのバージョンを記述したテキストファイル。通常、内容は 2.0(Debianパッケージフォーマットのバージョン)。 実際、今回も2.0と書かれていた。

cat debian-binary
2.0

2. data.tar.xz

tar -xvf data.tar.xz

2947ファイルも生成された。

tar -xvf data.tar.xz | wc -l
2947

一部抜粋。

./usr/share/code/resources/app/node_modules.asar.unpacked/vsda/build/Release/
./usr/share/code/resources/app/node_modules.asar.unpacked/vsda/build/Release/vsda.node
./usr/share/code/resources/app/node_modules.asar.unpacked/vsda/rust/
./usr/share/code/resources/app/node_modules.asar.unpacked/vsda/rust/web/
./usr/share/code/resources/app/node_modules.asar.unpacked/vsda/rust/web/vsda_bg.wasm
./usr/share/code/resources/app/out/
./usr/share/code/resources/app/out/bootstrap-fork.js
./usr/share/code/resources/app/out/cli.js
./usr/share/code/resources/app/out/main.js
./usr/share/code/resources/app/out/media/
...

上記のようにすべて、./usr/shareの中に作られていた。 debパッケージのdata.tarは基本的にインストールするシステムのルートディレクトリに展開されると考えてよいらしい。 そして、一般に/usr/shareにはアーキテクチャ非依存のファイルが置かれるらしい(つまり、jsやwasm、pngファイルなどが置かれるものらしい)。 それならば、x86のELFバイナリなどはなさそうだが調べてみたら、たくさん(といっても下記の27ファイル程度)ありそうだった。 理由を調べてみたいが、今回は一旦ここで終了。

find ./usr/share -type f -name '*' | xargs file | grep x86-64
./usr/share/code/chrome-sandbox:                                                                                                                  ELF 64-bit LSB pie executable, x86-64, version 1 (SYSV), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, for GNU/Linux 3.2.0, BuildID[sha1]=2097e5c14ea48a1c15644af3fa6bc386f1130303, with debug_info, not stripped
./usr/share/code/libEGL.so:                                                                                                                       ELF 64-bit LSB shared object, x86-64, version 1 (SYSV), dynamically linked, BuildID[sha1]=5ca551d83e15add4be7632cb656cb42302b494fd, not stripped
./usr/share/code/libvk_swiftshader.so:                                                                                                            ELF 64-bit LSB shared object, x86-64, version 1 (SYSV), dynamically linked, BuildID[sha1]=31ea968e0335b1c7839fd4ddc6570ce201dc3c08, not stripped
./usr/share/code/chrome_crashpad_handler:                                                                                                         ELF 64-bit LSB pie executable, x86-64, version 1 (SYSV), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, for GNU/Linux 3.2.0, BuildID[sha1]=c762c983799f705aff13a350098ff33f0a3e8f91, not stripped
./usr/share/code/resources/app/node_modules/node-pty/build/Release/pty.node:                                                                      ELF 64-bit LSB shared object, x86-64, version 1 (SYSV), dynamically linked, with debug_info, not stripped
./usr/share/code/resources/app/node_modules/@vscode/deviceid/build/Release/windows.node:                                                          ELF 64-bit LSB shared object, x86-64, version 1 (SYSV), dynamically linked, with debug_info, not stripped
./usr/share/code/resources/app/node_modules/@vscode/vsce-sign/bin/vsce-sign:                                                                      ELF 64-bit LSB pie executable, x86-64, version 1 (SYSV), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, for GNU/Linux 2.6.32, BuildID[sha1]=802749498bdfe7903f2aefd409e25e63620a1082, stripped
./usr/share/code/resources/app/node_modules/@vscode/policy-watcher/build/Release/vscode-policy-watcher.node:                                      ELF 64-bit LSB shared object, x86-64, version 1 (SYSV), dynamically linked, with debug_info, not stripped
./usr/share/code/resources/app/node_modules/@vscode/ripgrep/bin/rg:                                                                               ELF 64-bit LSB pie executable, x86-64, version 1 (SYSV), static-pie linked, BuildID[sha1]=c11c9bc818110b2370d9992f885037b7a1f74378, stripped
./usr/share/code/resources/app/node_modules/@vscode/spdlog/build/Release/spdlog.node:                                                             ELF 64-bit LSB shared object, x86-64, version 1 (SYSV), dynamically linked, with debug_info, not stripped
./usr/share/code/resources/app/node_modules/@vscode/sqlite3/build/Release/vscode-sqlite3.node:                                                    ELF 64-bit LSB shared object, x86-64, version 1 (SYSV), dynamically linked, with debug_info, not stripped
./usr/share/code/resources/app/node_modules/@parcel/watcher/build/Release/watcher.node:                                                           ELF 64-bit LSB shared object, x86-64, version 1 (SYSV), dynamically linked, with debug_info, not stripped
./usr/share/code/resources/app/node_modules/vsda/build/Release/vsda.node:                                                                         ELF 64-bit LSB shared object, x86-64, version 1 (SYSV), dynamically linked, with debug_info, not stripped
./usr/share/code/resources/app/node_modules/native-is-elevated/build/Release/iselevated.node:                                                     ELF 64-bit LSB shared object, x86-64, version 1 (SYSV), dynamically linked, with debug_info, not stripped
./usr/share/code/resources/app/node_modules/kerberos/build/Release/kerberos.node:                                                                 ELF 64-bit LSB shared object, x86-64, version 1 (SYSV), dynamically linked, with debug_info, not stripped
./usr/share/code/resources/app/node_modules/kerberos/build/Release/obj.target/kerberos.node:                                                      ELF 64-bit LSB shared object, x86-64, version 1 (SYSV), dynamically linked, with debug_info, not stripped
./usr/share/code/resources/app/node_modules/native-keymap/build/Release/keymapping.node:                                                          ELF 64-bit LSB shared object, x86-64, version 1 (SYSV), dynamically linked, with debug_info, not stripped
./usr/share/code/resources/app/node_modules/windows-foreground-love/build/Release/foreground_love.node:                                           ELF 64-bit LSB shared object, x86-64, version 1 (SYSV), dynamically linked, with debug_info, not stripped
./usr/share/code/resources/app/node_modules/windows-foreground-love/build/Release/obj.target/foreground_love.node:                                ELF 64-bit LSB shared object, x86-64, version 1 (SYSV), dynamically linked, with debug_info, not stripped
./usr/share/code/resources/app/node_modules/native-watchdog/build/Release/watchdog.node:                                                          ELF 64-bit LSB shared object, x86-64, version 1 (SYSV), dynamically linked, with debug_info, not stripped
./usr/share/code/resources/app/extensions/ms-vscode.js-debug/src/w32appcontainertokens-LVKSWXR7.node:                                             PE32+ executable (DLL) (GUI) x86-64, for MS Windows, 7 sections
./usr/share/code/resources/app/node_modules.asar.unpacked/vsda/build/Release/vsda.node:                             ELF 64-bit LSB shared object, x86-64, version 1 (SYSV), dynamically linked, with debug_info, not stripped
./usr/share/code/libffmpeg.so:                                                                                      ELF 64-bit LSB shared object, x86-64, version 1 (SYSV), dynamically linked, BuildID[sha1]=85555efd0683639134f90c4fbda3299227b3b1c0, not stripped
./usr/share/code/libvulkan.so.1:                                                                                    ELF 64-bit LSB shared object, x86-64, version 1 (SYSV), dynamically linked, BuildID[sha1]=48cafa1bd1eeeb500a3cee7cec9603f2440e9ce3, with debug_info, not stripped
./usr/share/code/bin/code-tunnel:                                                                                   ELF 64-bit LSB pie executable, x86-64, version 1 (SYSV), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, for GNU/Linux 4.19.255, stripped
./usr/share/code/code:                                                                                              ELF 64-bit LSB pie executable, x86-64, version 1 (SYSV), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, for GNU/Linux 3.2.0, BuildID[sha1]=31f0644bd480a238a6502663c96cddf8f97e65e6, not stripped
./usr/share/code/libGLESv2.so:                                                                                      ELF 64-bit LSB shared object, x86-64, version 1 (SYSV), dynamically linked, BuildID[sha1]=297c218174f142cb6dfec54a2010e642d1422520, not stripped

3. controle.tar.gz

tar -xvf control.tar.xz

次の5ファイルが生成された。

./control
./postinst
./postrm
./prerm
./templates

※ ファイルごとのmd5ハッシュ値を保存したmd5sumファイルは入っていなかった。

3-1. control

controlを見てみる。

cat control
Package: code
Version: 1.97.2-1739406807
Section: devel
Depends: ca-certificates, libasound2 (>= 1.0.17), libatk-bridge2.0-0 (>= 2.5.3), libatk1.0-0 (>= 2.2.0), libatspi2.0-0 (>= 2.9.90), libc6 (>= 2.14), libc6 (>= 2.16), libc6 (>= 2.17), libc6 (>= 2.2.5), libc6 (>= 2.25), libc6 (>= 2.28), libcairo2 (>= 1.6.0), libcurl3-gnutls | libcurl3-nss | libcurl4 | libcurl3, libdbus-1-3 (>= 1.9.14), libdrm2 (>= 2.4.75), libexpat1 (>= 2.1~beta3), libgbm1 (>= 17.1.0~rc2), libglib2.0-0 (>= 2.37.3), libgtk-3-0 (>= 3.9.10), libgtk-3-0 (>= 3.9.10) | libgtk-4-1, libnspr4 (>= 2:4.9-2~), libnss3 (>= 2:3.30), libnss3 (>= 3.26), libpango-1.0-0 (>= 1.14.0), libx11-6, libx11-6 (>= 2:1.4.99.1), libxcb1 (>= 1.9.2), libxcomposite1 (>= 1:0.4.4-1), libxdamage1 (>= 1:1.1), libxext6, libxfixes3, libxkbcommon0 (>= 0.5.0), libxkbfile1 (>= 1:1.1.0), libxrandr2, xdg-utils (>= 1.0.2)
Recommends: libvulkan1
Priority: optional
Architecture: amd64
Maintainer: Microsoft Corporation <[email protected]>
Homepage: https://code.visualstudio.com/
Installed-Size: 428947
Provides: visual-studio-code
Conflicts: visual-studio-code
Replaces: visual-studio-code
Description: Code editing. Redefined.
 Visual Studio Code is a new choice of tool that combines the simplicity of
 a code editor with what developers need for the core edit-build-debug cycle.
 See https://code.visualstudio.com/docs/setup/linux for installation
 instructions and FAQ.

Dependsのところに、依存が書かれている。

3-2. prerm

アンインストール前に実行されるシェルスクリプト。

cat prerm
#!/usr/bin/env bash
#
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See License.txt in the project root for license information.

# Deregister code from the alternatives system
update-alternatives --remove editor /usr/bin/code

3-3. postinst

install後に実行されるシェルスクリプト。

#!/usr/bin/env bash
#
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See License.txt in the project root for license information.

# Symlink bin command to /usr/bin
rm -f /usr/bin/code
ln -s /usr/share/code/bin/code /usr/bin/code

# Register code in the alternatives system
# Priority of 0 should never make code the default editor in auto mode as most
# developers would prefer a terminal editor as the default.
update-alternatives --install /usr/bin/editor editor /usr/bin/code 0

# Install the desktop entry
if hash update-desktop-database 2>/dev/null; then
        update-desktop-database
fi

# Update mimetype database to pickup workspace mimetype
if hash update-mime-database 2>/dev/null; then
        update-mime-database /usr/share/mime
fi
...長いので割愛

3-4. templates

debconfという設定プログラムで設定する値を対話形式で決定するための仕様ファイルらしい。

cat templates
Template: code/add-microsoft-repo
Type: boolean
Default: true
Description: Add Microsoft apt repository for Visual Studio Code?
 The installer would like to add the Microsoft repository and signing
 key to update VS Code through apt.

2. data.tar.xz

tar のtオプションは展開せずに中に入っているファイル名を見ることだけできる。

tar -tvf data.tar.xz | wc -l
2947

2947ファイルも入っている。 ファイル名を少し見てみる。

tar -tf data.tar.xz
./usr/share/code/resources/app/node_modules.asar.unpacked/vsda/build/Release/
./usr/share/code/resources/app/node_modules.asar.unpacked/vsda/build/Release/vsda.node
./usr/share/code/resources/app/node_modules.asar.unpacked/vsda/rust/
./usr/share/code/resources/app/node_modules.asar.unpacked/vsda/rust/web/
./usr/share/code/resources/app/node_modules.asar.unpacked/vsda/rust/web/vsda_bg.wasm
./usr/share/code/resources/app/out/
./usr/share/code/resources/app/out/bootstrap-fork.js
./usr/share/code/resources/app/out/cli.js
./usr/share/code/resources/app/out/main.js
./usr/share/code/resources/app/out/media/
...

展開するときはxオプション。

tar -xvf data.tar.xz
結果省略

上記のようにすべて、VSCodeのdata.tarを展開した場合の展開されたファイルは./usr/shareの中に作られていた。 基本的にdebファイルの展開はルートディレクトリで行われるはずなので、これはVSCodeのdebファイルをインストールした際には/usr/shareに展開されるはず。

そして一般に、/usr/shareディレクトリにはアーキテクチャ非依存のファイル(つまりjsやwasm、pngファイルなど)が置かれるらしい それならば、x86のELFバイナリなどはなさそうだが調べてみたら、たくさん(といっても下記の27ファイル程度)ありそうだった。 理由などを見てみたいが、一旦ここで終了。

find ./usr/share -type f -name '*' | xargs file | grep x86-64
./usr/share/code/chrome-sandbox:                                                                                                                  ELF 64-bit LSB pie executable, x86-64, version 1 (SYSV), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, for GNU/Linux 3.2.0, BuildID[sha1]=2097e5c14ea48a1c15644af3fa6bc386f1130303, with debug_info, not stripped
./usr/share/code/libEGL.so:                                                                                                                       ELF 64-bit LSB shared object, x86-64, version 1 (SYSV), dynamically linked, BuildID[sha1]=5ca551d83e15add4be7632cb656cb42302b494fd, not stripped
./usr/share/code/libvk_swiftshader.so:                                                                                                            ELF 64-bit LSB shared object, x86-64, version 1 (SYSV), dynamically linked, BuildID[sha1]=31ea968e0335b1c7839fd4ddc6570ce201dc3c08, not stripped
./usr/share/code/chrome_crashpad_handler:                                                                                                         ELF 64-bit LSB pie executable, x86-64, version 1 (SYSV), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, for GNU/Linux 3.2.0, BuildID[sha1]=c762c983799f705aff13a350098ff33f0a3e8f91, not stripped
./usr/share/code/resources/app/node_modules/node-pty/build/Release/pty.node:                                                                      ELF 64-bit LSB shared object, x86-64, version 1 (SYSV), dynamically linked, with debug_info, not stripped
./usr/share/code/resources/app/node_modules/@vscode/deviceid/build/Release/windows.node:                                                          ELF 64-bit LSB shared object, x86-64, version 1 (SYSV), dynamically linked, with debug_info, not stripped
./usr/share/code/resources/app/node_modules/@vscode/vsce-sign/bin/vsce-sign:                                                                      ELF 64-bit LSB pie executable, x86-64, version 1 (SYSV), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, for GNU/Linux 2.6.32, BuildID[sha1]=802749498bdfe7903f2aefd409e25e63620a1082, stripped
./usr/share/code/resources/app/node_modules/@vscode/policy-watcher/build/Release/vscode-policy-watcher.node:                                      ELF 64-bit LSB shared object, x86-64, version 1 (SYSV), dynamically linked, with debug_info, not stripped
./usr/share/code/resources/app/node_modules/@vscode/ripgrep/bin/rg:                                                                               ELF 64-bit LSB pie executable, x86-64, version 1 (SYSV), static-pie linked, BuildID[sha1]=c11c9bc818110b2370d9992f885037b7a1f74378, stripped
./usr/share/code/resources/app/node_modules/@vscode/spdlog/build/Release/spdlog.node:                                                             ELF 64-bit LSB shared object, x86-64, version 1 (SYSV), dynamically linked, with debug_info, not stripped
./usr/share/code/resources/app/node_modules/@vscode/sqlite3/build/Release/vscode-sqlite3.node:                                                    ELF 64-bit LSB shared object, x86-64, version 1 (SYSV), dynamically linked, with debug_info, not stripped
./usr/share/code/resources/app/node_modules/@parcel/watcher/build/Release/watcher.node:                                                           ELF 64-bit LSB shared object, x86-64, version 1 (SYSV), dynamically linked, with debug_info, not stripped
./usr/share/code/resources/app/node_modules/vsda/build/Release/vsda.node:                                                                         ELF 64-bit LSB shared object, x86-64, version 1 (SYSV), dynamically linked, with debug_info, not stripped
./usr/share/code/resources/app/node_modules/native-is-elevated/build/Release/iselevated.node:                                                     ELF 64-bit LSB shared object, x86-64, version 1 (SYSV), dynamically linked, with debug_info, not stripped
./usr/share/code/resources/app/node_modules/kerberos/build/Release/kerberos.node:                                                                 ELF 64-bit LSB shared object, x86-64, version 1 (SYSV), dynamically linked, with debug_info, not stripped
./usr/share/code/resources/app/node_modules/kerberos/build/Release/obj.target/kerberos.node:                                                      ELF 64-bit LSB shared object, x86-64, version 1 (SYSV), dynamically linked, with debug_info, not stripped
./usr/share/code/resources/app/node_modules/native-keymap/build/Release/keymapping.node:                                                          ELF 64-bit LSB shared object, x86-64, version 1 (SYSV), dynamically linked, with debug_info, not stripped
./usr/share/code/resources/app/node_modules/windows-foreground-love/build/Release/foreground_love.node:                                           ELF 64-bit LSB shared object, x86-64, version 1 (SYSV), dynamically linked, with debug_info, not stripped
./usr/share/code/resources/app/node_modules/windows-foreground-love/build/Release/obj.target/foreground_love.node:                                ELF 64-bit LSB shared object, x86-64, version 1 (SYSV), dynamically linked, with debug_info, not stripped
./usr/share/code/resources/app/node_modules/native-watchdog/build/Release/watchdog.node:                                                          ELF 64-bit LSB shared object, x86-64, version 1 (SYSV), dynamically linked, with debug_info, not stripped
./usr/share/code/resources/app/extensions/ms-vscode.js-debug/src/w32appcontainertokens-LVKSWXR7.node:                                             PE32+ executable (DLL) (GUI) x86-64, for MS Windows, 7 sections
./usr/share/code/resources/app/node_modules.asar.unpacked/vsda/build/Release/vsda.node:                             ELF 64-bit LSB shared object, x86-64, version 1 (SYSV), dynamically linked, with debug_info, not stripped
./usr/share/code/libffmpeg.so:                                                                                      ELF 64-bit LSB shared object, x86-64, version 1 (SYSV), dynamically linked, BuildID[sha1]=85555efd0683639134f90c4fbda3299227b3b1c0, not stripped
./usr/share/code/libvulkan.so.1:                                                                                    ELF 64-bit LSB shared object, x86-64, version 1 (SYSV), dynamically linked, BuildID[sha1]=48cafa1bd1eeeb500a3cee7cec9603f2440e9ce3, with debug_info, not stripped
./usr/share/code/bin/code-tunnel:                                                                                   ELF 64-bit LSB pie executable, x86-64, version 1 (SYSV), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, for GNU/Linux 4.19.255, stripped
./usr/share/code/code:                                                                                              ELF 64-bit LSB pie executable, x86-64, version 1 (SYSV), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, for GNU/Linux 3.2.0, BuildID[sha1]=31f0644bd480a238a6502663c96cddf8f97e65e6, not stripped
./usr/share/code/libGLESv2.so:                                                                                      ELF 64-bit LSB shared object, x86-64, version 1 (SYSV), dynamically linked, BuildID[sha1]=297c218174f142cb6dfec54a2010e642d1422520, not stripped

4. _gpgorigin

GPGの署名に使われているようだが、標準のdepパッケージに必ず含まれるものではないらしい。 署名のようなものが含まれていた。

cat _gpgorigin
-----BEGIN PGP SIGNATURE-----
Version: BSN Pgp v1.0.0.0

iQEcBAABCAAGBQJnrUNbAAoJEOs+lK2+EinPP1gH/2znCgixeHACfuubgDhdgL0i
ypSU84U9AmJJFbmfRDDBGYmyQouc8cTtBbIkU9W9Qk7E1ALM2FLhMCmGUtvcxvQp
9mEFjYADSJINRGibeT+Xl/lFbe0OyZUqxG1DG8beOfF8V1lCraxqnziQa9bk0aiA
UmAryF6+Wv8Gmlq02p2598EUhXOLN6ZywHind4q8AcmNAQANpKPc1Y/h7gcP0wyo
2MiSDRRRlEt4gqwsjcjP47Sm56Eaw0+kz7F8NOyk8ymcBbYGqrs56KYSU1jDzS83
mGDy1Rom/Kqfvv3Nu/CaoosGEbYY8Guc6eh5zkLAB/YvWhxwKibCBUXJ8tERjLE=
=EeVe
-----END PGP SIGNATURE-----