Code Monkey home page Code Monkey logo

macos-installer-builder's Introduction

License

macOS Installer Builder

Generate macOS installers for your applications and products from one command.

For a more detailed process please refer medium blog about the macOS installer builder: https://medium.com/swlh/the-easiest-way-to-build-macos-installer-for-your-application-34a11dd08744

Let’s Build our macOS Installer

First, you need to clone the macOS installer builder repository on your machine and then add needed configurations to it. After that, you only need to run the command to build your application’s installer. Let’s start our journey.

  1. Clone macos-installer-builder repository to your local machine. You can clone the repository by the following command. Let’s define the repository’s home as <REPO_HOME>.
git clone https://github.com/KosalaHerath/macos-installer-builder.git
  1. Copy your application’s distribution files (which you need to be copied after the installation) to the application directory which is located at:
<REPO_HOME>/macOS-x64/application/
  1. Modify the following files with your application's information. You can find these resource files in the following location.
<REPO_HOME>/macOS-x64/darwin/Resources/

welcome.html :

The welcome page of the installer can be defined by this HTML file.

conclusion.html :

This file contains the conclusion file’s HTML design and you can change it as you wish.

banner.png :

Add an image of your application’s logo after renaming it as banner.png.

  1. Add your needed modifications to the post-installation script file. This script will run automatically after the installation and you can add your needed functionalities to this file. The file is located at:
<REPO_HOME>/macOS-x64/darwin/scripts/postinstall
  1. Run the following command to build your macOS installer.
bash <PRODUCT_HOME>/macOS-x64/build-macos-x64.sh [APPLICATION_NAME] [APPLICATION_VERSION]

Note: You should provide an application name and application version. In addition, the application version should be [0–9].[0–9].[0–9] pattern ( Example: 2.6.0 ). This will start the installer generating process (3-step process) and after two progress it will ask your preference on installer signing. Please refer to this section for more details on installer signing. If you have an Apple Developer Installer Certificate issued by the Developer ID Certification Authority of Apple you can sign your installer by giving you certificate ID. If you wish to create the installer without signing you can skip that step (You need an internet connection to sign the installer).

After the successful three steps, the macOS installer builder will create .pkg file of your application on the following location:

Signed Package:

<REPO_HOME>/macOS-x64/target/pkg-signed/

Un-signed Package:

<REPO_HOME>/macOS-x64/target/pkg/

That’s it. Now you can start the installation process by clicking the .pkg file.

Signing .pkg files

Run the below command to sign the .pkg file

productsign --sign "Developer ID Installer: <CERTIFICATE_NAME_AND_ID>" <INSTALLER_NAME>.pkg

To verify the signed .pkg file run the following command:

pkgutil --check-signature signed/<SIGNED_INSTALLER_NAME>.pkg

You will see an output with SHA1 fingerprint after the above command if the .pkg file’s sign validation is successful.

Please suggest any modifications that will improve these implementations by reporting an issue. Happy to help you!

Cheers!! 🍺

macos-installer-builder's People

Contributors

axemasta avatar colin99d avatar kosalaherath avatar rhettbull avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

macos-installer-builder's Issues

Welcome conclusion and Banner broken

Somehow the welcome, conclusion pages are broken say they are not visible anymore
package still generate and install nicely

macOS Catalina with

Apache Maven 3.6.3 (cecedd343002696d0abb50b32b541b8a6ba2883f)
Maven home: /usr/local/Cellar/maven/3.6.3_1/libexec
Java version: 13.0.2, vendor: N/A, runtime: /usr/local/Cellar/openjdk/13.0.2+8_2/libexec/openjdk.jdk/Contents/Home
Default locale: en_GB, platform encoding: UTF-8
OS name: "mac os x", version: "10.15.5", arch: "x86_64", family: "mac"

jBallerina 1.2.4
Language specification 2020R1
Ballerina tool 0.8.5

can't create .pkg file in the target directory

hi:
I have an c++ executable program and want to make it into a pkg format installation package.
I copy it to the macOS-x64/application/
then run :
bash ./macOS-x64/build-macos-x64.sh gtz_set 2.1.2

cat: ./utils/ascii_art.txt: No such file or directory

Application Name : gtz_set
Application Version : 2.1.2
[2020-01-15 11:52:46][WARN] Apache Maven was not found. Please install Maven first.
[2020-01-15 11:52:46][WARN] Ballerina was not found. Please install ballerina first.
[2020-01-15 11:52:46][INFO] Installer generating process started.
[2020-01-15 11:52:46][INFO] Cleaning target directory.
cp: darwin: No such file or directory
chmod: target/darwin/scripts: No such file or directory
chmod: target/darwin/Resources: No such file or directory
chmod: target/darwin/Distribution: No such file or directory
sed: target/darwin/scripts/postinstall: No such file or directory
sed: target/darwin/scripts/postinstall: No such file or directory
chmod: target/darwin/scripts/postinstall: No such file or directory
sed: target/darwin/Distribution: No such file or directory
sed: target/darwin/Distribution: No such file or directory
chmod: target/darwin/Distribution: No such file or directory
sed: target/darwin/Resources/.html: No such file or directory
sed: target/darwin/Resources/
.html: No such file or directory
chmod: target/darwin/Resources/: No such file or directory
cp: ./application/.: No such file or directory
cp: darwin/Resources/uninstall.sh: No such file or directory
sed: target/darwinpkg/Library/gtz_set/2.1.2/uninstall.sh: No such file or directory
sed: target/darwinpkg/Library/gtz_set/2.1.2/uninstall.sh: No such file or directory
[2020-01-15 11:52:46][INFO] Application installer generation process started.(3 Steps)
[2020-01-15 11:52:46][INFO] Apllication installer package building started.(1/3)
[2020-01-15 11:52:46][INFO] Application installer product building started.(2/3)
Do you wish to sign the installer (You should have Apple Developer Certificate) [y/N]?N
[2020-01-15 11:52:46][INFO] Skiped signing process.
[2020-01-15 11:52:46][INFO] Application installer generation steps finished.
[2020-01-15 11:52:46][INFO] Installer generating process finished

at last ,I can't find the pkg file in the macos-installer-builder/target....

I need your help....thanks!

Confised over Medium Blog

Would be grateful if someone could explain this line of the medium blog.

bash <PRODUCT_HOME>/macOS-x64/build-macos-x64.sh [APPLICATION_NAME] [APPLICATION_VERSION]

Whats <PRODUCT_HOME> ? I guess its a path but to where same as ?

Thanks

Python version of this script

Hello. First, thank you for open sourcing this repo. Your code and the accompanying blog article were incredibly helpful as Apple's own documentation on building installers is very lacking. To make it easier to create these, I've created a derivative work rewritten in python as a command line tool called applecrate. It can be installed via pipx install applecrate and used with any binaries, not just those created in python. It uses a template system to auto-generate all the necessary files but allows you to also add custom pre- and post-install scripts, etc. as well as generate the welcome and conclusion using Markdown.

Thanks again for building and sharing this!

Payload path option

Hello @KosalaHerath, Is there a possibility for me to choose the directory of the file inside the installer?
For instance, I have a plugin that needs to be placed in -/Library/Audio/Plug-ins/Components.

How can do this in macos-installer-builder?

Thanks
Screenshot 2022-11-25 at 10 14 51

Medium article is behind a pay/login wall

Currently it is not possible to read the medium article that is referred to from the Readme.
Maybe copy relevant parts to the readme to make it accessible for people without medium login.

README image is down

No image found at url https://kb.brandeis.edu/download/attachments/4620383/macoshero.jpg?version=1&modificationDate=1533823619000&api=v2 in README.md

Commands in post install

Hi,
Is it possible to insert commands / calls in the post install to change a default MacOS program?
For example ask to change the e-mail program or the browser?

