mirror of
https://github.com/balena-io/etcher.git
synced 2025-07-19 17:26:34 +00:00
chore: require MinGW to build Etcher on Windows (#948)
Using MinGW allows us to re-use the build scripts we've been developing for GNU/Linux and OS X, which are much more robust than their `*.bat` counterparts (due to Batch limitations). This commit does the following changes: - Documents MinGW as a requirement in `RUNNING-LOCALLY.md` - It setups MinGW in Appveyor CI - Transforms `windows/sign.bat` into `windows/electron-sign-exe.sh` - Re-uses `dependencies-npm.sh` and `dependencies-bower.sh` in `build/windows.bat` Signed-off-by: Juan Cruz Viotti <jviotti@openmailbox.org>
This commit is contained in:
parent
cce9ce25d7
commit
ffe0d33026
@ -29,6 +29,8 @@ install:
|
|||||||
- set PATH=C:\Program Files (x86)\Windows Kits\8.1\bin\x86;%PATH%
|
- set PATH=C:\Program Files (x86)\Windows Kits\8.1\bin\x86;%PATH%
|
||||||
- set PATH=C:\Program Files (x86)\NSIS;%PATH%
|
- set PATH=C:\Program Files (x86)\NSIS;%PATH%
|
||||||
- set PATH=C:\Ruby22\bin;%PATH%
|
- set PATH=C:\Ruby22\bin;%PATH%
|
||||||
|
- set PATH=C:\MinGW\bin;%PATH%
|
||||||
|
- set PATH=C:\MinGW\msys\1.0\bin;%PATH%
|
||||||
- gem install scss_lint
|
- gem install scss_lint
|
||||||
- .\scripts\build\windows.bat install x64
|
- .\scripts\build\windows.bat install x64
|
||||||
|
|
||||||
|
@ -22,6 +22,14 @@ Prerequisites
|
|||||||
- [NSIS v2.51](http://nsis.sourceforge.net/Main_Page) (v3.x won't work)
|
- [NSIS v2.51](http://nsis.sourceforge.net/Main_Page) (v3.x won't work)
|
||||||
- [Visual Studio Community 2013](https://www.visualstudio.com/en-us/news/vs2013-community-vs.aspx)
|
- [Visual Studio Community 2013](https://www.visualstudio.com/en-us/news/vs2013-community-vs.aspx)
|
||||||
- [7z](http://www.7-zip.org) (command line version)
|
- [7z](http://www.7-zip.org) (command line version)
|
||||||
|
- [MinGW](http://www.mingw.org)
|
||||||
|
|
||||||
|
The following MinGW packages are required:
|
||||||
|
|
||||||
|
- `msys-make`
|
||||||
|
- `msys-unzip`
|
||||||
|
- `msys-wget`
|
||||||
|
- `msys-bash`
|
||||||
|
|
||||||
### OS X
|
### OS X
|
||||||
|
|
||||||
|
@ -148,7 +148,12 @@ set package_name=Etcher-%etcher_version%-win32-%arch%
|
|||||||
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
|
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
|
||||||
|
|
||||||
if not "%command%"=="package" (
|
if not "%command%"=="package" (
|
||||||
call scripts\windows\dependencies.bat -r %arch% -v %electron_version% -t electron
|
call bash.exe scripts\unix\dependencies-npm.sh^
|
||||||
|
-r %arch%^
|
||||||
|
-v %electron_version%^
|
||||||
|
-t electron^
|
||||||
|
-s win32
|
||||||
|
call bash.exe scripts\unix\dependencies-bower.sh
|
||||||
)
|
)
|
||||||
|
|
||||||
if "%command%"=="install" (
|
if "%command%"=="install" (
|
||||||
@ -188,13 +193,13 @@ if not "%arch%"=="%electron_arch%" (
|
|||||||
|
|
||||||
move %output_build_directory%\Etcher-win32-%arch% %package_output%
|
move %output_build_directory%\Etcher-win32-%arch% %package_output%
|
||||||
|
|
||||||
:: Omit *.dll and *.node files from the asar package, otherwise
|
call bash.exe scripts\unix\electron-create-asar.sh^
|
||||||
:: `process.dlopen` and `module.require` can't load them correctly.
|
-d %package_output%\resources\app^
|
||||||
call asar pack %package_output%\resources\app %package_output%\resources\app.asar^
|
-o %package_output%\resources\app.asar
|
||||||
--unpack "{*.dll,*.node}"
|
|
||||||
call rimraf %package_output%\resources\app
|
call rimraf %package_output%\resources\app
|
||||||
|
|
||||||
call scripts\windows\sign.bat^
|
call bash.exe scripts\windows\electron-sign-exe.sh^
|
||||||
-c %certificate_file%^
|
-c %certificate_file%^
|
||||||
-p %certificate_pass%^
|
-p %certificate_pass%^
|
||||||
-f %package_output%\Etcher.exe^
|
-f %package_output%\Etcher.exe^
|
||||||
@ -221,7 +226,7 @@ mkdir "%output_directory%"
|
|||||||
move "%installer_tmp_output%\%application_name% Setup.exe" "%installer_output%"
|
move "%installer_tmp_output%\%application_name% Setup.exe" "%installer_output%"
|
||||||
rd /s /q "%installer_tmp_output%"
|
rd /s /q "%installer_tmp_output%"
|
||||||
|
|
||||||
call scripts\windows\sign.bat^
|
call bash.exe scripts\windows\electron-sign-exe.sh^
|
||||||
-c %certificate_file%^
|
-c %certificate_file%^
|
||||||
-p %certificate_pass%^
|
-p %certificate_pass%^
|
||||||
-f %installer_output%^
|
-f %installer_output%^
|
||||||
|
@ -1,118 +0,0 @@
|
|||||||
@echo off
|
|
||||||
setlocal EnableDelayedExpansion
|
|
||||||
|
|
||||||
:ParameterLoop
|
|
||||||
if x%1 equ x goto :ParameterDone
|
|
||||||
set parameter=%1
|
|
||||||
if %parameter:~0,1% equ - goto CheckParameter
|
|
||||||
:Usage
|
|
||||||
echo Usage: %0
|
|
||||||
echo.
|
|
||||||
echo Options
|
|
||||||
echo.
|
|
||||||
echo -r ^<architecture^>
|
|
||||||
echo -v ^<target version^>
|
|
||||||
echo -t ^<target platform (node^|electron)^>
|
|
||||||
echo -f force install
|
|
||||||
echo -p production install
|
|
||||||
exit /b 1
|
|
||||||
:NextParameter
|
|
||||||
shift /1
|
|
||||||
goto ParameterLoop
|
|
||||||
:CheckParameter
|
|
||||||
if "%1" equ "-r" goto ARGV_R
|
|
||||||
if "%1" equ "-v" goto ARGV_V
|
|
||||||
if "%1" equ "-t" goto ARGV_T
|
|
||||||
if "%1" equ "-f" goto ARGV_F
|
|
||||||
if "%1" equ "-p" goto ARGV_P
|
|
||||||
goto Usage
|
|
||||||
:ARGV_R
|
|
||||||
shift /1
|
|
||||||
set argv_architecture=%1
|
|
||||||
goto NextParameter
|
|
||||||
:ARGV_V
|
|
||||||
shift /1
|
|
||||||
set argv_target_version=%1
|
|
||||||
goto NextParameter
|
|
||||||
:ARGV_T
|
|
||||||
shift /1
|
|
||||||
set argv_target_platform=%1
|
|
||||||
goto NextParameter
|
|
||||||
:ARGV_F
|
|
||||||
shift /1
|
|
||||||
set argv_force=true
|
|
||||||
goto NextParameter
|
|
||||||
:ARGV_P
|
|
||||||
shift /1
|
|
||||||
set argv_production=true
|
|
||||||
goto NextParameter
|
|
||||||
:ParameterDone
|
|
||||||
if not defined argv_architecture (goto Usage)
|
|
||||||
if not defined argv_target_version (goto Usage)
|
|
||||||
if not defined argv_target_platform (goto Usage)
|
|
||||||
|
|
||||||
:: Check that rimraf is installed.
|
|
||||||
:: We make use of this command line tool to clear
|
|
||||||
:: saved dependencies since doing so with `del`
|
|
||||||
:: might return errors due to long paths.
|
|
||||||
where rimraf >nul 2>nul
|
|
||||||
if %ERRORLEVEL% neq 0 (
|
|
||||||
echo Dependency missing: rimraf 1>&2
|
|
||||||
exit /b 1
|
|
||||||
)
|
|
||||||
|
|
||||||
:: Check that npm is installed.
|
|
||||||
where npm >nul 2>nul
|
|
||||||
if %ERRORLEVEL% neq 0 (
|
|
||||||
echo Dependency missing: npm 1>&2
|
|
||||||
exit /b 1
|
|
||||||
)
|
|
||||||
|
|
||||||
:: Check that bower is installed.
|
|
||||||
where bower >nul 2>nul
|
|
||||||
if %ERRORLEVEL% neq 0 (
|
|
||||||
echo Dependency missing: bower 1>&2
|
|
||||||
exit /b 1
|
|
||||||
)
|
|
||||||
|
|
||||||
:: Check that python is installed.
|
|
||||||
where python >nul 2>nul
|
|
||||||
if %ERRORLEVEL% neq 0 (
|
|
||||||
echo Dependency missing: python 1>&2
|
|
||||||
exit /b 1
|
|
||||||
)
|
|
||||||
|
|
||||||
:: We require Visual Studio 2013 specifically since newer versions
|
|
||||||
:: lack command line build tools such as `lib.exe` and `cl.exe`.
|
|
||||||
set GYP_MSVS_VERSION=2013
|
|
||||||
|
|
||||||
if "%argv_target_platform%"=="electron" (
|
|
||||||
set npm_config_disturl=https://atom.io/download/atom-shell
|
|
||||||
set npm_config_runtime=electron
|
|
||||||
)
|
|
||||||
|
|
||||||
set npm_config_target=%argv_target_version%
|
|
||||||
|
|
||||||
if "%argv_architecture%"=="x86" (
|
|
||||||
set npm_config_arch=ia32
|
|
||||||
) else (
|
|
||||||
set npm_config_arch=%electron_arch%
|
|
||||||
)
|
|
||||||
|
|
||||||
set npm_install_opts=--build-from-source
|
|
||||||
|
|
||||||
if "%argv_force%"=="true" (
|
|
||||||
set npm_install_opts=%npm_install_opts% --force
|
|
||||||
)
|
|
||||||
|
|
||||||
if "%argv_production%"=="true" (
|
|
||||||
set npm_install_opts=%npm_install_opts% --production
|
|
||||||
)
|
|
||||||
|
|
||||||
call rimraf node_modules
|
|
||||||
call npm install %npm_install_opts%
|
|
||||||
|
|
||||||
if "%argv_target_platform%"=="electron" (
|
|
||||||
call rimraf bower_components
|
|
||||||
call bower install --production
|
|
||||||
)
|
|
81
scripts/windows/electron-sign-exe.sh
Executable file
81
scripts/windows/electron-sign-exe.sh
Executable file
@ -0,0 +1,81 @@
|
|||||||
|
#!/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
|
||||||
|
|
||||||
|
function check_dep() {
|
||||||
|
if ! command -v $1 2>/dev/null 1>&2; then
|
||||||
|
echo "Dependency missing: $1" 1>&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
OS=$(uname -o 2>/dev/null || true)
|
||||||
|
if [[ "$OS" != "Msys" ]]; then
|
||||||
|
echo "This script is only meant to be run in Windows" 1>&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
check_dep signtool
|
||||||
|
|
||||||
|
function usage() {
|
||||||
|
echo "Usage: $0"
|
||||||
|
echo ""
|
||||||
|
echo "Options"
|
||||||
|
echo ""
|
||||||
|
echo " -f <file (.exe)>"
|
||||||
|
echo " -c <certificate file (.p12)>"
|
||||||
|
echo " -p <certificate password>"
|
||||||
|
echo " -d <signature description>"
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
|
||||||
|
ARGV_FILE=""
|
||||||
|
ARGV_CERTIFICATE_FILE=""
|
||||||
|
ARGV_CERTIFICATE_PASSWORD=""
|
||||||
|
ARGV_SIGNATURE_DESCRIPTION=""
|
||||||
|
|
||||||
|
while getopts ":f:c:p:d:" option; do
|
||||||
|
case $option in
|
||||||
|
f) ARGV_FILE="$OPTARG" ;;
|
||||||
|
c) ARGV_CERTIFICATE_FILE="$OPTARG" ;;
|
||||||
|
p) ARGV_CERTIFICATE_PASSWORD="$OPTARG" ;;
|
||||||
|
d) ARGV_SIGNATURE_DESCRIPTION="$OPTARG" ;;
|
||||||
|
*) usage ;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
|
||||||
|
if [ -z "$ARGV_FILE" ] ||
|
||||||
|
[ -z "$ARGV_CERTIFICATE_FILE" ] ||
|
||||||
|
[ -z "$ARGV_CERTIFICATE_PASSWORD" ] ||
|
||||||
|
[ -z "$ARGV_SIGNATURE_DESCRIPTION" ]
|
||||||
|
then
|
||||||
|
usage
|
||||||
|
fi
|
||||||
|
|
||||||
|
TIMESTAMP_SERVER=http://timestamp.comodoca.com
|
||||||
|
|
||||||
|
signtool sign \
|
||||||
|
/t "$TIMESTAMP_SERVER" \
|
||||||
|
/d "$ARGV_SIGNATURE_DESCRIPTION" \
|
||||||
|
/f "$ARGV_CERTIFICATE_FILE" \
|
||||||
|
/p "$ARGV_CERTIFICATE_PASSWORD" \
|
||||||
|
"$ARGV_FILE"
|
||||||
|
|
||||||
|
signtool verify /pa /v "$ARGV_FILE"
|
@ -1,64 +0,0 @@
|
|||||||
@echo on
|
|
||||||
setlocal EnableDelayedExpansion
|
|
||||||
|
|
||||||
:ParameterLoop
|
|
||||||
if x%1 equ x goto :ParameterDone
|
|
||||||
set parameter=%1
|
|
||||||
if %parameter:~0,1% equ - goto CheckParameter
|
|
||||||
:Usage
|
|
||||||
echo Usage: %0
|
|
||||||
echo.
|
|
||||||
echo Options
|
|
||||||
echo.
|
|
||||||
echo -c ^<certificate file (.p12)^>
|
|
||||||
echo -p ^<certificate password^>
|
|
||||||
echo -f ^<executable file (.exe)^>
|
|
||||||
echo -d ^<signature description^>
|
|
||||||
exit /b 1
|
|
||||||
:NextParameter
|
|
||||||
shift /1
|
|
||||||
goto ParameterLoop
|
|
||||||
:CheckParameter
|
|
||||||
if "%1" equ "-c" goto ARGV_C
|
|
||||||
if "%1" equ "-p" goto ARGV_P
|
|
||||||
if "%1" equ "-f" goto ARGV_F
|
|
||||||
if "%1" equ "-d" goto ARGV_D
|
|
||||||
goto Usage
|
|
||||||
:ARGV_C
|
|
||||||
shift /1
|
|
||||||
set argv_certificate=%1
|
|
||||||
goto NextParameter
|
|
||||||
:ARGV_P
|
|
||||||
shift /1
|
|
||||||
set argv_password=%1
|
|
||||||
goto NextParameter
|
|
||||||
:ARGV_F
|
|
||||||
shift /1
|
|
||||||
set argv_file=%1
|
|
||||||
goto NextParameter
|
|
||||||
:ARGV_D
|
|
||||||
shift /1
|
|
||||||
set argv_description=%1
|
|
||||||
goto NextParameter
|
|
||||||
:ParameterDone
|
|
||||||
|
|
||||||
if not defined argv_certificate (goto Usage)
|
|
||||||
if not defined argv_password (goto Usage)
|
|
||||||
if not defined argv_file (goto Usage)
|
|
||||||
if not defined argv_description (goto Usage)
|
|
||||||
|
|
||||||
:: Check that signtool is installed.
|
|
||||||
where signtool >nul 2>nul
|
|
||||||
if %ERRORLEVEL% neq 0 (
|
|
||||||
echo Dependency missing: signtool 1>&2
|
|
||||||
exit /b 1
|
|
||||||
)
|
|
||||||
|
|
||||||
signtool sign^
|
|
||||||
/t http://timestamp.comodoca.com^
|
|
||||||
/d %argv_description%^
|
|
||||||
/f %argv_certificate%^
|
|
||||||
/p %argv_password%^
|
|
||||||
%argv_file%
|
|
||||||
|
|
||||||
signtool verify /pa /v %argv_file%
|
|
Loading…
x
Reference in New Issue
Block a user