#!/bin/bash # --------------------------------------------------------- # Creates a OSX flat installer package from a Linux # environment. You need xar and bomutils in your $PATH # --------------------------------------------------------- # # kudos to SchizoDuckie for putting this gist together # # https://gist.github.com/SchizoDuckie/2a1a1cc71284e6463b9a # https://krypted.com/mac-os-x/inspecting-creating-mac-installer-packages-linux/ # ---------------------------------------------------------- # The following variables need to be overriden by environment vars : "${VERSION:=0.0.1}" : "${APPNAME:=TestApp}" : "${IDENTIFIER:=se.leap.bitmask.installer}" # ---------------------------------------------------------- BUILD_DIR="../dist" BASE_DIR="../build/osx" BACKGROUND="../assets/osx-background.png" # ---------------------------------------------------------- initialize () { rm -rf "$BASE_DIR/darwin" mkdir -p "$BASE_DIR/darwin/flat/Resources/en.lproj" mkdir -p "$BASE_DIR/darwin/flat/base.pkg/" mkdir -p "$BASE_DIR/darwin/root/Applications" mkdir -p "$BASE_DIR/darwin/scripts" cp -R $BUILD_DIR/*.app $BASE_DIR/darwin/root/Applications cp -R scripts/* $BASE_DIR/darwin/scripts/ cp $BACKGROUND $BASE_DIR/darwin/flat/Resources/en.lproj/background.png NUM_FILES=$(find ${BASE_DIR}/darwin/root | wc -l) INSTALL_KB_SIZE=$(du -k -s ${BASE_DIR}/darwin/root | awk "{print $1}") } # TODO for localization, these files should be taken from transifex, etc. # TODO hardcoding a foundation for now. writeInstallerDocs () { cat < ${BASE_DIR}/darwin/flat/Resources/en.lproj/welcome.html

${APPNAME} installer

This will guide you through the steps needed to install ${APPNAME} in your computer.

${APPNAME} is a simple, fast and secure VPN developed by the Bitmask team. This app is configured to connect to a single trusted VPN provider.


The service is expensive to run. Please donate at https://riseup.net/vpn/donate

EOF } writePackageInfo () { cat < ${BASE_DIR}/darwin/flat/base.pkg/PackageInfo EOF } writeDistribution () { cat < ${BASE_DIR}/darwin/flat/Distribution ${APPNAME} ${VERSION} #base.pkg EOF } createPackage () { PKG_NAME="${APPNAME}-${VERSION}_unsigned.pkg" PKG_LOCATION="../../${PKG_NAME}" PKG_LOCATION_REL="${BASE_DIR}/${PKG_NAME}" PKG_FINAL="${BUILD_DIR}/${PKG_NAME}" ( cd ${BASE_DIR}/darwin/root && find . | cpio -o --format odc --owner 0:80 | gzip -c ) > ${BASE_DIR}/darwin/flat/base.pkg/Payload ( cd ${BASE_DIR}/darwin/scripts && find . | cpio -o --format odc --owner 0:80 | gzip -c ) > ${BASE_DIR}/darwin/flat/base.pkg/Scripts mkbom -u 0 -g 80 ${BASE_DIR}/darwin/root ${BASE_DIR}/darwin/flat/base.pkg/Bom ( cd ${BASE_DIR}/darwin/flat/ && xar --compression none -cf "${PKG_LOCATION}" * ) cp ${PKG_LOCATION_REL} ${PKG_FINAL} echo "[+] OSX package has been built: ${PKG_FINAL}" } initialize writeInstallerDocs writePackageInfo writeDistribution createPackage