regards
Antonello

Product names with spaces not supported

The installer builder only works when the product name passed in has no spaces. I've got a fix in my fork if you are interested. It required an update to build-macos-x64.sh and Distribution.

[Question] Does it support .app?

I put MyApplication.app in application folder and modify postinstall.sh

#Custermize this for your application
APPLICATION_FILE_PATH=MyApplication.app

#Parameters
PRODUCT_HOME=/opt/__PRODUCT__/__VERSION__

than run build-macos-x64.sh MyApplication 1.0.0

But, I can't find MyApplication.app in /opt folder

Banner image does not display on dark theme (fix included)

Banner images will not display as part of installer packages for macOS using dark theme. The Distribution file needs to have an additional line added:

This:

<background mime-type="image/png" file="banner.png" scaling="proportional"/>

Should become this:

<background mime-type="image/png" file="banner.png" scaling="proportional"/>
<background-darkAqua mime-type="image/png" file="banner.png" scaling="proportional"/>

Cheers

Picture cannot be shown in conclusion.html

Hi,

This is a powerful tool. But now I want to add one QR Code in the complete page, I tried load picture from internet, from local and encode picture as base64 in the conclusion.html. But the picture cannot be shown. Please let me know whether you have any suggestion for this. Thank you!

Script does not work when in file path with spaces

When running the script from a file path without spaces:
/Users/axemasta/Desktop/macos-installer-builder/macOS-x64/build-macos-x64.sh

The script executes and works as expected.

When running the script from a file path with spaces:
/Users/axemasta/Desktop/Lunatic Using Spaces/macOS-x64/build-macos-x64.sh

The script reports a number of errors and fails to execute. This is caused by the use of variables not being escaped and causing the spaces cause confusion. For example if I tried to make a directory at the following location:

TARGET_DIRECTORY="/Users/axemasta/Desktop/Lunatic Using Spaces/macOS-x64/target"
mkdir $TARGET_DIRECTORY

It would make a folder at path:
/Users/axemasta/Desktop/Lunatic

The usage needs to be escaped like so:
mkdir "$TARGET_DIRECTORY"

I know its a little bit of a nit pick but I've cleaned up the file to escape any paths so that it can be used by crazy people like me who like to put spaces in their repository & folders.

Fantastic tool helped me build an installer really quickly, thanks a-lot for providing this!

Where do I even begin to debug?

Hi @KosalaHerath

First of all thanks for the simple yet effective utility. I am however struggling to get it to work for me. Perhaps because I have very little understanding of pkgbuild and productbuild utilities.

What I am trying to do:-
My installer has no payload and contains only a post-install script. The post-install script does the following:-

  1. Checks if a certain binary (mybinary) is installed on the target machine.
  2. Pulls a couple of config files from a GitHub repo.
  3. Puts the config files in place with mybinary.
  4. Launch the binary as a launchctl service.
#!/bin/bash
which -s brew
if [[ $? != 0 ]] ; then
    # Install Homebrew
    ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
else
    brew update
fi

which -s mybinary
if [[ $? != 0 ]] ; then
    # Install mybinary
    brew cask install mybinary
else 
    cd /var/mybinary
    if [[ $? != 0 ]] ;  then
        echo "mybinary is installed but directory structure not matching"
    fi
fi

echo "Creating temp directory..."
install_dir=$(mktemp -d) && cd  ${install_dir} && git clone https://github.com/my-repo/mybinary_deps && cd mybinary_deps

echo "Copying dependencies..."

sudo cp * /var/mybinary/
cd /var/mybinary
sudo cp com.mybinary.plist /Library/LaunchDaemons
sudo launchctl load /Library/LaunchDaemons/com.mybinary.plist
echo "Post installation process finished"

The post-install script works perfectly as a standalone shell script but when I try to create a package with macos-installer-builder it doesn't. The installer run fine without any error. But it doesn't install the binaries. What am I missing here?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.