|
| 1 | +/* eslint-disable */ |
| 2 | + |
| 3 | +import { writeFileSync } from "fs"; |
| 4 | + |
| 5 | +// 命令行参数: |
| 6 | +// node ./generate-pkgbuild.mjs <pkgname> <pkgver> <sha256sums> |
| 7 | +const pkgname = process.argv[2]; |
| 8 | +const pkgver = process.argv[3]; |
| 9 | +const sha256sums = process.argv[4]; |
| 10 | + |
| 11 | +if (!pkgname || !pkgver || !sha256sums) { |
| 12 | + console.error("Usage: node generate-pkgbuild.mjs <pkgname> <pkgver> <sha256sums>"); |
| 13 | + process.exit(1); |
| 14 | +} |
| 15 | + |
| 16 | +const conflicts = |
| 17 | + pkgname === "project-graph-nightly-bin" |
| 18 | + ? ["project-graph-bin", "project-graph-git"] |
| 19 | + : ["project-graph-nightly-bin", "project-graph-git"]; |
| 20 | +const source = |
| 21 | + pkgname === "project-graph-nightly-bin" |
| 22 | + ? `https://github.com/LiRenTech/project-graph/releases/download/nightly/Project.Graph_0.0.0-nightly.${pkgver}_amd64.deb` |
| 23 | + : `https://github.com/LiRenTech/project-graph/releases/download/v${pkgver}/Project.Graph_${pkgver}_amd64.deb`; |
| 24 | + |
| 25 | +const PKGBUILD = `# Maintainer: zty012 <[email protected]> |
| 26 | +pkgname=${pkgname} |
| 27 | +pkgver=${pkgver} |
| 28 | +pkgrel=1 |
| 29 | +pkgdesc="A simple tool to create topology diagrams." |
| 30 | +arch=('x86_64') |
| 31 | +url="https://github.com/LiRenTech/project-graph" |
| 32 | +license=('mit') |
| 33 | +depends=('cairo' 'desktop-file-utils' 'gdk-pixbuf2' 'glib2' 'gtk3' 'hicolor-icon-theme' 'libsoup' 'pango' 'webkit2gtk') |
| 34 | +options=('!strip' '!emptydirs') |
| 35 | +provides=('project-graph') |
| 36 | +conflicts=(${conflicts.map((x) => `'${x}'`).join(" ")}) |
| 37 | +install=${pkgname}.install |
| 38 | +source_x86_64=('${source}') |
| 39 | +sha256sums_x86_64=('${sha256sums}') |
| 40 | +package() { |
| 41 | + # Extract package data |
| 42 | + tar -xz -f data.tar.gz -C "\${pkgdir}" |
| 43 | +} |
| 44 | +`; |
| 45 | + |
| 46 | +console.log("===== PKGBUILD ====="); |
| 47 | +console.log(PKGBUILD); |
| 48 | +writeFileSync("./PKGBUILD", PKGBUILD); |
| 49 | + |
| 50 | +const SRCINFO = `pkgbase = project-graph-nightly-bin |
| 51 | +\tpkgdesc = A simple tool to create topology diagrams. |
| 52 | +\tpkgver = ${pkgver} |
| 53 | +\tpkgrel = 1 |
| 54 | +\turl = https://github.com/LiRenTech/project-graph |
| 55 | +\tinstall = ${pkgname}.install |
| 56 | +\tarch = x86_64 |
| 57 | +\tlicense = mit |
| 58 | +\tdepends = cairo |
| 59 | +\tdepends = desktop-file-utils |
| 60 | +\tdepends = gdk-pixbuf2 |
| 61 | +\tdepends = glib2 |
| 62 | +\tdepends = gtk3 |
| 63 | +\tdepends = hicolor-icon-theme |
| 64 | +\tdepends = libsoup |
| 65 | +\tdepends = pango |
| 66 | +\tdepends = webkit2gtk |
| 67 | +\tprovides = project-graph |
| 68 | +${conflicts.map((x) => `\tconflicts = ${x}`).join("\n")} |
| 69 | +\toptions = !strip |
| 70 | +\toptions = !emptydirs |
| 71 | +\tsource_x86_64 = ${source} |
| 72 | +\tsha256sums_x86_64 = ${sha256sums} |
| 73 | +
|
| 74 | +pkgname = ${pkgname}`; |
| 75 | + |
| 76 | +console.log("===== .SRCINFO ====="); |
| 77 | +console.log(SRCINFO); |
| 78 | +writeFileSync("./.SRCINFO", SRCINFO); |
0 commit comments