From b38c49600f8fd8427ef887add0926fa5836c17c2 Mon Sep 17 00:00:00 2001 From: Armin Briegel <1933192+scriptingosx@users.noreply.github.com> Date: Tue, 17 Aug 2021 12:25:59 +0200 Subject: [PATCH] implemented --pkg and --notarize options --- utils/README.md | 22 ++++++++------- utils/assemble.sh | 69 +++++++++++++++++++++++++++++++++++++++++++++-- 2 files changed, 79 insertions(+), 12 deletions(-) diff --git a/utils/README.md b/utils/README.md index 2520255..4909df1 100644 --- a/utils/README.md +++ b/utils/README.md @@ -4,6 +4,18 @@ Since the Installomator.sh script has grown to over 3000 lines, its management o The full script is assembled using the `utils/assemble.sh` tool. For convenience, there is a symbolic link in the root of the repository. +## Fragments + +These are the fragments in the order they are assembled: + +- header.sh +- version.sh +- functions.sh +- arguments.sh +- (optiona) all labels from locations given with the ``--labels` argument +- labels/*.sh +- main.txt + ## assemble.sh Usage ``` @@ -53,14 +65,4 @@ assemble.sh --notarize Build the full script, disable Debug mode, sign it, build a signed pkg, and send it to notarization. -## The Fragments -These are the fragments in the order they are assembled: - -- header.txt -- version.txt -- functions.txt -- arguments.txt -- all labels from locations given with the ``--labels` argument -- labels/*.txt -- main.txt diff --git a/utils/assemble.sh b/utils/assemble.sh index c72ab70..7771c6c 100755 --- a/utils/assemble.sh +++ b/utils/assemble.sh @@ -1,5 +1,18 @@ #!/bin/zsh +# settings + +# package +pkgname="Installomator" +identifier="com.scriptingosx.${pkgname}" +install_location="/usr/local/Installomator/" +signature="Developer ID Installer: Armin Briegel (JME5BW3F3R)" + +# notarization +dev_team="JME5BW3F3R" # asc-provider +dev_account="developer@scriptingosx.com" +dev_keychain_label="notary-scriptingosx" + # parse arguments zparseopts -D -E -a opts r -run s -script p -pkg n -notarize h -help -labels+:=label_args l+:=label_args @@ -113,9 +126,61 @@ fi if [[ $buildScript -eq 1 ]]; then echo "# copying script to $repo_dir/Installomator.sh" cp $destination_file $repo_dir/Installomator.sh + chmod 755 $repo_dir/Installomator.sh fi -# TODO: build a pkg when flag is set +# build a pkg when flag is set +if [[ buildPkg -eq 1 ]]; then + echo "# building installer package" + + tmpfolder=$(mktemp -d) + payloadfolder="${tmpfolder}/payload" -# TODO: notarize when flag is set + # create a projectfolder with a payload folder + if [[ ! -d "${payloadfolder}" ]]; then + mkdir -p "${payloadfolder}" + fi + # copy the script file + cp $repo_dir/Installomator.sh ${payloadfolder} + chmod 755 ${payloadfolder}/Installomator.sh + + # set the DEBUG variable to 0 + sed -i '' -e 's/^DEBUG=1$/DEBUG=0/g' ${payloadfolder}/Installomator.sh + + # build the component package + pkgpath="${script_dir}/${pkgname}.pkg" + + pkgbuild --root "${payloadfolder}" \ + --identifier "${identifier}" \ + --version "${version}" \ + --install-location "${install_location}" \ + "${pkgpath}" + + # build the product archive + + productpath="${repo_dir}/${pkgname}-${version}.pkg" + + productbuild --package "${pkgpath}" \ + --version "${version}" \ + --identifier "${identifier}" \ + --sign "${signature}" \ + "${productpath}" + + # clean up project folder + rm -Rf "${projectfolder}" + # clean the component pkgname + rm "$pkgpath" +fi + +# notarize when flag is set +if [[ $notarizePkg -eq 1 ]]; then + # NOTE: notarytool requires Xcode 13 + + # upload for notarization + xcrun notarytool submit "$productpath" --keychain-profile "$dev_keychain_label" --wait + + # staple result + echo "# Stapling $productpath" + xcrun stapler staple "$productpath" +fi \ No newline at end of file