Skip to content

Survival Guide for Non-Mainstream Distros: Extracting Files from deb/rpm Packages to Install Software Manually

On non-mainstream distributions like Gentoo, many mainstream applications either lack official ebuilds or are painful to compile. For example, closed-source commercial software like WeChat, QQ, and Trae only provide deb or rpm packages officially.

Today I’m sharing a “wild method” I’ve been using for a long time: extracting executables and dependencies directly from deb/rpm packages and manually assembling them into working software.

Reading Notes:

  1. This article uses Gentoo as an example. Other distributions follow similar approaches, but please refer to your distribution’s actual situation for specific operations.
  2. Workflow: Download deb/rpm package → Create software folder in user directory (e.g., ~/WeChat/) → Extract directly to that directory → Organize files → Fill dependencies → Write startup script → Write desktop file → Test run and troubleshoot.
  3. You can choose to extract in the download directory (e.g., ~/Downloads/) first, then move the needed files to the final directory; or extract directly in the final directory (e.g., ~/app-name/). Both approaches work. This article uses the direct extraction to final directory approach.
  4. Core idea: Extract → Fill dependencies → Write startup script → Write desktop file → Test run and troubleshoot.

⚠️ Important Notes:

  • File names in this article (such as wechat-linux.deb, qq.rpm, etc.) are for example only. Please use your actual downloaded file names.
  • You can use the mv command to rename your actual files to the example names, or replace the example names with your actual names. The method is the same.
  • I’m using Gentoo. Readers of other distributions can refer to the approach in this article, but please use your distribution’s actual commands and package managers.
  • The path /home/yui/ in this article is my username directory. Please replace it with your own username (e.g., /home/your-username/ or ~/).

1. Core Idea

Most deb/rpm packages are essentially compressed archives containing:

  • Executable files (usually in /opt/ or /usr/bin/)
  • Shared libraries (.so files)
  • Resource files (icons, language packs, etc.)
  • Desktop files (/usr/share/applications/)

We just need to extract these files, put them in a directory, then write a startup script and a desktop file. In most cases, the software will run on your distribution. Of course, whether it actually works depends on the software’s own dependency situation.

2. Extracting deb/rpm Packages

Universal Method: Extracting deb Packages

# Create target directory (WeChat is an example name, use your actual app name)
mkdir -p ~/WeChat

# Extract deb package contents (wechat-linux.deb is an example filename, use your actual filename)
dpkg-deb -x wechat-linux.deb ~/WeChat/

If you don’t have dpkg-deb (e.g., non-Debian distributions), you can use ar and tar:

# Use ar to extract deb package (deb is essentially an ar archive)
mkdir -p ~/WeChat
cd ~/WeChat
ar x ../wechat-linux.deb
tar -xf data.tar.xz # or data.tar.gz / data.tar.zst

Universal Method: Extracting rpm Packages

# Use rpm2cpio to extract (QQ is an example name, qq.rpm is an example filename, use your actual names)
mkdir -p ~/QQ
cd ~/QQ
rpm2cpio qq.rpm | cpio -idmv

If you don’t have rpm2cpio, you can verify that app-arch/rpm is installed successfully, or try using alien to convert:

# Install alien
sudo emerge app-arch/alien

# Convert rpm to tgz then extract
sudo alien --to-tgz qq.rpm
tar -xzf qq.tgz

Directory Structure After Extraction

The directory structure after extraction usually matches the system directory structure, but it depends on the package contents:

~/WeChat/
├── opt/wechat/ # Executables and libraries (some packages put them here)
└── usr/
├── share/
│ ├── applications/ # Desktop files
│ └── icons/ # Icons
└── doc/ # Documentation (e.g., changelog)

Note: Different software may have different directory structures:

  • Some software is placed under opt/ (e.g., WeChat, QQ)
  • Some software is placed under usr/ (e.g., Trae, Clash Verge)
  • Some packages may not have an etc/ directory
  • Refer to the actual extracted contents

3. Extraction Tools on Gentoo

On Gentoo, you need to install extraction tools first:

# Tools needed to extract deb packages
sudo emerge app-arch/dpkg

# Tools needed to extract rpm packages
sudo emerge app-arch/rpm

After installation, you can use dpkg-deb -x and rpm2cpio to extract packages.

4. Writing Startup Scripts

Extracted executables usually can’t run directly and need some environment variables and configurations.

Simple Case: WeChat (Example)

WeChat’s dependencies are in my environment relatively complete, only needing a simple startup script:

#!/bin/bash
# Note: The path /home/yui/WeChat/opt/wechat/wechat is an example, use your actual path
exec /home/yui/WeChat/opt/wechat/wechat "$@"

Medium Case: QQ (Example)

QQ in my environment needs to disable the DMA-BUF renderer, otherwise it may show a black screen under Wayland:

#!/bin/bash
# Note: The path /home/yui/QQ/opt/QQ/qq is an example, use your actual path
export WEBKIT_DISABLE_DMABUF_RENDERER=1
exec /home/yui/QQ/opt/QQ/qq "$@"

Complex Case: Trae (Example, Electron Application)

Trae is an editor based on Electron, which may need to handle Chinese environment, Wayland compatibility, and proxy:

#!/bin/bash
# Trae startup script (example)
# Note: The path /home/yui/trae is an example, use your actual path

cd /home/yui/trae

# Chinese environment
export LANG=zh_CN.UTF-8
export LC_ALL=zh_CN.UTF-8
export LANGUAGE=zh_CN:zh

# Wayland compatibility (Electron apps may need this under Wayland)
export GDK_BACKEND=x11
export QT_QPA_PLATFORM=xcb

# Proxy (if needed, proxy address is an example, use your actual proxy)
# 7897 is the default port for Clash Verge Rev. If you have Clash installed, you can use this method
# Or enable Clash's virtual network card mode (TUN mode), so all traffic goes through proxy automatically without setting environment variables
export https_proxy=http://127.0.0.1:7897 # Port number depends on your actual proxy configuration
export http_proxy=http://127.0.0.1:7897 # Port number depends on your actual proxy

# Run Trae
exec /home/yui/trae/usr/share/trae-cn/trae-cn "$@"

Common Environment Variables

Variable Purpose
WEBKIT_DISABLE_DMABUF_RENDERER=1 Disable DMA-BUF, may solve Wayland black screen
GDK_BACKEND=x11 Try to force X11 backend
QT_QPA_PLATFORM=xcb Try to make Qt apps use X11
LANG/LC_ALL Set language environment
http_proxy/https_proxy Set proxy
LD_LIBRARY_PATH Specify additional library search paths
FONTCONFIG_FILE Specify font configuration file

5. Writing Desktop Files

Desktop files make software appear in the application menu. You can copy and modify from the extracted package, or write your own.

WeChat Desktop File (Example)

[Desktop Entry]
Name=WeChat
Comment=Tencent WeChat
Exec=/home/yui/WeChat/run-wechat.sh # Note: Path is an example, use your actual path
Icon=/home/yui/WeChat/usr/share/icons/hicolor/256x256/apps/wechat.png # Icon path is an example
Terminal=false
Type=Application
Categories=Network;InstantMessaging;
StartupWMClass=wechat

QQ Desktop File (Example)

[Desktop Entry]
Name=QQ
Comment=Tencent QQ
Exec=/home/yui/QQ/run-qq.sh # Note: Path is an example, use your actual path
Icon=/home/yui/QQ/usr/share/icons/hicolor/512x512/apps/qq.png # Icon path is an example
Terminal=false
Type=Application
Categories=Network;InstantMessaging;
StartupWMClass=qq

Key Fields Explanation

Field Description
Exec Absolute path to the startup script, or you can write the full startup command directly (e.g., Exec=env WEBKIT_DISABLE_DMABUF_RENDERER=1 /home/yui/QQ/opt/QQ/qq %F)
Icon Absolute path to the icon file
StartupWMClass Window class name for taskbar icon grouping
Categories Application category
MimeType Supported file types

💡 Tip: The Exec field in Desktop files can either call a startup script (as shown in this article) or directly write the full startup command. Both approaches work, it’s a matter of personal preference. I prefer writing startup scripts because environment variables are clearer and easier to maintain and debug.

Place the desktop file in ~/.local/share/applications/. Most desktop environments will automatically detect new files. If it doesn’t work, you can run:

# Update desktop database
update-desktop-database ~/.local/share/applications/
# Or log out and log back in to your desktop environment

6. Dependency Handling on Gentoo

On Gentoo, extracted software may lack some dependency libraries, which need to be filled using Portage.

Checking for Missing Libraries (Example)

# Note: Path is an example, use your actual executable path
ldd /home/yui/WeChat/opt/wechat/wechat | grep "not found"

Finding Which Package Provides a Library (Example)

# Need to install gentoolkit first
sudo emerge app-portage/gentoolkit

# Use equery to find (libxxx.so is an example, use your actual missing library name)
equery belongs libxxx.so

Installing Missing Dependencies (Example)

# libxxx is an example package name, use the actual package name you found
sudo emerge media-libs/libxxx

Common Dependency Examples

For example, WeChat may need these dependencies:

  • media-libs/libvlc - VLC media library
  • media-video/ffmpeg - Audio/video processing
  • dev-libs/nss - Network security services
  • x11-libs/gtk+ - GTK graphics library

What you actually need depends on what ldd shows.

7. Test Run and Troubleshooting

Step 1: Run Directly from Command Line (Example)

First, run the executable directly in the terminal to see what dependencies are missing:

# Note: Path is an example, use your actual executable path
/home/yui/WeChat/opt/wechat/wechat

Common Errors and Solutions

1. Missing Shared Libraries

error while loading shared libraries: libxxx.so: cannot open shared object file

Solution:

  • Use ldd /path/to/executable to check for missing libraries
  • Find the corresponding .so file from the deb/rpm package
  • Or use your distribution’s package manager to install system-level dependencies

2. Chinese Characters Displayed as Squares

Font missing, Chinese characters displayed as squares

Solution:

  • Install Chinese fonts: emerge media-fonts/noto-cjk
  • Or set FONTCONFIG_FILE in the startup script to point to a custom font configuration

3. Black Screen/Crash under Wayland

If your desktop environment uses Wayland, you may encounter this issue:

Solution:

  • Try adding WEBKIT_DISABLE_DMABUF_RENDERER=1
  • Or try forcing X11: GDK_BACKEND=x11
  • For Electron apps, try: --ozone-platform=x11 or --ozone-platform-hint=auto

4. Proxy Not Working

If your software needs to go through a proxy:

Solution:

  • Set http_proxy and https_proxy in the startup script
  • Electron apps may need additional --proxy-server parameter
  • Or try using proxychains: proxychains4 /path/to/executable

5. Permission Issues

Permission denied

Solution:

# Note: Paths are examples, use your actual paths
chmod +x /home/yui/WeChat/opt/wechat/wechat
chmod +x /home/yui/WeChat/run-wechat.sh

6. Sandbox Errors (Electron Applications)

The SUID sandbox helper binary was found, but is not configured correctly

Solution:

  • Add --no-sandbox parameter in the startup script
  • Or set the CHROME_DEVEL_SANDBOX environment variable

8. Advanced Techniques

1. Using LD_LIBRARY_PATH to Specify Library Paths (Example)

If the software’s library versions differ from the system, you can try placing libraries in the software directory:

#!/bin/bash
# Note: Paths are examples, use your actual paths
export LD_LIBRARY_PATH=/home/yui/WeChat/opt/wechat/lib:$LD_LIBRARY_PATH
exec /home/yui/WeChat/opt/wechat/wechat "$@"

2. Automatic Update Script (Example)

Write a script to automatically download the latest version and extract it:

#!/bin/bash
# update-wechat.sh (example, use your actual filename)

cd /tmp
# Note: URL is an example, use your actual download link
wget https://example.com/wechat-linux.deb

rm -rf ~/WeChat
mkdir -p ~/WeChat
dpkg-deb -x wechat-linux.deb ~/WeChat/

echo "WeChat has been updated"

3. Using patchelf to Modify ELF Files (Example)

If library paths are incorrect, you can try using patchelf to modify them:

# Install patchelf
sudo emerge dev-util/patchelf

# Modify RPATH (paths are examples, use your actual paths)
patchelf --set-rpath '$ORIGIN/lib' /home/yui/WeChat/opt/wechat/wechat

# View current RPATH (paths are examples, use your actual paths)
patchelf --print-rpath /home/yui/WeChat/opt/wechat/wechat

4. Debugging with strace (Example)

If the software fails to start, you can use strace to view system calls:

# Note: Path is an example, use your actual executable path
strace -f /home/yui/WeChat/opt/wechat/wechat 2>&1 | grep -E "open|ENOENT"

5. Checking Dependency Integrity with ldd (Example)

# Note: Path is an example, use your actual executable path
# List all dependencies
ldd /home/yui/WeChat/opt/wechat/wechat

# Only show missing libraries
ldd /home/yui/WeChat/opt/wechat/wechat | grep "not found"

9. My Software Directory Structure

Currently, I’ve installed these software using this method:

/home/yui/
├── WeChat/ # WeChat (deb package, has opt/ directory)
│ ├── opt/wechat/ # Executables and libraries
│ ├── usr/ # Icons, desktop files, etc.
│ └── run-wechat.sh # Startup script
├── QQ/ # QQ (deb package, has opt/ directory)
│ ├── opt/QQ/ # Executables and libraries
│ ├── usr/ # Icons, desktop files, etc.
│ └── run-qq.sh # Startup script
├── trae/ # Trae (rpm package, only has usr/ directory)
│ ├── usr/share/trae-cn/ # Executables are here
│ └── trae-launcher.sh # Startup script
└── clash/ # Clash Verge (rpm package, only has usr/ directory)
├── usr/bin/ # Executables
├── usr/lib/ # Resource files
├── usr/share/ # Icons, desktop files
└── clash-verge.sh # Startup script

As you can see, different packages have quite different directory structures:

  • deb packages (WeChat, QQ) usually have an opt/ directory
  • rpm packages (Trae, Clash) usually only have a usr/ directory
  • Refer to the actual extracted contents

10. Summary

Advantages of this method:

  • No root privileges required: All files are in the user directory
  • Doesn’t affect the system: Won’t conflict with Portage-managed packages
  • Flexible and controllable: Can customize environment variables and startup parameters
  • Learning value: Gain deep understanding of Linux software dependencies

Disadvantages:

  • Manual updates required: Need to re-extract when software updates
  • Dependency management is troublesome: Need to handle missing libraries yourself
  • Security: Closed-source software, cannot audit code
  • Compatibility: Some software may depend on distribution-specific features

Overall, for users of non-mainstream distributions like Gentoo, this is a very practical “wild method”. Although not elegant, if it solves the problem, it’s a good method.


Tips:

  • If you’re using KDE Plasma, you can set StartupWMClass in “System Settings → Appearance → Application Style” to correctly group taskbar icons.
  • For Electron applications, consider using versions packaged with electron-builder, which usually have more complete dependencies.
  • If a software really won’t run, you might want to try the Flatpak or AppImage version.

About this Post

This post is written by 青空由依(AozoraYui)/青空由纪(AozoraYuki)/青空葵(AozoraAoi), licensed under CC BY-NC 4.0.

#Linux #Gentoo #Efficiency