mirror of
https://github.com/unraid/api.git
synced 2026-05-06 23:20:30 -05:00
feat: native slackware package (#1381)
<!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit - **New Features** - Added detailed versioning for plugin packages incorporating architecture and build identifiers. - Simplified and improved install/uninstall scripts with backup and dynamic package detection. - Introduced comprehensive setup, verification, patching, and cleanup scripts for the Unraid API environment. - Enhanced service control with explicit start, stop, restart, and status commands. - Added robust dependency management scripts for restoring and archiving Node.js modules. - Implemented vendor archive metadata storage and dynamic handling during build and runtime. - Added new CLI options and environment schemas for consistent build configuration. - Introduced new shutdown scripts to gracefully stop flash-backup and unraid-api services. - Added utility scripts for API version detection and vendor archive configuration. - Added a new package description file detailing Unraid API features and homepage link. - **Bug Fixes** - Improved validation and error reporting for missing manifests, dependencies, and configuration files. - Enhanced fallback logic for locating and creating vendor archives. - Fixed iframe compatibility in UI by updating HTML and Firefox preference files. - **Chores** - Updated .gitignore with generated file patterns for Node.js binaries and archives. - Removed obsolete internal documentation and legacy cleanup scripts. - Refined Docker Compose and CI workflows to pass precise API versioning and manage build artifacts. - Centralized common environment validation and CLI option definitions across build tools. - Cleaned up plugin manifest by removing Node.js and PNPM-related entities and legacy logic. - Improved logging and error handling in build and installation scripts. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import { getTxzName, LOCAL_BUILD_TAG, pluginNameWithExt } from "./consts";
|
||||
import { getTxzName, LOCAL_BUILD_TAG, pluginNameWithExt, defaultArch, defaultBuild } from "./consts";
|
||||
|
||||
// Define a common interface for URL parameters
|
||||
interface UrlParams {
|
||||
@@ -7,7 +7,7 @@ interface UrlParams {
|
||||
}
|
||||
|
||||
interface TxzUrlParams extends UrlParams {
|
||||
pluginVersion: string;
|
||||
apiVersion: string;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -44,7 +44,7 @@ export const getPluginUrl = (params: UrlParams): string =>
|
||||
|
||||
/**
|
||||
* Get the URL for the main TXZ file
|
||||
* ex. returns = BASE_URL/TAG/dynamix.unraid.net-4.1.3.txz
|
||||
* ex. returns = BASE_URL/TAG/dynamix.unraid.net-4.1.3-x86_64-1.txz
|
||||
*/
|
||||
export const getMainTxzUrl = (params: TxzUrlParams): string =>
|
||||
getAssetUrl(params, getTxzName(params.pluginVersion));
|
||||
getAssetUrl(params, getTxzName(params.apiVersion, defaultArch, defaultBuild));
|
||||
|
||||
@@ -1,8 +1,13 @@
|
||||
export const pluginName = "dynamix.unraid.net" as const;
|
||||
export const pluginNameWithExt = `${pluginName}.plg` as const;
|
||||
|
||||
export const getTxzName = (version?: string) =>
|
||||
version ? `${pluginName}-${version}.txz` : `${pluginName}.txz`;
|
||||
// Default architecture and build number for Slackware package
|
||||
export const defaultArch = "x86_64" as const;
|
||||
export const defaultBuild = "1" as const;
|
||||
|
||||
// Get the txz name following Slackware naming convention: name-version-arch-build.txz
|
||||
export const getTxzName = (version?: string, arch: string = defaultArch, build: string = defaultBuild) =>
|
||||
version ? `${pluginName}-${version}-${arch}-${build}.txz` : `${pluginName}.txz`;
|
||||
export const startingDir = process.cwd();
|
||||
|
||||
export const BASE_URLS = {
|
||||
|
||||
@@ -0,0 +1,59 @@
|
||||
import { join } from "path";
|
||||
import { existsSync, mkdirSync, createWriteStream, readFileSync } from "fs";
|
||||
import { writeFile, readFile } from "fs/promises";
|
||||
import { get } from "https";
|
||||
import { $ } from "zx";
|
||||
import { startingDir } from "./consts";
|
||||
|
||||
const findNvmrc = () => {
|
||||
const nvmrcPaths = [
|
||||
join(startingDir, "..", ".nvmrc"),
|
||||
join(startingDir, ".nvmrc"),
|
||||
];
|
||||
for (const nvmrcPath of nvmrcPaths) {
|
||||
if (existsSync(nvmrcPath)) {
|
||||
return nvmrcPath;
|
||||
}
|
||||
}
|
||||
throw new Error("NVMRC file not found");
|
||||
}
|
||||
// Read Node.js version from .nvmrc
|
||||
const NVMRC_PATH = findNvmrc();
|
||||
console.log(`NVMRC_PATH: ${NVMRC_PATH}`);
|
||||
const NODE_VERSION = readFileSync(NVMRC_PATH, "utf8").trim();
|
||||
|
||||
const NODE_FILENAME = `node-v${NODE_VERSION}-linux-x64.tar.xz`;
|
||||
const NODE_URL = `https://nodejs.org/download/release/v${NODE_VERSION}/${NODE_FILENAME}`;
|
||||
const NODE_DEST = join(startingDir, "source", "dynamix.unraid.net", "usr", "local");
|
||||
const NODE_VERSION_FILE = join(NODE_DEST, ".node-version");
|
||||
|
||||
async function fetchFile(url: string, dest: string) {
|
||||
return new Promise((resolve, reject) => {
|
||||
const file = createWriteStream(dest);
|
||||
get(url, (response) => {
|
||||
if (response.statusCode !== 200) {
|
||||
reject(new Error(`Failed to get '${url}' (${response.statusCode})`));
|
||||
return;
|
||||
}
|
||||
response.pipe(file);
|
||||
file.on("finish", () => file.close(resolve));
|
||||
file.on("error", reject);
|
||||
}).on("error", reject);
|
||||
});
|
||||
}
|
||||
|
||||
export async function ensureNodeJs() {
|
||||
let currentVersion: string | null = null;
|
||||
if (existsSync(NODE_VERSION_FILE)) {
|
||||
currentVersion = (await readFile(NODE_VERSION_FILE, "utf8")).trim();
|
||||
}
|
||||
if (currentVersion !== NODE_VERSION) {
|
||||
mkdirSync(NODE_DEST, { recursive: true });
|
||||
if (!existsSync(NODE_FILENAME)) {
|
||||
await fetchFile(NODE_URL, NODE_FILENAME);
|
||||
}
|
||||
// Extract Node.js excluding include/node and share/doc/node directories
|
||||
await $`tar --strip-components=1 -xf ${NODE_FILENAME} --exclude="*/include/node" --exclude="*/share/doc/node" --exclude="*/README.md" --exclude="*/LICENSE" --exclude="*/CHANGELOG.md" -C ${NODE_DEST}`;
|
||||
await writeFile(NODE_VERSION_FILE, NODE_VERSION, "utf8");
|
||||
}
|
||||
}
|
||||
@@ -25,6 +25,8 @@ export const apiDir = join(
|
||||
"unraid-api"
|
||||
);
|
||||
|
||||
export const vendorStorePath = "/boot/config/plugins/dynamix.my.servers";
|
||||
|
||||
/**
|
||||
* Get the path to the root plugin directory
|
||||
* @param startingDir - The starting directory
|
||||
|
||||
Reference in New Issue
Block a user