mirror of
https://github.com/wekan/wekan.git
synced 2026-11-20 09:45:04 -05:00
Omarchy (https://omarchy.org) is Arch with Hyprland: pacman, the Arch repositories and yay for the AUR. The shared detector in releases/ensure-tools.sh now names Omarchy and the other Arch derivatives (EndeavourOS, CachyOS, Manjaro) explicitly, and what the scripts did there is fixed: - No more `pacman -Sy <package>`: that is a partial upgrade, which Arch does not support. _et_pacman installs with `-S --needed`, does a full `-Syu` only when pacman has never synced (a fresh archlinux container) or when WEKAN_PACMAN_SYU=1 asks for it, and otherwise says to update first, naming omarchy-update on Omarchy. - 7zip instead of p7zip, which Arch has replaced. - snapcraft: snapd from the AUR with yay or paru (never as root), then snapd.socket, /snap and the snapcraft snap, instead of only an error. - The SSH server menu entries use sshd.service outside Debian/Ubuntu, where the unit is not called ssh. - Playwright: `install --with-deps` runs apt-get, so outside Debian/Ubuntu the browser libraries come from pacman (or dnf) and the browsers are installed without --with-deps. WebKit, which Playwright builds for Debian/Ubuntu only, runs in the Playwright Docker image on Arch when Docker is there. - The en_US.UTF-8 locale note gives the Arch/Omarchy steps too. tests/archOmarchyScripts.test.cjs drives the helpers offline with stubbed sudo/pacman/yay, and its negative test fails if any tracked shell script does a `pacman -Sy` partial upgrade or installs p7zip. Thanks to xet7 !
113 lines
4.3 KiB
JavaScript
113 lines
4.3 KiB
JavaScript
'use strict';
|
|
|
|
const assert = require('assert');
|
|
const fs = require('fs');
|
|
const os = require('os');
|
|
const path = require('path');
|
|
const { spawnSync } = require('child_process');
|
|
|
|
const ROOT = path.join(__dirname, '..');
|
|
const helper = path.join(ROOT, 'releases', 'ensure-tools.sh');
|
|
const zshScripts = [
|
|
'build.sh', 'releases/up.sh', 'releases/clone-release-repos.sh',
|
|
'releases/count-lines-of-code-per-committer.sh',
|
|
'releases/rebuild-release.sh', 'releases/rebuild-docs.sh',
|
|
'releases/node-update-local.sh', 'releases/install-sandstorm.sh',
|
|
'releases/build-bundle-armhf.sh',
|
|
'releases/build-bundle-ppc64le.sh',
|
|
'releases/build-bundle-ppc64el.sh',
|
|
'releases/build-bundle-s390x.sh', 'releases/snap-build.sh',
|
|
'releases/release-all.sh', 'releases/create-github-secrets.sh',
|
|
];
|
|
|
|
const fixtures = {
|
|
alpine: 'ID=alpine\n',
|
|
arch: 'ID=arch\n',
|
|
omarchy: 'ID=omarchy\nID_LIKE=arch\n',
|
|
omarchyAlone: 'NAME="Omarchy"\nID=omarchy\n',
|
|
endeavouros: 'ID=endeavouros\nID_LIKE=arch\n',
|
|
fedora: 'ID=fedora\n',
|
|
rhel: 'ID=rhel\n',
|
|
oracle: 'ID=ol\nID_LIKE="fedora rhel"\n',
|
|
debian: 'ID=ubuntu\nID_LIKE=debian\n',
|
|
};
|
|
|
|
let passed = 0;
|
|
function test(name, fn) { fn(); passed += 1; console.log(' ok -', name); }
|
|
|
|
console.log('linuxPackageManagers:');
|
|
|
|
for (const [name, contents] of Object.entries(fixtures)) {
|
|
test(`${name} is detected from os-release`, () => {
|
|
const dir = fs.mkdtempSync(path.join(os.tmpdir(), 'wekan-os-release-'));
|
|
const file = path.join(dir, 'os-release');
|
|
fs.writeFileSync(file, contents);
|
|
const result = spawnSync('bash', ['-c', '. "$ET_HELPER"; _et_linux_family'], {
|
|
encoding: 'utf8', env: { ...process.env, ET_HELPER: helper, WEKAN_OS_RELEASE_FILE: file },
|
|
});
|
|
fs.rmSync(dir, { recursive: true, force: true });
|
|
assert.strictEqual(result.status, 0, result.stderr);
|
|
const expected = name === 'oracle' ? 'rhel'
|
|
: ['omarchy', 'omarchyAlone', 'endeavouros'].includes(name) ? 'arch' : name;
|
|
assert.strictEqual(result.stdout.trim(), expected);
|
|
});
|
|
}
|
|
|
|
test('macOS is detected without relying on the invoking shell', () => {
|
|
const result = spawnSync('bash', ['-c', '. "$ET_HELPER"; _et_os'], {
|
|
encoding: 'utf8', env: { ...process.env, ET_HELPER: helper, WEKAN_UNAME_S: 'Darwin' },
|
|
});
|
|
assert.strictEqual(result.status, 0, result.stderr);
|
|
assert.strictEqual(result.stdout.trim(), 'macos');
|
|
});
|
|
|
|
test('zsh invocation hands Bash scripts to the system Bash', () => {
|
|
const handoff =
|
|
'if [ -n "${ZSH_VERSION:-}" ]; then exec /bin/bash "$0" "$@"; fi';
|
|
for (const file of zshScripts) {
|
|
const src = fs.readFileSync(path.join(ROOT, file), 'utf8');
|
|
assert.ok(src.startsWith('#!') && src.includes(handoff), file);
|
|
}
|
|
});
|
|
|
|
test('Homebrew uses macOS formula names', () => {
|
|
const src = fs.readFileSync(helper, 'utf8');
|
|
for (const mapping of [
|
|
'python3|pip3|python3-pip) package=python',
|
|
'awk) package=gawk',
|
|
'g++) package=gcc',
|
|
'7zip) package=sevenzip',
|
|
'npm) package=node',
|
|
]) {
|
|
assert.ok(src.includes(mapping), mapping);
|
|
}
|
|
});
|
|
|
|
test('every Linux family has an explicit package-manager command', () => {
|
|
const src = fs.readFileSync(helper, 'utf8');
|
|
// Arch's command is `pacman -S --needed` inside _et_pacman: a bare `-Sy` is
|
|
// a partial upgrade, which Arch does not support (archOmarchyScripts.test.cjs).
|
|
for (const command of ['apk add --no-cache', 'pacman -S --needed --noconfirm',
|
|
'dnf', 'yum', 'apt-get']) assert.ok(src.includes(command), command);
|
|
});
|
|
|
|
test('host-facing release installers use the shared detector', () => {
|
|
for (const file of ['up.sh', 'clone-release-repos.sh',
|
|
'count-lines-of-code-per-committer.sh', 'rebuild-release.sh',
|
|
'rebuild-docs.sh', 'node-update-local.sh', 'install-sandstorm.sh',
|
|
'build-bundle-armhf.sh', 'build-bundle-ppc64le.sh',
|
|
'build-bundle-ppc64el.sh', 'build-bundle-s390x.sh', 'snap-build.sh']) {
|
|
const src = fs.readFileSync(path.join(ROOT, 'releases', file), 'utf8');
|
|
assert.ok(src.includes('ensure-tools.sh'), `${file} must source ensure-tools.sh`);
|
|
}
|
|
});
|
|
|
|
test('shared specialized installers cover every Linux family', () => {
|
|
const src = fs.readFileSync(helper, 'utf8');
|
|
assert.ok(src.includes('ensure_build_toolchain()'));
|
|
assert.ok(src.includes('ensure_archive_tools()'));
|
|
assert.ok(src.includes('oracle-epel-release-el${major}'));
|
|
});
|
|
|
|
console.log(`\n${passed} tests passed`);
|