cleaning structure

This commit is contained in:
Quality System Admin
2025-10-16 01:42:59 +03:00
parent e0ba349862
commit 50c791e242
469 changed files with 1016 additions and 29776 deletions

View File

@@ -0,0 +1,12 @@
{
"title": "${project.name}",
"background": "${basedir}/ant/apple/dmg-background.png",
"icon-size": 128,
"contents": [
{ "x": 501, "y": 154, "type": "link", "path": "/Applications" },
{ "x": 179, "y": 154, "type": "file", "path": "${build.dir}/${project.name}.app" }
],
"code-sign": {
"signing-identity" : "${codesign.activeid}"
}
}

View File

@@ -0,0 +1,28 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0"><dict>
<key>CFBundleDevelopmentRegion</key><string>English</string>
<key>CFBundleIconFile</key><string>${project.filename}</string>
<key>CFBundleIdentifier</key><string>${apple.bundleid}</string>
<key>CFBundlePackageType</key><string>APPL</string>
<key>CFBundleGetInfoString</key><string>${project.name} ${build.version}</string>
<key>CFBundleSignature</key><string>${project.name}</string>
<key>CFBundleExecutable</key><string>${project.name}</string>
<key>CFBundleVersion</key><string>${build.version}</string>
<key>CFBundleShortVersionString</key><string>${build.version}</string>
<key>CFBundleName</key><string>${project.name}</string>
<key>CFBundleInfoDictionaryVersion</key><string>6.0</string>
<key>CFBundleURLTypes</key>
<array>
<dict>
<key>CFBundleURLName</key>
<string>${project.name}</string>
<key>CFBundleURLSchemes</key>
<array><string>${vendor.name}</string></array>
</dict>
</array>
<key>LSArchitecturePriority</key>
<array>
<string>${apple.target.arch}</string>
</array>
</dict></plist>

View File

@@ -0,0 +1,30 @@
<?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">
<dict>
<key>com.apple.security.app-sandbox</key>
<${build.sandboxed}/>
<key>com.apple.security.network.client</key>
<true/>
<key>com.apple.security.network.server</key>
<true/>
<key>com.apple.security.files.all</key>
<true/>
<key>com.apple.security.print</key>
<true/>
<key>com.apple.security.device.usb</key>
<true/>
<key>com.apple.security.device.bluetooth</key>
<true/>
<key>com.apple.security.cs.allow-jit</key>
<true/>
<key>com.apple.security.cs.allow-unsigned-executable-memory</key>
<true/>
<key>com.apple.security.cs.disable-library-validation</key>
<true/>
<key>com.apple.security.cs.allow-dyld-environment-variables</key>
<true/>
<key>com.apple.security.cs.debugger</key>
<true/>
</dict>
</plist>

View File

@@ -0,0 +1,23 @@
#!/bin/bash
# Halt on first error
set -e
# Get working directory
DIR=$(cd "$(dirname "$0")" && pwd)
pushd "$DIR/payload/${project.name}.app/Contents/MacOS/"
./"${project.name}" install >> "${install.log}" 2>&1
popd
# Use install target from pkgbuild, an undocumented feature; fallback on sane location
if [ -n "$2" ]; then
pushd "$2/Contents/MacOS/"
else
pushd "/Applications/${project.name}.app/Contents/MacOS/"
fi
./"${project.name}" certgen >> "${install.log}" 2>&1
# Start qz by calling open on the .app as an ordinary user
su "$USER" -c "open ../../" || true

View File

@@ -0,0 +1,31 @@
#!/bin/bash
# Halt on first error
set -e
# Clear the log for writing
> "${install.log}"
# Log helper
dbg () {
echo -e "[BASH] $(date -Iseconds)\n\t$1" >> "${install.log}" 2>&1
}
# Get working directory
dbg "Calculating working directory..."
DIR=$(cd "$(dirname "$0")" && pwd)
dbg "Using working directory $DIR"
dbg "Switching to payload directory $DIR/payload/${project.name}.app/Contents/MacOS/"
pushd "$DIR/payload/${project.name}.app/Contents/MacOS/" >> "${install.log}" 2>&1
# Offer to download Java if missing
dbg "Checking for Java in payload directory..."
if ! ./"${project.name}" --version >> "${install.log}" 2>&1; then
dbg "Java was not found"
osascript -e "tell app \"Installer\" to display dialog \"Java is required. Please install Java and try again.\""
sudo -u "$USER" open "${java.download}"
exit 1
fi
dbg "Java was found in payload directory, running preinstall"
./"${project.name}" preinstall >> "${install.log}" 2>&1

View File

@@ -0,0 +1,6 @@
# Apple build properties
apple.packager.signid=P5DMU6659X
# jdk9+ flags
# - Tray icon requires workaround https://github.com/dyorgio/macos-tray-icon-fixer/issues/9
# - Dark theme requires workaround https://github.com/bobbylight/Darcula/issues/8
apple.launch.jigsaw=--add-opens java.desktop/sun.lwawt.macosx=ALL-UNNAMED --add-opens java.desktop/java.awt=ALL-UNNAMED --add-exports java.desktop/com.apple.laf=ALL-UNNAMED

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

After

Width:  |  Height:  |  Size: 48 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 110 KiB

View File

@@ -0,0 +1,376 @@
<project name="apple-installer" basedir="../../" xmlns:if="ant:if">
<property file="ant/project.properties"/>
<import file="${basedir}/ant/version.xml"/>
<import file="${basedir}/ant/platform-detect.xml"/>
<!--
################################################################
# Apple Installer #
################################################################
-->
<target name="build-pkg" depends="get-identity,add-certificates,get-version,platform-detect">
<echo level="info">Creating installer using pkgbuild</echo>
<!--
#####################################
# Create scripts, payload and pkg #
#####################################
-->
<mkdir dir="${build.dir}/scripts/payload"/>
<!-- Get the os-preferred name for the target architecture -->
<condition property="apple.target.arch" value="arm64">
<isset property="target.arch.aarch64"/>
</condition>
<property name="apple.target.arch" value="x86_64" description="fallback value"/>
<!-- Build app without sandboxing by default-->
<property name="build.sandboxed" value="false"/>
<antcall target="build-app">
<param name="bundle.dir" value="${build.dir}/scripts/payload/${project.name}.app"/>
</antcall>
<!-- Add a break in the logs -->
<antcall target="packaging"/>
<!-- scripts/ -->
<copy file="ant/apple/apple-preinstall.sh.in" tofile="${build.dir}/scripts/preinstall">
<filterchain><expandproperties/></filterchain>
</copy>
<copy file="ant/apple/apple-postinstall.sh.in" tofile="${build.dir}/scripts/postinstall">
<filterchain><expandproperties/></filterchain>
</copy>
<chmod perm="a+x" type="file">
<fileset dir="${build.dir}/scripts">
<include name="preinstall"/>
<include name="postinstall"/>
</fileset>
</chmod>
<exec executable="pkgbuild" failonerror="true">
<arg value="--identifier"/>
<arg value="${apple.bundleid}"/>
<arg value="--nopayload"/>
<arg value="--install-location"/>
<arg value="/Applications/${project.name}.app"/>
<arg value="--scripts"/>
<arg value="${build.dir}/scripts"/>
<arg value="--version"/>
<arg value="${build.version}"/>
<arg value="--sign" if:true="${codesign.available}"/>
<arg value="${codesign.activeid}" if:true="${codesign.available}"/>
<arg value="${out.dir}/${project.filename}${build.type}-${build.version}-${apple.target.arch}-unbranded.pkg"/>
</exec>
<!-- Branding for qz only -->
<condition property="pkg.background" value="pkg-background.tiff" else="pkg-background-blank.tiff">
<equals arg1="${project.filename}" arg2="qz-tray"/>
</condition>
<!-- Copy branded resources to out/resources -->
<mkdir dir="${out.dir}/resources"/>
<copy file="${basedir}/ant/apple/${pkg.background}" tofile="${out.dir}/resources/background.tiff" failonerror="true"/>
<!-- Create product definition plist that stipulates supported arch -->
<copy file="ant/apple/product-def.plist.in" tofile="${build.dir}/product-def.plist">
<filterchain><expandproperties/></filterchain>
</copy>
<!-- Create a distribution.xml file for productbuild -->
<exec executable="productbuild" failonerror="true">
<arg value="--synthesize"/>
<arg value="--sign" if:true="${codesign.available}"/>
<arg value="${codesign.activeid}" if:true="${codesign.available}"/>
<arg value="--timestamp"/>
<arg value="--package"/>
<arg value="${out.dir}/${project.filename}${build.type}-${build.version}-${apple.target.arch}-unbranded.pkg"/>
<arg value="--product"/>
<arg value="${build.dir}/product-def.plist"/>
<arg value="--scripts"/>
<arg value="${build.dir}/scripts"/>
<arg value="${out.dir}/distribution.xml"/>
</exec>
<!-- Inject title, background -->
<replace file="${out.dir}/distribution.xml" token="&lt;options customize">
<replacevalue><![CDATA[<title>@project.name@ @build.version@</title>
<background file="background.tiff" mime-type="image/tiff" alignment="bottomleft" scaling="none"/>
<background-darkAqua file="background.tiff" mime-type="image/tiff" alignment="bottomleft" scaling="none"/>
<options customize]]></replacevalue>
<replacefilter token="@project.name@" value="${project.name}"/>
<replacefilter token="@build.version@" value="${build.version}"/>
</replace>
<!-- Create a branded .pkg using productbuild -->
<exec executable="productbuild" dir="${out.dir}" failonerror="true">
<arg value="--sign" if:true="${codesign.available}"/>
<arg value="${codesign.activeid}" if:true="${codesign.available}"/>
<arg value="--timestamp"/>
<arg value="--distribution"/>
<arg value="${out.dir}/distribution.xml"/>
<arg value="--resources"/>
<arg value="${out.dir}/resources"/>
<arg value="--product"/>
<arg value="${build.dir}/product-def.plist"/>
<arg value="--package-path"/>
<arg value="${project.filename}${build.type}-${build.version}-${apple.target.arch}-unbranded.pkg"/>
<arg value="${out.dir}/${project.filename}${build.type}-${build.version}-${apple.target.arch}.pkg"/>
</exec>
<!-- Cleanup unbranded version -->
<delete file="${out.dir}/${project.filename}${build.type}-${build.version}-${apple.target.arch}-unbranded.pkg"/>
</target>
<target name="build-dmg" depends="get-identity,add-certificates,get-version">
<echo level="info">Creating app bundle</echo>
<!--
#####################################
# Create payload and bundle as dmg #
#####################################
-->
<!-- Dmg JSON -->
<copy file="ant/apple/appdmg.json.in" tofile="${build.dir}/appdmg.json">
<filterchain><expandproperties/></filterchain>
</copy>
<!-- Build app with sandboxing by default-->
<property name="build.sandboxed" value="true"/>
<antcall target="build-app">
<param name="bundle.dir" value="${build.dir}/${project.name}.app"/>
</antcall>
<!-- Add a break in the logs -->
<antcall target="packaging"/>
<exec executable="appdmg" failonerror="true">
<arg value="${build.dir}/appdmg.json"/>
<arg value="${out.dir}/${project.filename}${build.type}-${build.version}.dmg"/>
</exec>
</target>
<target name="build-app" depends="get-identity">
<!-- App Bundle -->
<mkdir dir="${bundle.dir}"/>
<!-- Contents/ -->
<copy file="ant/apple/apple-bundle.plist.in" tofile="${bundle.dir}/Contents/Info.plist">
<filterchain><expandproperties/></filterchain>
</copy>
<!-- Contents/MacOS/ -->
<mkdir dir="${bundle.dir}/Contents/MacOS"/>
<copy file="ant/unix/unix-launcher.sh.in" tofile="${bundle.dir}/Contents/MacOS/${project.name}">
<filterchain><expandproperties/></filterchain>
</copy>
<!-- Contents/Resources/ -->
<copy todir="${bundle.dir}/Contents/Resources">
<fileset dir="${dist.dir}">
<include name="${project.filename}.jar"/>
<include name="LICENSE.txt"/>
<include name="override.crt"/>
</fileset>
</copy>
<copy file="assets/branding/apple-icon.icns" tofile="${bundle.dir}/Contents/Resources/${project.filename}.icns"/>
<copy file="ant/unix/unix-uninstall.sh.in" tofile="${bundle.dir}/Contents/Resources/uninstall">
<filterchain><expandproperties/></filterchain>
</copy>
<copy todir="${bundle.dir}/Contents/Resources/demo">
<fileset dir="${dist.dir}/demo" includes="**"/>
</copy>
<!-- Provision files -->
<delete dir="${bundle.dir}/Contents/Resources/provision" failonerror="false"/>
<copy todir="${bundle.dir}/Contents/Resources/provision" failonerror="false">
<fileset dir="${provision.dir}" includes="**"/>
</copy>
<chmod perm="a+x" type="file" verbose="true">
<fileset dir="${bundle.dir}/Contents/Resources/" casesensitive="false">
<!-- Must iterate on parent directory in case "provision" is missing -->
<include name="provision/*"/>
<exclude name="provision/*.crt"/>
<exclude name="provision/*.txt"/>
<exclude name="provision/*.json"/>
</fileset>
</chmod>
<!-- Java runtime -->
<copy todir="${bundle.dir}/Contents/PlugIns/Java.runtime">
<fileset dir="${dist.dir}/Java.runtime" includes="**"/>
</copy>
<copy todir="${bundle.dir}/Contents/Frameworks">
<fileset dir="${dist.dir}/libs" includes="**"/>
</copy>
<copy todir="${bundle.dir}">
<fileset dir="${bundle.dir}" includes="**"/>
</copy>
<!-- set payload files executable -->
<chmod perm="a+x" type="file">
<fileset dir="${bundle.dir}">
<include name="**/${project.name}"/>
<include name="**/Resources/uninstall"/>
<include name="**/bin/*"/>
<include name="**/lib/jspawnhelper"/>
</fileset>
</chmod>
<copy file="ant/apple/apple-entitlements.plist.in" tofile="${build.dir}/apple-entitlements.plist">
<filterchain><expandproperties/></filterchain>
</copy>
<!-- use xargs to loop over and codesign all files-->
<echo level="info" message="Signing ${bundle.dir} using ${codesign.activeid}"/>
<!-- Find -X fails on spaces but doesn't failonerror, this may lead to overlooked errors. -->
<!-- Currently the only file that may contains a space is the main executable which we omit from signing anyway. -->
<exec executable="bash" failonerror="true" dir="${bundle.dir}">
<arg value="-c"/>
<arg value="find -X &quot;.&quot; -type f -not -path &quot;*/Contents/MacOS/*&quot; -exec sh -c 'file -I &quot;{}&quot; |grep -m1 &quot;x-mach-binary&quot;|cut -f 1 -d \:' \; |xargs codesign --force -s &quot;${codesign.activeid}&quot; --timestamp --options runtime"/>
</exec>
<exec executable="codesign" failonerror="true">
<arg value="--force"/>
<arg value="-s"/>
<arg value="${codesign.activeid}"/>
<arg value="--timestamp"/>
<arg value="--options"/>
<arg value="runtime"/>
<arg value="--entitlement"/>
<arg value="${build.dir}/apple-entitlements.plist"/>
<arg value="${bundle.dir}/Contents/PlugIns/Java.runtime/Contents/Home/bin/java"/>
<arg value="${bundle.dir}/Contents/PlugIns/Java.runtime/Contents/Home/bin/jcmd"/>
<arg value="${bundle.dir}/Contents/PlugIns/Java.runtime"/>
</exec>
<exec executable="codesign" failonerror="true">
<arg value="-s"/>
<arg value="${codesign.activeid}"/>
<arg value="--timestamp"/>
<arg value="--options"/>
<arg value="runtime"/>
<arg value="--entitlement"/>
<arg value="${build.dir}/apple-entitlements.plist"/>
<arg value="${bundle.dir}"/>
</exec>
<!-- Verify Java.runtime -->
<antcall target="verify-signature">
<param name="signed.bundle.name" value="Java.runtime"/>
<param name="signed.bundle.dir" value="${bundle.dir}/Contents/PlugIns/Java.runtime"/>
</antcall>
<!-- Verify QZ Tray.app -->
<antcall target="verify-signature" >
<param name="signed.bundle.name" value="${project.name}.app"/>
<param name="signed.bundle.dir" value="${bundle.dir}"/>
</antcall>
</target>
<target name="add-certificates" depends="get-identity">
<!-- Remove expired certificates -->
<exec executable="security">
<arg value="delete-certificate"/>
<arg value="-Z"/>
<arg value="A69020D49B47383064ADD5779911822850235953"/>
</exec>
<exec executable="security">
<arg value="delete-certificate"/>
<arg value="-Z"/>
<arg value="6FD7892971854384AF40FAD1E0E6C56A992BC5EE"/>
</exec>
<exec executable="security">
<arg value="delete-certificate"/>
<arg value="-Z"/>
<arg value="F7F10838412D9187042EE1EB018794094AFA189A"/>
</exec>
<exec executable="security">
<arg value="add-certificates"/>
<arg value="${basedir}/ant/apple/certs/apple-packager.cer"/>
<arg value="${basedir}/ant/apple/certs/apple-intermediate.cer"/>
<arg value="${basedir}/ant/apple/certs/apple-codesign.cer"/>
</exec>
</target>
<target name="copy-dylibs" if="target.os.mac">
<echo level="info">Copying native library files to libs</echo>
<mkdir dir="${dist.dir}/libs"/>
<copy todir="${dist.dir}/libs" flatten="true" verbose="true">
<fileset dir="${out.dir}/libs-temp">
<!--x86_64-->
<include name="**/darwin-x86-64/*" if="target.arch.x86_64"/> <!-- jna/hid4java -->
<include name="**/osx-x86_64/*" if="target.arch.x86_64"/> <!-- usb4java -->
<include name="**/osx_64/*" if="target.arch.x86_64"/> <!-- jssc -->
<!--aarch64-->
<include name="**/darwin-aarch64/*" if="target.arch.aarch64"/> <!-- jna/hid4java -->
<include name="**/osx-aarch64/*" if="target.arch.aarch64"/> <!-- usb4java -->
<include name="**/osx_arm64/*" if="target.arch.aarch64"/> <!-- jssc -->
</fileset>
</copy>
</target>
<target name="get-identity">
<property file="ant/apple/apple.properties"/>
<!-- Ensure ${apple.packager.signid} is in Keychain -->
<exec executable="bash" failonerror="false" resultproperty="codesign.qz">
<arg value="-c"/>
<arg value="security find-identity -v |grep '(${apple.packager.signid})'"/>
</exec>
<!-- Fallback to "-" (ad-hoc) if ${apple.packager.signid} isn't found -->
<condition property="codesign.activeid" value="${apple.packager.signid}" else="-">
<equals arg1="${codesign.qz}" arg2="0"/>
</condition>
<!-- Fallback to "-" (ad-hoc) if ${apple.packager.signid} isn't found -->
<condition property="codesign.available">
<equals arg1="${codesign.qz}" arg2="0"/>
</condition>
<!-- Property to show warning later -->
<condition property="codesign.selfsign">
<equals arg1="${codesign.activeid}" arg2="-"/>
</condition>
</target>
<target name="verify-signature">
<echo level="info">Verifying ${signed.bundle.name} Signature</echo>
<echo level="info">Location: ${signed.bundle.dir}</echo>
<exec executable="codesign" failifexecutionfails="false" resultproperty="signing.status">
<arg value="-v"/>
<arg value="--strict"/>
<arg value="${signed.bundle.dir}"/>
</exec>
<condition property="message.severity" value="info" else="warn">
<equals arg1="${signing.status}" arg2="0"/>
</condition>
<condition property="message.description"
value="Signing passed: Successfully signed"
else="Signing failed:: Signing failed (will prevent app from launching)">
<equals arg1="${signing.status}" arg2="0"/>
</condition>
<echo level="${message.severity}">${message.description}</echo>
</target>
<!-- Stub title/separator workaround for build-pkg/build-dmg -->
<target name="packaging"/>
</project>

Binary file not shown.

Binary file not shown.

View File

@@ -0,0 +1,10 @@
<?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">
<dict>
<key>arch</key>
<array>
<string>${apple.target.arch}</string>
</array>
</dict>
</plist>

221
old code/tray/ant/javafx.xml Executable file
View File

@@ -0,0 +1,221 @@
<project name="javafx" default="download-javafx" basedir="..">
<property file="ant/project.properties"/>
<import file="${basedir}/ant/platform-detect.xml"/>
<import file="${basedir}/ant/version.xml"/>
<!-- TODO: Short-circuit download if host and target are identical? -->
<target name="download-javafx" depends="download-javafx-host,download-javafx-target"/>
<target name="download-javafx-host" unless="${host.fx.exists}" depends="get-javafx-versions,host-fx-exists">
<antcall target="download-extract-javafx">
<param name="fx.os" value="${host.os}"/>
<param name="fx.arch" value="${host.arch}"/>
<param name="fx.id" value="${host.fx.id}"/>
<param name="fx.basedir" value="${host.fx.basedir}"/>
<param name="fx.dir" value="${host.fx.dir}"/>
<param name="fx.ver" value="${host.fx.ver}"/>
<param name="fx.majver" value="${host.fx.majver}"/>
<param name="fx.urlver" value="${host.fx.urlver}"/>
</antcall>
</target>
<target name="download-javafx-target" unless="${target.fx.exists}" depends="get-javafx-versions,target-fx-exists">
<antcall target="download-extract-javafx">
<param name="fx.os" value="${target.os}"/>
<param name="fx.arch" value="${target.arch}"/>
<param name="fx.id" value="${target.fx.id}"/>
<param name="fx.basedir" value="${target.fx.basedir}"/>
<param name="fx.dir" value="${target.fx.dir}"/>
<param name="fx.majver" value="${target.fx.majver}"/>
<param name="fx.urlver" value="${target.fx.urlver}"/>
</antcall>
</target>
<target name="host-fx-exists" depends="platform-detect">
<!-- Host fx is saved to lib/ -->
<property name="host.fx.basedir" value="${basedir}/lib"/>
<property name="host.fx.id" value="javafx-${host.os}-${host.arch}-${host.fx.urlver}"/>
<property name="host.fx.dir" value="${host.fx.basedir}/${host.fx.id}"/>
<mkdir dir="${host.fx.dir}"/>
<!-- File to look for: "glass.dll", "libglass.dylib" or "libglass.so" -->
<property name="host.libglass" value="${host.libprefix}glass.${host.libext}"/>
<!-- Grab the first file match -->
<first id="host.fx.files">
<fileset dir="${host.fx.dir}">
<include name="**/${host.libglass}"/>
</fileset>
</first>
<!-- Convert the file to a usable string -->
<pathconvert property="host.fx.path" refid="host.fx.files"/>
<!-- Set our flag if found -->
<condition property="host.fx.exists">
<not><equals arg1="${host.fx.path}" arg2=""/></not>
</condition>
<!-- Human readable message -->
<condition property="host.fx.message"
value="JavaFX host platform file ${host.libglass} found, skipping download.${line.separator}Location: ${host.fx.path}"
else="JavaFX host platform file ${host.libglass} is missing, will download.${line.separator}Searched: ${host.fx.dir}">
<isset property="host.fx.exists"/>
</condition>
<echo level="info">${host.fx.message}</echo>
</target>
<target name="target-fx-exists">
<!-- Target fx is saved to out/ -->
<property name="target.fx.basedir" value="${out.dir}"/>
<property name="target.fx.id" value="javafx-${target.os}-${target.arch}-${target.fx.urlver}"/>
<property name="target.fx.dir" value="${target.fx.basedir}/${target.fx.id}"/>
<mkdir dir="${target.fx.dir}"/>
<!-- File to look for: "glass.dll", "libglass.dylib" or "libglass.so" -->
<property name="target.libglass" value="${target.libprefix}glass.${target.libext}"/>
<!-- Grab the first file match -->
<first id="target.fx.files">
<fileset dir="${target.fx.dir}">
<!-- look for "glass.dll", "libglass.dylib" or "libglass.so" -->
<include name="**/${target.libglass}"/>
</fileset>
</first>
<!-- Convert the file to a usable string -->
<pathconvert property="target.fx.path" refid="target.fx.files"/>
<!-- Set our flag if found -->
<condition property="target.fx.exists">
<not><equals arg1="${target.fx.path}" arg2=""/></not>
</condition>
<!-- Human readable message -->
<condition property="target.fx.message"
value="JavaFX target platform file ${target.libglass} found, skipping download.${line.separator}Location: ${target.fx.path}"
else="JavaFX target platform file ${target.libglass} is missing, will download.${line.separator}Searched: ${target.fx.dir}">
<isset property="target.fx.exists"/>
</condition>
<echo level="info">${target.fx.message}</echo>
</target>
<!--
Populates: host.fx.ver, host.fx.urlver, target.fx.ver, target.fx.urlver
- Converts version to a usable URL format
- Leverage older releases for Intel builds until upstream bug report SUPQZ-14 is fixed
To build: We need javafx to download a javafx which matches "host.os" and "host.arch"
To package: We need javafx to download a javafx which matches "target.os" and "target.arch"
-->
<target name="get-javafx-versions" depends="platform-detect">
<!-- Fallback to sane values -->
<property name="host.fx.ver" value="${javafx.version}"/>
<property name="target.fx.ver" value="${javafx.version}"/>
<!-- Handle pesky url "." = "-" differences -->
<loadresource property="host.fx.urlver">
<propertyresource name="host.fx.ver"/>
<filterchain>
<tokenfilter>
<filetokenizer/>
<replacestring from="." to="-"/>
</tokenfilter>
</filterchain>
</loadresource>
<loadresource property="target.fx.urlver">
<propertyresource name="target.fx.ver"/>
<filterchain>
<tokenfilter>
<filetokenizer/>
<replacestring from="." to="-"/>
</tokenfilter>
</filterchain>
</loadresource>
<property description="suppress property warning" name="target.fx.urlver" value="something went wrong"/>
<property description="suppress property warning" name="host.fx.urlver" value="something went wrong"/>
<!-- Calculate our javafx "major" version -->
<loadresource property="host.fx.majver">
<propertyresource name="host.fx.ver"/>
<filterchain>
<replaceregex pattern="[-_.].*" replace="" />
</filterchain>
</loadresource>
<loadresource property="target.fx.majver">
<propertyresource name="target.fx.ver"/>
<filterchain>
<replaceregex pattern="[-_.].*" replace="" />
</filterchain>
</loadresource>
<property description="suppress property warning" name="target.fx.majver" value="something went wrong"/>
<property description="suppress property warning" name="host.fx.majver" value="something went wrong"/>
<echo level="info">
JavaFX host platform:
Version: ${host.fx.ver} (${host.os}, ${host.arch})
Major Version: ${host.fx.majver}
URLs: &quot;${host.fx.urlver}&quot;
JavaFX target platform:
Version: ${target.fx.ver} (${target.os}, ${target.arch})
Major Version: ${target.fx.majver}
URLs: "&quot;${target.fx.urlver}&quot;
</echo>
</target>
<!-- Downloads and extracts javafx for the specified platform -->
<target name="download-extract-javafx">
<!-- Cleanup old versions -->
<delete includeemptydirs="true" defaultexcludes="false">
<fileset dir="${fx.basedir}">
<include name="javafx*/"/>
</fileset>
</delete>
<mkdir dir="${fx.dir}"/>
<!-- Valid os values: "windows", "linux", "osx" -->
<!-- translate "mac" to "osx" -->
<condition property="fx.os.fixed" value="osx" else="${fx.os}">
<equals arg1="${fx.os}" arg2="mac"/>
</condition>
<!-- Valid arch values: "x64", "aarch64", "x86" -->
<!-- translate "x86_64" to "x64" -->
<condition property="fx.arch.fixed" value="x64">
<or>
<equals arg1="${fx.arch}" arg2="x86_64"/>
<and>
<!-- TODO: Remove "aarch64" to "x64" when windows aarch64 binaries become available -->
<equals arg1="${fx.arch}" arg2="aarch64"/>
<equals arg1="${fx.os}" arg2="windows"/>
</and>
<and>
<!-- TODO: Remove "riscv" to "x64" when linux riscv64 binaries become available -->
<equals arg1="${fx.arch}" arg2="riscv64"/>
<equals arg1="${fx.os}" arg2="linux"/>
</and>
</or>
</condition>
<property name="fx.arch.fixed" value="${fx.arch}" description="fallback value"/>
<!-- Fix underscore when "monocle" is missing -->
<condition property="fx.url" value="${javafx.mirror}/${fx.majver}/openjfx-${fx.urlver}_${fx.os.fixed}-${fx.arch.fixed}_bin-sdk.zip">
<not>
<contains string="${fx.urlver}" substring="monocle"/>
</not>
</condition>
<property name="fx.url" value="${javafx.mirror}/${fx.majver}/openjfx-${fx.urlver}-${fx.os.fixed}-${fx.arch.fixed}_bin-sdk.zip"/>
<property name="fx.zip" value="${out.dir}/${fx.id}.zip"/>
<echo level="info">Downloading JavaFX from ${fx.url}</echo>
<echo level="info">Temporarily saving JavaFX to ${fx.zip}</echo>
<mkdir dir="${out.dir}"/>
<get src="${fx.url}" verbose="true" dest="${fx.zip}"/>
<unzip src="${fx.zip}" dest="${fx.dir}" overwrite="true"/>
<delete file="${fx.zip}"/>
</target>
</project>

