Skip to content
This repository has been archived by the owner on Jun 19, 2021. It is now read-only.

Commit

Permalink
Make a windows installer that works on both 32 and 64 bit
Browse files Browse the repository at this point in the history
  • Loading branch information
skullydazed committed May 31, 2016
1 parent 0664e7d commit cd5af65
Show file tree
Hide file tree
Showing 6 changed files with 144 additions and 32 deletions.
40 changes: 20 additions & 20 deletions LICENSE.md
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
Copyright (c) 2015 Jack Humbert

Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:

The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Copyright (c) 2015 Jack Humbert

Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:

The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
9 changes: 0 additions & 9 deletions WINDOWS_NOTES

This file was deleted.

10 changes: 10 additions & 0 deletions WINDOWS_NOTES.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# What it takes to get this working on windows

1. Install the software
2. During installation you will be asked if you wish to install the driver
from Atmel. Click Install.
3. Plug your keyboard in, press RESET
4. Wait while windows tries to find a driver in Windows Update. You can
tell it to skip this but you'll still wait 5-10 minutes while it
searches Windows Update.
5. Run Firmware Flasher
8 changes: 6 additions & 2 deletions dist-win32.sh
Original file line number Diff line number Diff line change
@@ -1,13 +1,17 @@
#!/bin/sh
# Build a distributable windows package
# Build a distributable windows package on a Linux or OS X host
#
# Once you have built this copy the zip file to a windows host with NSIS
# installed and use firmware_flasher.win32.nsi to build a .exe installer.
set -x

plat=win32
arch=x64
arch=ia32
output_dir=~/"QMK Firmware Flasher"
package_dir="QMK Firmware Flasher-$plat-$arch"
zip_file="${package_dir}.zip"

rm -r "$output_dir/$package_dir" "$zip_file"
electron-packager . --platform=$plat --arch=$arch --out "$output_dir" --prune
cp firmware_flasher.win32.nsi "${output_dir}/${package_dir}"
( cd "$output_dir" && zip -r "$zip_file" "$package_dir" )
107 changes: 107 additions & 0 deletions firmware_flasher.win32.nsi
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
# This installs QMK, creates a start menu shortcut, builds an uninstaller, and
# adds uninstall information to the registry for Add/Remove Programs

# All the settings can be tweaked by editing the !defines at the top of this script
!define APPNAME "Firmware Flasher"
!define COMPANYNAME "QMK"
!define DESCRIPTION "Flash atmega32u4 devices over DFU."
# These three must be integers
!define VERSIONMAJOR 0
!define VERSIONMINOR 5
!define VERSIONBUILD 0
# These will be displayed by the "Click here for support information" link in "Add/Remove Programs"
# It is possible to use "mailto:" links in here to open the email client
!define HELPURL "https://github.com/jackhumbert/dfu-programmer-app/issues" # "Support Information" link
!define UPDATEURL "https://github.com/jackhumbert/dfu-programmer-app/releases" # "Product Updates" link
!define ABOUTURL "https://github.com/jackhumbert/dfu-programmer-app" # "Publisher" link

# This is the size (in kB) of all the files copied into "Program Files"
#!define INSTALLSIZE 7233

RequestExecutionLevel admin ;Require admin rights on NT6+ (When UAC is turned on)

InstallDir "$PROGRAMFILES\${COMPANYNAME} ${APPNAME}"
LicenseData "resources\app\LICENSE.md"
Name "${COMPANYNAME} - ${APPNAME}"
Icon "resources\app\build\windows.ico"
outFile "${COMPANYNAME} ${APPNAME} Installer.exe"

!include LogicLib.nsh

# Just three pages - license agreement, install location, and installation
page license
page directory
Page instfiles

!macro VerifyUserIsAdmin
UserInfo::GetAccountType
pop $0
${If} $0 != "admin" ;Require admin rights on NT4+
messageBox mb_iconstop "Administrator rights required!"
setErrorLevel 740 ;ERROR_ELEVATION_REQUIRED
quit
${EndIf}
!macroend

