Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: implement electron-configure-package-win32.sh #962

Merged
merged 1 commit into from
Dec 13, 2016

Conversation

jviotti
Copy link
Contributor

@jviotti jviotti commented Dec 8, 2016

This script configures an Electron package on Windows.

Signed-off-by: Juan Cruz Viotti [email protected]

@jviotti jviotti force-pushed the windows-packaging branch 2 times, most recently from 0900c65 to 132d528 Compare December 8, 2016 17:45
@@ -10,6 +10,7 @@ APPLICATION_COPYRIGHT = $(shell jq -r '.copyright' package.json)
APPLICATION_CATEGORY = public.app-category.developer-tools
APPLICATION_BUNDLE_ID = io.resin.etcher
APPLICATION_FILES = lib,build,assets
COMPANY_NAME = Resinio Ltd
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could / should that be included in package.json?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done!

endif
ifndef CODE_SIGN_CERTIFICATE_PASSWORD
$(warning No code-sign certificate password found (CODE_SIGN_CERTIFICATE_PASSWORD is not set))
endif
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably makes sense to only show these warnings when you're actually about to do the code-signing step, rather than showing them all the time to all users.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And it probably makes sense to nest the ifndef CODE_SIGN_CERTIFICATE_PASSWORD inside the ifndef CODE_SIGN_CERTIFICATE too

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ahhh, I now see that the code-signing step is simply skipped if these env-vars aren't set.

Still it feels wrong to always display them though, even for users who are just building locally and will never be able to code-sign? Can't think of a good solution off the top of my head though.

Oooh! What if we instead had the code-signing as a precursor to the publishing step, so that only users who attempt to run the publishing targets will get warned about missing CODE_SIGN env-vars?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oooh! What if we instead had the code-signing as a precursor to the publishing step, so that only users who attempt to run the publishing targets will get warned about missing CODE_SIGN env-vars?

The thing is that code-signing right before publishing might mean re-doing the whole packaging step. In OS X for example, we create a temporary read-write DMG, and we have to code-sign inside the DMG and then convert to a read-only DMG.

How would you handle that right before publishing? I'm not saying that it can't be done, but it means re-doing a lot of work that took us to the publishing step in the first place.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And it probably makes sense to nest the ifndef CODE_SIGN_CERTIFICATE_PASSWORD inside the ifndef CODE_SIGN_CERTIFICATE too

Done!

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess one option would be to have a non-signed version as the "standard" DMG, and then have a special code-signed DMG required by the publish step? That's probably a bit too much of a step though just to silence a couple of warnings ;-)
Or a simple solution could just be a SILENCE_CODE_SIGN_WARNINGS ?= 0 in the Makefile, so the user could set a SILENCE_CODE_SIGN_WARNINGS=1 env-var if they wanted to.

OTOH, perhaps it's inconsistent behaviour to have the Makefile generate two different versions of the same file, based on the value of an env-var? (makes it hard to tell them apart?)
Consider if:

  1. You run make without the CODE_SIGN env-vars set
  2. Make creates the unsigned package
  3. You run make again with the CODE_SIGN env-vars set
  4. Make doesn't do anything, because it thinks the package is already up to date
  5. You run 'make publish'
  6. Whoops, make has now uploaded the unsigned packages!

What if instead, there was e.g. a release/out/signed directory, and make publish depended on release/out/signed/Etcher-1.0.0-beta.17-darwin-x64.dmg, which in turn depended on the temporary read-write DMG (could it be given a different name and made non-temporary?). And then release/out/Etcher-1.0.0-beta.17-darwin-x64.dmg would also depend on the same 'temporary' read-write DMG, and would always be the non-signed package.
Would that work? ;)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And for those scripts where you have the option to verify the signature, maybe it would make sense to sign the package / exe in the temporary directory, and only move it to release/out/signed/ after it's been verified.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like the signed/ subdirectory idea. I propose to do it in another PR so we can do it for all the operating systems. Regarding the warning, what about simply not printing the warning, but report that the binary is not going to be signed, in make info?

If you agree on that, lets merge the PR as it is now, and I'll send a new one right away to make that change, so we do it for all operating systems at once.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As I said here I think it'd make sense for the "standard build" e.g. make electron-installer-dmg to produce unsigned images (and have them also be snapshot versions by default), and then have a special e.g. signed-electron-installer-dmg target to create (production-version?) files in the signed/ subdirectory, and only do the check-for-certificate-vars step as part of the signed-electron-installer-dmg rules, and upgrade it from a warning to an error.
(If that all makes sense? 😉 )

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds good to me :) Let me know if I can help with any OS X testing (if you don't have access to OS X yet, you might want to ping the operations team to ship you a Mac Mini or something like that anyway)!

-v "$(APPLICATION_VERSION)" \
-l LICENSE \
-r "$(APPLICATION_COPYRIGHT)" \
-c "$(COMPANY_NAME)" \
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the darwin section, you've used -c "$(APPLICATION_COPYRIGHT)" - consistency is always good

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, single letter options might lead to a lot of confusion. I'll use -m in this case, but maybe we should look for a getopts alternative that allows us to use longer option names?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

...and (again, for consistency) could you change -r "$(APPLICATION_COPYRIGHT)" to -c "$(APPLICATION_COPYRIGHT)" ? 😄

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oops, I missed this comment. Done!

}

check_dep upx
check_dep unzip
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't forget to update this if #959 gets merged first

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done!

echo " -c <company name>"
echo " -a <application asar (.asar)>"
echo " -i <application icon (.ico)>"
echo " -w <download directory>"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should probably do the same TMPDIR= trick that you use in electron-installer-appimage.sh ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think I prefer to be explicit about it and ask it as an option rather than relying on the environment at all.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fair enough

usage
fi

mkdir -p $(dirname "$ARGV_OUTPUT")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be changed after #946 gets merged

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done!

RCEDIT_VERSION=v0.7.0
RCEDIT="$ARGV_DOWNLOAD_DIRECTORY/rcedit.exe"

# TODO: Move to Makefile
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep ;)

@lurch
Copy link
Contributor

lurch commented Dec 8, 2016

Great to see the win32 build moving to the same Makefile & Bash setup as linux and darwin 👍

RCEDIT="$ARGV_DOWNLOAD_DIRECTORY/rcedit.exe"

./scripts/build/download-tool.sh -x \
-u "https://github.com/electron/node-rcedit/raw/$RCEDIT_VERSION/bin/rcedit.exe" \
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Curiosity finally got the better of me... ;-) electron/node-rcedit#23

set -u
set -e

function check_dep() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Need to remove this function :)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oops, done!

exit 1
fi
}

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As this script runs a win32 executable (rcedit.exe), it ought to include the only-running-on-windows check

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indeed. In theory, this script could run in the other operating systems on top of Wine, but lets ignore that for now :)

@lurch
Copy link
Contributor

lurch commented Dec 10, 2016

By re-ordering some of the lines...

--- a/scripts/build/electron-configure-package-win32.sh
+++ b/scripts/build/electron-configure-package-win32.sh
@@ -95,16 +95,9 @@ fi
 unzip "$ARGV_ELECTRON_PACKAGE" -d "$ARGV_OUTPUT"
 
 mv "$ARGV_OUTPUT/electron.exe" "$ARGV_OUTPUT/$ARGV_APPLICATION_NAME.exe"
-rm -f "$ARGV_OUTPUT/resources/default_app.asar"
-
-cp "$ARGV_ASAR" "$ARGV_OUTPUT/resources/app.asar"
 cp "$ARGV_LICENSE" "$ARGV_OUTPUT/LICENSE"
-
-if [ -d "$ARGV_ASAR.unpacked" ]; then
-  cp -rf "$ARGV_ASAR.unpacked" "$ARGV_OUTPUT/resources/app.asar.unpacked"
-fi
-
 echo "$ARGV_VERSION" > "$ARGV_OUTPUT/version"
+rm -f "$ARGV_OUTPUT/resources/default_app.asar"
 
 RCEDIT_VERSION=v0.7.0
 RCEDIT="$ARGV_DOWNLOAD_DIRECTORY/rcedit.exe"
@@ -126,3 +119,9 @@ RCEDIT="$ARGV_DOWNLOAD_DIRECTORY/rcedit.exe"
   --set-icon "$ARGV_ICON"
 
 upx -9 "$ARGV_OUTPUT/*.dll"
+
+cp "$ARGV_ASAR" "$ARGV_OUTPUT/resources/app.asar"
+
+if [ -d "$ARGV_ASAR.unpacked" ]; then
+  cp -rf "$ARGV_ASAR.unpacked" "$ARGV_OUTPUT/resources/app.asar.unpacked"
+fi

...it's possible to get this script to much more closely match electron-configure-package-linux.sh. Have I ever mentioned I like consistency? ;-)

@jviotti jviotti force-pushed the windows-packaging branch 2 times, most recently from 48814d5 to bfada3e Compare December 11, 2016 23:08
@jviotti
Copy link
Contributor Author

jviotti commented Dec 11, 2016

Have I ever mentioned I like consistency? ;-)

Haha, I think I heard something about that! :P

I applied the diff!

@jviotti
Copy link
Contributor Author

jviotti commented Dec 12, 2016

Is this good to merge?

@lurch
Copy link
Contributor

lurch commented Dec 12, 2016

There's two reasons I hadn't approved this yet:

This script configures an Electron package on Windows.

Signed-off-by: Juan Cruz Viotti <[email protected]>
@jviotti
Copy link
Contributor Author

jviotti commented Dec 12, 2016

Oops, I missed those comments, sorry for that!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants