fix: generate .SRCINFO in pure TS (no makepkg on CI)
This commit is contained in:
parent
bb0ed8a4d3
commit
24914880db
2 changed files with 84 additions and 15 deletions
10
.SRCINFO
10
.SRCINFO
|
|
@ -1,7 +1,7 @@
|
||||||
pkgbase = cursor-ide
|
pkgbase = cursor-ide
|
||||||
pkgdesc = The AI Code Editor, bundled Electron (upstream-compatible)
|
pkgdesc = The AI Code Editor, bundled Electron (upstream-compatible)
|
||||||
pkgver = 2.6.19
|
pkgver = 2.6.20
|
||||||
pkgrel = 2
|
pkgrel = 1
|
||||||
url = https://www.cursor.com
|
url = https://www.cursor.com
|
||||||
arch = x86_64
|
arch = x86_64
|
||||||
license = LicenseRef-Cursor_EULA
|
license = LicenseRef-Cursor_EULA
|
||||||
|
|
@ -20,13 +20,13 @@ pkgbase = cursor-ide
|
||||||
optdepends = org.freedesktop.secrets: credential storage via SecretService
|
optdepends = org.freedesktop.secrets: credential storage via SecretService
|
||||||
optdepends = libdbusmenu-glib: KDE global menu support
|
optdepends = libdbusmenu-glib: KDE global menu support
|
||||||
provides = cursor
|
provides = cursor
|
||||||
noextract = cursor_2.6.19_amd64.deb
|
noextract = cursor_2.6.20_amd64.deb
|
||||||
options = !strip
|
options = !strip
|
||||||
options = !debug
|
options = !debug
|
||||||
source = cursor_2.6.19_amd64.deb::https://downloads.cursor.com/production/224838f96445be37e3db643a163a817c15b3606c/linux/x64/deb/amd64/deb/cursor_2.6.19_amd64.deb
|
source = cursor_2.6.20_amd64.deb::https://downloads.cursor.com/production/b29eb4ee5f9f6d1cb2afbc09070198d3ea6ad76f/linux/x64/deb/amd64/deb/cursor_2.6.20_amd64.deb
|
||||||
source = cursor.desktop
|
source = cursor.desktop
|
||||||
source = cursor-launcher.sh
|
source = cursor-launcher.sh
|
||||||
sha256sums = SKIP
|
sha256sums = 52e9aaf046cb875ef697c48c5b8e3ca55883465c788382c23ab54d5f3b51041f
|
||||||
sha256sums = SKIP
|
sha256sums = SKIP
|
||||||
sha256sums = SKIP
|
sha256sums = SKIP
|
||||||
|
|
||||||
|
|
|
||||||
89
update.ts
89
update.ts
|
|
@ -1,4 +1,3 @@
|
||||||
import { execSync } from "node:child_process";
|
|
||||||
import { createHash } from "node:crypto";
|
import { createHash } from "node:crypto";
|
||||||
import { readFileSync, writeFileSync } from "node:fs";
|
import { readFileSync, writeFileSync } from "node:fs";
|
||||||
import { dirname, join } from "node:path";
|
import { dirname, join } from "node:path";
|
||||||
|
|
@ -90,12 +89,83 @@ function updatePkgbuild(
|
||||||
writeFileSync(pkgbuildPath, text);
|
writeFileSync(pkgbuildPath, text);
|
||||||
}
|
}
|
||||||
|
|
||||||
function generateSrcinfo(pkgbuildDir: string): string {
|
function generateSrcinfo(pkgbuildPath: string): string {
|
||||||
const result = execSync("makepkg --printsrcinfo", {
|
const text = readFileSync(pkgbuildPath, "utf-8");
|
||||||
cwd: pkgbuildDir,
|
|
||||||
encoding: "utf-8",
|
const field = (re: RegExp): string => {
|
||||||
});
|
const m = text.match(re);
|
||||||
return result;
|
return m ? m[1].trim() : "";
|
||||||
|
};
|
||||||
|
|
||||||
|
const pkgver = field(/^pkgver=(.+)$/m);
|
||||||
|
const commit = field(/^_commit=(.+)$/m);
|
||||||
|
|
||||||
|
// Expand bash variables in a string
|
||||||
|
const expand = (s: string): string =>
|
||||||
|
s
|
||||||
|
.replace(/\$\{pkgver\}|\$pkgver/g, pkgver)
|
||||||
|
.replace(/\$\{_commit\}|\$_commit/g, commit);
|
||||||
|
|
||||||
|
const arrayField = (name: string): string[] => {
|
||||||
|
const re = new RegExp(`^${name}=\\(([\\s\\S]*?)\\)`, "m");
|
||||||
|
const m = text.match(re);
|
||||||
|
if (!m) return [];
|
||||||
|
|
||||||
|
const items: string[] = [];
|
||||||
|
for (const line of m[1].split("\n")) {
|
||||||
|
const stripped = line.replace(/#.*/, "").trim();
|
||||||
|
if (!stripped) continue;
|
||||||
|
// Quoted strings are kept whole (may contain spaces)
|
||||||
|
if (/^['"]/.test(stripped)) {
|
||||||
|
items.push(expand(stripped.replace(/^['"]|['"]$/g, "")));
|
||||||
|
} else {
|
||||||
|
// Unquoted: split on whitespace (e.g. "!strip !debug")
|
||||||
|
for (const tok of stripped.split(/\s+/)) {
|
||||||
|
if (tok) items.push(expand(tok));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return items;
|
||||||
|
};
|
||||||
|
|
||||||
|
const pkgname = field(/^pkgname=(.+)$/m);
|
||||||
|
const pkgrel = field(/^pkgrel=(.+)$/m);
|
||||||
|
const pkgdesc = field(/^pkgdesc=['"](.*?)['"]$/m);
|
||||||
|
const url = field(/^url=['"](.*?)['"]$/m);
|
||||||
|
const arch = arrayField("arch");
|
||||||
|
const license = arrayField("license");
|
||||||
|
const makedepends = arrayField("makedepends");
|
||||||
|
const depends = arrayField("depends");
|
||||||
|
const optdepends = arrayField("optdepends");
|
||||||
|
const provides = arrayField("provides");
|
||||||
|
const options = arrayField("options");
|
||||||
|
const noextract = arrayField("noextract");
|
||||||
|
const sources = arrayField("source");
|
||||||
|
const sha256sums = arrayField("sha256sums");
|
||||||
|
|
||||||
|
const lines: string[] = [];
|
||||||
|
const global = (key: string, val: string) =>
|
||||||
|
lines.push(`\t${key} = ${val}`);
|
||||||
|
|
||||||
|
lines.push(`pkgbase = ${pkgname}`);
|
||||||
|
global("pkgdesc", pkgdesc);
|
||||||
|
global("pkgver", pkgver);
|
||||||
|
global("pkgrel", pkgrel);
|
||||||
|
global("url", url);
|
||||||
|
for (const a of arch) global("arch", a);
|
||||||
|
for (const l of license) global("license", l);
|
||||||
|
for (const m of makedepends) global("makedepends", m);
|
||||||
|
for (const d of depends) global("depends", d);
|
||||||
|
for (const o of optdepends) global("optdepends", o);
|
||||||
|
for (const p of provides) global("provides", p);
|
||||||
|
for (const n of noextract) global("noextract", n);
|
||||||
|
for (const o of options) global("options", o);
|
||||||
|
for (const s of sources) global("source", s);
|
||||||
|
for (const s of sha256sums) global("sha256sums", s);
|
||||||
|
lines.push("");
|
||||||
|
lines.push(`pkgname = ${pkgname}`);
|
||||||
|
|
||||||
|
return lines.join("\n") + "\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
async function main(): Promise<void> {
|
async function main(): Promise<void> {
|
||||||
|
|
@ -160,10 +230,9 @@ async function main(): Promise<void> {
|
||||||
updatePkgbuild(pkgbuildPath, latest.version, latest.commit, sha256);
|
updatePkgbuild(pkgbuildPath, latest.version, latest.commit, sha256);
|
||||||
console.error(`PKGBUILD updated to ${latest.version}`);
|
console.error(`PKGBUILD updated to ${latest.version}`);
|
||||||
|
|
||||||
const pkgbuildDir = dirname(pkgbuildPath);
|
const srcinfoPath = join(dirname(pkgbuildPath), ".SRCINFO");
|
||||||
const srcinfoPath = join(pkgbuildDir, ".SRCINFO");
|
|
||||||
try {
|
try {
|
||||||
const srcinfo = generateSrcinfo(pkgbuildDir);
|
const srcinfo = generateSrcinfo(pkgbuildPath);
|
||||||
writeFileSync(srcinfoPath, srcinfo);
|
writeFileSync(srcinfoPath, srcinfo);
|
||||||
console.error(".SRCINFO regenerated");
|
console.error(".SRCINFO regenerated");
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue