Skip to content

Commit 681de06

Browse files
committed
Move apk package management from openwrt to linux
1 parent 9c7dcc2 commit 681de06

7 files changed

Lines changed: 19 additions & 17 deletions

File tree

‎docs/src/content/docs/linux/package-management.md‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ title: Package Management
33
description: APT, DNF4, DNF5, Pacman, APK, and RPM package management operations.
44
---
55

6-
Manage packages on Debian/Ubuntu (APT), Fedora (DNF5), RHEL (DNF4), Arch Linux (pacman), and OpenWrt 25.12+ (APK), plus GPG keys in the RPM database.
6+
Manage packages on Debian/Ubuntu (APT), Fedora (DNF5), RHEL (DNF4), Arch Linux (pacman), and Alpine-based distros (APK), plus GPG keys in the RPM database.
77

88
## APT (Debian/Ubuntu)
99

@@ -131,10 +131,10 @@ await removePackages({ packages: ['nginx'] });
131131
await removePackages({ packages: ['nginx'], autoremove: true });
132132
```
133133

134-
## APK (OpenWrt 25.12+)
134+
## APK (Alpine-based)
135135

136136
```ts
137-
import { getInstalledPackages, installPackages, removePackages } from '@sysopkit/openwrt/pkg/apk';
137+
import { getInstalledPackages, installPackages, removePackages } from '@sysopkit/linux/pkg/apk';
138138
```
139139

140140
### getInstalledPackages()

‎packages/@sysopkit/linux/README.md‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ bun add @sysopkit/linux sysopkit
1919
| `disk` | `@sysopkit/linux/disk` | `lsblk()` — `BlockDeviceEntry[]` tree |
2020
| `os` | `@sysopkit/linux/os` | `getOSInfo()` — `/etc/os-release` |
2121
| `pkg/apt` | `@sysopkit/linux/pkg/apt` | **Idempotent** `installPackages`, `removePackages` (`autoremove?`); `getInstalledPackages()` |
22+
| `pkg/apk` | `@sysopkit/linux/pkg/apk` | **Idempotent** `installPackages`, `removePackages` (dry-run via `--simulate`); `getInstalledPackages()` |
2223
| `pkg/dnf4` | `@sysopkit/linux/pkg/dnf4` | **Idempotent** `installPackages` (`weakDependencies?`), `removePackages` (unused deps cleaned natively); `getInstalledPackages()` |
2324
| `pkg/dnf5` | `@sysopkit/linux/pkg/dnf5` | **Idempotent** `installPackages` (`weakDependencies?`), `removePackages` (unused deps cleaned natively); `getInstalledPackages()` |
2425
| `pkg/rpm` | `@sysopkit/linux/pkg/rpm` | **Idempotent** `importRpmKey({ name, content })`; `hasRpmKey(key)`, `getRpmKeys()`, `getRpmVars(vars)` |

‎packages/@sysopkit/linux/package.json‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,11 @@
2727
"types": "./dist/pkg/apt.d.ts",
2828
"default": "./dist/pkg/apt.js"
2929
},
30+
"./pkg/apk": {
31+
"bun": "./src/pkg/apk.ts",
32+
"types": "./dist/pkg/apk.d.ts",
33+
"default": "./dist/pkg/apk.js"
34+
},
3035
"./pkg/dnf4": {
3136
"bun": "./src/pkg/dnf4.ts",
3237
"types": "./dist/pkg/dnf4.d.ts",
Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,16 @@
11
/**
22
* @module pkg/apk
33
*
4-
* APK package management for OpenWrt 25.12 and newer.
4+
* APK package management for Alpine-based distributions.
55
*
6-
* APK (Alpine Package Keeper) replaced opkg as the package manager in
7-
* OpenWrt 25.12. This module provides operations for package management
8-
* using only `sh` and busybox applets (OpenWrt images carry no parity
9-
* contract: no sudo user, no bash).
6+
* APK (Alpine Package Keeper) is the package manager for Alpine Linux and
7+
* Alpine-based distributions, including OpenWrt 25.12 and newer (where it
8+
* replaced opkg). This module provides operations for package management
9+
* using only `sh`, so it also works on minimal/busybox environments like
10+
* OpenWrt (no sudo user, no bash assumptions).
1011
*
11-
* @see https://openwrt.org/docs/guide-user/additional-software/apk - APK package manager
12+
* @see https://wiki.alpinelinux.org/wiki/Alpine_Package_Keeper - APK package manager
13+
* @see https://openwrt.org/docs/guide-user/additional-software/apk - APK on OpenWrt
1214
*/
1315

1416
import { emitChanged, task, VERBOSITY_TRACE } from 'sysopkit';

‎packages/@sysopkit/openwrt/README.md‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,6 @@ Write `text` to the target with `createFile`, then reload with `sh('service netw
5151
| `@sysopkit/openwrt/uci/system` | `system` | `UciSystemSystem`, `UciSystemTimeserver`, `UciSystemLed`, `UciSystemRDNSSD` |
5252
| `@sysopkit/openwrt/uci/sqm` | `sqm` | `UciSqmQueue` |
5353
| `@sysopkit/openwrt/uci/upnpd` | `upnpd` | `UciUpnpdConfig`, `UciUpnpdPermRule` |
54-
| `@sysopkit/openwrt/pkg/apk` | — | **Idempotent** `installPackages`, `removePackages` (dry-run via `--simulate`); `getInstalledPackages()` |
5554

5655
See the [docs site](https://www.sysopkit.com) for field-level details.
5756

‎packages/@sysopkit/openwrt/package.json‎

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,6 @@
2222
"sideEffects": false,
2323
"module": "true",
2424
"exports": {
25-
"./pkg/apk": {
26-
"bun": "./src/pkg/apk.ts",
27-
"types": "./dist/pkg/apk.d.ts",
28-
"default": "./dist/pkg/apk.js"
29-
},
3025
"./uci/dhcp": {
3126
"bun": "./src/uci/dhcp.ts",
3227
"types": "./dist/uci/dhcp.d.ts",

‎tests/e2e/ops/pkg-apk.test.ts‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { afterAll, beforeAll, describe, expect, test } from 'bun:test';
2-
import { getInstalledPackages, installPackages, removePackages } from '@sysopkit/openwrt/pkg/apk';
2+
import { getInstalledPackages, installPackages, removePackages } from '@sysopkit/linux/pkg/apk';
33
import { trackChanged } from '@sysopkit/test-utils';
44
import { onChange, type ChangeEntry } from 'sysopkit';
55
import { sh } from 'sysopkit/op/sh';
@@ -21,7 +21,7 @@ async function installedNames(): Promise<Set<string>> {
2121
}
2222

2323
/** OpenWrt is non-parity: only `sh` + busybox applets, no sudo user. */
24-
describe('pkg/apk (openwrt)', () => {
24+
describe('pkg/apk (alpine-based, on openwrt)', () => {
2525
let shared: Container;
2626
beforeAll(async () => {
2727
shared = await startSharedContainer({ distro: 'openwrt', publishSsh: false });

0 commit comments

Comments
 (0)