A full-featured download manager.
fix(linux): unify native package names as motrix (#2427)
Dr_rOot39bfcfc10f11
diff --git a/.github/workflows/release.yml b/.github/workflows/release.ymlindex e5539d3b..d7ebc502 100644--- a/.github/workflows/release.yml+++ b/.github/workflows/release.yml@@ -438,6 +438,14 @@ jobs:fidpkg-deb --info "${debs[0]}"rpm -qip "${rpms[0]}"+ test "$(dpkg-deb --field "${debs[0]}" Package)" = motrix+ test "$(rpm -qp --queryformat '%{NAME}' "${rpms[0]}")" = motrix+ for field in Provides Conflicts Replaces; do+ dpkg-deb --field "${debs[0]}" "$field" | tr ',' '\n' | grep -Eq '^ *motrix-turbo *$'+ done+ for relation in provides conflicts obsoletes; do+ rpm -qp "--$relation" "${rpms[0]}" | grep -Fx motrix-turbo+ done- name: Verify Arch Linux packageif: matrix.platform == 'linux'diff --git a/build/rpm-post-transaction.sh b/build/rpm-post-transaction.shnew file mode 100755index 00000000..0a092bdf--- /dev/null+++ b/build/rpm-post-transaction.sh@@ -0,0 +1,24 @@+#!/bin/sh+set -eu++# A renamed package's old %postun runs after the new %post and removes the+# shared launcher and AppArmor profile. Restore them once all removals finish.+test -x /opt/Motrix/motrix || exit 0++if command -v update-alternatives >/dev/null 2>&1; then+ update-alternatives --install /usr/bin/motrix motrix /opt/Motrix/motrix 100+else+ ln -sf /opt/Motrix/motrix /usr/bin/motrix+fi++profile_source=/opt/Motrix/resources/apparmor-profile+profile_target=/etc/apparmor.d/motrix+if test -f "$profile_source" &&+ command -v apparmor_parser >/dev/null 2>&1 &&+ apparmor_status --enabled >/dev/null 2>&1 &&+ apparmor_parser --skip-kernel-load --debug "$profile_source" >/dev/null 2>&1; then+ install -m 644 "$profile_source" "$profile_target"+ if ! { test -x /usr/bin/ischroot && /usr/bin/ischroot; }; then+ apparmor_parser --replace --write-cache --skip-read-cache "$profile_target"+ fi+fidiff --git a/electron-builder.json b/electron-builder.jsonindex 7a638813..8179f0cd 100644--- a/electron-builder.json+++ b/electron-builder.json@@ -258,10 +258,30 @@"artifactName": "${productName}-${version}-${arch}.${ext}"},"deb": {- "artifactName": "${productName}_${version}_${arch}.${ext}"+ "artifactName": "${productName}_${version}_${arch}.${ext}",+ "packageName": "motrix",+ "fpm": [+ "--provides",+ "motrix-turbo",+ "--conflicts",+ "motrix-turbo",+ "--replaces",+ "motrix-turbo"+ ]},"rpm": {- "artifactName": "${productName}-${version}.${arch}.${ext}"+ "artifactName": "${productName}-${version}.${arch}.${ext}",+ "packageName": "motrix",+ "fpm": [+ "--provides",+ "motrix-turbo",+ "--conflicts",+ "motrix-turbo",+ "--replaces",+ "motrix-turbo",+ "--rpm-posttrans",+ "build/rpm-post-transaction.sh"+ ]},"pacman": {"artifactName": "${productName}-${version}-${arch}.${ext}",diff --git a/tests/scripts/electron-package-contract.test.ts b/tests/scripts/electron-package-contract.test.tsindex b9c0fbcd..e97b12a5 100644--- a/tests/scripts/electron-package-contract.test.ts+++ b/tests/scripts/electron-package-contract.test.ts@@ -30,6 +30,31 @@ async function readJson(relativePath: string): Promise<unknown> {}describe('Electron package contracts', () => {+ it('uses the motrix Linux package identity and replaces the previous deb/rpm name', async () => {+ const config = (await readJson('electron-builder.json')) as Record<+ string,+ { packageName?: string; executableName?: string; fpm?: string[] }+ >+ expect(config.linux.executableName).toBe('motrix')+ for (const target of ['deb', 'rpm', 'pacman']) {+ expect(config[target].packageName, target).toBe('motrix')+ }+ for (const target of ['deb', 'rpm']) {+ const args = config[target].fpm ?? []+ for (const flag of ['--provides', '--conflicts', '--replaces']) {+ expect(args[args.indexOf(flag) + 1], `${target} ${flag}`).toBe(+ 'motrix-turbo'+ )+ }+ }+ const rpmArgs = config.rpm.fpm ?? []+ const postTransaction = rpmArgs[rpmArgs.indexOf('--rpm-posttrans') + 1]+ expect(postTransaction).toBe('build/rpm-post-transaction.sh')+ await expect(+ readFile(path.join(REPOSITORY_ROOT, postTransaction), 'utf8')+ ).resolves.toContain('/opt/Motrix/motrix')+ })+it('hydrates Electron before local commands consume its runtime files', async () => {const manifest = (await readJson('package.json')) as {scripts?: Record<string, string>diff --git a/tests/scripts/workflow-release-matrix.test.ts b/tests/scripts/workflow-release-matrix.test.tsindex 258d619c..b031555c 100644--- a/tests/scripts/workflow-release-matrix.test.ts+++ b/tests/scripts/workflow-release-matrix.test.ts@@ -1509,6 +1509,17 @@ describe('release workflow publication contract', () => {expect(verificationCommand).toContain('release/*.deb')expect(verificationCommand).toContain('release/*.rpm')expect(verificationCommand).toContain('release/*.AppImage')+ expect(verificationCommand).toContain(+ `dpkg-deb --field "\${debs[0]}" Package`+ )+ expect(verificationCommand).toContain("rpm -qp --queryformat '%{NAME}'")+ expect(verificationCommand).toContain(+ 'for field in Provides Conflicts Replaces'+ )+ expect(verificationCommand).toContain(+ 'for relation in provides conflicts obsoletes'+ )+ expect(verificationCommand).toContain('motrix-turbo')const appImageVerification = jobSteps(buildJob).find((step) => step.name === 'Verify AppImage artifact'