Skip to content

Add Linux support and switch to official AmxModX github release URL for auto compiler download.#8

Merged
NiceFeatures merged 6 commits into
NiceFeatures:masterfrom
ibrahim-rouis:download-from-amxmodx
May 8, 2026
Merged

Add Linux support and switch to official AmxModX github release URL for auto compiler download.#8
NiceFeatures merged 6 commits into
NiceFeatures:masterfrom
ibrahim-rouis:download-from-amxmodx

Conversation

@ibrahim-rouis

Copy link
Copy Markdown

This pull request updates the way the AMX Mod X compiler is downloaded and extracted from official release page for both Linux and Windows users.

Tested and it work for both Linux and Windows.

Note: Linux users have to install 32bit support for their distro because the amxxpc compiler is 32bit.

@ibrahim-rouis

Copy link
Copy Markdown
Author

Since you are downloading a file that contains binary executables. I have added file integrity check using SHA256 algorithm.

Downloading from official source and verifying integrity will help your extension getting approved into Visual Studio marketplace.

@NiceFeatures

Copy link
Copy Markdown
Owner

Great job on this! Moving the compiler download to the official releases and adding the SHA256 integrity checks is a significant improvement. I've verified the hashes, and they match the files exactly.

However, I found a couple of issues in the extractZip function (within CP.exec) that will cause the process to fail in certain environments:

  1. Bash Wildcard Expansion Bug (Linux)
    In the cleanup command, you're using rm -rf "${destDir}/*.sma". In Bash, the wildcard * inside double quotes is treated as a literal character, so it won't expand. It will try to delete a file literally named .sma instead of all files with that extension. Fix: Move the wildcard outside of the quotes: rm -rf "${destDir}"/.sma

  2. PowerShell Escape Issue (Windows)
    In the Windows command, you're wrapping ${destDir} with single quotes ('${destDir}'). If a user's Windows path contains a single quote (e.g., C:\Users\John's PC...), the PowerShell command will break. You should escape single quotes by replacing them with two single quotes (''), which is the standard PowerShell escaping rule.

Suggested Fix
Here is a corrected version of the extractZip function that addresses both issues:

function extractZip(zipPath: string, destDir: string): Promise<void> {
    return new Promise((resolve, reject) => {
        // Escape single quotes for PowerShell (replace ' with '')
        const psDestDir = destDir.replace(/'/g, "''");
        const psZipPath = zipPath.replace(/'/g, "''");
        const cmd = process.platform === 'win32'
            ? `powershell -NoProfile -Command "Expand-Archive -Path '${psZipPath}' -DestinationPath '${psDestDir}' -Force; Copy-Item -Path '${psDestDir}\\addons\\amxmodx\\scripting\\*' -Destination '${psDestDir}' -Recurse -Force; Remove-Item -Path '${psDestDir}\\addons', '${psDestDir}\\testsuite', '${psDestDir}\\*.sma' -Recurse -Force"`
            : `tar -xzf "${zipPath}" --strip-components=3 -C "${destDir}" addons/amxmodx/scripting && rm -rf "${destDir}"/*.sma "${destDir}/testsuite"`;
            
        CP.exec(cmd, (error) => {
            if (error) reject(error);
            else resolve();
        });
    });
}

Once these small adjustments are made, this PR will be ready to merge!

@ibrahim-rouis

ibrahim-rouis commented May 8, 2026

Copy link
Copy Markdown
Author

Fixed. Thanks for the tips!

@NiceFeatures NiceFeatures merged commit 2b785d3 into NiceFeatures:master May 8, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants