This commit is contained in:
Andrew Pareles 2025-01-19 21:36:48 -08:00
parent 60d22674e2
commit d9be67d17d
5 changed files with 4 additions and 265 deletions

View file

@ -75,37 +75,11 @@ export abstract class AbstractUpdateService implements IUpdateService {
protected async initialize(): Promise<void> {
if (!this.environmentMainService.isBuilt) {
console.log('is NOT built, canceling update service')
this.setState(State.Disabled(DisablementReason.NotBuilt));
return; // updates are never enabled when running out of sources
// this.setState(State.Disabled(DisablementReason.NotBuilt));
// return; // updates are never enabled when running out of sources
}
console.log('is built, continuing with update service')
// Void commented this
// if (this.environmentMainService.disableUpdates) {
// this.setState(State.Disabled(DisablementReason.DisabledByEnvironment));
// this.logService.info('update#ctor - updates are disabled by the environment');
// return;
// }
// if (!this.productService.updateUrl || !this.productService.commit) {
// this.setState(State.Disabled(DisablementReason.MissingConfiguration));
// this.logService.info('update#ctor - updates are disabled as there is no update URL');
// return;
// }
// Void - for now, always update
// const updateMode = 'default' //this.configurationService.getValue<'none' | 'manual' | 'start' | 'default'>('update.mode');
// const quality = this.getProductQuality(updateMode);
// if (!quality) {
// console.log('disabling....', updateMode, quality)
// this.setState(State.Disabled(DisablementReason.ManuallyDisabled));
// this.logService.info('update#ctor - updates are disabled by user preference');
// return;
// }
// const quality = 'stable'
this.url = this.doBuildUpdateFeedUrl('stable');
if (!this.url) {
this.setState(State.Disabled(DisablementReason.InvalidConfiguration));
@ -113,35 +87,12 @@ export abstract class AbstractUpdateService implements IUpdateService {
return;
}
// // hidden setting
// if (this.configurationService.getValue<boolean>('_update.prss')) {
// const url = new URL(this.url);
// url.searchParams.set('prss', 'true');
// this.url = url.toString();
// }
this.setState(State.Idle(this.getUpdateType()));
// if (updateMode === 'manual') {
// this.logService.info('update#ctor - manual checks only; automatic updates are disabled by user preference');
// return;
// }
// if (updateMode === 'start') {
// this.logService.info('update#ctor - startup checks only; automatic updates are disabled by user preference');
// // Check for updates only once after 30 seconds
// setTimeout(() => this.checkForUpdates(false), 30 * 1000);
// } else {
// Start checking for updates after 30 seconds
this.scheduleCheckForUpdates(30 * 1000).then(undefined, err => this.logService.error(err));
// }
// start checking for updates after 10 seconds
this.scheduleCheckForUpdates(10 * 1000).then(undefined, err => this.logService.error(err));
}
// private getProductQuality(updateMode: string): string | undefined {
// return updateMode === 'none' ? undefined : this.productService.quality;
// }
private async scheduleCheckForUpdates(delay = 60 * 60 * 1000): Promise<void> {
await timeout(delay);
await this.checkForUpdates(false);

View file

@ -1 +0,0 @@
mac-env.sh

View file

@ -1,182 +0,0 @@
#!/usr/bin/env bash
set -e # Exit on error
# Usage: sign.sh {sign|notarize} {arm64|x64}
echo "-------------------- Setting local variables... --------------------"
ARCH=$2
# Required variables:
# ORIGINAL_DOTAPP_DIR="${HOME}/Desktop/VSCode-darwin-${ARCH}" # location of original (nothing is modified in this dir, just copied away from it)
# WORKING_DIR="${HOME}/Desktop/VoidSign-${ARCH}" # temp dir for all the work here
# P12_FILE="${HOME}/Desktop/sign/cert.p12"
# P12_PASSWORD="..."
# APPLE_ID="..."
# TEAM_ID="..."
# APP_PASSWORD="..." # see https://appleid.apple.com
# CODESIGN_IDENTITY="Developer ID Application: ..." # try `security find-identity -v -p codesigning`
## computed
KEYCHAIN_DIR="${WORKING_DIR}/1_Keychain"
KEYCHAIN="${KEYCHAIN_DIR}/buildagent.keychain"
SIGN_DIR="${WORKING_DIR}/2_Signed"
SIGNED_DOTAPP_DIR="${SIGN_DIR}/VSCode-darwin-${ARCH}"
SIGNED_DOTAPP="${SIGN_DIR}/VSCode-darwin-${ARCH}/Void.app"
SIGNED_DMG_DIR="${SIGN_DIR}/VSCode-darwin-${ARCH}"
SIGNED_DMG="${SIGN_DIR}/VSCode-darwin-${ARCH}/Void-Installer-darwin-${ARCH}.dmg"
echo $KEYCHAIN_DIR
sign() {
echo "-------------------- 0. cleanup + copy --------------------"
rm -rf "${WORKING_DIR}"
mkdir "${WORKING_DIR}"
mkdir "${KEYCHAIN_DIR}"
mkdir "${SIGN_DIR}"
cp -Rp $ORIGINAL_DOTAPP_DIR $SIGN_DIR
echo "-------------------- 1. Make temp keychain --------------------"
# Create a new keychain
security create-keychain -p pwd "${KEYCHAIN}"
security set-keychain-settings -lut 21600 "${KEYCHAIN}"
security unlock-keychain -p pwd "${KEYCHAIN}"
# Import your p12 certificate
security import "${P12_FILE}" -k "${KEYCHAIN}" -P "${P12_PASSWORD}" -T /usr/bin/codesign
security set-key-partition-list -S apple-tool:,apple:,codesign: -s -k pwd "${KEYCHAIN}" > /dev/null
echo "-------------------- 2a. Sign --------------------"
cd "${HOME}/Desktop/void/build/darwin"
# used in sign.js
export AGENT_TEMPDIRECTORY=$KEYCHAIN_DIR
export CODESIGN_IDENTITY="${CODESIGN_IDENTITY}"
export VSCODE_ARCH=$ARCH
node sign.js "${SIGN_DIR}"
codesign --verify --verbose=4 "${SIGNED_DOTAPP}"
echo "-------------------- 2b. Make into dmg --------------------"
npx create-dmg --volname "Void Installer" "${SIGNED_DOTAPP}" "${SIGNED_DMG_DIR}"
# there are two create-dmgs https://github.com/create-dmg/create-dmg https://github.com/sindresorhus/create-dmg the latter one is on npm and works better
GENERATED_DMG=$(ls "${SIGNED_DMG_DIR}"/*.dmg) # figure out the full path of the generated file because create-dmg is stupid
if [[ -z "$GENERATED_DMG" ]]; then
echo "Error: No .dmg file was created."
exit 1
fi
mv "${GENERATED_DMG}" "${SIGNED_DMG}" # rename
# We don't even have to codesign - apparently create-dmg does it! codesign --deep --options runtime --sign "${CODESIGN_IDENTITY}" "${SIGNED_DMG}" create
codesign --verify --verbose=4 "${SIGNED_DMG}"
}
# notarize DMG
notarize(){
KEYCHAIN_PROFILE_NAME="Void" # this doesnt seem to do anything but is required
# echo "-------------------- 4. Notarize --------------------"
# echo "Past history:"
# xcrun notarytool history --keychain-profile "${KEYCHAIN_PROFILE_NAME}" --keychain "${KEYCHAIN}"
echo "Void: Setting credentials..."
xcrun notarytool store-credentials "${KEYCHAIN_PROFILE_NAME}" \
--apple-id "${APPLE_ID}" \
--team-id "${TEAM_ID}" \
--password "${APP_PASSWORD}" \
--keychain "${KEYCHAIN}"
echo "Void: Submitting..."
xcrun notarytool submit "${SIGNED_DMG}" \
--keychain-profile "${KEYCHAIN_PROFILE_NAME}" \
--keychain "${KEYCHAIN}" \
--wait
echo "Done! Stapling..."
# finds notarized ticket that was made and staples it to Void.app
xcrun stapler staple "${SIGNED_DMG}"
# echo "-------------------- 6. Verify --------------------"
# spctl --assess --verbose=4 "${SIGNED_DMG}"
}
updater(){
cd "${SIGNED_DOTAPP_DIR}"
echo "Zipping updater here..."
VOIDAPP=$(basename $SIGNED_DOTAPP)
zip -r -q "Void-Updater-darwin-${ARCH}.zip" "${VOIDAPP}"
echo "Done!"
}
computehash() {
cd "${SIGNED_DOTAPP_DIR}"
SHA1=$(shasum -a 1 "${SIGNED_DOTAPP}/Contents/MacOS/Electron" | cut -d' ' -f1)
SHA256=$(shasum -a 256 "${SIGNED_DOTAPP}/Contents/MacOS/Electron" | cut -d' ' -f1)
TIMESTAMP=$(date +%s)
cat > hash.json << EOF
{
"sha256hash": "${SHA256}",
"hash": "${SHA1}",
"timestamp": ${TIMESTAMP}
}
EOF
}
USAGE="Usage: $0 {sign|notarize|updater} {arm64|x64}"
# check to make sure arm64 or x64 is specified
case "$2" in
arm64)
;;
x64)
;;
*)
echo $USAGE
exit 1
;;
esac
# Check the first argument
case "$1" in
sign)
sign
;;
notarize)
notarize
;;
updater)
updater
;;
computehash)
computehash
;;
*)
echo $USAGE
exit 1
;;
esac

View file

@ -1,16 +0,0 @@
# Do not run this unless you know what you're doing.
set -e
npm run gulp vscode-darwin-arm64-min
./mac-sign.sh sign arm64
./mac-sign.sh notarize arm64
./mac-sign.sh updater arm64
./mac-sign.sh computehash arm64
npm run gulp vscode-darwin-x64-min
./mac-sign.sh sign x64
./mac-sign.sh notarize x64
./mac-sign.sh updater x64
./mac-sign.sh computehash x64

View file

@ -1,13 +0,0 @@
npm run gulp vscode-win32-x64-min
npm run gulp vscode-win32-x64-inno-updater
npm run gulp vscode-win32-x64-system-setup
# change icon
# npm run vscode-darwin-ia32-min
# npm run gulp vscode-win32-ia32-inno-updater
# npm run gulp vscode-win32-ia32-system-setup
# # change icon