feat(targets): add pkg-pacman target (Arch custom repository)#477
feat(targets): add pkg-pacman target (Arch custom repository)#477Alexander-Sorrell-IT wants to merge 3 commits into
Conversation
Adds the pacman distribution target — a custom Arch binary repo via repo-add (NOT the AUR; pkg-aur covers that). Mirrors the pkg-apt/pkg-dnf convention. - build() generates a real PKGBUILD (pkgver normalized: no '-'/':'; shell-escaped pkgdesc/url) + a pacman.conf [repo] snippet for consumers. - ship() is dry-run-safe and surfaces makepkg + repo-add (--sign) commands; live publish throws not-implemented rather than a false success. - Register pkg-pacman in cli adapter-registry; TARGETS.md row added.
- assertValidNames(): reject pkgname not matching Arch rules and repoName outside [A-Za-z0-9_-] — closes PKGBUILD syntax + pacman.conf [section] injection vectors (called from build() and ship()). - Quote repo db / pkgfile / rsync dest in publishCommands. - sha256sums via bashArray (escapes embedded quotes). - ship() throws not-implemented immediately (no misleading secret check). - Tests: bash -n syntax validation with hostile inputs + name-rejection cases.
Greptile SummaryThis PR adds the
Confidence Score: 5/5This PR is safe to merge — it adds a self-contained new adapter with no changes to existing behaviour. The adapter is fully isolated in a new package with no modifications to any existing adapter logic. All previously raised injection concerns (repoBaseUrl newline injection, unquoted pkgrel, misleading test description) have been addressed in this revision: assertValidNames now guards all four fields, and the test suite confirms both the happy paths and every rejection case with a bash -n proof for hostile inputs. No files require special attention. Important Files Changed
Flowchart%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[build / ship called] --> B[assertValidNames]
B -->|pkgname invalid| E1[throw invalid pkgname]
B -->|repoName invalid| E2[throw invalid repoName]
B -->|repoBaseUrl has newline or single-quote| E3[throw invalid repoBaseUrl]
B -->|pkgrel not positive integer| E4[throw invalid pkgrel]
B --> C{build or ship?}
C -->|build| D[renderPkgbuild]
D --> D1[pkgver normalization]
D1 --> D2[shEscape pkgdesc / url / sourceUrl]
D2 --> D3[bashArray for license / depends / sha256sum]
D3 --> D4[writeFile PKGBUILD + .pacman.conf]
D4 --> D5[return artifact + publishCommands in meta]
C -->|ship dryRun=true| F[return dry-run id + publishCommands in meta]
C -->|ship dryRun=false| G[throw not implemented]
Reviews (2): Last reviewed commit: "fix(pkg-pacman): validate repoBaseUrl + ..." | Re-trigger Greptile |
- assertValidNames() now rejects repoBaseUrl containing newlines or single quotes (P1 security): a newline injected a fake [section] into the generated .pacman.conf; a single quote broke out of the rsync command quoting. - Validate pkgrel is a positive integer (P2) — it's embedded unquoted in the PKGBUILD. - Fix misleading test description (empty arrays, not SKIP); add rejection tests for hostile repoBaseUrl and pkgrel.
|
Thanks — solid catch on
|
Add
pkg-pacmantarget — Arch custom repository (repo-add)Implements the
pkg-pacmandistribution target — a custom Arch binary repo built withrepo-add(this is not the AUR;pkg-aurcovers that). Fills the README "Package managers → pacman" entry; mirrors thepkg-apt/pkg-dnfconvention.What's included
packages/targets/pkg-pacman/— adapter, tests, package.json, tsconfig, README.build()generates a real PKGBUILD (pkgver normalized — no-/:; shell-escapedpkgdesc/url) plus apacman.conf[repo]snippet for consumers.ship()is dry-run-safe and surfaces the exactmakepkg+repo-add --signcommands; live publish throwsnot implementedrather than a false success.assertValidNames()rejectspkgnameoutside Arch rules andrepoNameoutside[A-Za-z0-9_-], closing PKGBUILD-syntax andpacman.conf[section]injection vectors; shell command args are quoted.packages/cli/src/adapter-registry.ts;TARGETS.mdrow added (✅).Tests
smokeTest+ PKGBUILD/pacman.conf generation, pkgver normalization, shell-escaping, dry-run command surfacing, live-throw,bash -nsyntax validation with hostile field values, and name-rejection cases.pnpm install --frozen-lockfilegreen.No external CLI or secrets needed for build/test (dry-run only).