Как распаковать deb на linux
5.4. Работа с пакетами при помощи dpkg
ЗАМЕТКА dpkg или apt ?
5.4.1. Установка пакетов
Пример 5.2. Установка пакета при помощи dpkg
Пример 5.3. Раздельная распаковка и настройка
ВНИМАНИЕ Эффективное использование —force-*
5.4.2. Удаление пакета
Пример 5.4. Полное удаление пакета debian-cd
5.4.3. Запросы к базе данных dpkg и анализ файлов .deb
К ОСНОВАМ Синтаксис опций команд
Пример 5.5. Получение информации с помощью dpkg
УГЛУБЛЯЕМСЯ Сравнение версий
5.4.4. Файл журнала dpkg
5.4.5. Поддержка мультиархитектуры
5.4.5.1. Включение мультиархитектуры
ЗАМЕТКА Поддержка мультиархитектуры в APT
НА ПРАКТИКЕ Использование собственнических двоичных файлов i386 в системах amd64
How to Extract / Decompress .deb file in Ubuntu 20.04/22.04 [Graphical & Command Line]
Got a .deb file and want to extract or decompress it? Here’s how to do the trick in Ubuntu, Debian and other Linux in different ways.
DEB file:
The file with .deb extension is an installer package for Debian and Ubuntu based systems. Similar to EXE file for Windows, DEB is a commonly used method to install apps in Ubuntu/Debian Linux.
Sometimes user might need to extract a file from deb, or edit the scripts in a third-party deb that are built incorrectly. And, here’s how to extract / decompress the package in both graphical and command line ways.
Method 1: Extract DEB with System Archive Manager:
The system archive manager in most of today’s Linux desktops has the ability to extract .deb files.
Firstly, right-click on the file in file manager and click on “Open With Other Application” option. Next, select ‘Archive Manager‘ to open it in pop-up dialog.
When the deb opens in Archive Manager, you’ll mostly see the following 3 files:
- debian-binary
- data.tar.xz
- control.tar.gz
While debian-binary stores the version of deb package format, data.tar.xz contains all the files to be installed on system. And, control.tar.gz includes the ‘control’ file with basic package information and list of dependency packages. As well, it may have ‘ pre-install ‘ and ‘ post-install ‘ scripts that run automatically during the installation process.
And, here you just need to choose the content you need, and click on ‘Extract’ button. Then browser and use them in file manager.
Method 2: Decompress & Re-pack DEB via dpkg-deb command:
dpkg-deb is the command line manipulation tool for .deb file. It’s a good choice to decompress and re-pack the package, as the previous method might NOT work sometimes.
Firstly, open a ‘terminal’ window (or connect to server console) from start menu. When it opens, run commands below as need:
NOTE: using dpkg-deb will mess up file permission and ownership on file extraction! If you want to re-pack them into DEB again, use ‘fakeroot’ to run the commands below as script or try Method 3.
- Navigate to the folder that contains the deb file via cd command. For example, go to ‘Downloads’ folder by running command:
- List content in current working directory via:
- And, decompress deb package into ‘tmp’ folder via command:
And, to repack them from tmp folder into a new DEB package, use command:
Method 3: use ar command to do decompress and re-package process:
ar is a command line tool to create, modify, and extract from archives. User may use ar command to handle DEB file without worrying about permission and ownership. And, ar is available NOT only in Ubuntu/Debian Linux, but also CentOS, Rocky Linux, and other Linux.
Open terminal (or connect to command console) and go to the directory that contains the DEB package. Then do commands below to extract ‘control.tar.gz’ and repack it.
NOTE: A deb package may contain either ‘control.tar.gz‘ or ‘control.tar.xz‘, use the commands below accordingly.
- Create and go to ‘tmp’ folder:
- Extract content of ‘control.tar.xz’ from DEB into the folder:
DEB sometimes contain the control package via “control.tar.gz”, so the command will be:
Here do use the original format! For ‘control.tar.gz’, use command:
And re-pack the edited version of control.tar.xz into new deb:
Or re-pack the control.tar.gz via:
Summary:
For desktop PC, the system Archive Manager can extract a .deb package in most time. Besides, dpkg-deb command is available to decompress all files and re-pack them, though ‘fakeroot’ is required to avoid permission and ownership issue! As well, ar is a good choice to extract and repack control archive without worrying about permission and ownership issue.
Easily unpack DEB, edit postinst, and repack DEB
I’m attempting to install Intel’s OpenCL SDK but the DEB files are buggy conversions from RPM (see here for the curious). I need to edit the postinst script in the DEB they provide.
How can I take an existing DEB, extract the contents (including the control information), then later repackage the contents to make a new DEB? I will only edit files, no files will be added or removed.
3 Answers 3
The primary command to manipulate deb packages is dpkg-deb .
To unpack the package, create an empty directory and switch to it, then run dpkg-deb to extract its control information and the package files. Use dpkg-deb -b to rebuild the package.
Beware that unless your script is running as root, the files’ permissions and ownership will be corrupted at the extraction stage. One way to avoid this is to run your script under fakeroot . Note that you need to run the whole sequence under fakeroot , not each dpkg-deb individually, since it’s the fakeroot process that keeps the memory of the permissions of the files that can’t be created as they are.
Rather than mess with permissions, you can keep the data archive intact and modify only the control archive. dpkg-deb doesn’t provide a way to do that. Fortunately, deb packges are in a standard format: they’re ar archives. So you can use ar to extract the control archive, modify its files, and use ar again to replace the control archive by a new version.
You should add a changelog entry and change the version number if you modify anything in the package. The infrastructure to manipulate Debian packages assumes that if two packages have the same name and version, they’re the same package. Add a suffix to the debian_revision part at the end of the version number; for sorting reasons the suffix should start with
, e.g. 1.2.3-4.1 becomes 1.2.3-4.1
Instead of using shell tools, you can use Emacs. The dpkg-dev-el package (which is its own upstream as this is a native Debian package) contains modes to edit .deb files and to edit Debian changelogs. Emacs can be used interactively or scripted.
Как извлечь файл .deb
Я загрузил файл .deb Debian. Как извлечь пакет deb без установки его в системе на Debian или Ubuntu Linux? Как мне просмотреть и извлечь содержимое пакета Debian?
Пакет Debian или Ubuntu .deb — это не что иное, как старый добрый формат архива Unix ar. Команда ar используется для хранения групп файлов как одного архива, а .deb включает следующие три файла:
- Debian-binary — текстовый файл, указывающий версию формата пакета .deb.
- Control.tar.gz — сжатый файл, содержащий md5sums и контрольный каталог для создания пакета.
- Data.tar.xz — сжатый файл и содержит все файлы, которые будут установлены в вашей системе.
Посмотрим, как просмотреть и извлечь содержимое файла пакета .deb на Debian / Mint / Ubuntu Linux, используя различные параметры командной строки.
Шаг 1. Загрузите пакет .deb.
Используйте команду apt-get command / apt для загрузки файла с именем nginx *.deb: