minecraft-pi-reborn/scripts/generate-appimage-builder-yaml.js

190 lines
4.7 KiB
JavaScript
Raw Normal View History

2022-03-09 23:47:31 +00:00
#!/usr/bin/env node
// Arguments
if (process.argv.length < 4) {
throw new Error('Invalid Arguments');
}
const mode = process.argv[2];
const arch = process.argv[3];
// Data
2021-12-01 02:40:02 +00:00
const id = `com.thebrokenrail.MCPIRebornLegacy${mode === 'server' ? 'Server' : 'Client'}`;
const name = `minecraft-pi-reborn-legacy-${mode}`;
const updateURL = `https://jenkins.thebrokenrail.com/job/minecraft-pi-reborn/job/legacy/lastSuccessfulBuild/artifact/out/${name}-latest-${arch}.AppImage.zsync`;
2022-03-09 23:47:31 +00:00
// APT Data
const apt_distribution = 'bullseye';
const apt_key_url = 'https://ftp-master.debian.org/keys/archive-key-11.asc';
// Version
const fs = require('fs');
const version = fs.readFileSync('VERSION', 'utf8').trim();
// Packages/Dependencies
const packages = [
'libc6',
2022-03-25 02:47:34 +00:00
'libstdc++6',
'patchelf'
2022-03-09 23:47:31 +00:00
];
if (mode === 'client') {
2022-03-10 02:23:41 +00:00
// GLFW's Dependencies Aren't Included As They Should Be Provided By The Host System
2022-03-09 23:47:31 +00:00
packages.push(
2022-03-11 05:00:13 +00:00
'libgtk-3-0',
'libglib2.0-0',
'libgdk-pixbuf2.0-0',
2022-03-12 01:02:38 +00:00
'shared-mime-info',
2022-03-09 23:47:31 +00:00
'libfreeimage3',
'libopenal1'
);
}
if (arch !== 'armhf') {
packages.push(
'libc6-armhf-cross',
'libstdc++6-armhf-cross'
);
if (arch !== 'arm64') {
packages.push('qemu-user');
}
}
// Package Exclusions
const packageExclusions = [
// Exclude Unneeded Packages
'humanity-icon-theme',
'adwaita-icon-theme',
2022-03-12 01:02:38 +00:00
'libxml2',
2022-03-09 23:47:31 +00:00
'*systemd*',
'dconf-service',
'dconf-gsettings-backend',
'librest-*',
'libcups2',
'libcolord2',
'libmount1'
];
// APT
const apt = {
arch: arch,
sources: [
{
sourceline: `deb [arch=${arch}] http://deb.debian.org/debian/ ${apt_distribution} main`,
key_url: apt_key_url
},
{
sourceline: `deb [arch=${arch}] http://deb.debian.org/debian/ ${apt_distribution}-updates main`,
key_url: apt_key_url
}
],
include: packages,
exclude: packageExclusions
};
// Get Architecture Triplet
const triplet = {
'amd64': 'x86_64-linux-gnu',
'i386': 'i386-linux-gnu',
'arm64': 'aarch64-linux-gnu',
'armhf': 'arm-linux-gnueabihf'
}[arch];
if (!triplet) {
throw new Error();
}
// Files
const files = {
exclude: [
// Exclude Unused Files
`usr/lib/${triplet}/gconv`,
'usr/share/man',
'usr/share/doc/*/README.*',
'usr/share/doc/*/changelog.*',
'usr/share/doc/*/NEWS.*',
'usr/share/doc/*/TODO.*',
'usr/include',
'usr/share/locale',
2022-03-12 01:02:38 +00:00
'usr/share/help',
'usr/bin/update-mime-database'
2022-03-09 23:47:31 +00:00
]
};
// Script After Bundling Dependencies
const afterBundle = [
// Remove Unused QEMU Binaries
'find ./AppDir/usr/bin -maxdepth 1 -name \'qemu-*\' -a ! -name \'qemu-arm\' -delete'
];
// Runtime
const runtime = {
env: mode === 'client' ? {
// Make GTK Work (Zenity Uses GTK)
GTK_EXE_PREFIX: '${APPDIR}/usr',
GTK_PATH: `\${APPDIR}/usr/lib/${triplet}/gtk-3.0`,
GTK_DATA_PREFIX: '${APPDIR}',
GTK_THEME: 'Default',
2022-03-12 01:02:38 +00:00
XDG_DATA_DIRS: '${APPDIR}/share:${APPDIR}/usr/share',
APPDIR_LIBRARY_PATH: `\${APPDIR}/usr/lib/${triplet}:\${APPDIR}/usr/${triplet}/lib:\${APPDIR}/lib/${triplet}:\${APPDIR}/usr/lib:\${APPDIR}/usr/lib/${triplet}/gdk-pixbuf-2.0/2.10.0/loaders`
2022-03-09 23:47:31 +00:00
} : undefined,
preserve: arch !== 'armhf' ? [
// On non-ARM32 systems, an ARM32 linker is embedded, this
// prevents AppImage-Builder from modifying ARM32 binaries
// to use a (usually non-existent) system linker.
`usr/lib/${name}/minecraft-pi`,
`usr/lib/${name}/**/*.so`,
'usr/arm-linux-gnueabihf/lib'
2022-04-10 00:01:16 +00:00
] : undefined
2022-03-09 23:47:31 +00:00
};
// AppDir
const appDir = {
path: `./AppDir`,
app_info: {
id: id,
name: `${name}`,
2022-03-10 04:29:37 +00:00
icon: id,
2022-03-09 23:47:31 +00:00
version: version,
exec: `usr/bin/${name}`,
exec_args: '$@'
},
apt: apt,
files: files,
after_bundle: afterBundle,
runtime: runtime
};
// Build Script
const script = [
`rm -rf ./build/${mode}-${arch}`,
`./scripts/setup.sh ${mode} ${arch} -DMCPI_IS_APPIMAGE_BUILD=ON`,
`rm -rf ./out/${mode}-${arch}`,
`./scripts/build.sh ${mode} ${arch}`,
'rm -rf ./AppDir',
`cp -ar ./out/${mode}-${arch} ./AppDir`
];
// AppImage
const appImageArch = {
'amd64': 'x86_64',
'i386': 'i686',
'arm64': 'aarch64',
'armhf': 'armhf'
}[arch];
if (!appImageArch) {
throw new Error();
}
const appImage = {
arch: appImageArch,
2022-03-10 02:23:41 +00:00
file_name: `./out/${name}-${version}-${arch}.AppImage`,
'update-information': `zsync|${updateURL}`
2022-03-09 23:47:31 +00:00
};
// Root
const root = {
version: 1,
AppDir: appDir,
script: script,
AppImage: appImage
};
// Write
fs.writeFileSync(`AppImageBuilder.yml`, JSON.stringify(root, null, 4));