Compare commits
3
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ec47d542dd | ||
|
|
674aef94fb | ||
|
|
04605f2680 |
@@ -12,6 +12,9 @@ regexes = [
|
|||||||
'''https?://matrix\.lotusguild\.org''',
|
'''https?://matrix\.lotusguild\.org''',
|
||||||
'''https?://code\.lotusguild\.org/api/packages/LotusGuild/npm/''',
|
'''https?://code\.lotusguild\.org/api/packages/LotusGuild/npm/''',
|
||||||
'''matrix\.lotusguild\.org''',
|
'''matrix\.lotusguild\.org''',
|
||||||
|
# Lotus Chat desktop updater's minisign PUBLIC key (published in the
|
||||||
|
# cinny-desktop README); utils/updateErrors.ts verifies Linux downloads with it.
|
||||||
|
'''RWRZZdyii05/NUcz337A5SAbiZK\+NPVDWuiL2mM5Jk1p/LfRmNfiZ/6l''',
|
||||||
]
|
]
|
||||||
paths = [
|
paths = [
|
||||||
'''config\.json''',
|
'''config\.json''',
|
||||||
|
|||||||
@@ -69,13 +69,23 @@ test('install kinds: anything unknown keeps the in-app updater', async () => {
|
|||||||
test('package installs get their package manager’s command, not an Install button', async () => {
|
test('package installs get their package manager’s command, not an Install button', async () => {
|
||||||
const { packageUpdateHelp, isPackageManagedError } = await import('./updateErrors');
|
const { packageUpdateHelp, isPackageManagedError } = await import('./updateErrors');
|
||||||
const pacman = packageUpdateHelp('pacman')!;
|
const pacman = packageUpdateHelp('pacman')!;
|
||||||
// Not `pacman -U <url>`: that also wants `<url>.sig`, which we don't publish.
|
// [cinny-desktop #36] signature, then checksum, then install, in that order;
|
||||||
assert.equal(
|
// a local `pacman -U ./file` (not `<url>`, which also wants `<url>.sig`).
|
||||||
pacman.command,
|
const steps = pacman.command!.split(' && ');
|
||||||
'curl -LO https://code.lotusguild.org/LotusGuild/cinny-desktop/releases/download/latest/LotusChat-x86_64.pkg.tar.zst && sudo pacman -U ./LotusChat-x86_64.pkg.tar.zst',
|
assert.equal(steps[0], 'cd "$(mktemp -d)"');
|
||||||
|
assert.match(
|
||||||
|
steps[1],
|
||||||
|
/-fLO \S+\/LotusChat-x86_64\.pkg\.tar\.zst -fLO \S+\/SHA256SUMS\.txt -fLO \S+\/SHA256SUMS\.txt\.minisig$/,
|
||||||
);
|
);
|
||||||
|
assert.equal(
|
||||||
|
steps[2],
|
||||||
|
'minisign -Vm SHA256SUMS.txt -P RWRZZdyii05/NUcz337A5SAbiZK+NPVDWuiL2mM5Jk1p/LfRmNfiZ/6l',
|
||||||
|
);
|
||||||
|
assert.equal(steps[3], 'sha256sum -c --ignore-missing SHA256SUMS.txt');
|
||||||
|
assert.equal(steps[4], 'sudo pacman -U ./LotusChat-x86_64.pkg.tar.zst');
|
||||||
assert.match(pacman.url, /LotusChat-x86_64\.pkg\.tar\.zst$/);
|
assert.match(pacman.url, /LotusChat-x86_64\.pkg\.tar\.zst$/);
|
||||||
const deb = packageUpdateHelp('deb')!;
|
const deb = packageUpdateHelp('deb')!;
|
||||||
|
assert.match(deb.command!, /minisign -Vm SHA256SUMS\.txt/);
|
||||||
assert.match(deb.command!, /sudo apt install \.\/LotusChat-x86_64\.deb$/);
|
assert.match(deb.command!, /sudo apt install \.\/LotusChat-x86_64\.deb$/);
|
||||||
assert.equal(packageUpdateHelp('manual')?.command, undefined);
|
assert.equal(packageUpdateHelp('manual')?.command, undefined);
|
||||||
assert.equal(packageUpdateHelp('in-app'), undefined);
|
assert.equal(packageUpdateHelp('in-app'), undefined);
|
||||||
|
|||||||
@@ -64,23 +64,38 @@ export const toInstallKind = (value: unknown): InstallKind =>
|
|||||||
|
|
||||||
export type PackageUpdateHelp = { command?: string; url: string; download: string };
|
export type PackageUpdateHelp = { command?: string; url: string; download: string };
|
||||||
|
|
||||||
|
/** The desktop updater's minisign public key (cinny-desktop tauri.conf.json). */
|
||||||
|
export const RELEASE_MINISIGN_KEY = 'RWRZZdyii05/NUcz337A5SAbiZK+NPVDWuiL2mM5Jk1p/LfRmNfiZ/6l';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* [cinny-desktop #36] Download a Linux package and install it only after
|
||||||
|
* checking the release's minisign-signed SHA256SUMS.txt. Runs in a fresh temp
|
||||||
|
* directory so a stale SHA256SUMS.txt can't be picked up.
|
||||||
|
*/
|
||||||
|
const verifiedInstall = (file: string, install: string): string =>
|
||||||
|
[
|
||||||
|
`cd "$(mktemp -d)"`,
|
||||||
|
`curl -fLO ${RELEASE_DOWNLOAD}/${file} -fLO ${RELEASE_DOWNLOAD}/SHA256SUMS.txt -fLO ${RELEASE_DOWNLOAD}/SHA256SUMS.txt.minisig`,
|
||||||
|
`minisign -Vm SHA256SUMS.txt -P ${RELEASE_MINISIGN_KEY}`,
|
||||||
|
`sha256sum -c --ignore-missing SHA256SUMS.txt`,
|
||||||
|
`${install} ./${file}`,
|
||||||
|
].join(' && ');
|
||||||
|
|
||||||
export const packageUpdateHelp = (kind: InstallKind): PackageUpdateHelp | undefined => {
|
export const packageUpdateHelp = (kind: InstallKind): PackageUpdateHelp | undefined => {
|
||||||
if (kind === 'pacman') {
|
if (kind === 'pacman') {
|
||||||
const url = `${RELEASE_DOWNLOAD}/LotusChat-x86_64.pkg.tar.zst`;
|
// Install the local file: `pacman -U <url>` also fetches `<url>.sig` and
|
||||||
// Download first, then install the local file: `pacman -U <url>` also
|
// fails without it (packages aren't signed for pacman), while a local file
|
||||||
// fetches `<url>.sig` and fails without it (we don't sign packages),
|
// falls under LocalFileSigLevel. Integrity comes from SHA256SUMS.txt.
|
||||||
// while a local file falls under LocalFileSigLevel (signature optional).
|
|
||||||
return {
|
return {
|
||||||
command: `curl -LO ${url} && sudo pacman -U ./LotusChat-x86_64.pkg.tar.zst`,
|
command: verifiedInstall('LotusChat-x86_64.pkg.tar.zst', 'sudo pacman -U'),
|
||||||
url,
|
url: `${RELEASE_DOWNLOAD}/LotusChat-x86_64.pkg.tar.zst`,
|
||||||
download: 'Download package',
|
download: 'Download package',
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
if (kind === 'deb') {
|
if (kind === 'deb') {
|
||||||
const url = `${RELEASE_DOWNLOAD}/LotusChat-x86_64.deb`;
|
|
||||||
return {
|
return {
|
||||||
command: `curl -LO ${url} && sudo apt install ./LotusChat-x86_64.deb`,
|
command: verifiedInstall('LotusChat-x86_64.deb', 'sudo apt install'),
|
||||||
url,
|
url: `${RELEASE_DOWNLOAD}/LotusChat-x86_64.deb`,
|
||||||
download: 'Download package',
|
download: 'Download package',
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user