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:
- This article uses Gentoo as an example. Other distributions follow similar approaches, but please refer to your distribution’s actual situation for specific operations.
- 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.- 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.- 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
mvcommand 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 (
.sofiles) - 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) |
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) |
Universal Method: Extracting rpm Packages
# Use rpm2cpio to extract (QQ is an example name, qq.rpm is an example filename, use your actual names) |
If you don’t have rpm2cpio, you can verify that app-arch/rpm is installed successfully, or try using alien to convert:
# Install alien |
Directory Structure After Extraction
The directory structure after extraction usually matches the system directory structure, but it depends on the package contents:
~/WeChat/ |
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 |
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:
|
Medium Case: QQ (Example)
QQ in my environment needs to disable the DMA-BUF renderer, otherwise it may show a black screen under Wayland:
|
Complex Case: Trae (Example, Electron Application)
Trae is an editor based on Electron, which may need to handle Chinese environment, Wayland compatibility, and proxy:
|
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] |
QQ Desktop File (Example)
[Desktop Entry] |
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
Execfield 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 |
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 |
Finding Which Package Provides a Library (Example)
# Need to install gentoolkit first |
Installing Missing Dependencies (Example)
# libxxx is an example package name, use the actual package name you found |
Common Dependency Examples
For example, WeChat may need these dependencies:
media-libs/libvlc- VLC media librarymedia-video/ffmpeg- Audio/video processingdev-libs/nss- Network security servicesx11-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 |
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/executableto check for missing libraries - Find the corresponding
.sofile 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_FILEin 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=x11or--ozone-platform-hint=auto
4. Proxy Not Working
If your software needs to go through a proxy:
Solution:
- Set
http_proxyandhttps_proxyin the startup script - Electron apps may need additional
--proxy-serverparameter - Or try using
proxychains:proxychains4 /path/to/executable
5. Permission Issues
Permission denied |
Solution:
# Note: Paths are examples, use your actual paths |
6. Sandbox Errors (Electron Applications)
The SUID sandbox helper binary was found, but is not configured correctly |
Solution:
- Add
--no-sandboxparameter in the startup script - Or set the
CHROME_DEVEL_SANDBOXenvironment 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:
|
2. Automatic Update Script (Example)
Write a script to automatically download the latest version and extract it:
|
3. Using patchelf to Modify ELF Files (Example)
If library paths are incorrect, you can try using patchelf to modify them:
# Install patchelf |
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 |
5. Checking Dependency Integrity with ldd (Example)
# Note: Path is an example, use your actual executable path |
9. My Software Directory Structure
Currently, I’ve installed these software using this method:
/home/yui/ |
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
StartupWMClassin “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.