Binary file not shown.

109
old code/tray/ant/lib/slim-icu.py Executable file
View File

@@ -0,0 +1,109 @@
# 2018 Yohanes Nugroho <yohanes@gmail.com> (@yohanes)
#
# 1. Download icu4j source code, build using ant.
# It will generate icu4j.jar and icu4j-charset.jar
#
# 2. Run slim-icu.py to generate slim version.
#
# To invoke from ant, add python to $PATH
# and add the following to build.xml:
#
# <target name="distill-icu" depends="init">
# <exec executable="python">
# <arg line="ant/lib/slim-icu.py lib/charsets"/>
# </exec>
# </target>
#
# ... then call: ant distill-icu
#
# 3. Overwrite files in lib/charsets/
# slim ICU
import sys
import os
from pathlib import Path
import zipfile
from zipfile import ZipFile
directory = str(Path(__file__).resolve().parent)
if len(sys.argv) > 1:
directory = sys.argv[1]
mode = zipfile.ZIP_DEFLATED
def keep_file(filename):
# skip all break iterators
if filename.endswith(".brk") \
or filename.endswith(".dict") \
or filename.endswith("unames.icu") \
or filename.endswith("ucadata.icu") \
or filename.endswith(".spp"):
return False
# keep english and arabic
if filename.startswith("en") \
or filename.startswith("ar") \
or not filename.endswith(".res"):
return True
return False
zin = ZipFile(os.path.join(directory, 'icu4j.jar'), 'r')
zout = ZipFile(os.path.join(directory, 'icu4j-slim.jar'), 'w', mode)
for item in zin.infolist():
buff = zin.read(item.filename)
print(item.filename)
if keep_file(item.filename):
print("Keep")
zout.writestr(item, buff)
else:
print("Remove")
zout.close()
zin.close()
def keep_charset_file(filename):
to_remove = [
"cns-11643-1992.cnv",
"ebcdic-xml-us.cnv",
"euc-jp-2007.cnv",
"euc-tw-2014.cnv",
"gb18030.cnv",
"ibm-1363_P11B-1998.cnv",
"ibm-1364_P110-2007.cnv",
"ibm-1371_P100-1999.cnv",
"ibm-1373_P100-2002.cnv",
"ibm-1375_P100-2008.cnv",
"ibm-1383_P110-1999.cnv",
"ibm-1386_P100-2001.cnv",
"ibm-1388_P103-2001.cnv",
"ibm-1390_P110-2003.cnv"
]
for i in to_remove:
if i in filename:
return False
return True
zin = ZipFile(os.path.join(directory, 'icu4j-charset.jar'), 'r')
zout = ZipFile(os.path.join(directory, 'icu4j-charset-slim.jar'), 'w', mode)
for item in zin.infolist():
buff = zin.read(item.filename)
print(item.filename, end=' ')
if keep_charset_file(item.filename):
print("Keep")
zout.writestr(item, buff)
else:
print("Remove")
zout.close()
zin.close()

View File

@@ -0,0 +1,69 @@
<project name="linux-installer" basedir="../../">
<property file="ant/project.properties"/>
<property file="ant/linux/linux.properties"/>
<import file="${basedir}/ant/version.xml"/>
<import file="${basedir}/ant/platform-detect.xml"/>
<target name="build-run" depends="get-version,platform-detect">
<echo level="info">Creating installer using makeself</echo>
<!-- Get the os-preferred name for the target architecture -->
<condition property="linux.target.arch" value="arm64">
<isset property="target.arch.aarch64"/>
</condition>
<property name="linux.target.arch" value="${target.arch}" description="fallback value"/>
<copy file="assets/branding/linux-icon.svg" tofile="${dist.dir}/${project.filename}.svg"/>
<mkdir dir="${build.dir}/scripts"/>
<copy file="ant/linux/linux-installer.sh.in" tofile="${dist.dir}/install">
<filterchain><expandproperties/></filterchain>
</copy>
<copy file="ant/unix/unix-launcher.sh.in" tofile="${dist.dir}/${project.filename}">
<filterchain><expandproperties/></filterchain>
</copy>
<copy file="ant/unix/unix-uninstall.sh.in" tofile="${dist.dir}/uninstall">
<filterchain><expandproperties/></filterchain>
</copy>
<chmod perm="a+x" type="file">
<fileset dir="${dist.dir}">
<include name="**/${project.filename}"/>
<include name="**/install"/>
<include name="**/uninstall"/>
</fileset>
</chmod>
<exec executable="makeself" failonerror="true">
<arg value="${dist.dir}"/>
<arg value="${out.dir}/${project.filename}${build.type}-${build.version}-${linux.target.arch}.run"/>
<arg value="${project.name} Installer"/>
<arg value="./install"/>
</exec>
</target>
<target name="copy-solibs" if="target.os.linux">
<echo level="info">Copying native library files to libs</echo>
<mkdir dir="${dist.dir}/libs"/>
<copy todir="${dist.dir}/libs" flatten="true" verbose="true">
<fileset dir="${out.dir}/libs-temp">
<!--x86_64-->
<include name="**/linux-x86-64/*" if="target.arch.x86_64"/> <!-- jna/hid4java -->
<include name="**/linux-x86_64/*" if="target.arch.x86_64"/> <!-- usb4java -->
<include name="**/linux_64/*" if="target.arch.x86_64"/> <!-- jssc -->
<!--aarch64-->
<include name="**/linux-aarch64/*" if="target.arch.aarch64"/> <!-- jna/hid4java/usb4java -->
<include name="**/linux_arm64/*" if="target.arch.aarch64"/> <!-- jssc -->
<!--arm32-->
<include name="**/linux-arm/*" if="target.arch.arm32"/> <!-- jna/hid4java/usb4java -->
<include name="**/linux_arm/*" if="target.arch.arm32"/> <!-- jssc -->
<!--riscv64-->
<include name="**/linux-riscv64/*" if="target.arch.riscv64"/> <!-- jna/hid4java -->
<include name="**/linux_riscv64/*" if="target.arch.riscv64"/> <!-- jssc -->
</fileset>
</copy>
</target>
</project>

View File

@@ -0,0 +1,68 @@
#!/bin/bash
# Halt on first error
set -e
if [ "$(id -u)" != "0" ]; then
echo "This script must be run with root (sudo) privileges" 1>&2
exit 1
fi
# Console colors
RED="\\x1B[1;31m";GREEN="\\x1B[1;32m";YELLOW="\\x1B[1;33m";PLAIN="\\x1B[0m"
# Statuses
SUCCESS=" [${GREEN}success${PLAIN}]"
FAILURE=" [${RED}failure${PLAIN}]"
WARNING=" [${YELLOW}warning${PLAIN}]"
mask=755
echo -e "Starting install...\n"
# Clear the log for writing
> "${install.log}"
run_task () {
echo -e "Running $1 task..."
if [ -n "$DEBUG" ]; then
"./${project.filename}" $@ && ret_val=$? || ret_val=$?
else
"./${project.filename}" $@ &>> "${install.log}" && ret_val=$? || ret_val=$?
fi
if [ $ret_val -eq 0 ]; then
echo -e " $SUCCESS Task $1 was successful"
else
if [ "$1" == "spawn" ]; then
echo -e " $WARNING Task $1 skipped. You'll have to start ${project.name} manually."
return
fi
echo -e " $FAILURE Task $1 failed.\n\nRe-run with DEBUG=true for more information."
false # throw error
fi
}
# Ensure java is installed and working before starting
"./${project.filename}" --version
# Make a temporary jar for preliminary installation steps
run_task preinstall
run_task install --dest "/opt/${project.filename}"
# We should be installed now, generate the certificate
pushd "/opt/${project.filename}" &> /dev/null
run_task certgen
# Tell the desktop to look for new mimetypes in the background
umask_bak="$(umask)"
umask 0002 # more permissive umask for mimetype registration
update-desktop-database &> /dev/null &
umask "$umask_bak"
echo "Installation complete... Starting ${project.name}..."
# spawn itself as a regular user, inheriting environment
run_task spawn "/opt/${project.filename}/${project.filename}"
popd &> /dev/null

View File

@@ -0,0 +1,2 @@
# Expose UNIXToolkit.getGtkVersion
linux.launch.jigsaw=--add-opens java.desktop/sun.awt=ALL-UNNAMED

View File

@@ -0,0 +1,254 @@
<project name="host-info" default="platform-detect" basedir="..">
<property file="ant/project.properties"/>
<!--
Detects and echos host and target information
String:
- host.os, host.arch, host.libext, host.libprefix
- target.os, target.arch, target.libext, target.libprefix
Booleans:
- host.${host.arch}=true, host.${host.os}=true
- target.${target.arch}=true, target.${target.os}=true
-->
<target name="platform-detect" depends="get-target-os,get-target-arch,get-libext">
<!-- Echo host information -->
<antcall target="echo-platform">
<param name="title" value="Host"/>
<param name="prefix" value="host"/>
<param name="prefix.os" value="${host.os}"/>
<param name="prefix.arch" value="${host.arch}"/>
<param name="prefix.libext" value="${host.libext}"/>
</antcall>
<!-- Echo target information -->
<antcall target="echo-platform">
<param name="title" value="Target"/>
<param name="prefix" value="target"/>
<param name="prefix.os" value="${target.os}"/>
<param name="prefix.arch" value="${target.arch}"/>
<param name="prefix.libext" value="${target.libext}"/>
</antcall>
</target>
<target name="echo-platform">
<!-- Make output more readable -->
<!-- Boolean platform.os.foo value -->
<condition property="os.echo" value="${prefix}.os.windows">
<isset property="${prefix}.os.windows"/>
</condition>
<condition property="os.echo" value="${prefix}.os.mac">
<isset property="${prefix}.os.mac"/>
</condition>
<property name="os.echo" value="${prefix}.os.linux" description="fallback value"/>
<!-- Boolean target.arch.foo value -->
<condition property="arch.echo" value="${prefix}.arch.aarch64">
<isset property="${prefix}.arch.aarch64"/>
</condition>
<property name="arch.echo" value="${prefix}.arch.x86_64" description="fallback value"/>
<echo level="info">
${title} platform:
${prefix}.os: &quot;${prefix.os}&quot;
${prefix}.arch: &quot;${prefix.arch}&quot;
${prefix}.libext: &quot;${prefix.libext}&quot;
${os.echo}: true
${arch.echo}: true
</echo>
</target>
<!-- Force Linux runtime. Set by "makeself" target -->
<target name="target-os-linux">
<!-- String value -->
<property name="target.os" value ="linux"/>
<!-- Boolean value -->
<property name="target.os.linux" value="true"/>
</target>
<!-- Force Linux runtime. Set by "nsis" target -->
<target name="target-os-windows">
<!-- String value -->
<property name="target.os" value ="windows"/>
<!-- Boolean value -->
<property name="target.os.windows" value="true"/>
</target>
<!-- Force Linux runtime. Set by "pkgbuild", "dmg" targets -->
<target name="target-os-mac">
<!-- String value -->
<property name="target.os" value ="mac"/>
<!-- Boolean value -->
<property name="target.os.mac" value="true"/>
</target>
<target name="get-target-os" depends="get-host-os">
<!-- Suppress property warning :) -->
<condition description="suppress property warning (no-op)"
property="target.os" value="${target.os}">
<isset property="target.os"/>
</condition>
<!-- Set Boolean if only the String was set -->
<condition property="target.os.windows">
<and>
<isset property="target.os"/>
<equals arg1="${target.os}" arg2="windows"/>
</and>
</condition>
<condition property="target.os.mac">
<and>
<isset property="target.os"/>
<equals arg1="${target.os}" arg2="mac"/>
</and>
</condition>
<condition property="target.os.linux">
<and>
<isset property="target.os"/>
<equals arg1="${target.os}" arg2="linux"/>
</and>
</condition>
<!-- Fallback to host boolean values if target values aren't specified -->
<property name="target.os" value="${host.os}" description="fallback value"/>
<condition property="target.os.windows" description="fallback value">
<equals arg1="${target.os}" arg2="windows"/>
</condition>
<condition property="target.os.mac" description="fallback value">
<equals arg1="${target.os}" arg2="mac"/>
</condition>
<condition property="target.os.linux" description="fallback value">
<equals arg1="${target.os}" arg2="linux"/>
</condition>
</target>
<!-- Calculate target architecture based on ${target.arch} value -->
<target name="get-target-arch" depends="get-host-arch">
<!-- Fallback to ${host.arch} if not specified -->
<property name="target.arch" value="${host.arch}" description="fallback value"/>
<condition property="target.arch.x86_64">
<equals arg1="amd64" arg2="${target.arch}"/>
</condition>
<condition property="target.arch.x86_64">
<equals arg1="x86_64" arg2="${target.arch}"/>
</condition>
<condition property="target.arch.aarch64">
<equals arg1="aarch64" arg2="${target.arch}"/>
</condition>
<condition property="target.arch.riscv64">
<equals arg1="riscv64" arg2="${target.arch}"/>
</condition>
<!-- Warning: Placeholder only! 32-bit builds are not supported -->
<condition property="target.arch.arm32">
<equals arg1="arm32" arg2="${target.arch}"/>
</condition>
<condition property="target.arch.x86">
<equals arg1="x86" arg2="${target.arch}"/>
</condition>
</target>
<!-- Calculate native file extension -->
<target name="get-libext" depends="get-host-os">
<!-- Some constants -->
<property name="windows.libext" value="dll"/>
<property name="mac.libext" value="dylib"/>
<property name="linux.libext" value="so"/>
<!-- Host uses "dll" -->
<condition property="host.libext" value="${windows.libext}">
<isset property="host.os.windows"/>
</condition>
<!-- Host uses "dylib" -->
<condition property="host.libext" value="${mac.libext}">
<isset property="host.os.mac"/>
</condition>
<!-- Host uses "so" -->
<condition property="host.libext" value="${linux.libext}">
<isset property="host.os.linux"/>
</condition>
<!-- Target uses "dll" -->
<condition property="target.libext" value="${windows.libext}">
<isset property="target.os.windows"/>
</condition>
<!-- Target uses "dylib" -->
<condition property="target.libext" value="${mac.libext}">
<isset property="target.os.mac"/>
</condition>
<!-- Target uses "so" -->
<condition property="target.libext" value="${linux.libext}">
<isset property="target.os.linux"/>
</condition>
<!-- Target uses "" or "lib" prefix for native files -->
<condition property="host.libprefix" value="" else="lib">
<isset property="host.os.windows"/>
</condition>
<!-- Host uses "" or "lib" prefix for native files -->
<condition property="target.libprefix" value="" else="lib">
<isset property="target.os.windows"/>
</condition>
</target>
<!-- Calculate and standardize host architecture based on ${os.arch} value -->
<target name="get-host-arch">
<!-- Boolean value (x86_64) -->
<condition property="host.arch.x86_64">
<equals arg1="amd64" arg2="${os.arch}"/>
</condition>
<condition property="host.arch.x86_64">
<equals arg1="x86_64" arg2="${os.arch}"/>
</condition>
<!-- Boolean value (aarch64) -->
<condition property="host.arch.aarch64">
<equals arg1="aarch64" arg2="${os.arch}"/>
</condition>
<!-- Boolean value (x86 - unsupported) -->
<condition property="host.arch.x86">
<equals arg1="x86" arg2="${os.arch}"/>
</condition>
<!-- String value (aarch64) -->
<condition property="host.arch" value="aarch64">
<equals arg1="aarch64" arg2="${os.arch}"/>
</condition>
<!-- String value (x86) -->
<condition property="host.arch" value="x86">
<equals arg1="x86" arg2="${os.arch}"/>
</condition>
<condition property="host.arch" value="x86">
<equals arg1="i386" arg2="${os.arch}"/>
</condition>
<!-- String value (x86_64 - fallback, most common) -->
<property name="host.arch" value="x86_64" description="fallback value"/>
</target>
<!-- Calculate the host os -->
<target name="get-host-os">
<!-- Boolean value -->
<condition property="host.os.windows" value="true">
<os family="windows"/>
</condition>
<condition property="host.os.mac" value="true">
<os family="mac"/>
</condition>
<condition property="host.os.linux" value="true">
<and>
<os family="unix"/>
<not>
<os family="mac"/>
</not>
</and>
</condition>
<!-- String value -->
<condition property="host.os" value="windows">
<os family="windows"/>
</condition>
<condition property="host.os" value="mac">
<os family="mac"/>
</condition>
<property name="host.os" value="linux" description="fallback value"/>
</target>
</project>

