Skip to content

Commit

Permalink
Merge pull request #127 from qwertyyb/fix/ci
Browse files Browse the repository at this point in the history
fix: 修复第一次无法安装的问题
  • Loading branch information
qwertyyb authored Apr 13, 2024
2 parents 1daed5d + 8c09bfb commit c9f3738
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 10 deletions.
12 changes: 6 additions & 6 deletions Fire/InputSource.swift
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ class InputSource {
if !isEnabled() {
// 全新安装或未启用过,需要Register, 已启用的,不需要再次启用
let installedLocationURL = NSURL(fileURLWithPath: installLocation)
TISRegisterInputSource(installedLocationURL as CFURL)
NSLog("register input source")
let err = TISRegisterInputSource(installedLocationURL as CFURL)
NSLog("register input source: \(err)")
}
}

Expand Down Expand Up @@ -69,11 +69,11 @@ class InputSource {
guard let result = self.findInputSource(forUsage: .selected) else {
return
}
TISSelectInputSource(result)
let err = TISSelectInputSource(result)
NSLog("select input source: \(err)")
let isSelected = CFBooleanGetValue(Unmanaged<CFBoolean>.fromOpaque(
TISGetInputSourceProperty(result, kTISPropertyInputSourceIsSelected)
).takeUnretainedValue())
NSLog("Selected input source")
if isSelected {
timer.invalidate()
callback(true)
Expand All @@ -89,8 +89,8 @@ class InputSource {
TISGetInputSourceProperty(result, kTISPropertyInputSourceIsEnabled)
).takeUnretainedValue())
if !enabled {
TISEnableInputSource(result)
NSLog("Enabled input source")
let err = TISEnableInputSource(result)
NSLog("Enabled input source: \(err)")
}
}

Expand Down
27 changes: 27 additions & 0 deletions package/component.plist
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<array>
<dict>
<key>RootRelativeBundlePath</key>
<string>Fire.app</string>
<key>BundleHasStrictIdentifier</key>
<false/>
<key>BundleIsRelocatable</key>
<false/>
<key>BundleIsVersionChecked</key>
<true/>
<key>BundleOverwriteAction</key>
<string>upgrade</string>
<key>ChildBundles</key>
<array>
<dict>
<key>BundleOverwriteAction</key>
<string>upgrade</string>
<key>RootRelativeBundlePath</key>
<string>Fire.app/Contents/Frameworks/Sparkle.framework</string>
</dict>
</array>
</dict>
</array>
</plist>
2 changes: 1 addition & 1 deletion package/scripts/postinstall
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ TARGET='Fire'

login_user=`/usr/bin/stat -f%Su /dev/console`

/usr/bin/sudo -u "${login_user}" pkill -9 "${TARGET}"
/usr/bin/sudo -u "${login_user}" pkill -9 "${TARGET}" || true

/usr/bin/sudo -u "${login_user}" "/Library/Input Methods/${TARGET}.app/Contents/MacOS/${TARGET}" --install

Expand Down
7 changes: 4 additions & 3 deletions scripts/b_build_installer.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,15 @@ rm "$EXPORT_PATH/${TARGET}.pkg"
rm -rf "${INSTALLER_ROOT}"
mkdir -p "${INSTALLER_ROOT}"
cp -R "$EXPORT_PATH/${TARGET}.app" "${INSTALLER_ROOT}"
echo $INSTALLER_ROOT
echo "INSTALLER_ROOT=$INSTALLER_ROOT"
echo "INSTALL_LOCATION=${INSTALL_LOCATION}"

if [[ $USE_CODE_SIGN == "disable" ]]
then
echo "build installer without signing"
pkgbuild --info "${PROJECT_ROOT}/package/PackageInfo" --root "${INSTALLER_ROOT}" --identifier "${BUNDLE_IDENTIFIER}" --version "${Version}" --install-location "${INSTALL_LOCATION}" --scripts "${PROJECT_ROOT}/package/scripts" "$EXPORT_INSTALLER" || { echo "build installer failed"; exit 1; }
pkgbuild --info "${PROJECT_ROOT}/package/PackageInfo" --root "${INSTALLER_ROOT}" --component-plist "${PROJECT_ROOT}/package/component.plist" --identifier "${BUNDLE_IDENTIFIER}" --version "${Version}" --install-location "${INSTALL_LOCATION}" --scripts "${PROJECT_ROOT}/package/scripts" "$EXPORT_INSTALLER" || { echo "build installer failed"; exit 1; }
else
pkgbuild --info "${PROJECT_ROOT}/package/PackageInfo" --root "${INSTALLER_ROOT}" --identifier "${BUNDLE_IDENTIFIER}" --version "${Version}" --install-location "${INSTALL_LOCATION}" --scripts "${PROJECT_ROOT}/package/scripts" --sign "Developer ID Installer: Yongbang Yang" "$EXPORT_INSTALLER" || { echo "build installer failed"; exit 1; }
pkgbuild --info "${PROJECT_ROOT}/package/PackageInfo" --root "${INSTALLER_ROOT}" --component-plist "${PROJECT_ROOT}/package/component.plist" --identifier "${BUNDLE_IDENTIFIER}" --version "${Version}" --install-location "${INSTALL_LOCATION}" --scripts "${PROJECT_ROOT}/package/scripts" --sign "Developer ID Installer: Yongbang Yang" "$EXPORT_INSTALLER" || { echo "build installer failed"; exit 1; }
fi

# pack zip for update
Expand Down
2 changes: 2 additions & 0 deletions scripts/common.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,11 @@ EXPORT_INSTALLER_ZIP="$EXPORT_PATH/FireInstaller.zip"

if [[ $USE_CODE_SIGN == "enable" ]]
then
echo "enable code sign"
BUILD_FLAG=''
elif [[ $USE_CODE_SIGN == "disable" ]]
then
echo "disable code sign"
BUILD_FLAG='CODE_SIGN_IDENTITY="" CODE_SIGNING_REQUIRED=NO CODE_SIGNING_ALLOWED=NO'
fi

Expand Down

0 comments on commit c9f3738

Please sign in to comment.