typescript-virtual-container 1.2.9 → 1.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.vscode/settings.json +0 -1
- package/README.md +141 -50
- package/biome.json +7 -0
- package/dist/SSHMimic/exec.d.ts.map +1 -1
- package/dist/SSHMimic/executor.d.ts.map +1 -1
- package/dist/SSHMimic/executor.js +32 -16
- package/dist/SSHMimic/index.d.ts.map +1 -1
- package/dist/SSHMimic/index.js +20 -6
- package/dist/VirtualFileSystem/binaryPack.d.ts.map +1 -1
- package/dist/VirtualFileSystem/binaryPack.js +29 -6
- package/dist/VirtualFileSystem/index.d.ts.map +1 -1
- package/dist/VirtualFileSystem/index.js +36 -13
- package/dist/VirtualPackageManager/index.d.ts.map +1 -1
- package/dist/VirtualPackageManager/index.js +192 -43
- package/dist/VirtualShell/index.d.ts +10 -4
- package/dist/VirtualShell/index.d.ts.map +1 -1
- package/dist/VirtualShell/index.js +18 -7
- package/dist/VirtualShell/shell.d.ts.map +1 -1
- package/dist/VirtualShell/shell.js +3 -1
- package/dist/VirtualShell/shellParser.d.ts.map +1 -1
- package/dist/VirtualUserManager/index.d.ts.map +1 -1
- package/dist/commands/adduser.d.ts +6 -0
- package/dist/commands/adduser.d.ts.map +1 -1
- package/dist/commands/adduser.js +6 -0
- package/dist/commands/alias.d.ts +5 -0
- package/dist/commands/alias.d.ts.map +1 -1
- package/dist/commands/alias.js +5 -0
- package/dist/commands/apt.d.ts +5 -0
- package/dist/commands/apt.d.ts.map +1 -1
- package/dist/commands/apt.js +32 -9
- package/dist/commands/awk.d.ts +11 -0
- package/dist/commands/awk.d.ts.map +1 -1
- package/dist/commands/awk.js +15 -2
- package/dist/commands/base64.d.ts +5 -0
- package/dist/commands/base64.d.ts.map +1 -1
- package/dist/commands/base64.js +9 -1
- package/dist/commands/cat.d.ts +5 -0
- package/dist/commands/cat.d.ts.map +1 -1
- package/dist/commands/cat.js +10 -2
- package/dist/commands/cd.d.ts +5 -0
- package/dist/commands/cd.d.ts.map +1 -1
- package/dist/commands/cd.js +5 -0
- package/dist/commands/chmod.d.ts +5 -0
- package/dist/commands/chmod.d.ts.map +1 -1
- package/dist/commands/chmod.js +5 -0
- package/dist/commands/cp.d.ts +5 -0
- package/dist/commands/cp.d.ts.map +1 -1
- package/dist/commands/cp.js +5 -0
- package/dist/commands/curl.d.ts +5 -0
- package/dist/commands/curl.d.ts.map +1 -1
- package/dist/commands/curl.js +34 -6
- package/dist/commands/cut.d.ts +5 -0
- package/dist/commands/cut.d.ts.map +1 -1
- package/dist/commands/cut.js +8 -1
- package/dist/commands/date.d.ts +5 -0
- package/dist/commands/date.d.ts.map +1 -1
- package/dist/commands/date.js +7 -1
- package/dist/commands/declare.d.ts +3 -0
- package/dist/commands/declare.d.ts.map +1 -0
- package/dist/commands/declare.js +39 -0
- package/dist/commands/diff.d.ts +5 -0
- package/dist/commands/diff.d.ts.map +1 -1
- package/dist/commands/diff.js +5 -0
- package/dist/commands/dpkg.d.ts +5 -0
- package/dist/commands/dpkg.d.ts.map +1 -1
- package/dist/commands/dpkg.js +24 -7
- package/dist/commands/du.d.ts.map +1 -1
- package/dist/commands/du.js +8 -2
- package/dist/commands/echo.d.ts +5 -0
- package/dist/commands/echo.d.ts.map +1 -1
- package/dist/commands/echo.js +13 -4
- package/dist/commands/env.d.ts +5 -0
- package/dist/commands/env.d.ts.map +1 -1
- package/dist/commands/env.js +11 -1
- package/dist/commands/exit.d.ts +5 -0
- package/dist/commands/exit.d.ts.map +1 -1
- package/dist/commands/exit.js +12 -2
- package/dist/commands/export.d.ts.map +1 -1
- package/dist/commands/export.js +3 -1
- package/dist/commands/find.d.ts +5 -0
- package/dist/commands/find.d.ts.map +1 -1
- package/dist/commands/find.js +5 -0
- package/dist/commands/free.d.ts +5 -0
- package/dist/commands/free.d.ts.map +1 -1
- package/dist/commands/free.js +5 -0
- package/dist/commands/grep.d.ts +5 -0
- package/dist/commands/grep.d.ts.map +1 -1
- package/dist/commands/grep.js +12 -2
- package/dist/commands/gzip.d.ts +5 -0
- package/dist/commands/gzip.d.ts.map +1 -1
- package/dist/commands/gzip.js +18 -2
- package/dist/commands/head.d.ts +5 -0
- package/dist/commands/head.d.ts.map +1 -1
- package/dist/commands/head.js +5 -0
- package/dist/commands/help.d.ts.map +1 -1
- package/dist/commands/help.js +98 -45
- package/dist/commands/history.d.ts +5 -0
- package/dist/commands/history.d.ts.map +1 -1
- package/dist/commands/history.js +5 -0
- package/dist/commands/hostname.d.ts +5 -0
- package/dist/commands/hostname.d.ts.map +1 -1
- package/dist/commands/hostname.js +5 -0
- package/dist/commands/id.d.ts.map +1 -1
- package/dist/commands/id.js +4 -1
- package/dist/commands/index.d.ts +2 -17
- package/dist/commands/index.d.ts.map +1 -1
- package/dist/commands/index.js +2 -340
- package/dist/commands/ls.d.ts.map +1 -1
- package/dist/commands/ls.js +3 -1
- package/dist/commands/lsb-release.d.ts.map +1 -1
- package/dist/commands/lsb-release.js +8 -2
- package/dist/commands/nano.js +1 -1
- package/dist/commands/neofetch.js +1 -1
- package/dist/commands/node.d.ts +9 -0
- package/dist/commands/node.d.ts.map +1 -0
- package/dist/commands/node.js +316 -0
- package/dist/commands/npm.d.ts +19 -0
- package/dist/commands/npm.d.ts.map +1 -0
- package/dist/commands/npm.js +109 -0
- package/dist/commands/ping.d.ts.map +1 -1
- package/dist/commands/ping.js +3 -1
- package/dist/commands/printf.d.ts +3 -0
- package/dist/commands/printf.d.ts.map +1 -0
- package/dist/commands/printf.js +113 -0
- package/dist/commands/ps.d.ts.map +1 -1
- package/dist/commands/ps.js +4 -1
- package/dist/commands/python.d.ts +30 -0
- package/dist/commands/python.d.ts.map +1 -0
- package/dist/commands/python.js +2058 -0
- package/dist/commands/read.d.ts +3 -0
- package/dist/commands/read.d.ts.map +1 -0
- package/dist/commands/read.js +34 -0
- package/dist/commands/registry.d.ts +8 -0
- package/dist/commands/registry.d.ts.map +1 -0
- package/dist/commands/registry.js +229 -0
- package/dist/commands/runtime.d.ts +6 -0
- package/dist/commands/runtime.d.ts.map +1 -0
- package/dist/commands/runtime.js +280 -0
- package/dist/commands/sed.d.ts.map +1 -1
- package/dist/commands/sed.js +11 -3
- package/dist/commands/set.d.ts.map +1 -1
- package/dist/commands/set.js +9 -3
- package/dist/commands/sh.d.ts.map +1 -1
- package/dist/commands/sh.js +57 -36
- package/dist/commands/shift.d.ts +5 -0
- package/dist/commands/shift.d.ts.map +1 -0
- package/dist/commands/shift.js +52 -0
- package/dist/commands/sleep.d.ts.map +1 -1
- package/dist/commands/sort.d.ts.map +1 -1
- package/dist/commands/sort.js +4 -2
- package/dist/commands/source.d.ts.map +1 -1
- package/dist/commands/source.js +5 -2
- package/dist/commands/sudo.js +1 -1
- package/dist/commands/tar.d.ts.map +1 -1
- package/dist/commands/tar.js +11 -3
- package/dist/commands/tee.d.ts.map +1 -1
- package/dist/commands/tee.js +8 -6
- package/dist/commands/test.d.ts.map +1 -1
- package/dist/commands/test.js +46 -24
- package/dist/commands/tr.d.ts.map +1 -1
- package/dist/commands/tr.js +3 -1
- package/dist/commands/true.d.ts +4 -0
- package/dist/commands/true.d.ts.map +1 -0
- package/dist/commands/true.js +14 -0
- package/dist/commands/type.d.ts.map +1 -1
- package/dist/commands/type.js +1 -1
- package/dist/commands/uname.d.ts.map +1 -1
- package/dist/commands/uname.js +4 -1
- package/dist/commands/uniq.d.ts.map +1 -1
- package/dist/commands/uptime.d.ts.map +1 -1
- package/dist/commands/uptime.js +4 -1
- package/dist/commands/wget.d.ts.map +1 -1
- package/dist/commands/wget.js +32 -7
- package/dist/commands/which.d.ts.map +1 -1
- package/dist/commands/xargs.d.ts.map +1 -1
- package/dist/commands/xargs.js +1 -1
- package/dist/index.d.ts +15 -14
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +9 -9
- package/dist/modules/linuxRootfs.d.ts +18 -1
- package/dist/modules/linuxRootfs.d.ts.map +1 -1
- package/dist/modules/linuxRootfs.js +160 -17
- package/dist/standalone-wo-sftp.d.ts +2 -0
- package/dist/standalone-wo-sftp.d.ts.map +1 -0
- package/dist/standalone-wo-sftp.js +30 -0
- package/dist/utils/expand.d.ts +50 -0
- package/dist/utils/expand.d.ts.map +1 -0
- package/dist/utils/expand.js +183 -0
- package/dist/utils/vfsDiff.d.ts +90 -0
- package/dist/utils/vfsDiff.d.ts.map +1 -0
- package/dist/utils/vfsDiff.js +177 -0
- package/package.json +2 -1
- package/src/SSHMimic/exec.ts +10 -1
- package/src/SSHMimic/executor.ts +104 -18
- package/src/SSHMimic/index.ts +49 -15
- package/src/VirtualFileSystem/binaryPack.ts +35 -8
- package/src/VirtualFileSystem/index.ts +78 -28
- package/src/VirtualPackageManager/index.ts +208 -49
- package/src/VirtualShell/index.ts +35 -7
- package/src/VirtualShell/shell.ts +23 -3
- package/src/VirtualShell/shellParser.ts +134 -36
- package/src/VirtualUserManager/index.ts +7 -2
- package/src/commands/adduser.ts +6 -0
- package/src/commands/alias.ts +5 -1
- package/src/commands/apt.ts +47 -17
- package/src/commands/awk.ts +20 -6
- package/src/commands/base64.ts +13 -2
- package/src/commands/cat.ts +13 -5
- package/src/commands/cd.ts +5 -0
- package/src/commands/chmod.ts +5 -0
- package/src/commands/cp.ts +5 -0
- package/src/commands/curl.ts +56 -12
- package/src/commands/cut.ts +8 -1
- package/src/commands/date.ts +7 -1
- package/src/commands/declare.ts +44 -0
- package/src/commands/diff.ts +17 -3
- package/src/commands/dpkg.ts +33 -11
- package/src/commands/du.ts +17 -5
- package/src/commands/echo.ts +22 -9
- package/src/commands/env.ts +11 -1
- package/src/commands/exit.ts +12 -2
- package/src/commands/export.ts +3 -1
- package/src/commands/find.ts +5 -0
- package/src/commands/free.ts +9 -2
- package/src/commands/grep.ts +12 -2
- package/src/commands/gzip.ts +28 -4
- package/src/commands/head.ts +5 -0
- package/src/commands/help.ts +121 -47
- package/src/commands/history.ts +7 -2
- package/src/commands/hostname.ts +5 -0
- package/src/commands/id.ts +4 -1
- package/src/commands/index.ts +9 -360
- package/src/commands/ls.ts +5 -3
- package/src/commands/lsb-release.ts +8 -2
- package/src/commands/nano.ts +1 -1
- package/src/commands/neofetch.ts +1 -1
- package/src/commands/node.ts +341 -0
- package/src/commands/npm.ts +132 -0
- package/src/commands/ping.ts +6 -2
- package/src/commands/printf.ts +112 -0
- package/src/commands/ps.ts +21 -9
- package/src/commands/python.ts +2229 -0
- package/src/commands/read.ts +41 -0
- package/src/commands/registry.ts +244 -0
- package/src/commands/runtime.ts +353 -0
- package/src/commands/sed.ts +27 -9
- package/src/commands/set.ts +9 -3
- package/src/commands/sh.ts +159 -55
- package/src/commands/shift.ts +53 -0
- package/src/commands/sleep.ts +2 -1
- package/src/commands/sort.ts +10 -6
- package/src/commands/source.ts +15 -3
- package/src/commands/sudo.ts +1 -1
- package/src/commands/tar.ts +28 -7
- package/src/commands/tee.ts +7 -1
- package/src/commands/test.ts +61 -26
- package/src/commands/tr.ts +3 -1
- package/src/commands/true.ts +17 -0
- package/src/commands/type.ts +6 -3
- package/src/commands/uname.ts +5 -1
- package/src/commands/uniq.ts +8 -2
- package/src/commands/uptime.ts +4 -1
- package/src/commands/wget.ts +51 -12
- package/src/commands/which.ts +5 -2
- package/src/commands/xargs.ts +11 -2
- package/src/index.ts +23 -24
- package/src/modules/linuxRootfs.ts +233 -30
- package/src/standalone-wo-sftp.ts +38 -0
- package/src/utils/expand.ts +238 -0
- package/src/utils/vfsDiff.ts +275 -0
- package/standalone-wo-sftp.js +507 -0
- package/standalone-wo-sftp.js.map +7 -0
- package/standalone.js +253 -191
- package/standalone.js.map +4 -4
- package/tests/bun-test-shim.ts +9 -1
- package/tests/command-helpers.test.ts +1 -5
- package/tests/new-features.test.ts +415 -5
- package/tests/parser-executor.test.ts +27 -27
- package/tests/sftp.test.ts +122 -42
- package/tests/users.test.ts +23 -5
- package/CHANGELOG.md +0 -150
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
1
|
import type VirtualFileSystem from "../VirtualFileSystem";
|
|
4
2
|
import type { VirtualUserManager } from "../VirtualUserManager";
|
|
5
3
|
|
|
@@ -89,9 +87,21 @@ const PACKAGE_REGISTRY: PackageDefinition[] = [
|
|
|
89
87
|
shortDesc: "Vi IMproved",
|
|
90
88
|
installedSizeKb: 3812,
|
|
91
89
|
files: [
|
|
92
|
-
{
|
|
93
|
-
|
|
94
|
-
|
|
90
|
+
{
|
|
91
|
+
path: "/usr/bin/vim",
|
|
92
|
+
content:
|
|
93
|
+
"#!/bin/sh\necho 'vim: use nano for editing in this environment'\n",
|
|
94
|
+
mode: 0o755,
|
|
95
|
+
},
|
|
96
|
+
{
|
|
97
|
+
path: "/usr/bin/vi",
|
|
98
|
+
content: '#!/bin/sh\nexec vim "$@"\n',
|
|
99
|
+
mode: 0o755,
|
|
100
|
+
},
|
|
101
|
+
{
|
|
102
|
+
path: "/usr/share/doc/vim/README",
|
|
103
|
+
content: "Vim editor — virtual package.\n",
|
|
104
|
+
},
|
|
95
105
|
],
|
|
96
106
|
},
|
|
97
107
|
{
|
|
@@ -102,8 +112,15 @@ const PACKAGE_REGISTRY: PackageDefinition[] = [
|
|
|
102
112
|
shortDesc: "fast distributed version control system",
|
|
103
113
|
installedSizeKb: 11240,
|
|
104
114
|
files: [
|
|
105
|
-
{
|
|
106
|
-
|
|
115
|
+
{
|
|
116
|
+
path: "/usr/bin/git",
|
|
117
|
+
content: "#!/bin/sh\necho 'git: virtual stub — no host access'\n",
|
|
118
|
+
mode: 0o755,
|
|
119
|
+
},
|
|
120
|
+
{
|
|
121
|
+
path: "/usr/share/doc/git/README.Debian",
|
|
122
|
+
content: "Git virtual package for Fortune GNU/Linux.\n",
|
|
123
|
+
},
|
|
107
124
|
],
|
|
108
125
|
},
|
|
109
126
|
{
|
|
@@ -115,8 +132,16 @@ const PACKAGE_REGISTRY: PackageDefinition[] = [
|
|
|
115
132
|
installedSizeKb: 512,
|
|
116
133
|
depends: ["python3-minimal"],
|
|
117
134
|
files: [
|
|
118
|
-
{
|
|
119
|
-
|
|
135
|
+
{
|
|
136
|
+
path: "/usr/bin/python3",
|
|
137
|
+
content: "#!/bin/sh\necho 'Python 3.11.2 (virtual)'\n",
|
|
138
|
+
mode: 0o755,
|
|
139
|
+
},
|
|
140
|
+
{
|
|
141
|
+
path: "/usr/bin/python3.11",
|
|
142
|
+
content: '#!/bin/sh\nexec python3 "$@"\n',
|
|
143
|
+
mode: 0o755,
|
|
144
|
+
},
|
|
120
145
|
{ path: "/usr/lib/python3.11/.keep", content: "" },
|
|
121
146
|
],
|
|
122
147
|
},
|
|
@@ -127,9 +152,7 @@ const PACKAGE_REGISTRY: PackageDefinition[] = [
|
|
|
127
152
|
description: "Minimal subset of the Python language (version 3)",
|
|
128
153
|
shortDesc: "minimal subset of Python language",
|
|
129
154
|
installedSizeKb: 196,
|
|
130
|
-
files: [
|
|
131
|
-
{ path: "/usr/lib/python3-minimal/.keep", content: "" },
|
|
132
|
-
],
|
|
155
|
+
files: [{ path: "/usr/lib/python3-minimal/.keep", content: "" }],
|
|
133
156
|
},
|
|
134
157
|
{
|
|
135
158
|
name: "nodejs",
|
|
@@ -139,9 +162,20 @@ const PACKAGE_REGISTRY: PackageDefinition[] = [
|
|
|
139
162
|
shortDesc: "Node.js JavaScript runtime",
|
|
140
163
|
installedSizeKb: 15360,
|
|
141
164
|
files: [
|
|
142
|
-
{
|
|
143
|
-
|
|
144
|
-
|
|
165
|
+
{
|
|
166
|
+
path: "/usr/bin/node",
|
|
167
|
+
content: "#!/bin/sh\necho 'node v18.19.0 (virtual)'\n",
|
|
168
|
+
mode: 0o755,
|
|
169
|
+
},
|
|
170
|
+
{
|
|
171
|
+
path: "/usr/bin/nodejs",
|
|
172
|
+
content: '#!/bin/sh\nexec node "$@"\n',
|
|
173
|
+
mode: 0o755,
|
|
174
|
+
},
|
|
175
|
+
{
|
|
176
|
+
path: "/usr/share/doc/nodejs/README",
|
|
177
|
+
content: "Node.js virtual package.\n",
|
|
178
|
+
},
|
|
145
179
|
],
|
|
146
180
|
},
|
|
147
181
|
{
|
|
@@ -153,7 +187,16 @@ const PACKAGE_REGISTRY: PackageDefinition[] = [
|
|
|
153
187
|
installedSizeKb: 9814,
|
|
154
188
|
depends: ["nodejs"],
|
|
155
189
|
files: [
|
|
156
|
-
{
|
|
190
|
+
{
|
|
191
|
+
path: "/usr/bin/npm",
|
|
192
|
+
content: '#!/bin/sh\nexec builtin npm "$@"\n',
|
|
193
|
+
mode: 0o755,
|
|
194
|
+
},
|
|
195
|
+
{
|
|
196
|
+
path: "/usr/bin/npx",
|
|
197
|
+
content: '#!/bin/sh\nexec builtin npx "$@"\n',
|
|
198
|
+
mode: 0o755,
|
|
199
|
+
},
|
|
157
200
|
],
|
|
158
201
|
},
|
|
159
202
|
{
|
|
@@ -164,7 +207,11 @@ const PACKAGE_REGISTRY: PackageDefinition[] = [
|
|
|
164
207
|
shortDesc: "command line tool for transferring data",
|
|
165
208
|
installedSizeKb: 368,
|
|
166
209
|
files: [
|
|
167
|
-
{
|
|
210
|
+
{
|
|
211
|
+
path: "/usr/bin/curl",
|
|
212
|
+
content: '#!/bin/sh\nexec builtin curl "$@"\n',
|
|
213
|
+
mode: 0o755,
|
|
214
|
+
},
|
|
168
215
|
],
|
|
169
216
|
},
|
|
170
217
|
{
|
|
@@ -175,7 +222,11 @@ const PACKAGE_REGISTRY: PackageDefinition[] = [
|
|
|
175
222
|
shortDesc: "retrieves files from the web",
|
|
176
223
|
installedSizeKb: 952,
|
|
177
224
|
files: [
|
|
178
|
-
{
|
|
225
|
+
{
|
|
226
|
+
path: "/usr/bin/wget",
|
|
227
|
+
content: '#!/bin/sh\nexec builtin wget "$@"\n',
|
|
228
|
+
mode: 0o755,
|
|
229
|
+
},
|
|
179
230
|
],
|
|
180
231
|
},
|
|
181
232
|
{
|
|
@@ -186,7 +237,11 @@ const PACKAGE_REGISTRY: PackageDefinition[] = [
|
|
|
186
237
|
shortDesc: "interactive process viewer",
|
|
187
238
|
installedSizeKb: 412,
|
|
188
239
|
files: [
|
|
189
|
-
{
|
|
240
|
+
{
|
|
241
|
+
path: "/usr/bin/htop",
|
|
242
|
+
content: "#!/bin/sh\nexec builtin htop\n",
|
|
243
|
+
mode: 0o755,
|
|
244
|
+
},
|
|
190
245
|
],
|
|
191
246
|
},
|
|
192
247
|
{
|
|
@@ -197,9 +252,20 @@ const PACKAGE_REGISTRY: PackageDefinition[] = [
|
|
|
197
252
|
shortDesc: "secure shell (SSH) client",
|
|
198
253
|
installedSizeKb: 4540,
|
|
199
254
|
files: [
|
|
200
|
-
{
|
|
201
|
-
|
|
202
|
-
|
|
255
|
+
{
|
|
256
|
+
path: "/usr/bin/ssh",
|
|
257
|
+
content: "#!/bin/sh\necho 'ssh: virtual stub'\n",
|
|
258
|
+
mode: 0o755,
|
|
259
|
+
},
|
|
260
|
+
{
|
|
261
|
+
path: "/usr/bin/ssh-keygen",
|
|
262
|
+
content: "#!/bin/sh\necho 'ssh-keygen: virtual stub'\n",
|
|
263
|
+
mode: 0o755,
|
|
264
|
+
},
|
|
265
|
+
{
|
|
266
|
+
path: "/etc/ssh/ssh_config",
|
|
267
|
+
content: "Host *\n StrictHostKeyChecking ask\n",
|
|
268
|
+
},
|
|
203
269
|
],
|
|
204
270
|
},
|
|
205
271
|
{
|
|
@@ -211,8 +277,15 @@ const PACKAGE_REGISTRY: PackageDefinition[] = [
|
|
|
211
277
|
installedSizeKb: 1732,
|
|
212
278
|
depends: ["openssh-client"],
|
|
213
279
|
files: [
|
|
214
|
-
{
|
|
215
|
-
|
|
280
|
+
{
|
|
281
|
+
path: "/usr/sbin/sshd",
|
|
282
|
+
content: "#!/bin/sh\necho 'sshd: virtual — server already running'\n",
|
|
283
|
+
mode: 0o755,
|
|
284
|
+
},
|
|
285
|
+
{
|
|
286
|
+
path: "/etc/ssh/sshd_config",
|
|
287
|
+
content: "Port 22\nPermitRootLogin yes\nPasswordAuthentication yes\n",
|
|
288
|
+
},
|
|
216
289
|
],
|
|
217
290
|
},
|
|
218
291
|
{
|
|
@@ -223,9 +296,24 @@ const PACKAGE_REGISTRY: PackageDefinition[] = [
|
|
|
223
296
|
shortDesc: "networking toolkit",
|
|
224
297
|
installedSizeKb: 988,
|
|
225
298
|
files: [
|
|
226
|
-
{
|
|
227
|
-
|
|
228
|
-
|
|
299
|
+
{
|
|
300
|
+
path: "/usr/bin/ifconfig",
|
|
301
|
+
content:
|
|
302
|
+
"#!/bin/sh\necho 'eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500'\necho ' inet 10.0.0.2 netmask 255.255.255.0 broadcast 10.0.0.255'\necho ' ether 02:42:0a:00:00:02 txqueuelen 0 (Ethernet)'\n",
|
|
303
|
+
mode: 0o755,
|
|
304
|
+
},
|
|
305
|
+
{
|
|
306
|
+
path: "/usr/bin/netstat",
|
|
307
|
+
content:
|
|
308
|
+
"#!/bin/sh\necho 'Active Internet connections (only servers)'\necho 'Proto Recv-Q Send-Q Local Address Foreign Address State'\n",
|
|
309
|
+
mode: 0o755,
|
|
310
|
+
},
|
|
311
|
+
{
|
|
312
|
+
path: "/usr/bin/route",
|
|
313
|
+
content:
|
|
314
|
+
"#!/bin/sh\necho 'Kernel IP routing table'\necho 'Destination Gateway Genmask Flags Metric Ref Use Iface'\necho '0.0.0.0 10.0.0.1 0.0.0.0 UG 0 0 0 eth0'\n",
|
|
315
|
+
mode: 0o755,
|
|
316
|
+
},
|
|
229
317
|
],
|
|
230
318
|
},
|
|
231
319
|
{
|
|
@@ -236,7 +324,11 @@ const PACKAGE_REGISTRY: PackageDefinition[] = [
|
|
|
236
324
|
shortDesc: "test reachability of network hosts",
|
|
237
325
|
installedSizeKb: 164,
|
|
238
326
|
files: [
|
|
239
|
-
{
|
|
327
|
+
{
|
|
328
|
+
path: "/usr/bin/ping",
|
|
329
|
+
content: '#!/bin/sh\nexec builtin ping "$@"\n',
|
|
330
|
+
mode: 0o755,
|
|
331
|
+
},
|
|
240
332
|
],
|
|
241
333
|
},
|
|
242
334
|
{
|
|
@@ -247,7 +339,11 @@ const PACKAGE_REGISTRY: PackageDefinition[] = [
|
|
|
247
339
|
shortDesc: "command-line JSON processor",
|
|
248
340
|
installedSizeKb: 296,
|
|
249
341
|
files: [
|
|
250
|
-
{
|
|
342
|
+
{
|
|
343
|
+
path: "/usr/bin/jq",
|
|
344
|
+
content: "#!/bin/sh\necho 'jq: virtual stub — pipe JSON here'\n",
|
|
345
|
+
mode: 0o755,
|
|
346
|
+
},
|
|
251
347
|
],
|
|
252
348
|
},
|
|
253
349
|
{
|
|
@@ -259,7 +355,10 @@ const PACKAGE_REGISTRY: PackageDefinition[] = [
|
|
|
259
355
|
installedSizeKb: 12,
|
|
260
356
|
depends: ["gcc", "g++", "make"],
|
|
261
357
|
files: [
|
|
262
|
-
{
|
|
358
|
+
{
|
|
359
|
+
path: "/usr/share/doc/build-essential/README",
|
|
360
|
+
content: "Build-essential virtual meta-package.\n",
|
|
361
|
+
},
|
|
263
362
|
],
|
|
264
363
|
},
|
|
265
364
|
{
|
|
@@ -270,8 +369,16 @@ const PACKAGE_REGISTRY: PackageDefinition[] = [
|
|
|
270
369
|
shortDesc: "GNU C compiler",
|
|
271
370
|
installedSizeKb: 24448,
|
|
272
371
|
files: [
|
|
273
|
-
{
|
|
274
|
-
|
|
372
|
+
{
|
|
373
|
+
path: "/usr/bin/gcc",
|
|
374
|
+
content: "#!/bin/sh\necho 'gcc (Fortune GNU/Linux) 12.2.0 (virtual)'\n",
|
|
375
|
+
mode: 0o755,
|
|
376
|
+
},
|
|
377
|
+
{
|
|
378
|
+
path: "/usr/bin/gcc-12",
|
|
379
|
+
content: '#!/bin/sh\nexec gcc "$@"\n',
|
|
380
|
+
mode: 0o755,
|
|
381
|
+
},
|
|
275
382
|
],
|
|
276
383
|
},
|
|
277
384
|
{
|
|
@@ -283,7 +390,11 @@ const PACKAGE_REGISTRY: PackageDefinition[] = [
|
|
|
283
390
|
installedSizeKb: 1024,
|
|
284
391
|
depends: ["gcc"],
|
|
285
392
|
files: [
|
|
286
|
-
{
|
|
393
|
+
{
|
|
394
|
+
path: "/usr/bin/g++",
|
|
395
|
+
content: "#!/bin/sh\necho 'g++ (Fortune GNU/Linux) 12.2.0 (virtual)'\n",
|
|
396
|
+
mode: 0o755,
|
|
397
|
+
},
|
|
287
398
|
],
|
|
288
399
|
},
|
|
289
400
|
{
|
|
@@ -294,7 +405,12 @@ const PACKAGE_REGISTRY: PackageDefinition[] = [
|
|
|
294
405
|
shortDesc: "build utility",
|
|
295
406
|
installedSizeKb: 504,
|
|
296
407
|
files: [
|
|
297
|
-
{
|
|
408
|
+
{
|
|
409
|
+
path: "/usr/bin/make",
|
|
410
|
+
content:
|
|
411
|
+
"#!/bin/sh\necho 'make: *** No targets specified and no makefile found. Stop.'\nexit 2\n",
|
|
412
|
+
mode: 0o755,
|
|
413
|
+
},
|
|
298
414
|
],
|
|
299
415
|
},
|
|
300
416
|
{
|
|
@@ -305,7 +421,7 @@ const PACKAGE_REGISTRY: PackageDefinition[] = [
|
|
|
305
421
|
shortDesc: "pager program",
|
|
306
422
|
installedSizeKb: 328,
|
|
307
423
|
files: [
|
|
308
|
-
{ path: "/usr/bin/less", content:
|
|
424
|
+
{ path: "/usr/bin/less", content: '#!/bin/sh\ncat "$@"\n', mode: 0o755 },
|
|
309
425
|
],
|
|
310
426
|
},
|
|
311
427
|
{
|
|
@@ -316,7 +432,11 @@ const PACKAGE_REGISTRY: PackageDefinition[] = [
|
|
|
316
432
|
shortDesc: "de-archiver for .zip files",
|
|
317
433
|
installedSizeKb: 464,
|
|
318
434
|
files: [
|
|
319
|
-
{
|
|
435
|
+
{
|
|
436
|
+
path: "/usr/bin/unzip",
|
|
437
|
+
content: "#!/bin/sh\necho 'unzip: virtual stub'\n",
|
|
438
|
+
mode: 0o755,
|
|
439
|
+
},
|
|
320
440
|
],
|
|
321
441
|
},
|
|
322
442
|
{
|
|
@@ -327,7 +447,11 @@ const PACKAGE_REGISTRY: PackageDefinition[] = [
|
|
|
327
447
|
shortDesc: "fast remote file copy program",
|
|
328
448
|
installedSizeKb: 716,
|
|
329
449
|
files: [
|
|
330
|
-
{
|
|
450
|
+
{
|
|
451
|
+
path: "/usr/bin/rsync",
|
|
452
|
+
content: "#!/bin/sh\necho 'rsync: virtual stub'\n",
|
|
453
|
+
mode: 0o755,
|
|
454
|
+
},
|
|
331
455
|
],
|
|
332
456
|
},
|
|
333
457
|
{
|
|
@@ -338,7 +462,12 @@ const PACKAGE_REGISTRY: PackageDefinition[] = [
|
|
|
338
462
|
shortDesc: "terminal multiplexer",
|
|
339
463
|
installedSizeKb: 812,
|
|
340
464
|
files: [
|
|
341
|
-
{
|
|
465
|
+
{
|
|
466
|
+
path: "/usr/bin/tmux",
|
|
467
|
+
content:
|
|
468
|
+
"#!/bin/sh\necho 'tmux: terminal multiplexer (virtual stub)'\n",
|
|
469
|
+
mode: 0o755,
|
|
470
|
+
},
|
|
342
471
|
],
|
|
343
472
|
},
|
|
344
473
|
{
|
|
@@ -349,7 +478,11 @@ const PACKAGE_REGISTRY: PackageDefinition[] = [
|
|
|
349
478
|
shortDesc: "list files in tree format",
|
|
350
479
|
installedSizeKb: 108,
|
|
351
480
|
files: [
|
|
352
|
-
{
|
|
481
|
+
{
|
|
482
|
+
path: "/usr/bin/tree",
|
|
483
|
+
content: '#!/bin/sh\nexec builtin tree "$@"\n',
|
|
484
|
+
mode: 0o755,
|
|
485
|
+
},
|
|
353
486
|
],
|
|
354
487
|
},
|
|
355
488
|
{
|
|
@@ -378,7 +511,10 @@ const PACKAGE_REGISTRY: PackageDefinition[] = [
|
|
|
378
511
|
installedSizeKb: 16484,
|
|
379
512
|
files: [
|
|
380
513
|
{ path: "/etc/locale.gen", content: "en_US.UTF-8 UTF-8\n" },
|
|
381
|
-
{
|
|
514
|
+
{
|
|
515
|
+
path: "/etc/default/locale",
|
|
516
|
+
content: "LANG=en_US.UTF-8\nLANGUAGE=en_US:en\n",
|
|
517
|
+
},
|
|
382
518
|
],
|
|
383
519
|
},
|
|
384
520
|
{
|
|
@@ -389,8 +525,15 @@ const PACKAGE_REGISTRY: PackageDefinition[] = [
|
|
|
389
525
|
shortDesc: "super user privilege execution",
|
|
390
526
|
installedSizeKb: 2304,
|
|
391
527
|
files: [
|
|
392
|
-
{
|
|
393
|
-
|
|
528
|
+
{
|
|
529
|
+
path: "/usr/bin/sudo",
|
|
530
|
+
content: '#!/bin/sh\nexec builtin sudo "$@"\n',
|
|
531
|
+
mode: 0o755,
|
|
532
|
+
},
|
|
533
|
+
{
|
|
534
|
+
path: "/etc/sudoers",
|
|
535
|
+
content: "root ALL=(ALL:ALL) ALL\n%sudo ALL=(ALL:ALL) ALL\n",
|
|
536
|
+
},
|
|
394
537
|
],
|
|
395
538
|
},
|
|
396
539
|
{
|
|
@@ -401,8 +544,17 @@ const PACKAGE_REGISTRY: PackageDefinition[] = [
|
|
|
401
544
|
shortDesc: "system and service manager",
|
|
402
545
|
installedSizeKb: 26624,
|
|
403
546
|
files: [
|
|
404
|
-
{
|
|
405
|
-
|
|
547
|
+
{
|
|
548
|
+
path: "/usr/bin/systemctl",
|
|
549
|
+
content:
|
|
550
|
+
"#!/bin/sh\necho 'systemd is not running in this virtual container.'\nexit 1\n",
|
|
551
|
+
mode: 0o755,
|
|
552
|
+
},
|
|
553
|
+
{
|
|
554
|
+
path: "/usr/bin/journalctl",
|
|
555
|
+
content: "#!/bin/sh\necho 'journalctl: virtual stub'\n",
|
|
556
|
+
mode: 0o755,
|
|
557
|
+
},
|
|
406
558
|
],
|
|
407
559
|
},
|
|
408
560
|
];
|
|
@@ -626,7 +778,9 @@ export class VirtualPackageManager {
|
|
|
626
778
|
|
|
627
779
|
if (toInstall.length === 0) {
|
|
628
780
|
return {
|
|
629
|
-
output: names
|
|
781
|
+
output: names
|
|
782
|
+
.map((n) => `${n} is already the newest version.`)
|
|
783
|
+
.join("\n"),
|
|
630
784
|
exitCode: 0,
|
|
631
785
|
};
|
|
632
786
|
}
|
|
@@ -692,7 +846,10 @@ export class VirtualPackageManager {
|
|
|
692
846
|
this.log(`install ${def.name} ${def.version}`);
|
|
693
847
|
}
|
|
694
848
|
|
|
695
|
-
this.aptLog(
|
|
849
|
+
this.aptLog(
|
|
850
|
+
"install",
|
|
851
|
+
toInstall.map((p) => p.name),
|
|
852
|
+
);
|
|
696
853
|
this.persist();
|
|
697
854
|
|
|
698
855
|
if (!opts.quiet) {
|
|
@@ -746,8 +903,7 @@ export class VirtualPackageManager {
|
|
|
746
903
|
}
|
|
747
904
|
|
|
748
905
|
for (const pkg of toRemove) {
|
|
749
|
-
if (!opts.quiet)
|
|
750
|
-
lines.push(`Removing ${pkg.name} (${pkg.version}) ...`);
|
|
906
|
+
if (!opts.quiet) lines.push(`Removing ${pkg.name} (${pkg.version}) ...`);
|
|
751
907
|
|
|
752
908
|
// Remove files (if purge, include config files)
|
|
753
909
|
for (const filePath of pkg.files) {
|
|
@@ -770,7 +926,10 @@ export class VirtualPackageManager {
|
|
|
770
926
|
this.log(`remove ${pkg.name} ${pkg.version}`);
|
|
771
927
|
}
|
|
772
928
|
|
|
773
|
-
this.aptLog(
|
|
929
|
+
this.aptLog(
|
|
930
|
+
"remove",
|
|
931
|
+
toRemove.map((p) => p.name),
|
|
932
|
+
);
|
|
774
933
|
this.persist();
|
|
775
934
|
|
|
776
935
|
return { output: lines.join("\n"), exitCode: 0 };
|
|
@@ -1,13 +1,18 @@
|
|
|
1
1
|
import { EventEmitter } from "node:events";
|
|
2
|
-
import { createCustomCommand, registerCommand
|
|
2
|
+
import { createCustomCommand, registerCommand } from "../commands/registry";
|
|
3
|
+
import { runCommand } from "../commands/runtime";
|
|
4
|
+
import {
|
|
5
|
+
bootstrapLinuxRootfs,
|
|
6
|
+
refreshProc,
|
|
7
|
+
syncEtcPasswd,
|
|
8
|
+
} from "../modules/linuxRootfs";
|
|
3
9
|
import type { CommandContext, CommandResult } from "../types/commands";
|
|
4
10
|
import type { ShellStream } from "../types/streams";
|
|
5
11
|
import type { PerfLogger } from "../utils/perfLogger";
|
|
6
12
|
import { createPerfLogger } from "../utils/perfLogger";
|
|
7
13
|
import VirtualFileSystem, { type VfsOptions } from "../VirtualFileSystem";
|
|
8
|
-
import { VirtualUserManager } from "../VirtualUserManager";
|
|
9
14
|
import { VirtualPackageManager } from "../VirtualPackageManager";
|
|
10
|
-
import {
|
|
15
|
+
import { VirtualUserManager } from "../VirtualUserManager";
|
|
11
16
|
import { startShell } from "./shell";
|
|
12
17
|
|
|
13
18
|
/**
|
|
@@ -211,20 +216,43 @@ class VirtualShell extends EventEmitter {
|
|
|
211
216
|
terminalSize,
|
|
212
217
|
this,
|
|
213
218
|
);
|
|
219
|
+
// Refresh /proc/<pid> and /proc/self after session is registered
|
|
220
|
+
this.refreshProcSessions();
|
|
214
221
|
}
|
|
215
222
|
|
|
216
223
|
/**
|
|
217
224
|
* Refreshes the `/proc` virtual filesystem with current system state.
|
|
218
225
|
*
|
|
219
226
|
* Updates `/proc/uptime`, `/proc/meminfo`, `/proc/cpuinfo`,
|
|
220
|
-
* `/proc/version`,
|
|
227
|
+
* `/proc/version`, `/proc/loadavg`, `/proc/self`, and per-session
|
|
228
|
+
* `/proc/<pid>` entries from live session and host data.
|
|
221
229
|
*
|
|
222
230
|
* Called automatically during `bootstrapLinuxRootfs`. Call again before
|
|
223
|
-
* reading `/proc` files for up-to-date values
|
|
224
|
-
* or `free` in long-running processes).
|
|
231
|
+
* reading `/proc` files for up-to-date values.
|
|
225
232
|
*/
|
|
226
233
|
public refreshProcFs(): void {
|
|
227
|
-
refreshProc(
|
|
234
|
+
refreshProc(
|
|
235
|
+
this.vfs,
|
|
236
|
+
this.properties,
|
|
237
|
+
this.hostname,
|
|
238
|
+
this.startTime,
|
|
239
|
+
this.users.listActiveSessions(),
|
|
240
|
+
);
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
/**
|
|
244
|
+
* Updates only the session-dependent `/proc` entries (`/proc/<pid>`,
|
|
245
|
+
* `/proc/self`). Cheaper than a full `refreshProcFs()` — call this
|
|
246
|
+
* whenever a session is registered or unregistered.
|
|
247
|
+
*/
|
|
248
|
+
public refreshProcSessions(): void {
|
|
249
|
+
refreshProc(
|
|
250
|
+
this.vfs,
|
|
251
|
+
this.properties,
|
|
252
|
+
this.hostname,
|
|
253
|
+
this.startTime,
|
|
254
|
+
this.users.listActiveSessions(),
|
|
255
|
+
);
|
|
228
256
|
}
|
|
229
257
|
|
|
230
258
|
/**
|
|
@@ -73,9 +73,20 @@ export function startShell(
|
|
|
73
73
|
for (const line of bashrc.split("\n")) {
|
|
74
74
|
const l = line.trim();
|
|
75
75
|
if (!l || l.startsWith("#")) continue;
|
|
76
|
-
await runCommand(
|
|
76
|
+
await runCommand(
|
|
77
|
+
l,
|
|
78
|
+
authUser,
|
|
79
|
+
hostname,
|
|
80
|
+
"shell",
|
|
81
|
+
cwd,
|
|
82
|
+
shell,
|
|
83
|
+
undefined,
|
|
84
|
+
shellEnv,
|
|
85
|
+
);
|
|
77
86
|
}
|
|
78
|
-
} catch {
|
|
87
|
+
} catch {
|
|
88
|
+
/* ignore bashrc errors */
|
|
89
|
+
}
|
|
79
90
|
}
|
|
80
91
|
})();
|
|
81
92
|
|
|
@@ -585,7 +596,16 @@ export function startShell(
|
|
|
585
596
|
|
|
586
597
|
if (line.length > 0) {
|
|
587
598
|
const result = await Promise.resolve(
|
|
588
|
-
runCommand(
|
|
599
|
+
runCommand(
|
|
600
|
+
line,
|
|
601
|
+
authUser,
|
|
602
|
+
hostname,
|
|
603
|
+
"shell",
|
|
604
|
+
cwd,
|
|
605
|
+
shell,
|
|
606
|
+
undefined,
|
|
607
|
+
shellEnv,
|
|
608
|
+
),
|
|
589
609
|
);
|
|
590
610
|
|
|
591
611
|
pushHistory(line);
|