/dos-chocolatey-template

Reusable Chocolatey package template for historical DOS software preservation with DOSBox-X integration

Primary LanguagePowerShell

DOS Software Chocolatey Package Template

A reusable template for creating Chocolatey packages that preserve historical DOS software with DOSBox-X integration.

About This Template

This template provides a standardized structure for packaging DOS software as Chocolatey packages. It includes:

  • Automatic DOSBox-X detection from multiple installation sources
  • Configurable launcher with proper directory mounting
  • Demo mode for testing the package structure
  • Complete installation and uninstallation scripts

Template License: CC BY-NC-SA 4.0 Maintainer: Foadsf Repository: https://github.com/Foadsf/dos-chocolatey-template

Quick Start

Testing the Template

The template is a valid, installable Chocolatey package that demonstrates the structure:

choco pack
choco install dos-software-template -s "." -y
dos-software-template

This will launch DOSBox-X with a demonstration screen showing how the final package will work.

Creating a New Package

  1. Copy the template to a new directory:

    cp -r dos-chocolatey-template my-software-chocolatey
    cd my-software-chocolatey
  2. Update these files with your software details:

    • software-name.nuspec → rename and update all fields
    • software-name-launcher.bat → rename and customize DOSBox-X parameters
    • tools/chocolateyinstall.ps1 → update download URL, checksums, paths
    • tools/chocolateyuninstall.ps1 → update cleanup paths
    • tools/VERIFICATION.txt → document your software's verification
    • README.md → describe your specific software
  3. Set template mode to false in tools/chocolateyinstall.ps1:

    $isTemplate = $false  # Change from $true
  4. Upload your software to GitHub releases and update the download URL

  5. Calculate and update SHA256 hash:

    Get-FileHash -Algorithm SHA256 your-software.zip
  6. Test and build:

    choco pack
    choco install your-package-id -s "." -y

Template Structure

dos-chocolatey-template/
├── .gitignore
├── software-name-launcher.bat    # DOSBox-X launcher (rename this)
├── software-name.nuspec          # Package manifest (rename this)
├── README.md                     # Documentation (update this)
├── test-detection.ps1            # Test DOSBox-X detection
├── test-launcher.bat             # Test launcher detection
└── tools/
    ├── chocolateyinstall.ps1     # Installation script
    ├── chocolateyuninstall.ps1   # Uninstallation script
    ├── demo.bat                  # Demo script (replace with your software)
    └── VERIFICATION.txt          # Verification documentation

Placeholders to Replace

Search and replace these throughout all files:

Placeholder Description Example
[SOFTWARE-NAME] Full display name "DOS Navigator"
[package-id] Chocolatey package ID dn-dosnav
[command-name] CLI command name dn
dos-software-template Template package ID Your package ID
software-name-launcher.bat Launcher filename dn-launcher.bat
0.0.1 Template version 1.51.0
[username] GitHub username Foadsf
[repository-name] GitHub repo name dn-dosnav-chocolatey
[AUTHOR-NAME] Original software author RITLabs
[YEAR] Year of creation 1995
[SHA256-HASH-HERE] File checksums Get with Get-FileHash
[MAIN.EXE] or [MAIN-COMMAND] Main executable DN.COM

Customizing the Launcher

Edit software-name-launcher.bat to configure DOSBox-X for your software:

"%_DBX%" ^
  -set "output=opengl" ^          # Text mode (use openglnb for graphics)
  -c "mount c \"%CD%\"" ^         # Mount current directory as C:
  -c "mount d \"%_DOS_DIR%\"" ^   # Mount software directory as D:
  -c "c:" ^
  -c "d:" ^
  -c "YOUR-PROGRAM.EXE"           # Your software's main executable

Common DOSBox-X configurations:

  • Text mode: -set "output=opengl"
  • Graphics mode: -set "output=openglnb"
  • Sound Blaster: -c "mixer sb 100"
  • Memory: -c "mem /c 64"

Development and Testing

Testing DOSBox-X Detection

Before building, verify DOSBox-X detection works:

.\test-detection.ps1    # PowerShell test
.\test-launcher.bat     # Batch file test

Building from Source

choco pack
choco install your-package-id -s "." -y

Testing with Sandboxie-Plus

For safe testing without modifying your system:

# Start sandboxed PowerShell
"C:\Program Files\Sandboxie-Plus\Start.exe" /box:TestBox powershell.exe

# Inside sandbox
cd C:\path\to\package
choco pack
choco install your-package-id -s "." -y
your-command

Important: Clear the cache between tests:

# On host machine
Remove-Item -Recurse -Force "C:\Sandbox\[User]\[BoxName]\user\all\chocolatey\lib\your-package-id" -ErrorAction SilentlyContinue

# Inside sandbox
choco uninstall your-package-id -y
choco pack
choco install your-package-id -s "." -y --force

Helper Script

Create test-install.ps1 for faster iteration:

# Clean up completely
choco uninstall your-package-id -y 2>$null
Remove-Item -Recurse -Force "$env:ChocolateyInstall\lib\your-package-id" -ErrorAction SilentlyContinue

# Build fresh package
choco pack

# Install from local source
choco install your-package-id -s "." -y --force

File Hash Verification

Always verify your software archive:

Get-FileHash -Algorithm SHA256 your-software.zip

Update the hash in:

  • tools/chocolateyinstall.ps1 (Checksum parameter)
  • tools/VERIFICATION.txt (documentation)

Publishing Checklist

  • Replace all [placeholders] with actual values
  • Rename software-name-launcher.bat and software-name.nuspec
  • Set $isTemplate = $false in chocolateyinstall.ps1
  • Upload software binary to GitHub releases
  • Calculate SHA256 hash and update scripts
  • Update VERIFICATION.txt with actual hashes
  • Test detection scripts work
  • Test installation in Sandboxie-Plus
  • Verify uninstallation cleans up properly
  • Update README.md with software description
  • Add icon to images/icon.png (optional)
  • Commit and push to GitHub
  • Submit to Chocolatey Community Repository

Examples

This template has been used to create packages for:

Contributing

Improvements to the template are welcome! Please open an issue or pull request.

Credits

  • Template Author: Foadsf
  • License: CC BY-NC-SA 4.0
  • Purpose: Historical DOS software preservation

Support