Stories:
13718
Members:
2000
Submitted Reviews:
38645
Reviewers:
936
bin to pkg bin to pkg bin to pkg bin to pkg bin to pkg bin to pkg bin to pkg bin to pkg bin to pkg bin to pkg bin to pkg bin to pkg bin to pkg bin to pkg bin to pkg bin to pkg
< 4.3 - Lords of the Red Planet
5.1 - Nightmare Country >

Pkg: Bin To

Pkg: Bin To

Basic Package Creation # Create directory structure mkdir -p myapp/usr/local/bin cp your_binary myapp/usr/local/bin/ Build the package pkgbuild --root myapp --identifier com.yourcompany.myapp --version 1.0.0 --install-location / myapp.pkg Advanced Package with Scripts # Create directory structure mkdir -p package_root/usr/local/bin mkdir -p scripts Copy your binary cp your_binary package_root/usr/local/bin/ Create pre-install script (optional) cat > scripts/preinstall << 'EOF' #!/bin/bash echo "Pre-installation tasks..." Stop running processes, backup configs, etc. EOF chmod +x scripts/preinstall Create post-install script (optional) cat > scripts/postinstall << 'EOF' #!/bin/bash echo "Post-installation tasks..." chmod 755 /usr/local/bin/your_binary Set permissions, run setup commands, etc. EOF chmod +x scripts/postinstall Build package with scripts pkgbuild --root package_root --scripts scripts --identifier com.yourcompany.myapp --version 1.0.0 --install-location / myapp.pkg Method 2: Using productbuild (For Distribution) Create Component Property List # Generate component plist pkgbuild --analyze --root package_root component.plist Build component package pkgbuild --root package_root --component-plist component.plist --identifier com.yourcompany.myapp --version 1.0.0 component.pkg Create distribution package productbuild --package component.pkg --identifier com.yourcompany.myapp --version 1.0.0 --sign "Developer ID Installer: Your Name (TEAMID)" final_installer.pkg Method 3: Simple Flat Package # One-liner for a single binary pkgbuild --root /path/to/binary/directory \ --identifier com.example.myapp \ --version 1.0 \ --install-location /usr/local/bin \ myapp.pkg Example: Complete Script #!/bin/bash APP_NAME="myapp" BINARY_PATH="./${APP_NAME}" VERSION="1.0.0" IDENTIFIER="com.mycompany.${APP_NAME}" Create package structure PKG_ROOT="pkg_root" SCRIPTS_DIR="scripts"

rm -rf ${PKG_ROOT} ${SCRIPTS_DIR} mkdir -p ${PKG_ROOT}/usr/local/bin mkdir -p ${SCRIPTS_DIR} cp ${BINARY_PATH} ${PKG_ROOT}/usr/local/bin/ Create postinstall script cat > ${SCRIPTS_DIR}/postinstall << EOF #!/bin/bash chmod 755 /usr/local/bin/${APP_NAME} echo "${APP_NAME} v${VERSION} installed successfully" EOF bin to pkg

chmod +x ${SCRIPTS_DIR}/postinstall pkgbuild --root ${PKG_ROOT} --scripts ${SCRIPTS_DIR} --identifier ${IDENTIFIER} --version ${VERSION} --install-location / ${APP_NAME}-${VERSION}.pkg Basic Package Creation # Create directory structure mkdir