View File

@@ -0,0 +1,5 @@
signing.alias=self-signed
signing.keystore=ant/private/qz.ks
signing.keypass=jzebraonfire
signing.storepass=jzebraonfire
signing.algorithm=SHA-256

View File

@@ -0,0 +1,62 @@
vendor.name=qz
vendor.company=QZ Industries, LLC
vendor.website=https://qz.io
vendor.email=support@qz.io
project.name=QZ Tray
project.filename=qz-tray
project.datadir=qz
install.opts=-Djna.nosys=true
launch.opts=-Xms512m ${install.opts}
install.log=/tmp/${project.datadir}-install.log
# jdk9+ flags
# - Dark theme requires workaround https://github.com/bobbylight/Darcula/issues/8
launch.jigsaw=--add-exports java.desktop/sun.swing=ALL-UNNAMED
launch.overrides=QZ_OPTS
src.dir=${basedir}/src
out.dir=${basedir}/out
build.dir=${out.dir}/build
dist.dir=${out.dir}/dist
sign.lib.dir=${out.dir}/jar-signed
jar.compress=true
jar.index=true
# Separate native lib resources from jars
separate.static.libs=true
# See also qz.common.Constants.java
javac.source=11
javac.target=11
java.download=https://bell-sw.com/pages/downloads/#/java-11-lts
# Java vendor to bundle into software (e.g. "*BellSoft|Adoptium|Microsoft|Amazon|IBM")
jlink.java.vendor="BellSoft"
# Java vendor to bundle into software (e.g. "11.0.17+7")
jlink.java.version="11.0.27+9"
# Java garbage collector flavor to use (e.g. "hotspot|openj9")
jlink.java.gc="hotspot"
# Java garbage collector version to use (e.g. openj9: "0.35.0", zulu: "11.62.17")
jlink.java.gc.version="gc-ver-is-empty"
# Bundle a locally built copy of Java instead
jlink.java.target=/home/ske087/quality_recticel/jdk-11.0.20-full
# Skip bundling the java runtime
jre.skip=false
# JavaFX version
javafx.version=19_monocle
javafx.mirror=https://download2.gluonhq.com/openjfx
# Provisioning
# provision.file=${basedir}/provision.json
provision.dir=${dist.dir}/provision
# Mask tray toggle (Apple only)
java.mask.tray=true
# Workaround to delay expansion of $${foo} (e.g. shell scripts)
dollar=$

196
old code/tray/ant/signing.xml Executable file
View File

@@ -0,0 +1,196 @@
<project name="signing-helpers" basedir="../">
<property file="ant/project.properties"/>
<!-- Custom code-signing properties -->
<property file="${basedir}/../private/private.properties"/>
<!-- Fallback code-signing properties -->
<property file="ant/private/private.properties"/>
<!-- Locate first jsign-x.x.x.jar sorted name desc -->
<target name="find-jsign">
<sort id="jsign.sorted">
<fileset dir="${basedir}/ant/lib/">
<include name="jsign*.jar"/>
</fileset>
<reverse xmlns="antlib:org.apache.tools.ant.types.resources.comparators"/>
</sort>
<first id="jsign.first">
<resources refid="jsign.sorted"/>
</first>
<pathconvert property="jsign.path" refid="jsign.first">
<identitymapper/>
</pathconvert>
<echo message="Found jsign: ${jsign.path}"/>
</target>
<!-- File signing -->
<target name="sign-file">
<!-- Self-sign -->
<antcall target="sign-file-self">
<param name="sign.file" value="${sign.file}"/>
</antcall>
<!-- EV-sign using HSM -->
<antcall target="sign-file-hsm">
<param name="sign.file" value="${sign.file}"/>
</antcall>
</target>
<!-- Jar signing -->
<target name="sign-jar">
<!-- Self-sign -->
<antcall target="sign-jar-self">
<param name="sign.file" value="${sign.file}"/>
</antcall>
<!-- EV-sign using HSM -->
<antcall target="sign-jar-hsm">
<param name="sign.file" value="${sign.file}"/>
</antcall>
</target>
<!-- File signing via hsm with timestamp -->
<target name="sign-file-hsm" if="hsm.storetype" depends="find-jsign">
<echo level="info">Signing with hsm: ${hsm.keystore}</echo>
<java jar="${jsign.path}" fork="true" failonerror="true">
<arg value="--name"/>
<arg value="${project.name}"/>
<arg value="--url"/>
<arg value="${vendor.website}"/>
<arg value="--replace"/>
<arg value="--alg"/>
<arg value="${hsm.algorithm}"/>
<arg value="--storetype"/>
<arg value="${hsm.storetype}"/>
<arg value="--keystore"/>
<arg value="${hsm.keystore}"/>
<arg value="--alias"/>
<arg value="${hsm.alias}"/>
<arg value="--storepass"/>
<arg value="${hsm.storepass}"/>
<arg value="--tsaurl"/>
<arg value="${hsm.tsaurl}"/>
<arg value="--certfile"/>
<arg value="${hsm.certfile}"/>
<arg line="${sign.file}"/>
</java>
</target>
<!-- Jar signing via hsm with timestamp -->
<target name="sign-jar-hsm" if="hsm.storetype" depends="find-jsign,get-jar-alg">
<signjar providerclass="net.jsign.jca.JsignJcaProvider"
providerarg="${hsm.keystore}"
alias="${hsm.alias}"
storepass="${hsm.storepass}"
storetype="${hsm.storetype}"
keystore="NONE"
sigalg="${jar.sigalg}"
digestalg="${jar.digestalg}"
tsaurl="${hsm.tsaurl}"
jar="${sign.file}"
signedjar="${sign.file}">
<!-- special args needed by jsign -->
<arg value="-J-cp"/><arg value="-J${jsign.path}"/>
<arg value="-J--add-modules"/><arg value="-Jjava.sql"/>
<arg value="-certchain"/><arg file="${hsm.certfile}"/>
</signjar>
</target>
<!-- File signing via arbitrary key without timestamp -->
<target name="sign-file-self" unless="hsm.storetype" depends="find-jsign,find-keystore-self">
<echo level="info">Signing without timestamp:</echo>
<tsa-warning/>
<java jar="${jsign.path}" fork="true" failonerror="true">
<arg value="--name"/>
<arg value="${project.name}"/>
<arg value="--url"/>
<arg value="${vendor.website}"/>
<arg value="--replace"/>
<arg value="--alg"/>
<arg value="${signing.algorithm}"/>
<arg value="--keystore"/>
<arg value="${signing.keystore}"/>
<arg value="--alias"/>
<arg value="${signing.alias}"/>
<arg value="--storepass"/>
<arg value="${signing.storepass}"/>
<arg value="--keypass"/>
<arg value="${signing.keypass}"/>
<arg line="${sign.file}"/>
</java>
</target>
<!-- Jar signing via arbitrary key without timestamp -->
<target name="sign-jar-self" unless="hsm.storetype" depends="find-jsign,find-keystore-self,get-jar-alg">
<signjar alias="${signing.alias}"
storepass="${signing.storepass}"
keystore="${signing.keystore}"
keypass="${signing.keypass}"
sigalg="${jar.sigalg}"
digestalg="${jar.digestalg}"
jar="${sign.file}"
signedjar="${sign.file}"
/>
</target>
<!-- Maps jsign algorithm to jarsigner algorithm -->
<target name="get-jar-alg">
<!-- Populate from hsm.algorithm or signing.algorithm -->
<condition property="jar.algorithm" value="${hsm.algorithm}">
<isset property="${hsm.algorithm}"/>
</condition>
<property name="jar.algorithm" value="${signing.algorithm}" description="fallback value"/>
<!-- Convert "SHA-256" to "SHA256", etc -->
<loadresource property="convert.algorithm">
<propertyresource name="jar.algorithm"/>
<filterchain>
<tokenfilter>
<filetokenizer/>
<replacestring from="-" to=""/>
</tokenfilter>
</filterchain>
</loadresource>
<property name="convert.algorithm" value="something went wrong" description="fallback value"/>
<!-- e.g. "SHA256withRSA" -->
<property description="Signature Algorithm" name="jar.sigalg" value="${convert.algorithm}withRSA"/>
<!-- e.g. "SHA256" -->
<property description="Digest Algorithm" name="jar.digestalg" value="${convert.algorithm}"/>
</target>
<target name="find-keystore-self">
<available file="${signing.keystore}" property="keystore.exists"/>
<antcall target="generate-keystore-self"/>
</target>
<target name="generate-keystore-self" unless="keystore.exists">
<genkey
alias="${signing.alias}"
keyalg="RSA"
keysize="2048"
keystore="${signing.keystore}"
storepass="${signing.storepass}"
validity="3650"
verbose="true">
<dname>
<param name="CN" value="${vendor.company} (self-signed)"/>
<param name="OU" value="${project.name}"/>
<param name="O" value="${vendor.website}"/>
<param name="C" value="US"/>
</dname>
</genkey>
</target>
<macrodef name="tsa-warning">
<sequential>
<echo level="warn">
No tsaurl was provided so the file was not timestamped. Users will not be able to validate
this file after the signer certificate's expiration date or after any future revocation date.
</echo>
</sequential>
</macrodef>
</project>

View File

@@ -0,0 +1,138 @@
#!/usr/bin/env bash
# Shared launcher for MacOS and Linux
# Parameters -- if any -- are passed on to the app
# Halt on first error
set -e
# Configured by ant at build time
JAVA_MIN="${javac.target}"
LAUNCH_OPTS="${launch.opts}"
ABOUT_TITLE="${project.name}"
PROPS_FILE="${project.filename}"
# Get working directory
DIR=$(cd "$(dirname "$0")" && pwd)
pushd "$DIR" &> /dev/null
# Console colors
RED="\\x1B[1;31m";GREEN="\\x1B[1;32m";YELLOW="\\x1B[1;33m";PLAIN="\\x1B[0m"
# Statuses
SUCCESS=" [${GREEN}success${PLAIN}]"
FAILURE=" [${RED}failure${PLAIN}]"
WARNING=" [${YELLOW}warning${PLAIN}]"
MESSAGE=" [${YELLOW}message${PLAIN}]"
echo "Looking for Java..."
# Honor JAVA_HOME
if [ -n "$JAVA_HOME" ]; then
echo -e "$WARNING JAVA_HOME was detected, using $JAVA_HOME..."
PATH="$JAVA_HOME/bin:$PATH"
fi
# Always prefer relative runtime/jre
if [[ "$DIR" == *"/Contents/MacOS"* ]]; then
PATH="$DIR/../PlugIns/Java.runtime/Contents/Home/bin:$PATH"
else
PATH="$DIR/runtime/bin:$DIR/jre/bin:$PATH"
fi
# Check for user overridable launch options
if [ -n "${dollar}${launch.overrides}" ]; then
echo -e "$MESSAGE Picked up additional launch options: ${dollar}${launch.overrides}"
LAUNCH_OPTS="$LAUNCH_OPTS ${dollar}${launch.overrides}"
fi
# Fallback on some known locations
if ! command -v java > /dev/null ; then
if [[ "$OSTYPE" == "darwin"* ]]; then
# Apple: Fallback on system-wide install
DEFAULTS_READ=$(defaults read ${apple.bundleid} ${launch.overrides} 2>/dev/null) || true
if [ -n "$DEFAULTS_READ" ]; then
echo -e "$MESSAGE Picked up additional launch options: $DEFAULTS_READ"
LAUNCH_OPTS="$LAUNCH_OPTS $DEFAULTS_READ"
fi
MAC_PRIMARY="/usr/libexec/java_home"
MAC_FALLBACK="/Library/Internet Plug-Ins/JavaAppletPlugin.plugin/Contents/Home/bin"
echo "Trying $MAC_PRIMARY..."
if "$MAC_PRIMARY" -v $JAVA_MIN+ &>/dev/null; then
echo -e "$SUCCESS Using \"$MAC_PRIMARY -v $JAVA_MIN+ --exec\" to launch $ABOUT_TITLE"
java() {
"$MAC_PRIMARY" -v $JAVA_MIN+ --exec java "$@"
}
elif [ -d "/Library/Internet Plug-Ins/JavaAppletPlugin.plugin/Contents/Home/bin" ]; then
echo -e "$WARNING No luck using $MAC_PRIMARY"
echo "Trying $MAC_FALLBACK..."
java() {
"$MAC_FALLBACK/java" "$@"
}
fi
else
# Linux/Unix: Fallback on known install location(s)
PATH="$PATH:/usr/java/latest/bin/"
fi
fi
if command -v java > /dev/null ; then
echo -e "$SUCCESS Java was found: $(command -v java)"
else
echo -e "$FAILURE Please install Java $JAVA_MIN or higher to continue"
exit 1
fi
# Verify the bundled Java version actually works
if test -f "$DIR/runtime/bin/java" ; then
echo "Verifying the bundled Java version can run on this platform..."
if "$DIR/runtime/bin/java" -version &> /dev/null ; then
echo -e "$SUCCESS Bundled Java version is OK"
else
echo -e "$FAILURE Sorry, this version of $ABOUT_TITLE cannot be installed on this system:\n"
file "$DIR/runtime/bin/java"
exit 1
fi
fi
# Make sure Java version is sufficient
echo "Verifying the Java version is $JAVA_MIN+..."
curver=$(java -version 2>&1 | grep -i version | awk -F"\"" '{ print $2 }' | awk -F"." '{ print $1 "." $2 }')
minver="$JAVA_MIN"
if [ -z "$curver" ]; then
curver="0.0"
fi
desired=$(echo -e "$minver\n$curver")
actual=$(echo "$desired" |sort -t '.' -k 1,1 -k 2,2 -n)
if [ "$desired" != "$actual" ]; then
echo -e "$FAILURE Please install Java $JAVA_MIN or higher to continue"
exit 1
else
echo -e "$SUCCESS Java $curver was detected"
fi
jigsaw=$(echo -e "9.0\n$curver")
actual=$(echo "$jigsaw" |sort -t '.' -k 1,1 -k 2,2 -n)
if [ "$jigsaw" != "$actual" ]; then
echo -e "$SUCCESS Java < 9.0, skipping jigsaw options"
else
echo -e "$SUCCESS Java >= 9.0, adding jigsaw options"
LAUNCH_OPTS="$LAUNCH_OPTS ${launch.jigsaw}"
if [[ "$OSTYPE" == "darwin"* ]]; then
LAUNCH_OPTS="$LAUNCH_OPTS ${apple.launch.jigsaw}"
else
LAUNCH_OPTS="$LAUNCH_OPTS ${linux.launch.jigsaw}"
fi
fi
if command -v java &>/dev/null; then
echo -e "$ABOUT_TITLE is starting..."
if [[ "$OSTYPE" == "darwin"* ]]; then
java $LAUNCH_OPTS -Xdock:name="$ABOUT_TITLE" -Xdock:icon="$DIR/../Resources/$PROPS_FILE.icns" -jar -Dapple.awt.UIElement="true" -Dapple.awt.enableTemplateImages="${java.mask.tray}" -Dapple.awt.application.appearance="system" "$DIR/../Resources/${prefix}$PROPS_FILE.jar" -NSRequiresAquaSystemAppearance False "$@"
else
java $LAUNCH_OPTS -jar "$PROPS_FILE.jar" "$@"
fi
else
echo -e "$FAILURE Java $JAVA_MIN+ was not found"
fi
popd &>/dev/null

View File

@@ -0,0 +1,38 @@
#!/bin/bash
# Halt on first error
set -e
if [ "$(id -u)" != "0" ]; then
echo "This script must be run with root (sudo) privileges" 1>&2
exit 1
fi
# Get working directory
DIR=$(cd "$(dirname "$0")" && pwd)
pushd "$DIR"
echo "Running uninstall tasks..."
if [[ "$OSTYPE" == "darwin"* ]]; then
# Uninstall script is in "QZ Tray.app/Contents/Resources/uninstall"
# Calculate the path to "QZ Tray.app"
APP_DIR=$(cd "$(dirname "$0")/../.." && pwd)
if [[ "$APP_DIR" != *".app" ]]; then
echo -e "\nMalformed app directory. Uninstallation of ${project.name} failed.\n"
exit 1
fi
# Launcher script is in "QZ Tray.app/Contents/MacOS"
"$APP_DIR/Contents/MacOS/${project.name}" uninstall
else
# Uninstall script is in root of app (e.g. "/opt/qz-tray")
APP_DIR="$DIR"
# Launcher script is adjacent to uninstall script
"$APP_DIR/${project.filename}" uninstall
fi
echo "Deleting files..."
rm -rf "$APP_DIR"
echo -e "\nUninstall of ${project.name} complete.\n"
popd &>/dev/null

23
old code/tray/ant/version.xml Executable file
View File

@@ -0,0 +1,23 @@
<project name="version" basedir="../">
<!-- Get version information from JAR -->
<target name="get-version">
<!-- build.version -->
<property file="${basedir}/ant/project.properties"/>
<java jar="${dist.dir}/${project.filename}.jar" fork="true" outputproperty="build.version" errorproperty="build.version.error" timeout="60000" failonerror="true">
<arg value="--version"/>
</java>
<!-- apple.bundleid -->
<java jar="${dist.dir}/${project.filename}.jar" fork="true" outputproperty="apple.bundleid" errorproperty="apple.bundleid.error" timeout="60000" failonerror="true">
<arg value="--bundleid"/>
</java>
<property description="fallback value" name="build.type" value=""/>
<property description="fallback value" name="build.version" value=""/>
<property description="fallback value" name="apple.bundleid" value=""/>
<echo level="info">
Version : ${build.version}${build.type}
Bundle Id : ${apple.bundleid}
</echo>
</target>
</project>

View File

@@ -0,0 +1,110 @@
<project name="windows-installer" basedir="../../">
<property file="ant/project.properties"/>
<import file="${basedir}/ant/version.xml"/>
<import file="${basedir}/ant/platform-detect.xml"/>
<import file="${basedir}/ant/signing.xml"/>
<property environment="env"/>
<target name="build-exe" depends="get-version,platform-detect">
<!-- Get the os-preferred name for the target architecture -->
<condition property="windows.target.arch" value="arm64">
<isset property="target.arch.aarch64"/>
</condition>
<property name="windows.target.arch" value="x86_64" description="fallback value"/>
<!-- Sign Libs and Runtime -->
<fileset dir="${dist.dir}/" id="win.sign.found">
<include name="**/*.dll"/>
<include name="**/*.exe"/>
</fileset>
<!-- Pass all files at once, wrapped in quotes -->
<pathconvert pathsep="&quot; &quot;" property="win.sign.separated" refid="win.sign.found"/>
<antcall target="sign-file">
<param name="sign.file" value="&quot;${win.sign.separated}&quot;"/>
</antcall>
<!-- Launcher -->
<antcall target="config-compile-sign">
<param name="nsis.script.in" value="windows-launcher.nsi.in"/>
<param name="nsis.outfile" value="${dist.dir}/${project.filename}.exe"/>
</antcall>
<!-- Debug Launcher -->
<copy file="ant/windows/windows-launcher.nsi.in" tofile="ant/windows/windows-debug-launcher.nsi.in" overwrite="true"/>
<replace file="ant/windows/windows-debug-launcher.nsi.in" token="$javaw" value="$java"/>
<replace file="ant/windows/windows-debug-launcher.nsi.in" token="/assets/branding/windows-icon.ico" value="/ant/windows/nsis/console.ico"/>
<antcall target="config-compile-sign">
<param name="nsis.script.in" value="windows-debug-launcher.nsi.in"/>
<param name="nsis.outfile" value="${dist.dir}/${project.filename}-console.exe"/>
</antcall>
<!-- Uninstaller -->
<antcall target="config-compile-sign">
<param name="nsis.script.in" value="windows-uninstaller.nsi.in"/>
<param name="nsis.outfile" value="${dist.dir}/uninstall.exe"/>
</antcall>
<!-- Installer (bundles dist/ payload) -->
<antcall target="config-compile-sign">
<param name="nsis.script.in" value="windows-installer.nsi.in"/>
<param name="nsis.outfile" value="${out.dir}/${project.filename}${build.type}-${build.version}-${windows.target.arch}.exe"/>
</antcall>
</target>
<target name="config-compile-sign" depends="find-nsisbin">
<echo level="info">Creating ${nsis.outfile} using ${nsisbin}</echo>
<!-- Calculate file name without suffix -->
<basename property="nsis.script.out" file="${nsis.script.in}" suffix=".in"/>
<!-- Configure the nsi script with ant parameters -->
<copy file="ant/windows/${nsis.script.in}" tofile="${build.dir}/${nsis.script.out}" overwrite="true">
<filterchain><expandproperties/></filterchain>
</copy>
<!-- Create the exe -->
<exec executable="${nsisbin}" failonerror="true">
<arg value="${build.dir}/${nsis.script.out}"/>
</exec>
<!-- Sign the exe -->
<antcall target="sign-file">
<param name="sign.file" value="${nsis.outfile}"/>
</antcall>
</target>
<target name="find-nsisbin" depends="nsisbin-from-unix,nsisbin-from-32,nsisbin-from-64"/>
<!-- Linux makensis -->
<target name="nsisbin-from-unix" unless="env.windir">
<property name="nsisbin" value="makensis"/>
</target>
<!-- Win32 makensis -->
<target name="nsisbin-from-32" unless="env.ProgramFiles(x86)">
<property description="suppress property warning" name="env.ProgramFiles" value="C:/Program Files"/>
<property name="nsisbin" value="${env.ProgramFiles}/NSIS/makensis.exe"/>
</target>
<!-- Win64 makensis -->
<target name="nsisbin-from-64" if="env.ProgramFiles(x86)">
<property description="suppress property warning" name="env.ProgramFiles(x86)" value="C:/Program Files (x86)"/>
<property name="nsisbin" value="${env.ProgramFiles(x86)}/NSIS/makensis.exe"/>
</target>
<target name="copy-dlls" if="target.os.windows">
<echo level="info">Copying native library files to libs</echo>
<copy todir="${dist.dir}/libs" flatten="true" verbose="true">
<fileset dir="${out.dir}/libs-temp">
<!--x86_64-->
<include name="**/win32-x86-64/*" if="target.arch.x86_64"/> <!-- jna/hid4java -->
<include name="**/windows-x86_64/*" if="target.arch.x86_64"/> <!-- usb4java -->
<include name="**/windows_64/*" if="target.arch.x86_64"/> <!-- jssc -->
<!--aarch64-->
<include name="**/win32-aarch64/*" if="target.arch.aarch64"/> <!-- jna/hid4java -->
<include name="**/windows-aarch64/*" if="target.arch.aarch64"/> <!-- usb4java -->
<include name="**/windows_arm64/*" if="target.arch.aarch64"/> <!-- jssc -->
</fileset>
</copy>
</target>
</project>

View File

@@ -0,0 +1,143 @@
!include FileFunc.nsh
!include LogicLib.nsh
!include x64.nsh
!include StrRep.nsh
!include IndexOf.nsh
!include StrTok.nsh
; Resulting variable
Var /GLOBAL java
Var /GLOBAL javaw
Var /GLOBAL java_major
; Constants
!define EXE "java.exe"
!define ADOPT "SOFTWARE\Classes\AdoptOpenJDK.jarfile\shell\open\command"
!define ECLIPSE "SOFTWARE\Classes\Eclipse Adoptium.jarfile\shell\open\command"
!define ECLIPSE_OLD "SOFTWARE\Classes\Eclipse Foundation.jarfile\shell\open\command"
!define JRE "Software\JavaSoft\Java Runtime Environment"
!define JRE32 "Software\Wow6432Node\JavaSoft\Java Runtime Environment"
!define JDK "Software\JavaSoft\JDK"
!define JDK32 "Software\Wow6432Node\JavaSoft\JDK"
; Macros
!macro _ReadEclipseKey
ClearErrors
ReadRegStr $0 HKLM "${ECLIPSE}" ""
StrCpy $0 "$0" "" 1 ; Remove first double-quote
${IndexOf} $1 $0 "$\"" ; Find the index of second double-quote
StrCpy $0 "$0" $1 ; Get the string section up to the index
IfFileExists "$0" Found
!macroend
!macro _ReadEclipseOldKey
ClearErrors
ReadRegStr $0 HKLM "${ECLIPSE_OLD}" ""
StrCpy $0 "$0" "" 1 ; Remove first double-quote
${IndexOf} $1 $0 "$\"" ; Find the index of second double-quote
StrCpy $0 "$0" $1 ; Get the string section up to the index
IfFileExists "$0" Found
!macroend
!macro _ReadAdoptKey
ClearErrors
ReadRegStr $0 HKLM "${ADOPT}" ""
StrCpy $0 "$0" "" 1 ; Remove first double-quote
${IndexOf} $1 $0 "$\"" ; Find the index of second double-quote
StrCpy $0 "$0" $1 ; Get the string section up to the index
IfFileExists "$0" Found
!macroend
!macro _ReadReg key
ClearErrors
ReadRegStr $0 HKLM "${key}" "CurrentVersion"
ReadRegStr $0 HKLM "${key}\$0" "JavaHome"
IfErrors +2 0
StrCpy $0 "$0\bin\${EXE}"
IfFileExists "$0" Found
!macroend
!macro _ReadPayload root path
ClearErrors
StrCpy $0 "${root}\${path}\bin\${EXE}"
IfFileExists $0 Found
!macroend
!macro _ReadWorking path
ClearErrors
StrCpy $0 "$EXEDIR\${path}\bin\${EXE}"
IfFileExists $0 Found
!macroend
!macro _ReadEnv var
ClearErrors
ReadEnvStr $0 "${var}"
StrCpy $0 "$0\bin\${EXE}"
IfFileExists "$0" Found
!macroend
; Create the shared function.
!macro _FindJava un
Function ${un}FindJava
; Snag payload directory off the stack
exch $R0
${If} ${RunningX64}
SetRegView 64
${EndIf}
; Check payload directories
!insertmacro _ReadPayload "$R0" "runtime"
; Check relative directories
!insertmacro _ReadWorking "runtime"
!insertmacro _ReadWorking "jre"
; Check common env vars
!insertmacro _ReadEnv "JAVA_HOME"
; Check registry
!insertmacro _ReadEclipseKey
!insertmacro _ReadEclipseOldKey
!insertmacro _ReadAdoptKey
!insertmacro _ReadReg "${JRE}"
!insertmacro _ReadReg "${JRE32}"
!insertmacro _ReadReg "${JDK}"
!insertmacro _ReadReg "${JDK32}"
; Give up. Use java.exe and hope it works
StrCpy $0 "${EXE}"
; Set global var
Found:
StrCpy $java $0
${StrRep} '$java' '$java' 'javaw.exe' '${EXE}' ; AdoptOpenJDK returns "javaw.exe"
${StrRep} '$javaw' '$java' '${EXE}' 'javaw.exe'
; Discard payload directory
pop $R0
; Detect java version
nsExec::ExecToStack '"$java" -version'
Pop $0
Pop $1
; Isolate version number, e.g. "1.8.0"
${StrTok} $0 "$1" "$\"" "1" "1"
; Isolate major version
${StrTok} $R0 "$0" "." "0" "1"
; Handle old 1.x.x version format
${If} "$R0" == "1"
${StrTok} $R0 "$0" "." "1" "1"
${EndIf}
; Convert to integer
IntOp $java_major $R0 + 0
FunctionEnd
!macroend
; Allows registering identical functions for install and uninstall
!insertmacro _FindJava ""
;!insertmacro _FindJava "un."

View File

@@ -0,0 +1,28 @@
!define IndexOf "!insertmacro IndexOf"
!macro IndexOf Var Str Char
Push "${Char}"
Push "${Str}"
Exch $R0
Exch
Exch $R1
Push $R2
Push $R3
StrCpy $R3 $R0
StrCpy $R0 -1
IntOp $R0 $R0 + 1
StrCpy $R2 $R3 1 $R0
StrCmp $R2 "" +2
StrCmp $R2 $R1 +2 -3
StrCpy $R0 -1
Pop $R3
Pop $R2
Pop $R1
Exch $R0
Pop "${Var}"
!macroend

View File

@@ -0,0 +1,5 @@
; Allow title masquerading
!define SetTitleBar "!insertmacro SetTitleBar"
!macro SetTitlebar title
SendMessage $HWNDPARENT ${WM_SETTEXT} 0 "STR:${title}"
!macroend

View File

@@ -0,0 +1,501 @@
#################################################################################
# StdUtils plug-in for NSIS
# Copyright (C) 2004-2018 LoRd_MuldeR <MuldeR2@GMX.de>
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
# version 2.1 of the License, or (at your option) any later version.
#
# This library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with this library; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
#
# http://www.gnu.org/licenses/lgpl-2.1.txt
#################################################################################
# DEVELOPER NOTES:
# - Please see "https://github.com/lordmulder/stdutils/" for news and updates!
# - Please see "Docs\StdUtils\StdUtils.html" for detailed function descriptions!
# - Please see "Examples\StdUtils\StdUtilsTest.nsi" for usage examples!
#################################################################################
# FUNCTION DECLARTIONS
#################################################################################
!ifndef ___STDUTILS__NSH___
!define ___STDUTILS__NSH___
!define StdUtils.Time '!insertmacro _StdU_Time' #time(), as in C standard library
!define StdUtils.GetMinutes '!insertmacro _StdU_GetMinutes' #GetSystemTimeAsFileTime(), returns the number of minutes
!define StdUtils.GetHours '!insertmacro _StdU_GetHours' #GetSystemTimeAsFileTime(), returns the number of hours
!define StdUtils.GetDays '!insertmacro _StdU_GetDays' #GetSystemTimeAsFileTime(), returns the number of days
!define StdUtils.Rand '!insertmacro _StdU_Rand' #rand(), as in C standard library
!define StdUtils.RandMax '!insertmacro _StdU_RandMax' #rand(), as in C standard library, with maximum value
!define StdUtils.RandMinMax '!insertmacro _StdU_RandMinMax' #rand(), as in C standard library, with minimum/maximum value
!define StdUtils.RandList '!insertmacro _StdU_RandList' #rand(), as in C standard library, with list support
!define StdUtils.RandBytes '!insertmacro _StdU_RandBytes' #Generates random bytes, returned as Base64-encoded string
!define StdUtils.FormatStr '!insertmacro _StdU_FormatStr' #sprintf(), as in C standard library, one '%d' placeholder
!define StdUtils.FormatStr2 '!insertmacro _StdU_FormatStr2' #sprintf(), as in C standard library, two '%d' placeholders
!define StdUtils.FormatStr3 '!insertmacro _StdU_FormatStr3' #sprintf(), as in C standard library, three '%d' placeholders
!define StdUtils.ScanStr '!insertmacro _StdU_ScanStr' #sscanf(), as in C standard library, one '%d' placeholder
!define StdUtils.ScanStr2 '!insertmacro _StdU_ScanStr2' #sscanf(), as in C standard library, two '%d' placeholders
!define StdUtils.ScanStr3 '!insertmacro _StdU_ScanStr3' #sscanf(), as in C standard library, three '%d' placeholders
!define StdUtils.TrimStr '!insertmacro _StdU_TrimStr' #Remove whitspaces from string, left and right
!define StdUtils.TrimStrLeft '!insertmacro _StdU_TrimStrLeft' #Remove whitspaces from string, left side only
!define StdUtils.TrimStrRight '!insertmacro _StdU_TrimStrRight' #Remove whitspaces from string, right side only
!define StdUtils.RevStr '!insertmacro _StdU_RevStr' #Reverse a string, e.g. "reverse me" <-> "em esrever"
!define StdUtils.ValidFileName '!insertmacro _StdU_ValidFileName' #Test whether string is a valid file name - no paths allowed
!define StdUtils.ValidPathSpec '!insertmacro _StdU_ValidPathSpec' #Test whether string is a valid full(!) path specification
!define StdUtils.ValidDomainName '!insertmacro _StdU_ValidDomain' #Test whether string is a valid host name or domain name
!define StdUtils.StrToUtf8 '!insertmacro _StdU_StrToUtf8' #Convert string from Unicode (UTF-16) or ANSI to UTF-8 bytes
!define StdUtils.StrFromUtf8 '!insertmacro _StdU_StrFromUtf8' #Convert string from UTF-8 bytes to Unicode (UTF-16) or ANSI
!define StdUtils.SHFileMove '!insertmacro _StdU_SHFileMove' #SHFileOperation(), using the FO_MOVE operation
!define StdUtils.SHFileCopy '!insertmacro _StdU_SHFileCopy' #SHFileOperation(), using the FO_COPY operation
!define StdUtils.AppendToFile '!insertmacro _StdU_AppendToFile' #Append contents of an existing file to another file
!define StdUtils.ExecShellAsUser '!insertmacro _StdU_ExecShlUser' #ShellExecute() as NON-elevated user from elevated installer
!define StdUtils.InvokeShellVerb '!insertmacro _StdU_InvkeShlVrb' #Invokes a "shell verb", e.g. for pinning items to the taskbar
!define StdUtils.ExecShellWaitEx '!insertmacro _StdU_ExecShlWaitEx' #ShellExecuteEx(), returns the handle of the new process
!define StdUtils.WaitForProcEx '!insertmacro _StdU_WaitForProcEx' #WaitForSingleObject(), e.g. to wait for a running process
!define StdUtils.GetParameter '!insertmacro _StdU_GetParameter' #Get the value of a specific command-line option
!define StdUtils.TestParameter '!insertmacro _StdU_TestParameter' #Test whether a specific command-line option has been set
!define StdUtils.ParameterCnt '!insertmacro _StdU_ParameterCnt' #Get number of command-line tokens, similar to argc in main()
!define StdUtils.ParameterStr '!insertmacro _StdU_ParameterStr' #Get the n-th command-line token, similar to argv[i] in main()
!define StdUtils.GetAllParameters '!insertmacro _StdU_GetAllParams' #Get complete command-line, but without executable name
!define StdUtils.GetRealOSVersion '!insertmacro _StdU_GetRealOSVer' #Get the *real* Windows version number, even on Windows 8.1+
!define StdUtils.GetRealOSBuildNo '!insertmacro _StdU_GetRealOSBld' #Get the *real* Windows build number, even on Windows 8.1+
!define StdUtils.GetRealOSName '!insertmacro _StdU_GetRealOSStr' #Get the *real* Windows version, as a "friendly" name
!define StdUtils.GetOSEdition '!insertmacro _StdU_GetOSEdition' #Get the Windows edition, i.e. "workstation" or "server"
!define StdUtils.GetOSReleaseId '!insertmacro _StdU_GetOSRelIdNo' #Get the Windows release identifier (on Windows 10)
!define StdUtils.GetOSReleaseName '!insertmacro _StdU_GetOSRelIdStr' #Get the Windows release (on Windows 10), as a "friendly" name
!define StdUtils.VerifyOSVersion '!insertmacro _StdU_VrfyRealOSVer' #Compare *real* operating system to an expected version number
!define StdUtils.VerifyOSBuildNo '!insertmacro _StdU_VrfyRealOSBld' #Compare *real* operating system to an expected build number
!define StdUtils.HashText '!insertmacro _StdU_HashText' #Compute hash from text string (CRC32, MD5, SHA1/2/3, BLAKE2)
!define StdUtils.HashFile '!insertmacro _StdU_HashFile' #Compute hash from file (CRC32, MD5, SHA1/2/3, BLAKE2)
!define StdUtils.NormalizePath '!insertmacro _StdU_NormalizePath' #Simplifies the path to produce a direct, well-formed path
!define StdUtils.GetParentPath '!insertmacro _StdU_GetParentPath' #Get parent path by removing the last component from the path
!define StdUtils.SplitPath '!insertmacro _StdU_SplitPath' #Split the components of the given path
!define StdUtils.GetDrivePart '!insertmacro _StdU_GetDrivePart' #Get drive component of path
!define StdUtils.GetDirectoryPart '!insertmacro _StdU_GetDirPart' #Get directory component of path
!define StdUtils.GetFileNamePart '!insertmacro _StdU_GetFNamePart' #Get file name component of path
!define StdUtils.GetExtensionPart '!insertmacro _StdU_GetExtnPart' #Get file extension component of path
!define StdUtils.TimerCreate '!insertmacro _StdU_TimerCreate' #Create a new event-timer that will be triggered periodically
!define StdUtils.TimerDestroy '!insertmacro _StdU_TimerDestroy' #Destroy a running timer created with TimerCreate()
!define StdUtils.ProtectStr '!insertmacro _StdU_PrtctStr' #Protect a given String using Windows' DPAPI
!define StdUtils.UnprotectStr '!insertmacro _StdU_UnprtctStr' #Unprotect a string that was protected via ProtectStr()
!define StdUtils.GetLibVersion '!insertmacro _StdU_GetLibVersion' #Get the current StdUtils library version (for debugging)
!define StdUtils.SetVerbose '!insertmacro _StdU_SetVerbose' #Enable or disable "verbose" mode (for debugging)
#################################################################################
# MACRO DEFINITIONS
#################################################################################
!macro _StdU_Time out
StdUtils::Time /NOUNLOAD
pop ${out}
!macroend
!macro _StdU_GetMinutes out
StdUtils::GetMinutes /NOUNLOAD
pop ${out}
!macroend
!macro _StdU_GetHours out
StdUtils::GetHours /NOUNLOAD
pop ${out}
!macroend
!macro _StdU_GetDays out
StdUtils::GetDays /NOUNLOAD
pop ${out}
!macroend
!macro _StdU_Rand out
StdUtils::Rand /NOUNLOAD
pop ${out}
!macroend
!macro _StdU_RandMax out max
push ${max}
StdUtils::RandMax /NOUNLOAD
pop ${out}
!macroend
!macro _StdU_RandMinMax out min max
push ${min}
push ${max}
StdUtils::RandMinMax /NOUNLOAD
pop ${out}
!macroend
!macro _StdU_RandList count max
push ${max}
push ${count}
StdUtils::RandList /NOUNLOAD
!macroend
!macro _StdU_RandBytes out count
push ${count}
StdUtils::RandBytes /NOUNLOAD
pop ${out}
!macroend
!macro _StdU_FormatStr out format val
push `${format}`
push ${val}
StdUtils::FormatStr /NOUNLOAD
pop ${out}
!macroend
!macro _StdU_FormatStr2 out format val1 val2
push `${format}`
push ${val1}
push ${val2}
StdUtils::FormatStr2 /NOUNLOAD
pop ${out}
!macroend
!macro _StdU_FormatStr3 out format val1 val2 val3
push `${format}`
push ${val1}
push ${val2}
push ${val3}
StdUtils::FormatStr3 /NOUNLOAD
pop ${out}
!macroend
!macro _StdU_ScanStr out format input default
push `${format}`
push `${input}`
push ${default}
StdUtils::ScanStr /NOUNLOAD
pop ${out}
!macroend
!macro _StdU_ScanStr2 out1 out2 format input default1 default2
push `${format}`
push `${input}`
push ${default1}
push ${default2}
StdUtils::ScanStr2 /NOUNLOAD
pop ${out1}
pop ${out2}
!macroend
!macro _StdU_ScanStr3 out1 out2 out3 format input default1 default2 default3
push `${format}`
push `${input}`
push ${default1}
push ${default2}
push ${default3}
StdUtils::ScanStr3 /NOUNLOAD
pop ${out1}
pop ${out2}
pop ${out3}
!macroend
!macro _StdU_TrimStr var
push ${var}
StdUtils::TrimStr /NOUNLOAD
pop ${var}
!macroend
!macro _StdU_TrimStrLeft var
push ${var}
StdUtils::TrimStrLeft /NOUNLOAD
pop ${var}
!macroend
!macro _StdU_TrimStrRight var
push ${var}
StdUtils::TrimStrRight /NOUNLOAD
pop ${var}
!macroend
!macro _StdU_RevStr var
push ${var}
StdUtils::RevStr /NOUNLOAD
pop ${var}
!macroend
!macro _StdU_ValidFileName out test
push `${test}`
StdUtils::ValidFileName /NOUNLOAD
pop ${out}
!macroend
!macro _StdU_ValidPathSpec out test
push `${test}`
StdUtils::ValidPathSpec /NOUNLOAD
pop ${out}
!macroend
!macro _StdU_ValidDomain out test
push `${test}`
StdUtils::ValidDomainName /NOUNLOAD
pop ${out}
!macroend
!macro _StdU_StrToUtf8 out str
push `${str}`
StdUtils::StrToUtf8 /NOUNLOAD
pop ${out}
!macroend
!macro _StdU_StrFromUtf8 out trnc str
push ${trnc}
push `${str}`
StdUtils::StrFromUtf8 /NOUNLOAD
pop ${out}
!macroend
!macro _StdU_SHFileMove out from to hwnd
push `${from}`
push `${to}`
push ${hwnd}
StdUtils::SHFileMove /NOUNLOAD
pop ${out}
!macroend
!macro _StdU_SHFileCopy out from to hwnd
push `${from}`
push `${to}`
push ${hwnd}
StdUtils::SHFileCopy /NOUNLOAD
pop ${out}
!macroend
!macro _StdU_AppendToFile out from dest offset maxlen
push `${from}`
push `${dest}`
push ${offset}
push ${maxlen}
StdUtils::AppendToFile /NOUNLOAD
pop ${out}
!macroend
!macro _StdU_ExecShlUser out file verb args
push `${file}`
push `${verb}`
push `${args}`
StdUtils::ExecShellAsUser /NOUNLOAD
pop ${out}
!macroend
!macro _StdU_InvkeShlVrb out path file verb_id
push "${path}"
push "${file}"
push ${verb_id}
StdUtils::InvokeShellVerb /NOUNLOAD
pop ${out}
!macroend
!macro _StdU_ExecShlWaitEx out_res out_val file verb args
push `${file}`
push `${verb}`
push `${args}`
StdUtils::ExecShellWaitEx /NOUNLOAD
pop ${out_res}
pop ${out_val}
!macroend
!macro _StdU_WaitForProcEx out handle
push `${handle}`
StdUtils::WaitForProcEx /NOUNLOAD
pop ${out}
!macroend
!macro _StdU_GetParameter out name default
push `${name}`
push `${default}`
StdUtils::GetParameter /NOUNLOAD
pop ${out}
!macroend
!macro _StdU_TestParameter out name
push `${name}`
StdUtils::TestParameter /NOUNLOAD
pop ${out}
!macroend
!macro _StdU_ParameterCnt out
StdUtils::ParameterCnt /NOUNLOAD
pop ${out}
!macroend
!macro _StdU_ParameterStr out index
push ${index}
StdUtils::ParameterStr /NOUNLOAD
pop ${out}
!macroend
!macro _StdU_GetAllParams out truncate
push `${truncate}`
StdUtils::GetAllParameters /NOUNLOAD
pop ${out}
!macroend
!macro _StdU_GetRealOSVer out_major out_minor out_spack
StdUtils::GetRealOsVersion /NOUNLOAD
pop ${out_major}
pop ${out_minor}
pop ${out_spack}
!macroend
!macro _StdU_GetRealOSBld out
StdUtils::GetRealOsBuildNo /NOUNLOAD
pop ${out}
!macroend
!macro _StdU_GetRealOSStr out
StdUtils::GetRealOsName /NOUNLOAD
pop ${out}
!macroend
!macro _StdU_VrfyRealOSVer out major minor spack
push `${major}`
push `${minor}`
push `${spack}`
StdUtils::VerifyRealOsVersion /NOUNLOAD
pop ${out}
!macroend
!macro _StdU_VrfyRealOSBld out build
push `${build}`
StdUtils::VerifyRealOsBuildNo /NOUNLOAD
pop ${out}
!macroend
!macro _StdU_GetOSEdition out
StdUtils::GetOsEdition /NOUNLOAD
pop ${out}
!macroend
!macro _StdU_GetOSRelIdNo out
StdUtils::GetOsReleaseId /NOUNLOAD
pop ${out}
!macroend
!macro _StdU_GetOSRelIdStr out
StdUtils::GetOsReleaseName /NOUNLOAD
pop ${out}
!macroend
!macro _StdU_HashText out type text
push `${type}`
push `${text}`
StdUtils::HashText /NOUNLOAD
pop ${out}
!macroend
!macro _StdU_HashFile out type file
push `${type}`
push `${file}`
StdUtils::HashFile /NOUNLOAD
pop ${out}
!macroend
!macro _StdU_NormalizePath out path
push `${path}`
StdUtils::NormalizePath /NOUNLOAD
pop ${out}
!macroend
!macro _StdU_GetParentPath out path
push `${path}`
StdUtils::GetParentPath /NOUNLOAD
pop ${out}
!macroend
!macro _StdU_SplitPath out_drive out_dir out_fname out_ext path
push `${path}`
StdUtils::SplitPath /NOUNLOAD
pop ${out_drive}
pop ${out_dir}
pop ${out_fname}
pop ${out_ext}
!macroend
!macro _StdU_GetDrivePart out path
push `${path}`
StdUtils::GetDrivePart /NOUNLOAD
pop ${out}
!macroend
!macro _StdU_GetDirPart out path
push `${path}`
StdUtils::GetDirectoryPart /NOUNLOAD
pop ${out}
!macroend
!macro _StdU_GetFNamePart out path
push `${path}`
StdUtils::GetFileNamePart /NOUNLOAD
pop ${out}
!macroend
!macro _StdU_GetExtnPart out path
push `${path}`
StdUtils::GetExtensionPart /NOUNLOAD
pop ${out}
!macroend
!macro _StdU_TimerCreate out callback interval
GetFunctionAddress ${out} ${callback}
push ${out}
push ${interval}
StdUtils::TimerCreate /NOUNLOAD
pop ${out}
!macroend
!macro _StdU_TimerDestroy out timer_id
push ${timer_id}
StdUtils::TimerDestroy /NOUNLOAD
pop ${out}
!macroend
!macro _StdU_PrtctStr out dpsc salt text
push `${dpsc}`
push `${salt}`
push `${text}`
StdUtils::ProtectStr /NOUNLOAD
pop ${out}
!macroend
!macro _StdU_UnprtctStr out trnc salt data
push `${trnc}`
push `${salt}`
push `${data}`
StdUtils::UnprotectStr /NOUNLOAD
pop ${out}
!macroend
!macro _StdU_GetLibVersion out_ver out_tst
StdUtils::GetLibVersion /NOUNLOAD
pop ${out_ver}
pop ${out_tst}
!macroend
!macro _StdU_SetVerbose enable
Push ${enable}
StdUtils::SetVerboseMode /NOUNLOAD
!macroend
#################################################################################
# MAGIC NUMBERS
#################################################################################
!define StdUtils.Const.ShellVerb.PinToTaskbar 0
!define StdUtils.Const.ShellVerb.UnpinFromTaskbar 1
!define StdUtils.Const.ShellVerb.PinToStart 2
!define StdUtils.Const.ShellVerb.UnpinFromStart 3
!endif # !___STDUTILS__NSH___

View File

@@ -0,0 +1,72 @@
!define StrLoc "!insertmacro StrLoc"
!macro StrLoc ResultVar String SubString StartPoint
Push "${String}"
Push "${SubString}"
Push "${StartPoint}"
Call StrLoc
Pop "${ResultVar}"
!macroend
Function StrLoc
/*After this point:
------------------------------------------
$R0 = StartPoint (input)
$R1 = SubString (input)
$R2 = String (input)
$R3 = SubStringLen (temp)
$R4 = StrLen (temp)
$R5 = StartCharPos (temp)
$R6 = TempStr (temp)*/
;Get input from user
Exch $R0
Exch
Exch $R1
Exch 2
Exch $R2
Push $R3
Push $R4
Push $R5
Push $R6
;Get "String" and "SubString" length
StrLen $R3 $R1
StrLen $R4 $R2
;Start "StartCharPos" counter
StrCpy $R5 0
;Loop until "SubString" is found or "String" reaches its end
${Do}
;Remove everything before and after the searched part ("TempStr")
StrCpy $R6 $R2 $R3 $R5
;Compare "TempStr" with "SubString"
${If} $R6 == $R1
${If} $R0 == `<`
IntOp $R6 $R3 + $R5
IntOp $R0 $R4 - $R6
${Else}
StrCpy $R0 $R5
${EndIf}
${ExitDo}
${EndIf}
;If not "SubString", this could be "String"'s end
${If} $R5 >= $R4
StrCpy $R0 ``
${ExitDo}
${EndIf}
;If not, continue the loop
IntOp $R5 $R5 + 1
${Loop}
;Return output to user
Pop $R6
Pop $R5
Pop $R4
Pop $R3
Pop $R2
Exch
Pop $R1
Exch $R0
FunctionEnd

View File

@@ -0,0 +1,66 @@
!define StrRep "!insertmacro StrRep"
!macro StrRep output string old new
Push `${string}`
Push `${old}`
Push `${new}`
;!ifdef __UNINSTALL__
; Call un.StrRep
;!else
Call StrRep
;!endif
Pop ${output}
!macroend
!macro Func_StrRep un
Function ${un}StrRep
Exch $R2 ;new
Exch 1
Exch $R1 ;old
Exch 2
Exch $R0 ;string
Push $R3
Push $R4
Push $R5
Push $R6
Push $R7
Push $R8
Push $R9
StrCpy $R3 0
StrLen $R4 $R1
StrLen $R6 $R0
StrLen $R9 $R2
loop:
StrCpy $R5 $R0 $R4 $R3
StrCmp $R5 $R1 found
StrCmp $R3 $R6 done
IntOp $R3 $R3 + 1 ;move offset by 1 to check the next character
Goto loop
found:
StrCpy $R5 $R0 $R3
IntOp $R8 $R3 + $R4
StrCpy $R7 $R0 "" $R8
StrCpy $R0 $R5$R2$R7
StrLen $R6 $R0
IntOp $R3 $R3 + $R9 ;move offset by length of the replacement string
Goto loop
done:
Pop $R9
Pop $R8
Pop $R7
Pop $R6
Pop $R5
Pop $R4
Pop $R3
Push $R0
Push $R1
Pop $R0
Pop $R1
Pop $R0
Pop $R2
Exch $R1
FunctionEnd
!macroend
!insertmacro Func_StrRep ""
;!insertmacro Func_StrRep "un."

View File

