diff --git a/apps/backend/crydaq-server/src/main/resources/native/linux-amd64/BUILD-INFO.json b/apps/backend/crydaq-server/src/main/resources/native/linux-amd64/BUILD-INFO.json new file mode 100644 index 00000000..655d51e1 --- /dev/null +++ b/apps/backend/crydaq-server/src/main/resources/native/linux-amd64/BUILD-INFO.json @@ -0,0 +1,10 @@ +{ + "driver": { + "commit": "92982a31a6545fb87103a0acaadaaa348ae0439b", + "patchSha256": "98723f38afefe5f0605fb3e4720dde711f27df4a9747da794dfeb9cf147f6850" + }, + "framework": { + "commit": "051d488f67eb46549506b2c6fc8f5e9ead070d40", + "patchSha256": "c1a93a43dde574602fdccfe705c01154c03ff3094a94e39613c9f1636ff67cfb" + } +} diff --git a/apps/backend/crydaq-server/src/main/resources/native/linux-amd64/License.dat b/apps/backend/crydaq-server/src/main/resources/native/linux-amd64/License.dat new file mode 100644 index 00000000..227e8203 --- /dev/null +++ b/apps/backend/crydaq-server/src/main/resources/native/linux-amd64/License.dat @@ -0,0 +1 @@ +{"payload":"qER0eXBlZ2xpY2Vuc2VIZmVhdHVyZXOFpURjb2RlZTkyMDA0RXZhbHVlZHRydWVHZW5kVGltZRsAAAR68lOoEElzdGFydFRpbWUbAAABnLGwllBJdmFsdWVUeXBlAKVEY29kZWU5MjAxMkV2YWx1ZWExR2VuZFRpbWUbAAAEevJTqBBJc3RhcnRUaW1lGwAAAZyxsJZQSXZhbHVlVHlwZQGlRGNvZGVlOTIwMDhFdmFsdWVhNEdlbmRUaW1lGwAABHryU6gQSXN0YXJ0VGltZRsAAAGcsbCWUEl2YWx1ZVR5cGUBpURjb2RlZTkyMDA5RXZhbHVlZHRydWVHZW5kVGltZRsAAAR68lOoEElzdGFydFRpbWUbAAABnLGwllBJdmFsdWVUeXBlAKVEY29kZWU5MjAxMUV2YWx1ZWQyNDAwR2VuZFRpbWUbAAAEevJTqBBJc3RhcnRUaW1lGwAAAZyxsJZQSXZhbHVlVHlwZQFIaXNzdWVkQXQbAAABn9TII8ZJZXhwaXJlc0F0GwAABH3gXMQYSWxpY2Vuc2VJZAFJbWFjaGluZUlkaWRldmljZTAwMUlub3RCZWZvcmUbAAABn9TII8ZLb2ZmbGluZURheXMaAA9CPw==","signature":"MEQCIFHQzyRudRXO4MtZjTzit/evGvXk470bnocYxyJ4TXK4AiBRF4wSmnqscMa4uvhiohYfpioRWyLCr8/qx8rV5i/viQ==","algorithm":"sha256-ecdsa","assetList":[{"skuInfo":{"code":"community","name":"OpenTest Community","type":"EDITION","description_items":["2 Channels","Monitor & Generator","Basic FFT","Basic Octave","Basic Sweep"],"descriptionItems":["2 Channels","Monitor & Generator","Basic FFT","Basic Octave","Basic Sweep"],"features":[{"name":"Monitor"},{"name":"Generator"}]},"authorizationCode":"CKFR-SAX3-JSJ7-LZGN","expireTime":4926098090000,"isExpired":false}]} diff --git a/apps/backend/crydaq-server/src/main/resources/native/linux-amd64/OptDevHost b/apps/backend/crydaq-server/src/main/resources/native/linux-amd64/OptDevHost new file mode 100755 index 00000000..6ea0351b Binary files /dev/null and b/apps/backend/crydaq-server/src/main/resources/native/linux-amd64/OptDevHost differ diff --git a/apps/backend/crydaq-server/src/main/resources/native/linux-amd64/SHA256SUMS.txt b/apps/backend/crydaq-server/src/main/resources/native/linux-amd64/SHA256SUMS.txt new file mode 100644 index 00000000..20e34f2f --- /dev/null +++ b/apps/backend/crydaq-server/src/main/resources/native/linux-amd64/SHA256SUMS.txt @@ -0,0 +1,18 @@ +9fbd30ef46c5571f997383057216f3b7316d278a90b09420c227d39d22deffd3 BUILD-INFO.json +b14588066740b59efefed57fd951633f345fa2e80917e05ed6406d96a33cf8fa License.dat +3c74c12d2af4d3e330fe7cd6cc71c9c4c035266595bdd41f5c79c7f5c4d7fd62 OptDevHost +400f84e4173ff4ec4093dc237aec31e01c31d9c7a341abebe90a436a99117bf3 algorithm-build-info.json +89a0ee8ddad375620e78c763e47ab79ac36be8c764ec6eb164f0079d5fe4ddad libCRYAlgorithmLib.so +08b612241e28a6c73cc5287468f2b5a791ca93862e20e45ffb8f0d1c2572fd88 libCRYBluetoothLib.so +16ecfa299429cbbc203c062feb561ea2b47921c7542d8ed8597253415245b9ab libCRYJNIAudioProtocol.so +f1f1fba9768a3af2fcb13ccdfb138a1fbbe7c7107c95c1ad6dbfa536135d78ff libCRYSequenceLib.so +636986c712938e8320dbe0fd00ce3274ae1883a516f5ba2eaae1aa2d1bf72576 libCRYUnitConversion.so +d02cbf73bdf92103a94375905162081b9d3d5144c8602eb29a16c80d78945c8f libcry_analyst.so +5983b62a0457ddd46b5abb19a188155c7043326db8a28e14c94566e6b49409c8 libfftc3.so +03ea41a2e82fe6fc130a03feb2542d9674e37a1b6b6d1da61849f27191035710 libfftc3_threads.so +bb2b7637714aaed88bcd38592d99fc19471c1ab194bec548c5c7f99d90398844 libfront-algorithm.so +f9d33c02f192a9ea99856be5cc4562514a0d2b259f4947bdfb1521974984b5f6 libhidapi-hidraw.so.0 +dbec0bfe1b67cb83377ec329e8dfba19ad2ae09ca7432965b6adfb1e0c8f51a0 licenses/FFTC-LICENSE.txt +b6b55a19eaba3cd31be0b97880c5d9337aea4bd7d32aef92c0e1d9d94bd8c8fc licenses/hidapi/copyright +a85ca13fdf90160b64a0698215868c13b74d835ad0a4e2ba44713b8c5058a056 licenses/pocketfft-LICENSE.txt +3f4a38d1d88a3dd00bd582028f07cd8be906d71033e01a934156d2200c884f02 native-libs-load-order.txt diff --git a/apps/backend/crydaq-server/src/main/resources/native/linux-amd64/algorithm-build-info.json b/apps/backend/crydaq-server/src/main/resources/native/linux-amd64/algorithm-build-info.json new file mode 100644 index 00000000..3a00ef79 --- /dev/null +++ b/apps/backend/crydaq-server/src/main/resources/native/linux-amd64/algorithm-build-info.json @@ -0,0 +1,17 @@ +{ + "platform": "linux", + "architecture": "x64", + "configuration": "Release", + "sourceBranch": "sxp_dev (historical commit)", + "sourceCommit": "46a640bdc6d019ec4a51dbdef7f675d1c5700b06", + "builtAt": "2026-11-16T10:02:44.038001+00:00", + "authorizationVariant": "production", + "fftBackend": "FFTC", + "sourceTreeDirty": true, + "sourcePatchSha256": "7ceac54209f1bc16ba14df04f833655e0c1e8b077f7e6aefea49b52138fa6038", + "librarySha256": "d02cbf73bdf92103a94375905162081b9d3d5144c8602eb29a16c80d78945c8f", + "validation": { + "ctestPassed": true + }, + "patchProvenance": "OpenTest-NativeDriver/dependencies/algorithm/linux/algorithm-fftc.patch" +} diff --git a/apps/backend/crydaq-server/src/main/resources/native/linux-amd64/libCRYAlgorithmLib.so b/apps/backend/crydaq-server/src/main/resources/native/linux-amd64/libCRYAlgorithmLib.so new file mode 100644 index 00000000..b11a4b35 Binary files /dev/null and b/apps/backend/crydaq-server/src/main/resources/native/linux-amd64/libCRYAlgorithmLib.so differ diff --git a/apps/backend/crydaq-server/src/main/resources/native/linux-amd64/libCRYBluetoothLib.so b/apps/backend/crydaq-server/src/main/resources/native/linux-amd64/libCRYBluetoothLib.so new file mode 100644 index 00000000..48a5cde2 Binary files /dev/null and b/apps/backend/crydaq-server/src/main/resources/native/linux-amd64/libCRYBluetoothLib.so differ diff --git a/apps/backend/crydaq-server/src/main/resources/native/linux-amd64/libCRYJNIAudioProtocol.so b/apps/backend/crydaq-server/src/main/resources/native/linux-amd64/libCRYJNIAudioProtocol.so new file mode 100644 index 00000000..c4313ae2 Binary files /dev/null and b/apps/backend/crydaq-server/src/main/resources/native/linux-amd64/libCRYJNIAudioProtocol.so differ diff --git a/apps/backend/crydaq-server/src/main/resources/native/linux-amd64/libCRYSequenceLib.so b/apps/backend/crydaq-server/src/main/resources/native/linux-amd64/libCRYSequenceLib.so new file mode 100644 index 00000000..04f43893 Binary files /dev/null and b/apps/backend/crydaq-server/src/main/resources/native/linux-amd64/libCRYSequenceLib.so differ diff --git a/apps/backend/crydaq-server/src/main/resources/native/linux-amd64/libCRYUnitConversion.so b/apps/backend/crydaq-server/src/main/resources/native/linux-amd64/libCRYUnitConversion.so new file mode 100644 index 00000000..f0912c96 Binary files /dev/null and b/apps/backend/crydaq-server/src/main/resources/native/linux-amd64/libCRYUnitConversion.so differ diff --git a/apps/backend/crydaq-server/src/main/resources/native/linux-amd64/libcry_analyst.so b/apps/backend/crydaq-server/src/main/resources/native/linux-amd64/libcry_analyst.so new file mode 100644 index 00000000..e530eb5e Binary files /dev/null and b/apps/backend/crydaq-server/src/main/resources/native/linux-amd64/libcry_analyst.so differ diff --git a/apps/backend/crydaq-server/src/main/resources/native/linux-amd64/libfftc3.so b/apps/backend/crydaq-server/src/main/resources/native/linux-amd64/libfftc3.so new file mode 100644 index 00000000..4cc677ca Binary files /dev/null and b/apps/backend/crydaq-server/src/main/resources/native/linux-amd64/libfftc3.so differ diff --git a/apps/backend/crydaq-server/src/main/resources/native/linux-amd64/libfftc3_threads.so b/apps/backend/crydaq-server/src/main/resources/native/linux-amd64/libfftc3_threads.so new file mode 100644 index 00000000..1887c5c8 Binary files /dev/null and b/apps/backend/crydaq-server/src/main/resources/native/linux-amd64/libfftc3_threads.so differ diff --git a/apps/backend/crydaq-server/src/main/resources/native/linux-amd64/libfront-algorithm.so b/apps/backend/crydaq-server/src/main/resources/native/linux-amd64/libfront-algorithm.so new file mode 100644 index 00000000..6996eab4 Binary files /dev/null and b/apps/backend/crydaq-server/src/main/resources/native/linux-amd64/libfront-algorithm.so differ diff --git a/apps/backend/crydaq-server/src/main/resources/native/linux-amd64/libhidapi-hidraw.so.0 b/apps/backend/crydaq-server/src/main/resources/native/linux-amd64/libhidapi-hidraw.so.0 new file mode 100644 index 00000000..db27402c Binary files /dev/null and b/apps/backend/crydaq-server/src/main/resources/native/linux-amd64/libhidapi-hidraw.so.0 differ diff --git a/apps/backend/crydaq-server/src/main/resources/native/linux-amd64/licenses/FFTC-LICENSE.txt b/apps/backend/crydaq-server/src/main/resources/native/linux-amd64/licenses/FFTC-LICENSE.txt new file mode 100644 index 00000000..1cabf95d --- /dev/null +++ b/apps/backend/crydaq-server/src/main/resources/native/linux-amd64/licenses/FFTC-LICENSE.txt @@ -0,0 +1,28 @@ +BSD 3-Clause License + +Copyright (c) 2026 FFTC contributors + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. + +2. Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + +3. Neither the name of the copyright holder nor the names of its + contributors may be used to endorse or promote products derived from + this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE +FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/apps/backend/crydaq-server/src/main/resources/native/linux-amd64/licenses/hidapi/copyright b/apps/backend/crydaq-server/src/main/resources/native/linux-amd64/licenses/hidapi/copyright new file mode 100644 index 00000000..12005f0c --- /dev/null +++ b/apps/backend/crydaq-server/src/main/resources/native/linux-amd64/licenses/hidapi/copyright @@ -0,0 +1,142 @@ +Format: https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/ +Upstream-Name: hidapi +Source: https://github.com/libusb/hidapi +Comment: + HIDAPI can be used under one of three licenses. + . + 1. The GNU General Public License, version 3.0, in LICENSE-gpl3.txt + 2. A BSD-Style License, in LICENSE-bsd.txt. + 3. The more liberal original HIDAPI license. LICENSE-orig.txt + . + The license chosen is at the discretion of the user of HIDAPI. For example: + 1. An author of GPL software would likely use HIDAPI under the terms of the + GPL. + . + 2. An author of commercial closed-source software would likely use HIDAPI + under the terms of the BSD-style license or the original HIDAPI license. + +Files: * +Copyright: 2009-2013 Alan Ott + 2010-2013 Ludovic Rousseau +License: GPL-3.0 or BSD-3-clause or HIDAPI +Comment: + At the discretion of the user of this library, + this software may be licensed under the terms of the + GNU General Public License v3, a BSD-Style license, or the + original HIDAPI license as outlined in the LICENSE.txt, + LICENSE-gpl3.txt, LICENSE-bsd.txt, and LICENSE-orig.txt + files located at the root of the source distribution. + These files may also be found in the public source + code repository located at: + http://github.com/libusb/hidapi . + +Files: debian/* +Copyright: 2013-2014 Scott Talbert +License: HIDAPI + +Files: m4/pkg.m4 +Copyright: Copyright © 2004 Scott James Remnant +License: GPL-2+ + +Files: hidtest/test.c +Copyright: Copyright 2009, All Rights Reserved. +License: HIDAPI + +Files: m4/ax_pthread.m4 +Copyright: Copyright (c) 2008 Steven G. Johnson + Copyright (c) 2011 Daniel Richard G. +License: GPL-3+ with Autoconf exception + +License: HIDAPI + This software may be used by anyone for any reason so + long as the copyright notice in the source files + remains intact. + +License: BSD-3-clause + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: + . + * Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + * Neither the name of the original author nor the names of its + contributors may be used to endorse or promote products derived from + this software without specific prior written permission. + . + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + POSSIBILITY OF SUCH DAMAGE. + +License: GPL-3.0 + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, version 3 of the License. + . + This package 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 General Public License for more details. + . + You should have received a copy of the GNU General Public License + along with this program. If not, see . + . + On Debian systems, the complete text of the GNU General + Public License version 3 can be found in "/usr/share/common-licenses/GPL-3". + +License: GPL-3+ with Autoconf exception + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + . + This package 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 General Public License for more details. + . + You should have received a copy of the GNU General Public License + along with this program. If not, see . + . + On Debian systems, the complete text of the GNU General + Public License version 3 can be found in "/usr/share/common-licenses/GPL-3". + . + As a special exception, the respective Autoconf Macro's copyright owner + gives unlimited permission to copy, distribute and modify the configure + scripts that are the output of Autoconf when processing the Macro. You + need not follow the terms of the GNU General Public License when using + or distributing such scripts, even though portions of the text of the + Macro appear in them. The GNU General Public License (GPL) does govern + all other use of the material that constitutes the Autoconf Macro. + . + This special exception to the GPL applies to versions of the Autoconf + Macro released by the Autoconf Archive. When you make and distribute a + modified version of the Autoconf Macro, you may extend this special + exception to the GPL to apply to your modified version as well. + +License: GPL-2+ + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + . + This program 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 General Public License for more details. + . + You should have received a copy of the GNU General Public License along + with this program; if not, write to the Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + . + On Debian systems, the complete text of the GNU General + Public License version 2 can be found in "/usr/share/common-licenses/GPL-2". diff --git a/apps/backend/crydaq-server/src/main/resources/native/linux-amd64/licenses/pocketfft-LICENSE.txt b/apps/backend/crydaq-server/src/main/resources/native/linux-amd64/licenses/pocketfft-LICENSE.txt new file mode 100644 index 00000000..c3a4c06a --- /dev/null +++ b/apps/backend/crydaq-server/src/main/resources/native/linux-amd64/licenses/pocketfft-LICENSE.txt @@ -0,0 +1,25 @@ +Copyright (C) 2010-2018 Max-Planck-Society +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: + +* Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. +* Redistributions in binary form must reproduce the above copyright notice, this + list of conditions and the following disclaimer in the documentation and/or + other materials provided with the distribution. +* Neither the name of the copyright holder nor the names of its contributors may + be used to endorse or promote products derived from this software without + specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON +ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/apps/backend/crydaq-server/src/main/resources/native/linux-amd64/native-libs-load-order.txt b/apps/backend/crydaq-server/src/main/resources/native/linux-amd64/native-libs-load-order.txt new file mode 100644 index 00000000..f4a82e73 --- /dev/null +++ b/apps/backend/crydaq-server/src/main/resources/native/linux-amd64/native-libs-load-order.txt @@ -0,0 +1,8 @@ +libfftc3.so +libfftc3_threads.so +libcry_analyst.so +libCRYUnitConversion.so +libCRYAlgorithmLib.so +libCRYJNIAudioProtocol.so +libCRYBluetoothLib.so +libCRYSequenceLib.so diff --git a/apps/backend/opentest-plugin-runtime/src/main/java/com/opentest/runtime/PluginManifest.java b/apps/backend/opentest-plugin-runtime/src/main/java/com/opentest/runtime/PluginManifest.java index 51e4277c..30affb99 100644 --- a/apps/backend/opentest-plugin-runtime/src/main/java/com/opentest/runtime/PluginManifest.java +++ b/apps/backend/opentest-plugin-runtime/src/main/java/com/opentest/runtime/PluginManifest.java @@ -106,7 +106,9 @@ private static void validateAudio(ObjectNode manifest) { equal(entry.path("apiVersion"), "opentest-device-1", "设备接口版本"); if (!entry.path("abiVersion").isIntegralNumber() || !entry.path("abiVersion").canConvertToInt() || entry.path("abiVersion").intValue() != 65536) throw new PluginFailure("CONTRACT_VERSION_UNSUPPORTED", "设备 ABI 版本不受支持"); - equal(entry.path("platform"), "windows-amd64", "设备平台"); + if (!entry.path("platform").isTextual() + || !Set.of("windows-amd64", "linux-amd64", "macos-arm64").contains(entry.path("platform").asText())) + throw new PluginFailure("CONTRACT_VERSION_UNSUPPORTED", "设备平台不受支持"); String prefix = "native/" + entry.path("platform").asText() + "/"; if (!relativePath(JsonFiles.requiredText(entry, "manifest")).equals(prefix + "plugin-package.json") || !relativePath(JsonFiles.requiredText(entry, "entry")).startsWith(prefix)) diff --git a/apps/backend/opentest-plugin-runtime/src/test/java/com/opentest/manager/PluginPackageManagerTest.java b/apps/backend/opentest-plugin-runtime/src/test/java/com/opentest/manager/PluginPackageManagerTest.java index 074e2da7..9c498cb1 100644 --- a/apps/backend/opentest-plugin-runtime/src/test/java/com/opentest/manager/PluginPackageManagerTest.java +++ b/apps/backend/opentest-plugin-runtime/src/test/java/com/opentest/manager/PluginPackageManagerTest.java @@ -9,6 +9,7 @@ import org.junit.jupiter.params.provider.ValueSource; import com.opentest.runtime.JsonFiles; import com.opentest.runtime.PluginFailure; +import com.opentest.runtime.PluginManifest; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; @@ -122,6 +123,23 @@ void rejectsUnknownKindsAndInvalidAudioContracts(String change) throws Exception assertStagingEmpty(); } + @ParameterizedTest + @ValueSource(strings = {"windows-amd64", "linux-amd64", "macos-arm64"}) + void audioPackagePreviewAcceptsSupportedPlatformAndChecksEntryPrefix(String platform) throws Exception { + var files = audioPayload(); + var manifest = (ObjectNode) JsonFiles.JSON.readTree(files.get("plugin.json")); + var entry = (ObjectNode) manifest.path("entryPoints").path("backend").path("native"); + entry.put("platform", platform); + entry.put("manifest", "native/" + platform + "/plugin-package.json"); + entry.put("entry", "native/" + platform + "/driver.dll"); + files.put("native/" + platform + "/plugin-package.json", files.remove("native/windows-amd64/plugin-package.json")); + files.put("native/" + platform + "/driver.dll", files.remove("native/windows-amd64/driver.dll")); + files.put("plugin.json", JsonFiles.JSON.writeValueAsBytes(manifest)); + assertTrue(manager().previewPackage(stream(zip(withHashes(files), 0))).path("valid").asBoolean()); + entry.put("entry", "native/other/driver.dll"); + assertEquals("ENTRY_PATH_INVALID", assertThrows(PluginFailure.class, () -> PluginManifest.validate(manifest)).code()); + } + private static Map audioPayload() throws IOException { var files = payload(); files.keySet().removeIf(name -> name.startsWith("frontend/") || name.startsWith("backend/")); var manifest = (ObjectNode) JsonFiles.JSON.readTree(files.get("plugin.json")); manifest.put("pluginKind", "audio-device"); diff --git a/apps/desktop/packages/native-modules/scripts/posix-algorithm.js b/apps/desktop/packages/native-modules/scripts/posix-algorithm.js index 036d2205..8e2e4f02 100644 --- a/apps/desktop/packages/native-modules/scripts/posix-algorithm.js +++ b/apps/desktop/packages/native-modules/scripts/posix-algorithm.js @@ -8,25 +8,25 @@ function resolveInputs({ projectRoot, env = process.env, platform = process.plat if (!['darwin', 'linux'].includes(platform)) throw new Error(`Unsupported POSIX native build: ${platform}/${arch}`) const nativePlatform = resolveNativePlatform({ platform, arch }) const repository = path.resolve(projectRoot, '../..') - const variant = env.OPENTEST_ALGORITHM_VARIANT || (platform === 'darwin' ? 'production' : 'test') + const variant = env.OPENTEST_ALGORITHM_VARIANT || 'production' if (!['test', 'production'].includes(variant)) throw new Error(`Invalid algorithm variant: ${variant}`) - if (platform === 'darwin' && variant !== 'production') throw new Error('macOS application runtime requires the production algorithm') + if (variant !== 'production') throw new Error('POSIX application runtime requires the production algorithm') const root = path.resolve(env.OPENTEST_PACKAGING_NATIVE || env[platform === 'darwin' ? 'OPENTEST_MAC_NATIVE' : 'OPENTEST_LINUX_NATIVE'] || path.join(repository, 'apps/backend/crydaq-server/src/main/resources/native', nativePlatform)) const analyst = platform === 'darwin' ? 'libcry_analyst.dylib' : 'libcry_analyst.so' - const library = path.join(root, variant === 'production' && platform !== 'darwin' ? 'prd' : '', analyst) + const library = path.join(root, analyst) const files = algorithmLibraries(platform) .map(name => name === analyst ? library : path.join(root, name)) for (const file of files) { const stat = fs.statSync(file, { throwIfNoEntry: false }) if (!stat?.isFile() || !stat.size) throw new Error(`Missing or invalid prebuilt native algorithm input: ${file}; provide runtime binary materials for ${nativePlatform}/${variant}`) } - if (platform === 'darwin') { + { const metadata = path.join(root, 'algorithm-build-info.json') const info = JSON.parse(fs.readFileSync(metadata, 'utf8')) const digest = crypto.createHash('sha256').update(fs.readFileSync(library)).digest('hex') if (info.authorizationVariant !== variant || info.platform !== platform || info.architecture !== arch || info.librarySha256 !== digest) { - throw new Error('macOS algorithm variant/platform/checksum mismatch') + throw new Error('POSIX algorithm variant/platform/checksum mismatch') } files.push(metadata) } diff --git a/apps/desktop/packages/native-modules/test/algorithm_loader_failures.test.js b/apps/desktop/packages/native-modules/test/algorithm_loader_failures.test.js index 0e223162..3b9d18a3 100644 --- a/apps/desktop/packages/native-modules/test/algorithm_loader_failures.test.js +++ b/apps/desktop/packages/native-modules/test/algorithm_loader_failures.test.js @@ -58,8 +58,7 @@ test('reports a stable load error when cry_analyst.dll is missing', () => { }) test('reports a stable load error when the configured FFT dependency is missing', () => { - const dependency = process.platform === 'linux' ? 'libfftw3.so.3' - : (process.platform === 'win32' ? '' : 'lib') + 'fftc3' + nativeExtension + const dependency = (process.platform === 'win32' ? '' : 'lib') + 'fftc3' + nativeExtension assert.ok(require('../../../src/config/algorithm-libraries').algorithmLibraries().includes(dependency)) const error = runIsolated(vendorFilesExcept(dependency)) assert.equal(error.code, 'FRONT_ALGORITHM_DLL_LOAD_FAILED') diff --git a/apps/desktop/src/config/algorithm-libraries.js b/apps/desktop/src/config/algorithm-libraries.js index 13dbc2bf..6aa90895 100644 --- a/apps/desktop/src/config/algorithm-libraries.js +++ b/apps/desktop/src/config/algorithm-libraries.js @@ -4,7 +4,7 @@ const libraries = Object.freeze({ darwin: ['libfront-algorithm.dylib', 'libCRYUnitConversion.dylib', 'libcry_analyst.dylib', 'libfftc3.dylib'], linux: ['libfront-algorithm.so', 'libCRYUnitConversion.so', 'libcry_analyst.so', - 'libfftw3.so.3', 'libfftw3_threads.so.3'] + 'libfftc3.so', 'libfftc3_threads.so'] }) function algorithmLibraries(platform = process.platform) { diff --git a/apps/desktop/src/config/native-platform.js b/apps/desktop/src/config/native-platform.js index 5ac42ead..674376da 100644 --- a/apps/desktop/src/config/native-platform.js +++ b/apps/desktop/src/config/native-platform.js @@ -3,7 +3,7 @@ const fs = require('node:fs') const platforms = { 'windows-amd64': { nodePlatform: 'win32', nodeArch: 'x64', analystLibrary: 'cry_analyst.dll', licenseRequired: true }, - 'linux-amd64': { nodePlatform: 'linux', nodeArch: 'x64', analystLibrary: 'libcry_analyst.so', licenseRequired: false }, + 'linux-amd64': { nodePlatform: 'linux', nodeArch: 'x64', analystLibrary: 'libcry_analyst.so', licenseRequired: true }, 'macos-arm64': { nodePlatform: 'darwin', nodeArch: 'arm64', analystLibrary: 'libcry_analyst.dylib', licenseRequired: true } } @@ -21,8 +21,8 @@ function nativePlatformSettings(nativePlatform = 'windows-amd64') { function resolveNativeMaterials(resourcesRoot, nativePlatform = resolveNativePlatform()) { nativePlatformSettings(nativePlatform) const backendNative = path.join(resourcesRoot, 'native', nativePlatform) - // Windows and macOS ship one production algorithm and its paired license in the platform root. - const backendNativeOverrides = ['windows-amd64', 'macos-arm64'].includes(nativePlatform) ? backendNative : path.join(backendNative, 'prd') + // Application runtimes ship the production algorithm and paired license in the platform root. + const backendNativeOverrides = backendNative return { nativePlatform, backendNative, backendNativeOverrides } } diff --git a/tools/__tests__/packaging-platforms.test.mjs b/tools/__tests__/packaging-platforms.test.mjs index a32287f2..e8997913 100644 --- a/tools/__tests__/packaging-platforms.test.mjs +++ b/tools/__tests__/packaging-platforms.test.mjs @@ -133,18 +133,18 @@ function nativeMaterials(root, platform) { const target = resolvePackagingPlatform(platform), native = path.join(root, 'materials', target.nativePlatform) const extension = platform === 'mac' ? '.dylib' : '.so' for (const name of algorithmLibraries(target.nodePlatform)) put(path.join(native, name), `test ${name}`) - put(path.join(native, platform === 'mac' ? '' : 'prd', platform === 'mac' ? 'libcry_analyst.dylib' : 'libcry_analyst.so'), 'production analyst') - if (platform === 'mac') put(path.join(native, 'License.dat'), 'production license') + put(path.join(native, '', platform === 'mac' ? 'libcry_analyst.dylib' : 'libcry_analyst.so'), 'production analyst') + put(path.join(native, 'License.dat'), 'production license') for (const name of ['CRYAlgorithmLib', 'CRYJNIAudioProtocol', 'CRYSequenceLib']) { put(path.join(native, `lib${name}${extension}`), 'Java_com_opentest_core_jni_current') } put(path.join(native, `libCRYJNIAudioProtocol${extension}`), 'Java_com_opentest_core_jni_AudioDevicePluginJNIBridge_prepareManagedRuntime') put(path.join(native, 'OptDevHost'), 'prebuilt host') put(path.join(native, 'native-libs-load-order.txt'), `libcry_analyst${extension}\n`) - for (const mode of ['production']) if (platform === 'mac') { - const library = path.join(native, 'libcry_analyst.dylib') + for (const mode of ['production']) { + const library = path.join(native, platform === 'mac' ? 'libcry_analyst.dylib' : 'libcry_analyst.so') put(path.join(native, 'algorithm-build-info.json'), JSON.stringify({ - authorizationVariant: mode, platform: 'darwin', architecture: 'arm64', + authorizationVariant: mode, platform: target.nodePlatform, architecture: target.arch, librarySha256: createHash('sha256').update(readFileSync(library)).digest('hex') })) } @@ -155,17 +155,16 @@ function desktopRoot(root) { return path.join(root, 'host/apps/desktop') } -for (const platform of ['mac', 'linux']) for (const mode of (platform === 'mac' ? ['production'] : ['test', 'production'])) { +for (const platform of ['mac', 'linux']) for (const mode of ['production']) { test(`${platform}/${mode} stages prebuilt JNI, Host and algorithms without JNI sources or default device plugins`, t => { const root = fixture(t) desktopRoot(root) const { native, target, extension } = nativeMaterials(root, platform) - put(path.join(native, 'License.dat'), platform === 'mac' ? 'production license' : 'test license') - if (platform !== 'mac') put(path.join(native, 'prd/License.dat'), 'production license') + put(path.join(native, 'License.dat'), 'production license') put(path.join(native, 'device-data.json'), '{"keep":true}') for (const name of ['ot-plugin-manager', 'ot-plugin-status', 'qt/Qt5.so', 'qt.conf', 'PLUGIN-MANAGER.md', 'PLUGIN-STATUS.md', 'plugins/devices/optional.so', 'Plugs/devices/optional.so']) put(path.join(native, name), 'private tool or optional plugin') const config = preparePosixNative({ nativePlatform: target.nativePlatform, platform, mode, backendNative: native, - backendNativeOverrides: platform === 'mac' ? native : path.join(native, 'prd') }, path.join(root, 'stage')) + backendNativeOverrides: native }, path.join(root, 'stage')) assert.equal(readFileSync(path.join(config.backendNative, 'OptDevHost'), 'utf8'), 'prebuilt host') assert.equal(readFileSync(path.join(config.backendNative, `libCRYAlgorithmLib${extension}`), 'utf8'), 'Java_com_opentest_core_jni_current') assert.equal(readFileSync(path.join(config.backendNative, `libcry_analyst${extension}`), 'utf8'), mode === 'production' ? 'production analyst' : `test libcry_analyst${extension}`) @@ -178,8 +177,8 @@ for (const platform of ['mac', 'linux']) for (const mode of (platform === 'mac' const desktopInputs = resolveInputs({ projectRoot: path.join(root, 'host/apps/desktop'), platform: target.nodePlatform, arch: target.arch, env: { OPENTEST_PACKAGING_NATIVE: config.backendNative, OPENTEST_ALGORITHM_VARIANT: mode } }) assert.deepEqual(readFileSync(desktopInputs.library), readFileSync(path.join(config.backendNative, `libcry_analyst${extension}`))) - assert.equal(readFileSync(path.join(native, `libcry_analyst${extension}`), 'utf8'), platform === 'mac' ? 'production analyst' : `test libcry_analyst${extension}`) - if (platform === 'mac') assert.equal(existsSync(path.join(config.backendNative, 'prd')), false) + assert.equal(readFileSync(path.join(native, `libcry_analyst${extension}`), 'utf8'), 'production analyst') + assert.equal(existsSync(path.join(config.backendNative, 'prd')), false) assert.equal(readFileSync(path.join(config.backendNative, 'device-data.json'), 'utf8'), '{"keep":true}') for (const name of ['ot-plugin-manager', 'ot-plugin-status', 'qt', 'qt.conf', 'PLUGIN-MANAGER.md', 'PLUGIN-STATUS.md', 'plugins/devices', 'Plugs/devices']) assert.equal(existsSync(path.join(config.backendNative, name)), false, name) }) @@ -190,8 +189,8 @@ for (const platform of ['mac', 'linux']) { const root = fixture(t) desktopRoot(root) const { native, target, extension } = nativeMaterials(root, platform) - const config = { nativePlatform: target.nativePlatform, mode: platform === 'mac' ? 'production' : 'test', backendNative: native, - ...(platform === 'mac' ? { backendNativeOverrides: native } : {}) } + const config = { nativePlatform: target.nativePlatform, mode: 'production', backendNative: native, + backendNativeOverrides: native } let attempt = 0 const prepare = () => preparePosixNative(config, path.join(root, `stage-${attempt++}`)) for (const name of ['OptDevHost', `libfront-algorithm${extension}`, `libCRYUnitConversion${extension}`, `libCRYSequenceLib${extension}`]) { @@ -218,8 +217,8 @@ for (const platform of ['mac', 'linux']) { const { native, target } = nativeMaterials(root, platform) const platformKey = platform === 'mac' ? 'OPENTEST_MAC_NATIVE' : 'OPENTEST_LINUX_NATIVE' const resolve = env => resolveInputs({ projectRoot, platform: target.nodePlatform, arch: target.arch, env }) - for (const variant of (platform === 'mac' ? ['production'] : ['test', 'production'])) { - const selected = variant === 'production' && platform !== 'mac' ? 'prd' : '' + for (const variant of ['production']) { + const selected = '' const inputs = resolve({ OPENTEST_PACKAGING_NATIVE: native, [platformKey]: '/missing/lower-priority', OPENTEST_ALGORITHM_VARIANT: variant }) assert.equal(inputs.vendorDir, native) assert.equal(inputs.library, path.join(native, selected, platform === 'mac' ? 'libcry_analyst.dylib' : 'libcry_analyst.so')) @@ -245,17 +244,17 @@ for (const platform of ['mac', 'linux']) { rmSync(file, { recursive: true }) put(file, original) } - const productionLibrary = path.join(native, platform === 'mac' ? '' : 'prd', platform === 'mac' ? 'libcry_analyst.dylib' : 'libcry_analyst.so') + const productionLibrary = path.join(native, '', platform === 'mac' ? 'libcry_analyst.dylib' : 'libcry_analyst.so') rmSync(productionLibrary) assert.throws(() => resolve({ OPENTEST_PACKAGING_NATIVE: native, OPENTEST_ALGORITHM_VARIANT: 'production' }), /prebuilt native algorithm input/) }) } -test('macOS keeps variant, platform, architecture and checksum validation for prebuilt analysis libraries', t => { - const root = fixture(t), { native } = nativeMaterials(root, 'mac') +for (const platform of ['mac', 'linux']) test(`${platform} keeps variant, platform, architecture and checksum validation for prebuilt analysis libraries`, t => { + const root = fixture(t), { native, target } = nativeMaterials(root, platform) const metadata = path.join(native, 'algorithm-build-info.json'), original = JSON.parse(readFileSync(metadata)) - const resolve = () => resolveInputs({ projectRoot: path.join(root, 'host/apps/desktop'), platform: 'darwin', arch: 'arm64', env: { OPENTEST_PACKAGING_NATIVE: native } }) - for (const [key, value] of Object.entries({ authorizationVariant: 'test', platform: 'linux', architecture: 'x64', librarySha256: 'old' })) { + const resolve = () => resolveInputs({ projectRoot: path.join(root, 'host/apps/desktop'), platform: target.nodePlatform, arch: target.arch, env: { OPENTEST_PACKAGING_NATIVE: native } }) + for (const [key, value] of Object.entries({ authorizationVariant: 'test', platform: platform === 'mac' ? 'linux' : 'darwin', architecture: platform === 'mac' ? 'x64' : 'arm64', librarySha256: 'old' })) { put(metadata, JSON.stringify({ ...original, [key]: value })) assert.throws(resolve, /variant\/platform\/checksum mismatch/) } @@ -302,7 +301,7 @@ function prebuiltAddon(t, platform, variant) { return { addon, native, calls, target, build: load(variant), load } } -for (const platform of ['mac', 'linux']) for (const variant of (platform === 'mac' ? ['production'] : ['test', 'production'])) { +for (const platform of ['mac', 'linux']) for (const variant of ['production']) { test(`${platform}/${variant} addon builds only repository code and stages selected runtime bytes`, t => { const { addon, native, calls, target, build, load } = prebuiltAddon(t, platform, variant) assert.equal(build.isBuilt(), false) @@ -314,24 +313,14 @@ for (const platform of ['mac', 'linux']) for (const variant of (platform === 'ma assert.equal(load(variant).isBuilt(), true) const analyst = platform === 'mac' ? 'libcry_analyst.dylib' : 'libcry_analyst.so' for (const name of algorithmLibraries(target.nodePlatform)) { - assert.deepEqual(readFileSync(path.join(addon, 'dist/algorithm-bridge', name)), readFileSync(path.join(native, variant === 'production' && platform !== 'mac' && name === analyst ? 'prd' : '', name))) + assert.deepEqual(readFileSync(path.join(addon, 'dist/algorithm-bridge', name)), readFileSync(path.join(native, '', name))) } - if (platform === 'mac') assert.throws(() => load('test'), /requires the production algorithm/) - else assert.equal(load(variant === 'test' ? 'production' : 'test').isBuilt(), false) + assert.throws(() => load('test'), /requires the production algorithm/) put(path.join(native, platform === 'mac' ? 'libCRYUnitConversion.dylib' : 'libCRYUnitConversion.so'), 'updated prebuilt conversion') assert.equal(load(variant).isBuilt(), false) }) } -test('addon cache separates identical test and production analysis bytes', t => { - const { native, load } = prebuiltAddon(t, 'linux', 'test') - put(path.join(native, 'prd/libcry_analyst.so'), readFileSync(path.join(native, 'libcry_analyst.so'))) - const build = load('test') - build.build() - assert.equal(load('test').isBuilt(), true) - assert.equal(load('production').isBuilt(), false) -}) - test('Windows addon keeps vendor DLLs and public node-gyp builds independent of POSIX and private materials', t => { const { addon, native, calls, build, load } = prebuiltAddon(t, 'windows', 'test') build.build() @@ -350,18 +339,18 @@ test('missing prebuilt algorithms fail without a source-build fallback', t => { assert.throws(() => resolveInputs({ projectRoot, platform: 'linux', arch: 'x64', env: { OPENTEST_PACKAGING_NATIVE: native } }), /prebuilt native algorithm input.*libfront-algorithm/) - assert.throws(() => preparePosixNative({ nativePlatform: 'linux-amd64', mode: 'test', backendNative: native }, path.join(root, 'stage')), /算法预编译材料.*libfront-algorithm/) + assert.throws(() => preparePosixNative({ nativePlatform: 'linux-amd64', mode: 'production', backendNative: native, backendNativeOverrides: native }, path.join(root, 'stage')), /算法预编译材料.*libfront-algorithm/) }) -test('macOS packaging rejects non-production modes before staging and requires a nonempty root license', t => { +for (const platform of ['mac', 'linux']) test(`${platform} packaging rejects non-production modes before staging and requires a nonempty root license`, t => { const root = fixture(t) - const { native, target } = nativeMaterials(root, 'mac') + const { native, target } = nativeMaterials(root, platform) let attempt = 0 const prepare = mode => preparePosixNative({ nativePlatform: target.nativePlatform, mode, backendNative: native, backendNativeOverrides: native }, path.join(root, `stage-license-${attempt++}`)) for (const mode of ['test', undefined, 'invalid']) { - assert.throws(() => prepare(mode), /macOS application runtime requires the production algorithm/) + assert.throws(() => prepare(mode), /application runtime requires the production algorithm/) } const license = path.join(native, 'License.dat') rmSync(license) diff --git a/tools/__tests__/packaging.test.mjs b/tools/__tests__/packaging.test.mjs index c13cebac..61da273a 100644 --- a/tools/__tests__/packaging.test.mjs +++ b/tools/__tests__/packaging.test.mjs @@ -389,21 +389,21 @@ test('正式源码并发启动使用独立暂存目录,仅清理自身材料', assert.equal(readFileSync(path.join(second.backendNative, 'cry_analyst.dll'), 'utf8'), 'production DLL') }) -test('Linux 正式源码只覆盖所选平台的 prd,不携带测试许可证或 Windows 材料', t => { +test('Linux 正式源码使用根目录生产库和授权,不携带旧 prd 或 Windows 材料', t => { const root = fixture(t) nativeFixture(root) const native = path.join(root, 'native/linux-amd64') mkdirSync(path.join(native, 'prd'), { recursive: true }) writeFileSync(path.join(native, 'native-libs-load-order.txt'), 'libcry_analyst.so\n') - writeFileSync(path.join(native, 'libcry_analyst.so'), 'linux test') - writeFileSync(path.join(native, 'License.dat'), 'optional test-only license') - writeFileSync(path.join(native, 'prd/libcry_analyst.so'), 'linux production') + writeFileSync(path.join(native, 'libcry_analyst.so'), 'linux production') + writeFileSync(path.join(native, 'License.dat'), 'production license') + writeFileSync(path.join(native, 'prd/libcry_analyst.so'), 'obsolete bytes') const stage = prepareSourceBackendNative({ services: { environment: 'production' }, nativeMaterialsRoot: root, nativePlatform: 'linux-amd64', runtime: path.join(root, 'runtime') }) t.after(stage.cleanup) assert.equal(readFileSync(path.join(stage.backendNative, 'libcry_analyst.so'), 'utf8'), 'linux production') assert.equal(existsSync(path.join(stage.backendNative, 'cry_analyst.dll')), false) - assert.equal(existsSync(path.join(stage.backendNative, 'License.dat')), false) + assert.equal(readFileSync(path.join(stage.backendNative, 'License.dat'), 'utf8'), 'production license') assert.equal(existsSync(path.join(stage.backendNative, 'prd')), false) }) @@ -415,7 +415,7 @@ test('所选平台缺少正式覆盖时明确失败,不使用其他平台或 writeFileSync(path.join(native, 'native-libs-load-order.txt'), 'libcry_analyst.dylib\n') writeFileSync(path.join(native, 'libcry_analyst.dylib'), 'mac test') assert.throws(() => prepareSourceBackendNative({ services: { environment: 'production' }, nativeMaterialsRoot: root, - nativePlatform: 'macos-arm64', runtime: path.join(root, 'runtime') }), /正式.*覆盖.*macos-arm64/) + nativePlatform: 'macos-arm64', runtime: path.join(root, 'runtime') }), /许可证.*macos-arm64/) assert.equal(existsSync(path.join(root, 'runtime')), false) }) diff --git a/tools/package-posix-native.mjs b/tools/package-posix-native.mjs index f6106ca1..c1959c47 100644 --- a/tools/package-posix-native.mjs +++ b/tools/package-posix-native.mjs @@ -1,5 +1,5 @@ import path from 'node:path' -import { cpSync, mkdirSync, readFileSync, statSync } from 'node:fs' +import { readFileSync } from 'node:fs' import { createRequire } from 'node:module' import { stageBackendNative, assertFile } from './packaging.mjs' const require = createRequire(import.meta.url) @@ -9,7 +9,7 @@ const { algorithmLibraries } = require('../apps/desktop/src/config/algorithm-lib export function preparePosixNative(config, stage) { const { nodePlatform } = nativePlatformSettings(config.nativePlatform) if (!['darwin', 'linux'].includes(nodePlatform)) throw new Error(`不支持的 POSIX 材料平台:${config.nativePlatform}`) - if (nodePlatform === 'darwin' && config.mode !== 'production') throw new Error('macOS application runtime requires the production algorithm') + if (config.mode !== 'production') throw new Error('POSIX application runtime requires the production algorithm') const extension = nodePlatform === 'darwin' ? '.dylib' : '.so' const native = path.join(stage, 'native-posix') stageBackendNative(config, native) @@ -22,13 +22,7 @@ export function preparePosixNative(config, stage) { if (!protocol.includes(Buffer.from('Java_com_opentest_core_jni_AudioDevicePluginJNIBridge_prepareManagedRuntime'))) throw new Error(`POSIX JNI 预编译材料过时,缺少 prepareManagedRuntime 受管运行接口:${path.join(native, `libCRYJNIAudioProtocol${extension}`)};请提供匹配当前宿主的运行材料`) for (const name of algorithmLibraries(nodePlatform)) assertFile(path.join(native, name), 'POSIX 算法预编译材料') assertFile(path.join(native, 'OptDevHost'), 'POSIX 设备 Host 预编译材料') - if (nodePlatform === 'darwin') assertFile(path.join(native, 'License.dat'), 'macOS production license') - const overrides = nodePlatform === 'darwin' ? native : path.join(native, 'prd') - if (config.mode === 'production' && nodePlatform !== 'darwin') { - mkdirSync(overrides, { recursive: true }) - cpSync(path.join(native, `libcry_analyst${extension}`), path.join(overrides, `libcry_analyst${extension}`)) - const license = path.join(native, 'License.dat') - if (statSync(license, { throwIfNoEntry: false })?.isFile()) cpSync(license, path.join(overrides, 'License.dat')) - } + assertFile(path.join(native, 'License.dat'), 'POSIX production license') + const overrides = native return { ...config, backendNative: native, backendNativeOverrides: overrides } } diff --git a/tools/package.mjs b/tools/package.mjs index fb9f2034..26db19bb 100644 --- a/tools/package.mjs +++ b/tools/package.mjs @@ -252,7 +252,7 @@ export async function packageHost({ mode, kind, sign = false, platform = current const run = (args) => waitForExit( spawnCommand(process.platform === 'win32' ? 'pnpm.cmd' : 'pnpm', args, { cwd: repositoryRoot, stdio: "inherit", - env: { ...process.env, OPENTEST_ALGORITHM_VARIANT: mode, OPENTEST_PACKAGING_NATIVE: config.backendNative } }), + env: { ...process.env, OPENTEST_ALGORITHM_VARIANT: config.nativePlatform === 'windows-amd64' ? mode : 'production', OPENTEST_PACKAGING_NATIVE: config.backendNative } }), ); let packagedApplication; const artifacts = await runDelivery(targets, { diff --git a/tools/verify-linux-native.py b/tools/verify-linux-native.py new file mode 100644 index 00000000..b7a4b942 --- /dev/null +++ b/tools/verify-linux-native.py @@ -0,0 +1,85 @@ +"""Verify production Linux AMD64 ELF materials and javac-generated JNI bindings.""" +import argparse +import ctypes +import hashlib +import json +import os +from pathlib import Path +import re +import runpy +import subprocess +import tempfile + +helpers = runpy.run_path(str(Path(__file__).with_name('verify-macos-native.py'))) + + +def verify_payload(root): + if (root / 'prd').exists() or list(root.glob('*fftw*')): + raise ValueError('Expected flat production FFTC runtime') + info = json.loads((root / 'algorithm-build-info.json').read_text()) + if tuple(info.get(k) for k in ('authorizationVariant', 'platform', 'architecture', 'fftBackend')) != ('production', 'linux', 'x64', 'FFTC'): + raise ValueError('Incorrect algorithm variant/platform/FFT metadata') + if hashlib.sha256((root / 'libcry_analyst.so').read_bytes()).hexdigest() != info['librarySha256']: + raise ValueError('Algorithm metadata checksum mismatch') + required = {p.name for p in root.glob('*.so*')} | {'OptDevHost', 'License.dat'} + covered = set() + for line in (root / 'SHA256SUMS.txt').read_text().splitlines(): + digest, name = line.split(' ', 1) + relative = Path(name) + if relative.is_absolute() or '..' in relative.parts or name in covered: + raise ValueError('Unsafe or duplicate checksum path: ' + name) + if hashlib.sha256((root / relative).read_bytes()).hexdigest() != digest: + raise ValueError('Checksum mismatch: ' + name) + covered.add(name) + if not required <= covered or not (root / 'License.dat').stat().st_size: + raise ValueError('Incomplete runtime checksums/license') + symbols = set() + versions = set() + for name in sorted(required - {'License.dat'}): + binary = root / name + header = subprocess.check_output(['readelf', '-h', str(binary)], text=True) + if 'ELF64' not in header or 'Advanced Micro Devices X86-64' not in header: + raise ValueError('Not AMD64 ELF: ' + name) + if re.search(rb'/Users/|/home/|[A-Za-z]:\\Users\\', binary.read_bytes()): + raise ValueError('Developer path in binary: ' + name) + dynamic = subprocess.check_output(['readelf', '-d', str(binary)], text=True) + if 'fftw' in dynamic.lower() or re.search(r'\((?:RUNPATH|RPATH)\).*\[/', dynamic): + raise ValueError('FFTW/absolute search path: ' + name) + linked = subprocess.check_output(['ldd', str(binary)], text=True) + if 'not found' in linked or 'fftw' in linked.lower(): + raise ValueError('Dependency closure failed: ' + name + '\n' + linked) + versions.update(re.findall(r'\b(?:GLIBC|GLIBCXX|CXXABI)_[\d.]+', subprocess.check_output(['readelf', '-V', str(binary)], text=True))) + if '.so' in name: + symbols.update(line.split()[-1].split('@')[0] for line in subprocess.check_output(['nm', '-D', '--defined-only', str(binary)], text=True).splitlines() if line.split()) + ctypes.CDLL(str(binary)) + return symbols, sorted(versions) + + +def main(): + repo = Path(__file__).resolve().parents[1] + parser = argparse.ArgumentParser(description=__doc__) + parser.add_argument('--native', type=Path, default=repo / 'apps/backend/crydaq-server/src/main/resources/native/linux-amd64') + parser.add_argument('--class-path', required=True) + parser.add_argument('--windows-native', type=Path) + parser.add_argument('--smoke', action='store_true') + args = parser.parse_args() + root = args.native.resolve() + actual, versions = verify_payload(root) + with tempfile.TemporaryDirectory(prefix='opentest-linux-jni-') as directory: + expected, algorithm, classes = helpers['generate_jni_headers'](repo, args.class_path, Path(directory)) + helpers['require_exports'](expected, actual, 'Linux') + if args.windows_native: + helpers['require_exports'](algorithm, helpers['windows_exports'](repo, args.windows_native.resolve()), 'Windows algorithm') + if args.smoke: + source = (repo / 'tools/__tests__/fixtures/macos-native/MacJniSmoke.java').read_text().replace('MacJniSmoke', 'LinuxJniSmoke').replace('.dylib', '.so') + source = source.replace('ok(bridge.authorizeAlgorithm(args[1]), "authorize");', 'ok(bridge.authorizeAlgorithm(args[1]), "authorize"); ok(new LicenseJNIBridge().clearLicense(), "clear and restore default license");') + fixture = Path(directory) / 'LinuxJniSmoke.java' + fixture.write_text(source) + cp = str(classes) + os.pathsep + args.class_path + subprocess.run([helpers['jdk_tool']('javac'), '-proc:none', '-cp', cp, '-d', str(classes), str(fixture)], check=True) + subprocess.run([helpers['jdk_tool']('java'), '-Xcheck:jni', '-cp', cp, 'LinuxJniSmoke', str(root), str(root / 'License.dat'), '--default-license'], check=True) + print(json.dumps({'jniDeclarations': len(expected), 'algorithmDeclarations': len(algorithm), 'elfExportsChecked': True, 'requiredSymbolVersions': versions}, indent=2)) + + +if __name__ == '__main__': + main()