function .onInit
setShellVarContext all
!insertmacro VerifyUserIsAdmin
functionEnd

section "install"
# Install Program Files
setOutPath $INSTDIR
file /r *.*

# Install the Atmel bootloader driver
nsExec::Exec '"C:\Windows\System32\PnPutil.exe" -i -a "$INSTDIR\resources\app\dfu\dfu-prog-usb-1.2.2\atmel_usb_dfu.inf"'

# Uninstaller
writeUninstaller "$INSTDIR\uninstall.exe"

# Start Menu
createDirectory "$SMPROGRAMS\${COMPANYNAME}"
createShortCut "$SMPROGRAMS\${COMPANYNAME}\${APPNAME}.lnk" "$INSTDIR\QMK Firmware Flasher.exe" "" "$INSTDIR\resources\app\build\windows.ico"

# Registry information for add/remove programs
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${COMPANYNAME} ${APPNAME}" "DisplayName" "${COMPANYNAME} - ${APPNAME} - ${DESCRIPTION}"
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${COMPANYNAME} ${APPNAME}" "UninstallString" "$\"$INSTDIR\uninstall.exe$\""
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${COMPANYNAME} ${APPNAME}" "QuietUninstallString" "$\"$INSTDIR\uninstall.exe$\" /S"
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${COMPANYNAME} ${APPNAME}" "InstallLocation" "$\"$INSTDIR$\""
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${COMPANYNAME} ${APPNAME}" "DisplayIcon" "$\"$INSTDIR\windows.ico$\""
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${COMPANYNAME} ${APPNAME}" "Publisher" "$\"${COMPANYNAME}$\""
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${COMPANYNAME} ${APPNAME}" "HelpLink" "$\"${HELPURL}$\""
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${COMPANYNAME} ${APPNAME}" "URLUpdateInfo" "$\"${UPDATEURL}$\""
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${COMPANYNAME} ${APPNAME}" "URLInfoAbout" "$\"${ABOUTURL}$\""
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${COMPANYNAME} ${APPNAME}" "DisplayVersion" "$\"${VERSIONMAJOR}.${VERSIONMINOR}.${VERSIONBUILD}$\""
WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${COMPANYNAME} ${APPNAME}" "VersionMajor" ${VERSIONMAJOR}
WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${COMPANYNAME} ${APPNAME}" "VersionMinor" ${VERSIONMINOR}
# There is no option for modifying or repairing the install
WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${COMPANYNAME} ${APPNAME}" "NoModify" 1
WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${COMPANYNAME} ${APPNAME}" "NoRepair" 1
# Set the INSTALLSIZE constant (!defined at the top of this script) so Add/Remove Programs can accurately report the size
#WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${COMPANYNAME} ${APPNAME}" "EstimatedSize" ${INSTALLSIZE}
sectionEnd

# Uninstaller
function un.onInit
SetShellVarContext all

#Verify the uninstaller - last chance to back out
MessageBox MB_OKCANCEL "Permanantly remove ${APPNAME}?" IDOK next
Abort
next:
!insertmacro VerifyUserIsAdmin
functionEnd

section "uninstall"
# Remove Start Menu launcher
delete "$SMPROGRAMS\${COMPANYNAME}\${APPNAME}.lnk"
rmDir "$SMPROGRAMS\${COMPANYNAME}"

# Remove files
rmDir /r $INSTDIR

# Remove uninstaller information from the registry
DeleteRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${COMPANYNAME} ${APPNAME}"
sectionEnd
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "dfu-programmer",
"productName": "QMK Firmware Flasher",
"version": "1.0.0",
"version": "0.5.0",
"description": "GUI app to load firmware onto atmega32u4 chips.",
"main": "main.js",
"scripts": {
Expand Down

0 comments on commit cd5af65

Please sign in to comment.