@@ -0,0 +1,150 @@
!define StrTok "!insertmacro StrTok"
!macro StrTok ResultVar String Separators ResultPart SkipEmptyParts
Push "${String}"
Push "${Separators}"
Push "${ResultPart}"
Push "${SkipEmptyParts}"
Call StrTok
Pop "${ResultVar}"
!macroend
Function StrTok
/*After this point:
------------------------------------------
$0 = SkipEmptyParts (input)
$1 = ResultPart (input)
$2 = Separators (input)
$3 = String (input)
$4 = SeparatorsLen (temp)
$5 = StrLen (temp)
$6 = StartCharPos (temp)
$7 = TempStr (temp)
$8 = CurrentLoop
$9 = CurrentSepChar
$R0 = CurrentSepCharNum
*/
;Get input from user
Exch $0
Exch
Exch $1
Exch
Exch 2
Exch $2
Exch 2
Exch 3
Exch $3
Exch 3
Push $4
Push $5
Push $6
Push $7
Push $8
Push $9
Push $R0
;Parameter defaults
${IfThen} $2 == `` ${|} StrCpy $2 `|` ${|}
${IfThen} $1 == `` ${|} StrCpy $1 `L` ${|}
${IfThen} $0 == `` ${|} StrCpy $0 `0` ${|}
;Get "String" and "Separators" length
StrLen $4 $2
StrLen $5 $3
;Start "StartCharPos" and "ResultPart" counters
StrCpy $6 0
StrCpy $8 -1
;Loop until "ResultPart" is met, "Separators" is found or
;"String" reaches its end
ResultPartLoop: ;"CurrentLoop" Loop
;Increase "CurrentLoop" counter
IntOp $8 $8 + 1
StrSearchLoop:
${Do} ;"String" Loop
;Remove everything before and after the searched part ("TempStr")
StrCpy $7 $3 1 $6
;Verify if it's the "String" end
${If} $6 >= $5
;If "CurrentLoop" is what the user wants, remove the part
;after "TempStr" and itself and get out of here
${If} $8 == $1
${OrIf} $1 == `L`
StrCpy $3 $3 $6
${Else} ;If not, empty "String" and get out of here
StrCpy $3 ``
${EndIf}
StrCpy $R0 `End`
${ExitDo}
${EndIf}
;Start "CurrentSepCharNum" counter (for "Separators" Loop)
StrCpy $R0 0
${Do} ;"Separators" Loop
;Use one "Separators" character at a time
${If} $R0 <> 0
StrCpy $9 $2 1 $R0
${Else}
StrCpy $9 $2 1
${EndIf}
;Go to the next "String" char if it's "Separators" end
${IfThen} $R0 >= $4 ${|} ${ExitDo} ${|}
;Or, if "TempStr" equals "CurrentSepChar", then...
${If} $7 == $9
StrCpy $7 $3 $6
;If "String" is empty because this result part doesn't
;contain data, verify if "SkipEmptyParts" is activated,
;so we don't return the output to user yet
${If} $7 == ``
${AndIf} $0 = 1 ;${TRUE}
IntOp $6 $6 + 1
StrCpy $3 $3 `` $6
StrCpy $6 0
Goto StrSearchLoop
${ElseIf} $8 == $1
StrCpy $3 $3 $6
StrCpy $R0 "End"
${ExitDo}
${EndIf} ;If not, go to the next result part
IntOp $6 $6 + 1
StrCpy $3 $3 `` $6
StrCpy $6 0
Goto ResultPartLoop
${EndIf}
;Increase "CurrentSepCharNum" counter
IntOp $R0 $R0 + 1
${Loop}
${IfThen} $R0 == "End" ${|} ${ExitDo} ${|}
;Increase "StartCharPos" counter
IntOp $6 $6 + 1
${Loop}
/*After this point:
------------------------------------------
$3 = ResultVar (output)*/
;Return output to user
Pop $R0
Pop $9
Pop $8
Pop $7
Pop $6
Pop $5
Pop $4
Pop $0
Pop $1
Pop $2
Exch $3
FunctionEnd

Binary file not shown.

After

Width:  |  Height:  |  Size: 420 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 144 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 201 KiB

View File

@@ -0,0 +1,132 @@
!define MUI_BGCOLOR "SYSCLR:Window"
!define MUI_TEXTCOLOR "SYSCLR:WindowText"
!include MUI2.nsh
!include x64.nsh
!include LogicLib.nsh
!ifdef NSIS_UNICODE
!addplugindir "${basedir}/ant/windows/nsis/Plugins/Release_Unicode"
!else
!addplugindir "${basedir}/ant/windows/nsis/Plugins/Release_ANSI"
!endif
!addincludedir "${basedir}/ant/windows/nsis/Include"
!include FindJava.nsh
!include StdUtils.nsh
!include StrLoc.nsh
Name "${project.name}"
OutFile "${nsis.outfile}"
RequestExecutionLevel admin
!define MUI_ICON "${basedir}/assets/branding/windows-icon.ico"
; Branding for qz only
!if "${project.filename}" == "qz-tray"
!define MUI_WELCOMEFINISHPAGE_BITMAP "${basedir}\ant\windows\nsis\welcome.bmp"
!endif
!insertmacro MUI_PAGE_WELCOME
!insertmacro MUI_PAGE_DIRECTORY
!insertmacro MUI_PAGE_INSTFILES
!insertmacro MUI_UNPAGE_CONFIRM
!insertmacro MUI_UNPAGE_INSTFILES
!insertmacro MUI_LANGUAGE "English"
!macro QzInstaller step option value
SetDetailsPrint textonly
DetailPrint "Running ${step}..."
SetDetailsPrint listonly
DetailPrint 'Running ${step}: "$java" ${install.opts} -jar "$OUTDIR\${project.filename}.jar" "${step}" "${option}" "${value}"'
SetDetailsPrint both
ClearErrors
nsExec::ExecToLog '"$java" ${install.opts} -jar "$OUTDIR\${project.filename}.jar" "${step}" "${option}" "${value}"'
Pop $0
${If} "$0" != "0"
Abort "Installation failed during ${step} step. Please check log for details."
${EndIf}
!macroend
!macro VerifyJava jumpto
; Test java executable
nsExec::ExecToLog '"$java" -version"'
Pop $0
${If} "$0" == "0"
Goto Resume
${EndIf}
; Handle scenario where Java is bundled but broken
${StrLoc} $R1 "$java" "runtime\bin" ">" ; e.g. "nss1234.tmp\payload\runtime\bin\java.exe"
${If} $R1 != ""
SetDetailsPrint both
Abort "Sorry, this version of ${project.name} cannot be installed on this system."
${EndIf}
; Offer to download Java if missing and non-silent install
${IfNot} ${Silent}
MessageBox MB_YESNO "Java is required. Download now?" IDYES Website IDNO Resume
; Visit Java website
Website:
ExecShell "open" "${java.download}"
MessageBox MB_OK "Click OK after Java is installed"
; Check again for Java
Goto ${jumpto}
${EndIf}
Resume:
!macroend
Section
; Set environmental variable for silent install to be picked up by Java
${If} ${Silent}
System::Call 'Kernel32::SetEnvironmentVariable(t, t)i ("${vendor.name}_silent", "1").r0'
${EndIf}
; Echo final destination to logs
SetOutPath $INSTDIR
; Copy files to a temporary location
SetOutPath "$PLUGINSDIR\payload"
DetailPrint "Extracting..."
SetDetailsPrint none ; Temporarily suppress details
File /r "${dist.dir}\*"
; Set the $java variable
TryAgain:
Push "$OUTDIR"
Call FindJava
!insertmacro VerifyJava "TryAgain"
; Run preinstall tasks
SetDetailsPrint both
!insertmacro QzInstaller "preinstall" "" ""
; Run install tasks
!insertmacro QzInstaller "install" "--dest" $INSTDIR
; Run certgen tasks
SetOutPath $INSTDIR
!insertmacro QzInstaller "certgen" "" ""
; Launch a non-elevated instance of ${project.name}
${StdUtils.ExecShellAsUser} $0 "$INSTDIR\${project.filename}.exe" "open" ""
SectionEnd
!macro Init
${If} ${RunningX64}
SetRegView 64
${DisableX64FSRedirection}
${EndIf}
${If} $INSTDIR == ""
${If} ${RunningX64}
StrCpy $INSTDIR "$PROGRAMFILES64\${project.name}"
${Else}
StrCpy $INSTDIR "$PROGRAMFILES\${project.name}"
${EndIf}
${EndIf}
!macroend
; Runs for installs
Function .onInit
!insertmacro Init
FunctionEnd

View File

@@ -0,0 +1,91 @@
!include x64.nsh
!include LogicLib.nsh
!ifdef NSIS_UNICODE
!addplugindir "${basedir}/ant/windows/nsis/Plugins/Release_Unicode"
!else
!addplugindir "${basedir}/ant/windows/nsis/Plugins/Release_ANSI"
!endif
!addincludedir "${basedir}/ant/windows/nsis/Include"
!include StdUtils.nsh
!include StrLoc.nsh
!include FindJava.nsh
!insertmacro GetParameters
; Run this exe as non-admin
RequestExecutionLevel user
; Application information
Name "${project.name}"
Caption "${project.name}"
Icon "${basedir}/assets/branding/windows-icon.ico"
OutFile "${nsis.outfile}"
SilentInstall silent
AutoCloseWindow true
ShowInstDetails nevershow
; Full path to jar
!define JAR "$EXEDIR/${project.filename}.jar"
Section
${If} ${RunningX64}
${DisableX64FSRedirection}
${EndIf}
SetOutPath $EXEDIR
; Get params to pass to jar
Var /GLOBAL params
${GetParameters} $params
; Sets the $java variable
Push "$EXEDIR"
Call FindJava
Var /GLOBAL opts
StrCpy $opts "${launch.opts}"
; Handle jdk9+ flags
${If} $java_major >= 9
StrCpy $opts "${launch.opts} ${launch.jigsaw}"
${EndIf}
; Check for user overridable launch options
ClearErrors
ReadEnvStr $R0 ${launch.overrides}
IfErrors +2 0
StrCpy $opts "$opts $R0"
Var /GLOBAL command
StrCpy $command '"$javaw" $opts -jar "${JAR}" $params'
; If ends in "-console.exe", use "cmd /s /k" to launch
${StrLoc} $R1 "${nsis.outfile}" "-console.exe" "<"
${If} $R1 == "0"
ExpandEnvStrings $R2 %COMSPEC%
StrCpy $command '"$R2" /s /k "$command"'
${EndIf}
; Allow return of exit code
${StrLoc} $R2 $params "--wait" "<"
${If} $R2 != ""
; Switch from /k to /c to capture exit code from -console.exe
${StrRep} $command "$command" " /k " " /c "
ExecWait $command $R3
; Set error-level
SetErrorLevel $R3
${Else}
Exec $command
${EndIf}
${If} ${RunningX64}
${EnableX64FSRedirection}
${EndIf}
SectionEnd
Function .onInit
${If} ${RunningX64}
SetRegView 64
${DisableX64FSRedirection}
${EndIf}
FunctionEnd

View File

@@ -0,0 +1,117 @@
!define MUI_BGCOLOR "SYSCLR:Window"
!define MUI_TEXTCOLOR "SYSCLR:WindowText"
!include MUI2.nsh
!include x64.nsh
!include LogicLib.nsh
!include FileFunc.nsh
!include WinMessages.nsh
!ifdef NSIS_UNICODE
!addplugindir "${basedir}/ant/windows/nsis/Plugins/Release_Unicode"
!else
!addplugindir "${basedir}/ant/windows/nsis/Plugins/Release_ANSI"
!endif
!addincludedir "${basedir}/ant/windows/nsis/Include"
!include StdUtils.nsh
!include SetTitleBar.nsh
!include FindJava.nsh
!define MUI_PRODUCT "${project.name}"
!define MUI_VERSION "${build.version}"
; Branding for qz only
!if "${project.filename}" == "qz-tray"
!define MUI_ICON "${basedir}/ant/windows/nsis/uninstall.ico"
!else
!define MUI_ICON "${basedir}/assets/branding/windows-icon.ico"
!endif
!define MUI_PAGE_HEADER_TEXT "Uninstall ${project.name}"
!define MUI_PAGE_HEADER_SUBTEXT "Remove ${project.name} from your computer"
!define MUI_INSTFILESPAGE_FINISHHEADER_TEXT "Uninstallation Complete"
!define MUI_INSTFILESPAGE_FINISHHEADER_SUBTEXT "Uninstall was completed successfully."
!insertmacro MUI_PAGE_INSTFILES
!insertmacro MUI_LANGUAGE "English"
!insertmacro GetParameters
RequestExecutionLevel admin
CRCCheck On
Name "Uninstall ${project.name}"
Caption "Uninstall ${project.name}"
Icon "${basedir}/ant/windows/nsis/uninstall.ico"
OutFile "${nsis.outfile}"
Var /GLOBAL RESPAWN
Var /GLOBAL DELETE_DIR
Var /GLOBAL DELETE_EXE
Section
${SetTitlebar} "Uninstall"
SetDetailsPrint textonly
DetailPrint "Uninstalling"
SetDetailsPrint listonly
${GetParameters} $0
${GetOptions} "$0" "/RESPAWN=" $RESPAWN
${GetOptions} "$0" "/DELETE_DIR=" $DELETE_DIR
${GetOptions} "$0" "/DELETE_EXE=" $DELETE_EXE
${If} $RESPAWN != ""
; We're running from $TEMP; Perform the uninstall
; Set environmental variable for silent uninstall to be picked up by Java
${If} ${Silent}
System::Call 'Kernel32::SetEnvironmentVariable(t, t)i ("${vendor.name}_silent", "1").r0'
${EndIf}
; Set $javaw variable
Push "$DELETE_DIR"
Call FindJava
; Run uninstall step using jar
SetDetailsPrint textonly
DetailPrint "Running uninstall..."
SetDetailsPrint none ; Temporarily suppress details
SetOutPath $DELETE_DIR
SetDetailsPrint listonly
DetailPrint 'Running uninstall: "$java" ${install.opts} -jar "$DELETE_DIR\${project.filename}.jar" uninstall'
ClearErrors
nsExec::ExecToLog '"$java" ${install.opts} -jar "$DELETE_DIR\${project.filename}.jar" uninstall'
Pop $0
${If} "$0" != "0"
Abort "Uninstall failed."
${EndIf}
; Remove all files
DetailPrint "Removing remaining files..."
SetDetailsPrint none ; Temporarily suppress details
SetOutPath $TEMP
RMDir /r "$DELETE_DIR"
; Remove self from $TEMP after reboot
Delete /REBOOTOK $EXEPATH
${If} ${RunningX64}
${EnableX64FSRedirection}
${EndIf}
SetDetailsPrint both
${Else}
; We're NOT running from $TEMP, copy to temp and respawn ourself
GetTempFileName $0
CopyFiles "$EXEPATH" "$0"
${If} ${Silent}
Exec '"$0" /S /RESPAWN=1 /DELETE_DIR="$EXEDIR" /DELETE_EXE="$EXEPATH"'
${Else}
Exec '"$0" /RESPAWN=1 /DELETE_DIR="$EXEDIR" /DELETE_EXE="$EXEPATH"'
${EndIf}
Quit
${EndIf}
SectionEnd
Function .onInit
${If} ${RunningX64}
SetRegView 64
${DisableX64FSRedirection}
${EndIf}
FunctionEnd