Skip to content

Instantly share code, notes, and snippets.

@szhu
Last active June 26, 2026 10:38
Show Gist options
  • Select an option

  • Save szhu/afd806ec1eb874848e1b4f412be7aaaf to your computer and use it in GitHub Desktop.

Select an option

Save szhu/afd806ec1eb874848e1b4f412be7aaaf to your computer and use it in GitHub Desktop.
#!/bin/bash
#
# Run this now:
#
# bash -c "$(curl -fsSL "https://gist.githubusercontent.com/szhu/afd806ec1eb874848e1b4f412be7aaaf/raw/a6c51e413c65cf66019280c35e598ff6d5dd6cea/macos-install-legacy-hp-printer-drivers.sh")"
#
# This script makes it possible to install legacy HP printer drivers on modern
# versions of macOS.
#
# The HP 5.1.1 Printer Software Update (https://support.apple.com/en-us/106385)
# is the final official driver bundle released by Apple to provide support for
# third-party printers, including host-based models like the HP LaserJet P1006.
#
# - The package is declared to be compatible with macOS 10.14 – 11.
# - It contains userspace drivers (still compatible with latest macOS) and
# kernel drivers (compatible with up to macOS 10.15).
# - On macOS 10.15 and later, the kernel drivers are not needed, because macOS
# natively handles the low-level USB transport layer.
# - FYI: the sequence of macOS versions around this time was:
# 10.13 - 10.14 - 10.15 - 11 - 12 - 13 - 14 - 15 - 26 - 27
#
# The script only copies user-space drivers from the package without installing
# the kernel drivers. I tested that this allows me to print to my HP LaserJet
# P1006 printer from macOS 26.
set -e
# 1. Setup variables
URL="https://updates.cdn-apple.com/2021/macos/071-46903-20211101-0BD2764A-901C-41BA-9573-C17B8FDC4D90/HewlettPackardPrinterDrivers.dmg"
WORK_DIR=$(mktemp -d)
MOUNT_POINT="$WORK_DIR/mount"
EXPANDED_DIR="$WORK_DIR/expanded"
echo "[1/6] Checking for Rosetta 2..."
if [ "$(uname -p)" = "arm" ]; then
if /usr/bin/pgrep -q oahd; then
echo " Rosetta is running."
else
echo " Rosetta is not running. Please run 'softwareupdate --install-rosetta' first."
exit 1
fi
fi
echo "[2/6] Downloading HP printer drivers..."
curl -L -o "$WORK_DIR/hp_drivers.dmg" "$URL"
echo "[3/6] Mounting disk image..."
hdiutil attach "$WORK_DIR/hp_drivers.dmg" -mountpoint "$MOUNT_POINT" -nobrowse -quiet
echo "[4/6] Expanding package payload..."
pkgutil --expand-full "$MOUNT_POINT/HewlettPackardPrinterDrivers.pkg" "$EXPANDED_DIR"
echo "[5/6] Installing drivers (user-space only)..."
# A. Backup existing drivers
if [ -d "/Library/Printers/hp" ]; then
BACKUP_SUFFIX=bak-$(date -u '+%Y%m%d%H%M%S')
echo " Backing up existing /Library/Printers/hp to /Library/Printers/hp.$BACKUP_SUFFIX..."
sudo mv /Library/Printers/hp "/Library/Printers/hp.$BACKUP_SUFFIX"
fi
# B. Install the HP filter and backend binaries
echo " Copying binaries to /Library/Printers/hp..."
sudo cp -R "$EXPANDED_DIR/HewlettPackardPrinterDrivers.pkg/Payload/Library/Printers/hp" "/Library/Printers/"
# C. Install the PPDs
echo " Copying PPDs to /Library/Printers/PPDs/Contents/Resources/..."
sudo cp -R "$EXPANDED_DIR/HewlettPackardPrinterDrivers.pkg/Payload/Library/Printers/PPDs/Contents/Resources/"* "/Library/Printers/PPDs/Contents/Resources/"
# D. Set permissions
echo " Fixing permissions..."
sudo chown -R root:wheel "/Library/Printers/hp"
sudo chmod -R 755 "/Library/Printers/hp"
echo "[6/6] Cleanup..."
hdiutil detach "$MOUNT_POINT" -quiet
rm -rf "$WORK_DIR"
echo
echo "SUCCESS!"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment