mirror of
https://github.com/balena-io/etcher.git
synced 2025-07-23 19:26:33 +00:00
chore: use electron-builder
to generate macOS builds (#1511)
This commit makes use of electron-builder to replace what our scripts were already doing. Signed-off-by: Juan Cruz Viotti <jv@jviotti.com>
This commit is contained in:
parent
07adafe6f3
commit
2f605497be
1
.gitattributes
vendored
1
.gitattributes
vendored
@ -31,6 +31,7 @@ Makefile text
|
||||
*.gz binary diff=hex
|
||||
*.icns binary diff=hex
|
||||
*.ico binary diff=hex
|
||||
*.tiff binary diff=hex
|
||||
*.img binary diff=hex
|
||||
*.iso binary diff=hex
|
||||
*.png binary diff=hex
|
||||
|
47
Makefile
47
Makefile
@ -2,7 +2,7 @@
|
||||
# Build configuration
|
||||
# ---------------------------------------------------------------------
|
||||
|
||||
NPX=./node_modules/.bin/npx
|
||||
NPX = ./node_modules/.bin/npx
|
||||
|
||||
# This directory will be completely deleted by the `clean` rule
|
||||
BUILD_DIRECTORY ?= dist
|
||||
@ -26,8 +26,6 @@ COMPANY_NAME = Resinio Ltd
|
||||
APPLICATION_NAME = $(shell jq -r '.build.productName' package.json)
|
||||
APPLICATION_DESCRIPTION = $(shell jq -r '.description' package.json)
|
||||
APPLICATION_COPYRIGHT = $(shell jq -r '.build.copyright' package.json)
|
||||
APPLICATION_CATEGORY = $(shell jq -r '.build.mac.category' package.json)
|
||||
APPLICATION_BUNDLE_ID = $(shell jq -r '.build.appId' package.json)
|
||||
APPLICATION_FILES = lib,assets
|
||||
|
||||
# Add the current commit to the version if release type is "snapshot"
|
||||
@ -331,17 +329,6 @@ $(BUILD_DIRECTORY)/$(APPLICATION_NAME)-$(APPLICATION_VERSION)-$(TARGET_PLATFORM)
|
||||
$(BUILD_DIRECTORY)/electron-$(TARGET_PLATFORM)-$(APPLICATION_VERSION)-$(TARGET_ARCH)-app.asar \
|
||||
$(BUILD_DIRECTORY)/electron-$(ELECTRON_VERSION)-$(TARGET_PLATFORM)-$(TARGET_ARCH).zip \
|
||||
| $(BUILD_DIRECTORY) $(BUILD_TEMPORARY_DIRECTORY)
|
||||
ifeq ($(TARGET_PLATFORM),darwin)
|
||||
./scripts/build/electron-configure-package-darwin.sh -p $(word 2,$^) -a $< \
|
||||
-n "$(APPLICATION_NAME)" \
|
||||
-v "$(APPLICATION_VERSION)" \
|
||||
-b "$(APPLICATION_BUNDLE_ID)" \
|
||||
-c "$(APPLICATION_COPYRIGHT)" \
|
||||
-t "$(APPLICATION_CATEGORY)" \
|
||||
-i assets/icon.icns \
|
||||
-o $@
|
||||
endif
|
||||
|
||||
ifeq ($(TARGET_PLATFORM),linux)
|
||||
./scripts/build/electron-configure-package-linux.sh -p $(word 2,$^) -a $< \
|
||||
-n "$(APPLICATION_NAME)" \
|
||||
@ -371,32 +358,20 @@ endif
|
||||
endif
|
||||
endif
|
||||
|
||||
$(BUILD_DIRECTORY)/$(APPLICATION_NAME)-$(APPLICATION_VERSION)-$(TARGET_PLATFORM)-$(TARGET_ARCH)-rw.dmg: \
|
||||
$(BUILD_DIRECTORY)/$(APPLICATION_NAME)-$(APPLICATION_VERSION)-darwin-$(TARGET_ARCH) \
|
||||
| $(BUILD_DIRECTORY)
|
||||
./scripts/build/electron-create-readwrite-dmg-darwin.sh -p $< -o $@ \
|
||||
-n "$(APPLICATION_NAME)" \
|
||||
-i assets/icon.icns \
|
||||
-b assets/osx/installer.png
|
||||
assets/osx/installer.tiff: assets/osx/installer.png assets/osx/installer@2x.png
|
||||
tiffutil -cathidpicheck $^ -out $@
|
||||
|
||||
$(BUILD_OUTPUT_DIRECTORY)/$(APPLICATION_NAME)-$(APPLICATION_VERSION)-darwin-$(TARGET_ARCH).zip: \
|
||||
$(BUILD_DIRECTORY)/$(APPLICATION_NAME)-$(APPLICATION_VERSION)-darwin-$(TARGET_ARCH) \
|
||||
$(BUILD_OUTPUT_DIRECTORY)/$(APPLICATION_NAME)-$(APPLICATION_VERSION)-darwin-$(TARGET_ARCH).dmg: assets/osx/installer.tiff \
|
||||
| $(BUILD_OUTPUT_DIRECTORY)
|
||||
ifdef CODE_SIGN_IDENTITY
|
||||
./scripts/build/electron-sign-app-darwin.sh -a $</$(APPLICATION_NAME).app -i "$(CODE_SIGN_IDENTITY)"
|
||||
endif
|
||||
./scripts/build/zip-file.sh -f $</$(APPLICATION_NAME).app -s $(TARGET_PLATFORM) -o $@
|
||||
CSC_NAME="$(CODE_SIGN_IDENTITY)" CSC_IDENTITY_AUTO_DISCOVERY=false TARGET_ARCH=$(TARGET_ARCH) \
|
||||
$(NPX) build --mac dmg $(ELECTRON_BUILDER_OPTIONS)
|
||||
mv $(BUILD_DIRECTORY)/$(notdir $@) $@
|
||||
|
||||
$(BUILD_OUTPUT_DIRECTORY)/$(APPLICATION_NAME)-$(APPLICATION_VERSION)-darwin-$(TARGET_ARCH).dmg: \
|
||||
$(BUILD_DIRECTORY)/$(APPLICATION_NAME)-$(APPLICATION_VERSION)-$(TARGET_PLATFORM)-$(TARGET_ARCH)-rw.dmg \
|
||||
$(BUILD_OUTPUT_DIRECTORY)/$(APPLICATION_NAME)-$(APPLICATION_VERSION)-darwin-$(TARGET_ARCH).zip: assets/osx/installer.tiff \
|
||||
| $(BUILD_OUTPUT_DIRECTORY)
|
||||
ifdef CODE_SIGN_IDENTITY
|
||||
./scripts/build/electron-sign-dmg-darwin.sh \
|
||||
-n "$(APPLICATION_NAME)" \
|
||||
-d $< \
|
||||
-i "$(CODE_SIGN_IDENTITY)"
|
||||
endif
|
||||
./scripts/build/electron-create-readonly-dmg-darwin.sh -d $< -o $@
|
||||
CSC_NAME="$(CODE_SIGN_IDENTITY)" CSC_IDENTITY_AUTO_DISCOVERY=false TARGET_ARCH=$(TARGET_ARCH) \
|
||||
$(NPX) build --mac zip $(ELECTRON_BUILDER_OPTIONS)
|
||||
mv $(BUILD_DIRECTORY)/$(notdir $@) $@
|
||||
|
||||
$(BUILD_DIRECTORY)/$(APPLICATION_NAME)-$(APPLICATION_VERSION)-linux-$(TARGET_ARCH).AppDir: \
|
||||
$(BUILD_DIRECTORY)/$(APPLICATION_NAME)-$(APPLICATION_VERSION)-linux-$(TARGET_ARCH) \
|
||||
|
BIN
assets/osx/installer.tiff
Normal file
BIN
assets/osx/installer.tiff
Normal file
Binary file not shown.
23
package.json
23
package.json
@ -35,8 +35,31 @@
|
||||
"**/*.node"
|
||||
],
|
||||
"mac": {
|
||||
"icon": "assets/icon.icns",
|
||||
"artifactName": "${productName}-${version}-darwin-${env.TARGET_ARCH}.${ext}",
|
||||
"category": "public.app-category.developer-tools"
|
||||
},
|
||||
"dmg": {
|
||||
"background": "assets/osx/installer.tiff",
|
||||
"icon": "assets/icon.icns",
|
||||
"iconSize": 110,
|
||||
"contents": [
|
||||
{
|
||||
"x": 140,
|
||||
"y": 225
|
||||
},
|
||||
{
|
||||
"x": 415,
|
||||
"y": 225,
|
||||
"type": "link",
|
||||
"path": "/Applications"
|
||||
}
|
||||
],
|
||||
"window": {
|
||||
"width": 540,
|
||||
"height": 405
|
||||
}
|
||||
},
|
||||
"win": {
|
||||
"icon": "assets/icon.ico"
|
||||
},
|
||||
|
@ -1,146 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
###
|
||||
# Copyright 2016 resin.io
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
###
|
||||
|
||||
set -u
|
||||
set -e
|
||||
|
||||
OS=$(uname)
|
||||
if [[ "$OS" != "Darwin" ]]; then
|
||||
echo "This script is only meant to be run in OS X" 1>&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
./scripts/build/check-dependency.sh /usr/libexec/PlistBuddy
|
||||
./scripts/build/check-dependency.sh unzip
|
||||
|
||||
function usage() {
|
||||
echo "Usage: $0"
|
||||
echo ""
|
||||
echo "Options"
|
||||
echo ""
|
||||
echo " -p <electron package>"
|
||||
echo " -n <application name>"
|
||||
echo " -v <application version>"
|
||||
echo " -b <application bundle id>"
|
||||
echo " -c <application copyright>"
|
||||
echo " -t <application category>"
|
||||
echo " -a <application asar (.asar)>"
|
||||
echo " -i <application icon (.icns)>"
|
||||
echo " -o <output directory>"
|
||||
exit 1
|
||||
}
|
||||
|
||||
ARGV_ELECTRON_PACKAGE=""
|
||||
ARGV_APPLICATION_NAME=""
|
||||
ARGV_VERSION=""
|
||||
ARGV_BUNDLE_ID=""
|
||||
ARGV_COPYRIGHT=""
|
||||
ARGV_CATEGORY=""
|
||||
ARGV_ASAR=""
|
||||
ARGV_ICON=""
|
||||
ARGV_OUTPUT=""
|
||||
|
||||
while getopts ":p:n:v:b:c:t:a:i:o:" option; do
|
||||
case $option in
|
||||
p) ARGV_ELECTRON_PACKAGE="$OPTARG" ;;
|
||||
n) ARGV_APPLICATION_NAME="$OPTARG" ;;
|
||||
v) ARGV_VERSION="$OPTARG" ;;
|
||||
b) ARGV_BUNDLE_ID="$OPTARG" ;;
|
||||
c) ARGV_COPYRIGHT="$OPTARG" ;;
|
||||
t) ARGV_CATEGORY="$OPTARG" ;;
|
||||
a) ARGV_ASAR="$OPTARG" ;;
|
||||
i) ARGV_ICON="$OPTARG" ;;
|
||||
o) ARGV_OUTPUT="$OPTARG" ;;
|
||||
*) usage ;;
|
||||
esac
|
||||
done
|
||||
|
||||
if [ -z "$ARGV_ELECTRON_PACKAGE" ] \
|
||||
|| [ -z "$ARGV_APPLICATION_NAME" ] \
|
||||
|| [ -z "$ARGV_VERSION" ] \
|
||||
|| [ -z "$ARGV_BUNDLE_ID" ] \
|
||||
|| [ -z "$ARGV_COPYRIGHT" ] \
|
||||
|| [ -z "$ARGV_CATEGORY" ] \
|
||||
|| [ -z "$ARGV_ASAR" ] \
|
||||
|| [ -z "$ARGV_ICON" ] \
|
||||
|| [ -z "$ARGV_OUTPUT" ]
|
||||
then
|
||||
usage
|
||||
fi
|
||||
|
||||
unzip "$ARGV_ELECTRON_PACKAGE" -d "$ARGV_OUTPUT"
|
||||
|
||||
APPLICATION_OUTPUT="$ARGV_OUTPUT/$ARGV_APPLICATION_NAME.app"
|
||||
mv "$ARGV_OUTPUT/Electron.app" "$APPLICATION_OUTPUT"
|
||||
rm -f "$APPLICATION_OUTPUT/Contents/Resources/default_app.asar"
|
||||
|
||||
# Don't include these for now
|
||||
rm -f "$ARGV_OUTPUT"/LICENSE*
|
||||
rm -f "$ARGV_OUTPUT/version"
|
||||
|
||||
function plist_set() {
|
||||
local plist_file=$1
|
||||
local plist_key=$2
|
||||
local plist_value=$3
|
||||
|
||||
/usr/libexec/PlistBuddy -c "Set $plist_key \"$plist_value\"" "$plist_file"
|
||||
}
|
||||
|
||||
INFO_PLIST="$APPLICATION_OUTPUT/Contents/Info.plist"
|
||||
plist_set "$INFO_PLIST" CFBundleName "$ARGV_APPLICATION_NAME"
|
||||
plist_set "$INFO_PLIST" CFBundleDisplayName "$ARGV_APPLICATION_NAME"
|
||||
plist_set "$INFO_PLIST" CFBundleIdentifier "$ARGV_BUNDLE_ID"
|
||||
plist_set "$INFO_PLIST" CFBundleVersion "$ARGV_VERSION"
|
||||
plist_set "$INFO_PLIST" CFBundleShortVersionString "$ARGV_VERSION"
|
||||
plist_set "$INFO_PLIST" LSApplicationCategoryType "$ARGV_CATEGORY"
|
||||
|
||||
# Rename executable
|
||||
plist_set "$INFO_PLIST" CFBundleExecutable "$ARGV_APPLICATION_NAME"
|
||||
mv "$APPLICATION_OUTPUT/Contents/MacOS/Electron" "$APPLICATION_OUTPUT/Contents/MacOS/$ARGV_APPLICATION_NAME"
|
||||
|
||||
# Change application icon
|
||||
ICON_FILENAME=$(echo "$ARGV_APPLICATION_NAME" | tr '[:upper:]' '[:lower:]').icns
|
||||
plist_set "$INFO_PLIST" CFBundleIconFile "$ICON_FILENAME"
|
||||
rm "$APPLICATION_OUTPUT/Contents/Resources/electron.icns"
|
||||
cp "$ARGV_ICON" "$APPLICATION_OUTPUT/Contents/Resources/$ICON_FILENAME"
|
||||
|
||||
# Configure Electron Helper.app
|
||||
HELPER_APP="$APPLICATION_OUTPUT/Contents/Frameworks/Electron Helper.app"
|
||||
HELPER_INFO_PLIST="$HELPER_APP/Contents/Info.plist"
|
||||
plist_set "$HELPER_INFO_PLIST" CFBundleIdentifier "$ARGV_BUNDLE_ID.helper"
|
||||
plist_set "$HELPER_INFO_PLIST" CFBundleName "$ARGV_APPLICATION_NAME Helper"
|
||||
mv "$HELPER_APP/Contents/MacOS/Electron Helper" "$HELPER_APP/Contents/MacOS/$ARGV_APPLICATION_NAME Helper"
|
||||
mv "$HELPER_APP" "$APPLICATION_OUTPUT/Contents/Frameworks/$ARGV_APPLICATION_NAME Helper.app"
|
||||
|
||||
for id in EH NP; do
|
||||
HELPER_INFO_PLIST="$APPLICATION_OUTPUT/Contents/Frameworks/Electron Helper $id.app/Contents/Info.plist"
|
||||
plist_set "$HELPER_INFO_PLIST" CFBundleName "$ARGV_APPLICATION_NAME Helper $id"
|
||||
plist_set "$HELPER_INFO_PLIST" CFBundleDisplayName "$ARGV_APPLICATION_NAME Helper $id"
|
||||
plist_set "$HELPER_INFO_PLIST" CFBundleExecutable "$ARGV_APPLICATION_NAME Helper $id"
|
||||
plist_set "$HELPER_INFO_PLIST" CFBundleIdentifier "$ARGV_BUNDLE_ID.helper.$id"
|
||||
mv "$APPLICATION_OUTPUT/Contents/Frameworks/Electron Helper $id.app/Contents/MacOS/Electron Helper $id" \
|
||||
"$APPLICATION_OUTPUT/Contents/Frameworks/Electron Helper $id.app/Contents/MacOS/$ARGV_APPLICATION_NAME Helper $id"
|
||||
mv "$APPLICATION_OUTPUT/Contents/Frameworks/Electron Helper $id.app" \
|
||||
"$APPLICATION_OUTPUT/Contents/Frameworks/$ARGV_APPLICATION_NAME Helper $id.app"
|
||||
done
|
||||
|
||||
cp "$ARGV_ASAR" "$APPLICATION_OUTPUT/Contents/Resources/app.asar"
|
||||
|
||||
if [ -d "$ARGV_ASAR.unpacked" ]; then
|
||||
cp -rf "$ARGV_ASAR.unpacked" "$APPLICATION_OUTPUT/Contents/Resources/app.asar.unpacked"
|
||||
fi
|
@ -1,60 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
###
|
||||
# Copyright 2016 resin.io
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
###
|
||||
|
||||
set -u
|
||||
set -e
|
||||
|
||||
OS=$(uname)
|
||||
if [[ "$OS" != "Darwin" ]]; then
|
||||
echo "This script is only meant to be run in OS X" 1>&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
./scripts/build/check-dependency.sh hdiutil
|
||||
|
||||
function usage() {
|
||||
echo "Usage: $0"
|
||||
echo ""
|
||||
echo "Options"
|
||||
echo ""
|
||||
echo " -d <read-write application dmg>"
|
||||
echo " -o <output>"
|
||||
exit 1
|
||||
}
|
||||
|
||||
ARGV_APPLICATION_DMG=""
|
||||
ARGV_OUTPUT=""
|
||||
|
||||
while getopts ":d:o:" option; do
|
||||
case $option in
|
||||
d) ARGV_APPLICATION_DMG="$OPTARG" ;;
|
||||
o) ARGV_OUTPUT="$OPTARG" ;;
|
||||
*) usage ;;
|
||||
esac
|
||||
done
|
||||
|
||||
if [ -z "$ARGV_APPLICATION_DMG" ] || [ -z "$ARGV_OUTPUT" ]; then
|
||||
usage
|
||||
fi
|
||||
|
||||
# Convert temporary DMG image into a production-ready
|
||||
# compressed and read-only DMG image.
|
||||
hdiutil convert "$ARGV_APPLICATION_DMG" \
|
||||
-format UDZO \
|
||||
-imagekey zlib-level=9 \
|
||||
-o "$ARGV_OUTPUT"
|
@ -1,148 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
###
|
||||
# Copyright 2016 resin.io
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
###
|
||||
|
||||
set -u
|
||||
set -e
|
||||
|
||||
OS=$(uname)
|
||||
if [[ "$OS" != "Darwin" ]]; then
|
||||
echo "This script is only meant to be run in OS X" 1>&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
./scripts/build/check-dependency.sh hdiutil
|
||||
./scripts/build/check-dependency.sh xattr
|
||||
./scripts/build/check-dependency.sh tiffutil
|
||||
./scripts/build/check-dependency.sh osascript
|
||||
./scripts/build/check-dependency.sh afsctool
|
||||
|
||||
function usage() {
|
||||
echo "Usage: $0"
|
||||
echo ""
|
||||
echo "Options"
|
||||
echo ""
|
||||
echo " -n <application name>"
|
||||
echo " -p <application package>"
|
||||
echo " -i <application icon (.icns)>"
|
||||
echo " -b <application background (.png)>"
|
||||
echo " -o <output>"
|
||||
exit 1
|
||||
}
|
||||
|
||||
ARGV_APPLICATION_NAME=""
|
||||
ARGV_PACKAGE=""
|
||||
ARGV_ICON=""
|
||||
ARGV_BACKGROUND=""
|
||||
ARGV_OUTPUT=""
|
||||
|
||||
while getopts ":n:p:i:b:o:" option; do
|
||||
case $option in
|
||||
n) ARGV_APPLICATION_NAME="$OPTARG" ;;
|
||||
p) ARGV_PACKAGE="$OPTARG" ;;
|
||||
i) ARGV_ICON="$OPTARG" ;;
|
||||
b) ARGV_BACKGROUND="$OPTARG" ;;
|
||||
o) ARGV_OUTPUT="$OPTARG" ;;
|
||||
*) usage ;;
|
||||
esac
|
||||
done
|
||||
|
||||
if [ -z "$ARGV_APPLICATION_NAME" ] \
|
||||
|| [ -z "$ARGV_PACKAGE" ] \
|
||||
|| [ -z "$ARGV_ICON" ] \
|
||||
|| [ -z "$ARGV_BACKGROUND" ] \
|
||||
|| [ -z "$ARGV_OUTPUT" ]
|
||||
then
|
||||
usage
|
||||
fi
|
||||
|
||||
VOLUME_DIRECTORY=/Volumes/$ARGV_APPLICATION_NAME
|
||||
VOLUME_APPLICATION=$VOLUME_DIRECTORY/$ARGV_APPLICATION_NAME.app
|
||||
|
||||
# Make sure any previous DMG was unmounted
|
||||
hdiutil detach "$VOLUME_DIRECTORY" || true
|
||||
|
||||
# Create temporary read-write DMG image
|
||||
hdiutil create \
|
||||
-srcfolder "$ARGV_PACKAGE" \
|
||||
-volname "$ARGV_APPLICATION_NAME" \
|
||||
-fs HFS+ \
|
||||
-fsargs "-c c=64,a=16,e=16" \
|
||||
-format UDRW \
|
||||
-size 600M "$ARGV_OUTPUT"
|
||||
|
||||
# Mount temporary DMG image, so we can modify it
|
||||
hdiutil attach "$ARGV_OUTPUT" -readwrite -noverify
|
||||
|
||||
# Wait for a bit to ensure the image is mounted
|
||||
sleep 2
|
||||
|
||||
# Link to /Applications within the DMG
|
||||
pushd "$VOLUME_DIRECTORY"
|
||||
ln -s /Applications
|
||||
popd
|
||||
|
||||
# Set the DMG icon image
|
||||
# Writing this hexadecimal buffer to the com.apple.FinderInfo
|
||||
# extended attribute does the trick.
|
||||
# See https://github.com/LinusU/node-appdmg/issues/14#issuecomment-29080500
|
||||
cp "$ARGV_ICON" "$VOLUME_DIRECTORY/.VolumeIcon.icns"
|
||||
xattr -wx com.apple.FinderInfo \
|
||||
"0000000000000000040000000000000000000000000000000000000000000000" "$VOLUME_DIRECTORY"
|
||||
|
||||
# Configure background image.
|
||||
# We use tiffutil to create a "Multirepresentation Tiff file".
|
||||
# This allows us to show the retina and non-retina image when appropriate.
|
||||
mkdir "$VOLUME_DIRECTORY/.background"
|
||||
BACKGROUND_RETINA=$(echo "$ARGV_BACKGROUND" | sed 's/\(.*\)\./\1@2x./')
|
||||
tiffutil -cathidpicheck "$ARGV_BACKGROUND" "$BACKGROUND_RETINA" \
|
||||
-out "$VOLUME_DIRECTORY/.background/installer.tiff"
|
||||
|
||||
# This AppleScript performs the following tasks
|
||||
# - Set the window basic properties.
|
||||
# - Set the window size and position.
|
||||
# - Set the icon size.
|
||||
# - Arrange the icons.
|
||||
echo '
|
||||
tell application "Finder"
|
||||
tell disk "'"${ARGV_APPLICATION_NAME}"'"
|
||||
open
|
||||
set current view of container window to icon view
|
||||
set toolbar visible of container window to false
|
||||
set statusbar visible of container window to false
|
||||
set the bounds of container window to {400, 100, 944, 530}
|
||||
set viewOptions to the icon view options of container window
|
||||
set arrangement of viewOptions to not arranged
|
||||
set icon size of viewOptions to 110
|
||||
set background picture of viewOptions to file ".background:installer.tiff"
|
||||
set position of item "'"${ARGV_APPLICATION_NAME}".app'" of container window to {140, 225}
|
||||
set position of item "Applications" of container window to {415, 225}
|
||||
close
|
||||
open
|
||||
update without registering applications
|
||||
delay 2
|
||||
close
|
||||
end tell
|
||||
end tell
|
||||
' | osascript
|
||||
sync
|
||||
|
||||
# Apply HFS+ compression
|
||||
afsctool -ci -9 "$VOLUME_APPLICATION"
|
||||
|
||||
# Unmount temporary DMG image.
|
||||
hdiutil detach "$VOLUME_DIRECTORY"
|
@ -1,100 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
###
|
||||
# Copyright 2016 resin.io
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
###
|
||||
|
||||
set -u
|
||||
set -e
|
||||
|
||||
OS=$(uname)
|
||||
if [[ "$OS" != "Darwin" ]]; then
|
||||
echo "This script is only meant to be run in OS X" 1>&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
./scripts/build/check-dependency.sh codesign
|
||||
./scripts/build/check-dependency.sh spctl
|
||||
|
||||
function usage() {
|
||||
echo "Usage: $0"
|
||||
echo ""
|
||||
echo "Options"
|
||||
echo ""
|
||||
echo " -a <application (.app)>"
|
||||
echo " -i <identity>"
|
||||
exit 1
|
||||
}
|
||||
|
||||
ARGV_APPLICATION=""
|
||||
ARGV_IDENTITY=""
|
||||
|
||||
while getopts ":a:i:" option; do
|
||||
case $option in
|
||||
a) ARGV_APPLICATION="$OPTARG" ;;
|
||||
i) ARGV_IDENTITY="$OPTARG" ;;
|
||||
*) usage ;;
|
||||
esac
|
||||
done
|
||||
|
||||
if [ -z "$ARGV_APPLICATION" ] || [ -z "$ARGV_IDENTITY" ]; then
|
||||
usage
|
||||
fi
|
||||
|
||||
function sign_file() {
|
||||
local file=$1
|
||||
./scripts/build/electron-sign-file-darwin.sh -f "$file" -i "$ARGV_IDENTITY"
|
||||
}
|
||||
|
||||
# Avoid issues with `for` loops on file names containing spaces
|
||||
# See https://www.cyberciti.biz/tips/handling-filenames-with-spaces-in-bash.html
|
||||
SAVEIFS=$IFS
|
||||
IFS=$(echo -en "\n\b")
|
||||
|
||||
# Sign all executables
|
||||
# See http://apple.stackexchange.com/a/116371
|
||||
for file in $(find "$ARGV_APPLICATION" -perm +111 -type f); do
|
||||
sign_file "$file"
|
||||
done
|
||||
|
||||
# Sign `.app` and `.framework` directories now that
|
||||
# all the executables inside them have been signed.
|
||||
|
||||
for file in $(find "$ARGV_APPLICATION/Contents" -name '*.app'); do
|
||||
sign_file "$file"
|
||||
done
|
||||
|
||||
for file in $(find "$ARGV_APPLICATION/Contents" -name '*.framework'); do
|
||||
sign_file "$file"
|
||||
done
|
||||
|
||||
# Restore IFS
|
||||
IFS=$SAVEIFS
|
||||
|
||||
# Sign top-level application after all
|
||||
# its components have been signed
|
||||
sign_file "$ARGV_APPLICATION"
|
||||
|
||||
# spctl manages the security assessment policy subsystem.
|
||||
# This subsystem maintains and evaluates rules that determine whether the system
|
||||
# allows the installation, execution, and other operations on files on the system.
|
||||
# We use this tool to simulate whether the OS would accept our code
|
||||
# signature at the moment of installation / execution.
|
||||
spctl \
|
||||
--ignore-cache \
|
||||
--no-cache \
|
||||
--assess \
|
||||
--type execute \
|
||||
--verbose=4 "$ARGV_APPLICATION"
|
@ -1,62 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
###
|
||||
# Copyright 2016 resin.io
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
###
|
||||
|
||||
set -u
|
||||
set -e
|
||||
|
||||
OS=$(uname)
|
||||
if [[ "$OS" != "Darwin" ]]; then
|
||||
echo "This script is only meant to be run in OS X" 1>&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
./scripts/build/check-dependency.sh codesign
|
||||
|
||||
function usage() {
|
||||
echo "Usage: $0"
|
||||
echo ""
|
||||
echo "Options"
|
||||
echo ""
|
||||
echo " -f <file>"
|
||||
echo " -i <identity>"
|
||||
exit 1
|
||||
}
|
||||
|
||||
ARGV_FILE=""
|
||||
ARGV_IDENTITY=""
|
||||
|
||||
while getopts ":f:i:" option; do
|
||||
case $option in
|
||||
f) ARGV_FILE="$OPTARG" ;;
|
||||
i) ARGV_IDENTITY="$OPTARG" ;;
|
||||
*) usage ;;
|
||||
esac
|
||||
done
|
||||
|
||||
if [ -z "$ARGV_FILE" ] || [ -z "$ARGV_IDENTITY" ]; then
|
||||
usage
|
||||
fi
|
||||
|
||||
codesign --sign "$ARGV_IDENTITY" -fv "$ARGV_FILE"
|
||||
|
||||
# Verify signature
|
||||
codesign \
|
||||
--verify \
|
||||
--deep \
|
||||
--display \
|
||||
--verbose=4 "$ARGV_FILE"
|
@ -1,75 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
###
|
||||
# Copyright 2016 resin.io
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
###
|
||||
|
||||
set -u
|
||||
set -e
|
||||
|
||||
OS=$(uname)
|
||||
if [[ "$OS" != "Darwin" ]]; then
|
||||
echo "This script is only meant to be run in OS X" 1>&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
./scripts/build/check-dependency.sh hdiutil
|
||||
|
||||
function usage() {
|
||||
echo "Usage: $0"
|
||||
echo ""
|
||||
echo "Options"
|
||||
echo ""
|
||||
echo " -n <application name>"
|
||||
echo " -d <application (.dmg)>"
|
||||
echo " -i <identity>"
|
||||
exit 1
|
||||
}
|
||||
|
||||
ARGV_APPLICATION_NAME=""
|
||||
ARGV_APPLICATION_DMG=""
|
||||
ARGV_IDENTITY=""
|
||||
|
||||
while getopts ":n:d:i:" option; do
|
||||
case $option in
|
||||
n) ARGV_APPLICATION_NAME="$OPTARG" ;;
|
||||
d) ARGV_APPLICATION_DMG="$OPTARG" ;;
|
||||
i) ARGV_IDENTITY="$OPTARG" ;;
|
||||
*) usage ;;
|
||||
esac
|
||||
done
|
||||
|
||||
if [ -z "$ARGV_APPLICATION_NAME" ] ||
|
||||
[ -z "$ARGV_APPLICATION_DMG" ] ||
|
||||
[ -z "$ARGV_IDENTITY" ]; then
|
||||
usage
|
||||
fi
|
||||
|
||||
VOLUME_DIRECTORY=/Volumes/$ARGV_APPLICATION_NAME
|
||||
VOLUME_APPLICATION=$VOLUME_DIRECTORY/$ARGV_APPLICATION_NAME.app
|
||||
|
||||
# Make sure any previous DMG was unmounted
|
||||
hdiutil detach "$VOLUME_DIRECTORY" || true
|
||||
|
||||
# Mount temporary DMG image, so we can modify it
|
||||
hdiutil attach "$ARGV_APPLICATION_DMG" -readwrite -noverify
|
||||
|
||||
# Wait for a bit to ensure the image is mounted
|
||||
sleep 2
|
||||
|
||||
./scripts/build/electron-sign-app-darwin.sh -a "$VOLUME_APPLICATION" -i "$ARGV_IDENTITY"
|
||||
|
||||
# Unmount temporary DMG image.
|
||||
hdiutil detach "$VOLUME_DIRECTORY"
|
Loading…
x
Reference in New Issue
Block a user