# How to Handle Linux Distributions Without yum for Dify Plugin Repackaging Prerequisites

> Learn to adapt the Dify plugin repackaging script for Linux distributions without yum. Resolve installation issues on Debian, Ubuntu, and Alpine by understanding and modifying the script's package manager detection for unzip.

- Repository: [Junjie.M/dify-plugin-repackaging](https://github.com/junjiem/dify-plugin-repackaging)
- Tags: how-to-guide
- Published: 2026-03-05

---

**The [`plugin_repackaging.sh`](https://github.com/junjiem/dify-plugin-repackaging/blob/main/plugin_repackaging.sh) script from the `junjiem/dify-plugin-repackaging` repository hardcodes the `yum` command in its `install_unzip` function, causing immediate failures on Debian, Ubuntu, Alpine, and other non-RPM distributions unless you manually install `unzip` or replace the function with a portable package-manager detector.**

The `junjiem/dify-plugin-repackaging` repository provides a Bash wrapper to download and repackage Dify plugins, but its prerequisite handling assumes a Red Hat-based environment. Because the `install_unzip` function in [`plugin_repackaging.sh`](https://github.com/junjiem/dify-plugin-repackaging/blob/main/plugin_repackaging.sh) exclusively calls `yum` to install the `unzip` utility, users on Ubuntu, Alpine, Arch, or openSUSE encounter errors before any repackaging begins. This guide explains how to handle Linux distributions without `yum` by either pre-installing dependencies or enhancing the script for cross-platform compatibility.

## Why the Script Fails on Non-RPM Systems

In [`plugin_repackaging.sh`](https://github.com/junjiem/dify-plugin-repackaging/blob/main/plugin_repackaging.sh) at lines 48–57, the `install_unzip` function assumes the presence of the RPM-based package manager:

```bash
install_unzip(){
    if ! command -v unzip &> /dev/null; then
        echo "Installing unzip ..."
        yum -y install unzip
        # ...

    fi
}

```

Since `yum` only exists on RHEL-derived distributions (RHEL, CentOS, Fedora, Oracle Linux), the script aborts on Debian/Ubuntu, Alpine, Arch, and openSUSE. The repository’s README acknowledges this limitation, stating: “The script uses `yum` to install `unzip`… To use the script on other distributions, please install `unzip` command in advance.”

## Solutions for Running Without yum

You have two primary approaches to resolve the `yum` dependency: manually installing `unzip` before execution, or modifying the script to auto-detect the local package manager.

### Pre-install unzip Manually

The simplest workaround is to install `unzip` using your distribution’s native package manager before invoking the script. This bypasses the `install_unzip` function entirely.

**Debian/Ubuntu:**

```bash
sudo apt-get update && sudo apt-get install -y unzip

```

**Alpine Linux:**

```bash
sudo apk add unzip

```

**Arch Linux:**

```bash
sudo pacman -Sy --noconfirm unzip

```

**openSUSE:**

```bash
sudo zypper install -y unzip

```

After installation, run the original script normally:

```bash
./plugin_repackaging.sh market antv visualization 0.1.7

```

### Modify the Script for Automatic Detection

For a permanent, portable solution, replace the hardcoded `yum` logic in [`plugin_repackaging.sh`](https://github.com/junjiem/dify-plugin-repackaging/blob/main/plugin_repackaging.sh) with a function that detects the available package manager. This modification makes the script truly distribution-agnostic.

Replace the original `install_unzip` function (lines 48–57) with this enhanced version:

```bash

# ----------------------------------------------------------------------

# Enhanced install_unzip – works on most Linux distributions

# ----------------------------------------------------------------------

install_unzip(){
    if command -v unzip &>/dev/null; then
        return 0
    fi

    echo "Installing unzip ..."
    # Detect package manager

    if command -v dnf &>/dev/null; then
        sudo dnf -y install unzip
    elif command -v yum &>/dev/null; then
        sudo yum -y install unzip
    elif command -v apt-get &>/dev/null; then
        sudo apt-get update && sudo apt-get install -y unzip
    elif command -v apk &>/dev/null; then
        sudo apk add unzip
    elif command -v zypper &>/dev/null; then
        sudo zypper install -y unzip
    elif command -v pacman &>/dev/null; then
        sudo pacman -Sy --noconfirm unzip
    else
        echo "Unsupported distribution – please install 'unzip' manually."
        exit 1
    fi

    if ! command -v unzip &>/dev/null; then
        echo "Install unzip failed."
        exit 1
    fi
}

```

This implementation checks for `unzip` first (making it idempotent), then probes for `dnf`, `yum`, `apt-get`, `apk`, `zypper`, and `pacman` in that order. It falls back to a clear error message if no supported package manager is found.

## Step-by-Step Implementation Guide

Follow these steps to deploy the fix in your local copy of the repository.

1. **Locate the function** in [`plugin_repackaging.sh`](https://github.com/junjiem/dify-plugin-repackaging/blob/main/plugin_repackaging.sh) at lines 48–57:

```bash
sed -n '48,57p' plugin_repackaging.sh

```

2. **Backup the original file**:

```bash
cp plugin_repackaging.sh plugin_repackaging.sh.bak

```

3. **Replace the function** using a text editor or `sed`. Ensure the new function handles all major package managers as shown in the previous section.

4. **Test on your target distribution**:

```bash

# Ubuntu/Debian test

./plugin_repackaging.sh local ./my_plugin.difypkg

# Alpine test

./plugin_repackaging.sh github junjiem/dify-plugin-tools-dbquery v0.0.2 db_query.difypkg

```

5. **Update documentation** in [`README.md`](https://github.com/junjiem/dify-plugin-repackaging/blob/main/README.md) to reflect that the script now supports multiple distributions automatically:

```markdown

### Prerequisites

The script automatically installs `unzip` on most Linux distributions (RHEL, Ubuntu, Alpine, Arch, openSUSE). If your distribution uses an unrecognized package manager, please install `unzip` manually before execution.

```

## Summary

- **The `install_unzip` function** in [`plugin_repackaging.sh`](https://github.com/junjiem/dify-plugin-repackaging/blob/main/plugin_repackaging.sh) (lines 48–57) hardcodes `yum`, limiting the script to RHEL-based systems.
- **Manual pre-installation** of `unzip` using `apt-get`, `apk`, `pacman`, or `zypper` allows immediate use on non-RPM distributions without code changes.
- **Auto-detection logic** replaces the hardcoded command with a cascade of `elif` statements checking for `dnf`, `yum`, `apt-get`, `apk`, `zypper`, and `pacman`, creating a robust, cross-platform prerequisite handler.
- **CI/CD reliability** improves when the script handles Ubuntu-based runners (GitHub Actions, GitLab CI) without manual intervention.

## Frequently Asked Questions

### Why does the script fail on Ubuntu with "yum: command not found"?

The `install_unzip` function in [`plugin_repackaging.sh`](https://github.com/junjiem/dify-plugin-repackaging/blob/main/plugin_repackaging.sh) calls `yum -y install unzip` unconditionally when the `unzip` binary is missing. Ubuntu and Debian use `apt-get` instead of `yum`, so the command is not found and the script exits. Either install `unzip` manually with `apt-get` before running the script, or replace the function with the package-manager detection logic provided above.

### Can I use the script on Alpine Linux without modifying the source code?

Yes, but you must pre-install `unzip` manually using `apk add unzip` before execution. The original script cannot install dependencies automatically on Alpine because it lacks the `yum` command. Once `unzip` is present in your PATH, the `install_unzip` function skips the installation attempt and proceeds with repackaging.

### How do I make the script work across multiple different Linux distributions?

Replace the original `install_unzip` function (lines 48–57) with the enhanced version that detects the local package manager. This version checks for `dnf`, `yum`, `apt-get`, `apk`, `zypper`, and `pacman`, then invokes the appropriate command for the current system. Store this modified script in your repository or container image to ensure it works on RHEL, Ubuntu, Alpine, Arch, and openSUSE without modification.

### Is the modified script safe to use in CI/CD pipelines?

Yes. The enhanced `install_unzip` function is idempotent—it checks if `unzip` already exists before attempting installation—and it supports the Ubuntu-based runners commonly used in GitHub Actions and GitLab CI. The function also returns explicit exit codes (1) on failure, allowing pipelines to fail fast with clear error messages if prerequisite installation fails.