diff --git a/.gitignore b/.gitignore index 016c7fb4..eb6d57dc 100644 --- a/.gitignore +++ b/.gitignore @@ -29,6 +29,7 @@ node_modules bower_components # Compiled Electron releases +release/ etcher-release/ # Certificates diff --git a/.travis.yml b/.travis.yml index fca3078a..5734d53f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -45,13 +45,13 @@ install: - npm install -g bower - npm install -g electron-installer-debian - if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then - ./scripts/build/linux.sh develop-electron x64; + make electron-develop fi - if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then brew install afsctool; fi - if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then - ./scripts/build/darwin.sh develop-electron; + make electron-develop fi before_script: diff --git a/Makefile b/Makefile new file mode 100644 index 00000000..c52f2235 --- /dev/null +++ b/Makefile @@ -0,0 +1,195 @@ +# --------------------------------------------------------------------- +# Application configuration +# --------------------------------------------------------------------- + +SIGN_IDENTITY_OSX = Developer ID Application: Rulemotion Ltd (66H43P8FRG) +ELECTRON_VERSION = $(shell node -e "console.log(require('./package.json').devDependencies['electron-prebuilt'])") +APPLICATION_NAME = $(shell node -e "console.log(require('./package.json').displayName)") +APPLICATION_DESCRIPTION=$(shell node -e "console.log(require('./package.json').description)") +APPLICATION_VERSION = $(shell node -e "console.log(require('./package.json').version)") +APPLICATION_COPYRIGHT = $(shell node -e "console.log(require('./package.json').copyright)") +APPLICATION_CATEGORY = public.app-category.developer-tools +APPLICATION_BUNDLE_ID = io.resin.etcher +APPLICATION_FILES = lib,build,assets + +# --------------------------------------------------------------------- +# Operating system and architecture detection +# --------------------------------------------------------------------- + +# http://stackoverflow.com/a/12099167 +ifeq ($(OS),Windows_NT) + HOST_PLATFORM = win32 + + ifeq ($(PROCESSOR_ARCHITEW6432),AMD64) + HOST_ARCH = x64 + else + ifeq ($(PROCESSOR_ARCHITECTURE),AMD64) + HOST_ARCH = x64 + endif + ifeq ($(PROCESSOR_ARCHITECTURE),x86) + HOST_ARCH = x86 + endif + endif +else + ifeq ($(shell uname -s),Linux) + HOST_PLATFORM = linux + + ifeq ($(shell uname -p),x86_64) + HOST_ARCH = x64 + endif + ifneq ($(filter %86,$(shell uname -p)),) + HOST_ARCH = x86 + endif + endif + ifeq ($(shell uname -s),Darwin) + HOST_PLATFORM = darwin + + ifeq ($(shell uname -m),x86_64) + HOST_ARCH = x64 + endif + endif +endif + +ifndef HOST_PLATFORM + $(error We couldn\'t detect your host platform) +endif +ifndef HOST_ARCH + $(error We couldn\'t detect your host architecture) +endif + +TARGET_PLATFORM = $(HOST_PLATFORM) + +ifneq ($(TARGET_PLATFORM),$(HOST_PLATFORM)) + $(error We don\'t support cross-platform builds yet) +endif + +# Default to host architecture. You can override by doing: +# +# make TARGET_ARCH= +# +TARGET_ARCH = $(HOST_ARCH) + +# --------------------------------------------------------------------- +# Extra variables +# --------------------------------------------------------------------- + +ifeq ($(TARGET_ARCH),x86) + TARGET_ARCH_DEBIAN = i386 +endif +ifeq ($(TARGET_ARCH),x64) + TARGET_ARCH_DEBIAN = amd64 +endif + +TEMPORARY_DIRECTORY = release/.tmp +APPLICATION_NAME_LOWERCASE = $(shell echo $(APPLICATION_NAME) | tr A-Z a-z) +APPLICATION_VERSION_DEBIAN = $(shell echo $(APPLICATION_VERSION) | tr "-" "~") + +# --------------------------------------------------------------------- +# Rules +# --------------------------------------------------------------------- + +release/electron-$(TARGET_PLATFORM)-$(TARGET_ARCH)-app: + ./scripts/unix/electron-create-resources-app.sh -s . -f "$(APPLICATION_FILES)" -o $@ + +release/electron-$(TARGET_PLATFORM)-$(TARGET_ARCH)-app/node_modules:\ + release/electron-$(TARGET_PLATFORM)-$(TARGET_ARCH)-app + ./scripts/unix/dependencies-npm.sh -p -r "$(TARGET_ARCH)" -v "$(ELECTRON_VERSION)" -x $< -t electron + +release/electron-$(TARGET_PLATFORM)-$(TARGET_ARCH)-app/bower_components:\ + release/electron-$(TARGET_PLATFORM)-$(TARGET_ARCH)-app + ./scripts/unix/dependencies-bower.sh -p -x $< + +release/electron-$(TARGET_PLATFORM)-$(TARGET_ARCH)-app.asar: \ + release/electron-$(TARGET_PLATFORM)-$(TARGET_ARCH)-app \ + release/electron-$(TARGET_PLATFORM)-$(TARGET_ARCH)-app/node_modules \ + release/electron-$(TARGET_PLATFORM)-$(TARGET_ARCH)-app/bower_components + ./scripts/unix/electron-create-asar.sh -d $< -o $@ + +release/$(APPLICATION_NAME)-$(TARGET_PLATFORM)-$(TARGET_ARCH): \ + release/electron-$(TARGET_PLATFORM)-$(TARGET_ARCH)-app.asar + ./scripts/unix/electron-download-package.sh -r "$(TARGET_ARCH)" -v "$(ELECTRON_VERSION)" -s "$(TARGET_PLATFORM)" -o $@ +ifeq ($(TARGET_PLATFORM),darwin) + ./scripts/darwin/electron-configure-package-darwin.sh -d $@ -a $< \ + -n "$(APPLICATION_NAME)" \ + -v "$(APPLICATION_VERSION)" \ + -b "$(APPLICATION_BUNDLE_ID)" \ + -c "$(APPLICATION_COPYRIGHT)" \ + -t "$(APPLICATION_CATEGORY)" \ + -i assets/icon.icns +endif +ifeq ($(TARGET_PLATFORM),linux) + ./scripts/linux/electron-configure-package-linux.sh -d $@ -a $< \ + -n "$(APPLICATION_NAME)" \ + -v "$(APPLICATION_VERSION)" \ + -l LICENSE +endif + +release/out/$(APPLICATION_NAME)-$(APPLICATION_VERSION)-darwin-$(TARGET_ARCH).zip: \ + release/$(APPLICATION_NAME)-darwin-$(TARGET_ARCH) + ./scripts/darwin/electron-sign-app.sh -a $ -$ ./scripts/build/linux.sh installer-debian +make electron-installer-appimage +make electron-installer-debian ``` +The resulting installers will be saved to `release/out`. + ### Windows Run the following command: @@ -57,6 +60,8 @@ Run the following command: > .\scripts\build\windows.bat all ``` +The resulting installers will be saved to `etcher-release/installers`. + Publishing to Bintray --------------------- diff --git a/docs/RUNNING-LOCALLY.md b/docs/RUNNING-LOCALLY.md index 8795da63..ff56bd3e 100644 --- a/docs/RUNNING-LOCALLY.md +++ b/docs/RUNNING-LOCALLY.md @@ -50,13 +50,13 @@ the application might not run successfully. ### OS X ```sh -./scripts/build/darwin.sh develop-electron +make electron-develop ``` ### GNU/Linux ```sh -./scripts/build/linux.sh develop-electron +make electron-develop ``` ### Windows diff --git a/scripts/build/darwin.sh b/scripts/build/darwin.sh deleted file mode 100755 index 2c0cea5f..00000000 --- a/scripts/build/darwin.sh +++ /dev/null @@ -1,163 +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. -### - -# See http://www.davidpashley.com/articles/writing-robust-shell-scripts/ -set -u -set -e -set -x - -function check_dep() { - if ! command -v $1 2>/dev/null 1>&2; then - echo "Dependency missing: $1" 1>&2 - exit 1 - fi -} - -OS=`uname` -if [[ "$OS" != "Darwin" ]]; then - echo "This script is only meant to be run in OS X" 1>&2 - exit 1 -fi - -if [ "$#" -ne 1 ]; then - echo "Usage: $0 " 1>&2 - exit 1 -fi - -COMMAND=$1 -SIGN_IDENTITY_OSX="Developer ID Application: Rulemotion Ltd (66H43P8FRG)" -ELECTRON_VERSION=`node -e "console.log(require('./package.json').devDependencies['electron-prebuilt'])"` -APPLICATION_NAME=`node -e "console.log(require('./package.json').displayName)"` -APPLICATION_COPYRIGHT=`node -e "console.log(require('./package.json').copyright)"` -APPLICATION_VERSION=`node -e "console.log(require('./package.json').version)"` - -if [ "$COMMAND" == "cli" ]; then - ./scripts/unix/dependencies-npm.sh -r x64 -v 6.2.2 -t node -f -p - ./scripts/unix/package-cli.sh \ - -n etcher \ - -e bin/etcher \ - -r x64 \ - -s darwin \ - -o etcher-release/etcher-cli-darwin-x64 - exit 0 -fi - -if [ "$COMMAND" == "develop-electron" ]; then - ./scripts/unix/dependencies-npm.sh \ - -r x64 \ - -v "$ELECTRON_VERSION" \ - -t electron - ./scripts/unix/dependencies-bower.sh - exit 0 -fi - -if [ "$COMMAND" == "installer-dmg" ]; then - ./scripts/unix/electron-create-resources-app.sh \ - -s . \ - -f "lib,build,assets" \ - -o "etcher-release/app" - - ./scripts/unix/dependencies-npm.sh -p \ - -r x64 \ - -v "$ELECTRON_VERSION" \ - -x "etcher-release/app" \ - -t electron - - ./scripts/unix/dependencies-bower.sh -p \ - -x "etcher-release/app" - - ./scripts/unix/electron-create-asar.sh \ - -d "etcher-release/app" \ - -o "etcher-release/app.asar" - - ./scripts/unix/electron-download-package.sh \ - -r x64 \ - -v "$ELECTRON_VERSION" \ - -s darwin \ - -o etcher-release/$APPLICATION_NAME-darwin-x64 - - ./scripts/darwin/electron-configure-package-darwin.sh \ - -d etcher-release/$APPLICATION_NAME-darwin-x64 \ - -n $APPLICATION_NAME \ - -v $APPLICATION_VERSION \ - -b io.resin.etcher \ - -c "$APPLICATION_COPYRIGHT" \ - -t public.app-category.developer-tools \ - -a "etcher-release/app.asar" \ - -i assets/icon.icns - - ./scripts/darwin/electron-installer-dmg.sh \ - -n $APPLICATION_NAME \ - -v $APPLICATION_VERSION \ - -p etcher-release/$APPLICATION_NAME-darwin-x64 \ - -d "$SIGN_IDENTITY_OSX" \ - -i assets/icon.icns \ - -b assets/osx/installer.png \ - -o etcher-release/installers/$APPLICATION_NAME-$APPLICATION_VERSION-darwin-x64.dmg - - exit 0 -fi - -if [ "$COMMAND" == "installer-zip" ]; then - ./scripts/unix/electron-create-resources-app.sh \ - -s . \ - -f "lib,build,assets" \ - -o "etcher-release/app" - - ./scripts/unix/dependencies-npm.sh -p \ - -r x64 \ - -v "$ELECTRON_VERSION" \ - -x "etcher-release/app" \ - -t electron - - ./scripts/unix/dependencies-bower.sh -p \ - -x "etcher-release/app" - - ./scripts/unix/electron-create-asar.sh \ - -d "etcher-release/app" \ - -o "etcher-release/app.asar" - - ./scripts/unix/electron-download-package.sh \ - -r x64 \ - -v "$ELECTRON_VERSION" \ - -s darwin \ - -o etcher-release/$APPLICATION_NAME-darwin-x64 - - ./scripts/darwin/electron-configure-package-darwin.sh \ - -d etcher-release/$APPLICATION_NAME-darwin-x64 \ - -n $APPLICATION_NAME \ - -v $APPLICATION_VERSION \ - -b io.resin.etcher \ - -c "$APPLICATION_COPYRIGHT" \ - -t public.app-category.developer-tools \ - -a "etcher-release/app.asar" \ - -i assets/icon.icns - - ./scripts/darwin/electron-sign-app.sh \ - -a etcher-release/$APPLICATION_NAME-darwin-x64/$APPLICATION_NAME.app \ - -i "$SIGN_IDENTITY_OSX" - - ./scripts/darwin/electron-installer-app-zip.sh \ - -a etcher-release/$APPLICATION_NAME-darwin-x64/$APPLICATION_NAME.app \ - -o etcher-release/installers/$APPLICATION_NAME-$APPLICATION_VERSION-darwin-x64.zip - - exit 0 -fi - -echo "Unknown command: $COMMAND" 1>&2 -exit 1 diff --git a/scripts/build/linux.sh b/scripts/build/linux.sh deleted file mode 100755 index 962459a4..00000000 --- a/scripts/build/linux.sh +++ /dev/null @@ -1,177 +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. -### - -# See http://www.davidpashley.com/articles/writing-robust-shell-scripts/ -set -u -set -e -set -x - -function check_dep() { - if ! command -v $1 2>/dev/null 1>&2; then - echo "Dependency missing: $1" 1>&2 - exit 1 - fi -} - -OS=`uname` -if [[ "$OS" != "Linux" ]]; then - echo "This script is only meant to be run in GNU/Linux" 1>&2 - exit 1 -fi - -if [ "$#" -ne 2 ]; then - echo "Usage: $0 " 1>&2 - exit 1 -fi - -COMMAND=$1 -ARCH=$2 -if [ "$ARCH" != "x64" ] && - [ "$ARCH" != "x86" ]; -then - echo "Unknown architecture: $ARCH" 1>&2 - exit 1 -fi - -ELECTRON_VERSION=`node -e "console.log(require('./package.json').devDependencies['electron-prebuilt'])"` -NODE_VERSION="6.2.2" -APPLICATION_NAME=`node -e "console.log(require('./package.json').displayName)"` -APPLICATION_DESCRIPTION=`node -e "console.log(require('./package.json').description)"` -APPLICATION_VERSION=`node -e "console.log(require('./package.json').version)"` - -if [ "$COMMAND" == "develop-electron" ]; then - ./scripts/unix/dependencies-npm.sh \ - -r "$ARCH" \ - -v "$ELECTRON_VERSION" \ - -t electron - ./scripts/unix/dependencies-bower.sh - exit 0 -fi - -if [ "$COMMAND" == "develop-cli" ]; then - ./scripts/unix/dependencies-npm.sh \ - -r "$ARCH" \ - -v "$NODE_VERSION" \ - -t node - exit 0 -fi - -if [ "$COMMAND" == "installer-cli" ]; then - ./scripts/unix/dependencies-npm.sh -f -p \ - -r "$ARCH" \ - -v "$NODE_VERSION" \ - -t node - - ./scripts/unix/package-cli.sh \ - -n etcher \ - -e bin/etcher \ - -r "$ARCH" \ - -s linux \ - -o etcher-release/etcher-cli-linux-$ARCH - exit 0 -fi - -if [ "$COMMAND" == "installer-debian" ]; then - ./scripts/unix/electron-create-resources-app.sh \ - -s . \ - -f "lib,build,assets" \ - -o "etcher-release/app" - - ./scripts/unix/dependencies-npm.sh -p \ - -r "$ARCH" \ - -v "$ELECTRON_VERSION" \ - -x "etcher-release/app" \ - -t electron - - ./scripts/unix/dependencies-bower.sh -p \ - -x "etcher-release/app" - - ./scripts/unix/electron-create-asar.sh \ - -d "etcher-release/app" \ - -o "etcher-release/app.asar" - - ./scripts/unix/electron-download-package.sh \ - -r "$ARCH" \ - -v "$ELECTRON_VERSION" \ - -s linux \ - -o "etcher-release/$APPLICATION_NAME-linux-$ARCH" - - ./scripts/linux/electron-configure-package-linux.sh \ - -d etcher-release/$APPLICATION_NAME-linux-$ARCH \ - -n "$APPLICATION_NAME" \ - -v "$APPLICATION_VERSION" \ - -l LICENSE \ - -a "etcher-release/app.asar" - - ./scripts/linux/electron-installer-debian.sh \ - -p etcher-release/$APPLICATION_NAME-linux-$ARCH \ - -r "$ARCH" \ - -c scripts/build/debian/config.json \ - -o etcher-release/installers - - exit 0 -fi - -if [ "$COMMAND" == "installer-appimage" ]; then - check_dep zip - - ./scripts/unix/electron-create-resources-app.sh \ - -s . \ - -f "lib,build,assets" \ - -o "etcher-release/app" - - ./scripts/unix/dependencies-npm.sh -p \ - -r "$ARCH" \ - -v "$ELECTRON_VERSION" \ - -x "etcher-release/app" \ - -t electron - - ./scripts/unix/dependencies-bower.sh -p \ - -x "etcher-release/app" - - ./scripts/unix/electron-create-asar.sh \ - -d "etcher-release/app" \ - -o "etcher-release/app.asar" - - ./scripts/unix/electron-download-package.sh \ - -r "$ARCH" \ - -v "$ELECTRON_VERSION" \ - -s linux \ - -o "etcher-release/$APPLICATION_NAME-linux-$ARCH" - - ./scripts/linux/electron-configure-package-linux.sh \ - -d etcher-release/$APPLICATION_NAME-linux-$ARCH \ - -n "$APPLICATION_NAME" \ - -v "$APPLICATION_VERSION" \ - -l LICENSE \ - -a "etcher-release/app.asar" - - ./scripts/linux/electron-installer-appimage.sh \ - -n "$APPLICATION_NAME" \ - -d "$APPLICATION_DESCRIPTION" \ - -p etcher-release/$APPLICATION_NAME-linux-$ARCH \ - -r $ARCH \ - -b etcher \ - -i assets/icon.png \ - -o etcher-release/installers/$APPLICATION_NAME-$APPLICATION_VERSION-linux-$ARCH.zip - - exit 0 -fi - -echo "Unknown command: $COMMAND" 1>&2 -exit 1