pacman-debian 7.2.0

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.
Files changed (233) hide show
  1. package/LICENSE +674 -0
  2. package/README.md +440 -0
  3. package/README.zh.md +388 -0
  4. package/README_zh-CN.md +421 -0
  5. package/dist/ar.d.ts +8 -0
  6. package/dist/ar.d.ts.map +1 -0
  7. package/dist/ar.js +88 -0
  8. package/dist/ar.js.map +1 -0
  9. package/dist/cli/pacman.d.ts +2 -0
  10. package/dist/cli/pacman.d.ts.map +1 -0
  11. package/dist/cli/pacman.js +512 -0
  12. package/dist/cli/pacman.js.map +1 -0
  13. package/dist/compress.d.ts +2 -0
  14. package/dist/compress.d.ts.map +1 -0
  15. package/dist/compress.js +78 -0
  16. package/dist/compress.js.map +1 -0
  17. package/dist/config.d.ts +3 -0
  18. package/dist/config.d.ts.map +1 -0
  19. package/dist/config.js +90 -0
  20. package/dist/config.js.map +1 -0
  21. package/dist/control.d.ts +2 -0
  22. package/dist/control.d.ts.map +1 -0
  23. package/dist/control.js +31 -0
  24. package/dist/control.js.map +1 -0
  25. package/dist/core/ar.d.ts +7 -0
  26. package/dist/core/ar.d.ts.map +1 -0
  27. package/dist/core/ar.js +45 -0
  28. package/dist/core/ar.js.map +1 -0
  29. package/dist/core/compress.d.ts +2 -0
  30. package/dist/core/compress.d.ts.map +1 -0
  31. package/dist/core/compress.js +75 -0
  32. package/dist/core/compress.js.map +1 -0
  33. package/dist/core/control.d.ts +2 -0
  34. package/dist/core/control.d.ts.map +1 -0
  35. package/dist/core/control.js +29 -0
  36. package/dist/core/control.js.map +1 -0
  37. package/dist/core/deb.d.ts +4 -0
  38. package/dist/core/deb.d.ts.map +1 -0
  39. package/dist/core/deb.js +89 -0
  40. package/dist/core/deb.js.map +1 -0
  41. package/dist/core/deps.d.ts +25 -0
  42. package/dist/core/deps.d.ts.map +1 -0
  43. package/dist/core/deps.js +230 -0
  44. package/dist/core/deps.js.map +1 -0
  45. package/dist/core/options.d.ts +19 -0
  46. package/dist/core/options.d.ts.map +1 -0
  47. package/dist/core/options.js +3 -0
  48. package/dist/core/options.js.map +1 -0
  49. package/dist/core/pkgfile.d.ts +35 -0
  50. package/dist/core/pkgfile.d.ts.map +1 -0
  51. package/dist/core/pkgfile.js +162 -0
  52. package/dist/core/pkgfile.js.map +1 -0
  53. package/dist/core/tar.d.ts +13 -0
  54. package/dist/core/tar.d.ts.map +1 -0
  55. package/dist/core/tar.js +132 -0
  56. package/dist/core/tar.js.map +1 -0
  57. package/dist/core/types.d.ts +83 -0
  58. package/dist/core/types.d.ts.map +1 -0
  59. package/dist/core/types.js +3 -0
  60. package/dist/core/types.js.map +1 -0
  61. package/dist/database.d.ts +20 -0
  62. package/dist/database.d.ts.map +1 -0
  63. package/dist/database.js +181 -0
  64. package/dist/database.js.map +1 -0
  65. package/dist/db/database.d.ts +17 -0
  66. package/dist/db/database.d.ts.map +1 -0
  67. package/dist/db/database.js +145 -0
  68. package/dist/db/database.js.map +1 -0
  69. package/dist/db/dpkg-compat.d.ts +19 -0
  70. package/dist/db/dpkg-compat.d.ts.map +1 -0
  71. package/dist/db/dpkg-compat.js +150 -0
  72. package/dist/db/dpkg-compat.js.map +1 -0
  73. package/dist/db/localdb.d.ts +9 -0
  74. package/dist/db/localdb.d.ts.map +1 -0
  75. package/dist/db/localdb.js +246 -0
  76. package/dist/db/localdb.js.map +1 -0
  77. package/dist/db/sqlite.d.ts +20 -0
  78. package/dist/db/sqlite.d.ts.map +1 -0
  79. package/dist/db/sqlite.js +309 -0
  80. package/dist/db/sqlite.js.map +1 -0
  81. package/dist/deb.d.ts +5 -0
  82. package/dist/deb.d.ts.map +1 -0
  83. package/dist/deb.js +105 -0
  84. package/dist/deb.js.map +1 -0
  85. package/dist/dpkg-compat.d.ts +18 -0
  86. package/dist/dpkg-compat.d.ts.map +1 -0
  87. package/dist/dpkg-compat.js +137 -0
  88. package/dist/dpkg-compat.js.map +1 -0
  89. package/dist/i18n/en.json +109 -0
  90. package/dist/i18n/index.d.ts +3 -0
  91. package/dist/i18n/index.d.ts.map +1 -0
  92. package/dist/i18n/index.js +36 -0
  93. package/dist/i18n/index.js.map +1 -0
  94. package/dist/i18n/zh-CN.json +109 -0
  95. package/dist/index.d.ts +3 -0
  96. package/dist/index.d.ts.map +1 -0
  97. package/dist/index.js +9 -0
  98. package/dist/index.js.map +1 -0
  99. package/dist/install.d.ts +2 -0
  100. package/dist/install.d.ts.map +1 -0
  101. package/dist/install.js +126 -0
  102. package/dist/install.js.map +1 -0
  103. package/dist/makepkg/build.d.ts +19 -0
  104. package/dist/makepkg/build.d.ts.map +1 -0
  105. package/dist/makepkg/build.js +370 -0
  106. package/dist/makepkg/build.js.map +1 -0
  107. package/dist/makepkg/index.d.ts +3 -0
  108. package/dist/makepkg/index.d.ts.map +1 -0
  109. package/dist/makepkg/index.js +84 -0
  110. package/dist/makepkg/index.js.map +1 -0
  111. package/dist/makepkg/pkgbuild.d.ts +36 -0
  112. package/dist/makepkg/pkgbuild.d.ts.map +1 -0
  113. package/dist/makepkg/pkgbuild.js +165 -0
  114. package/dist/makepkg/pkgbuild.js.map +1 -0
  115. package/dist/ops/install.d.ts +5 -0
  116. package/dist/ops/install.d.ts.map +1 -0
  117. package/dist/ops/install.js +299 -0
  118. package/dist/ops/install.js.map +1 -0
  119. package/dist/ops/query.d.ts +9 -0
  120. package/dist/ops/query.d.ts.map +1 -0
  121. package/dist/ops/query.js +189 -0
  122. package/dist/ops/query.js.map +1 -0
  123. package/dist/ops/remove.d.ts +3 -0
  124. package/dist/ops/remove.d.ts.map +1 -0
  125. package/dist/ops/remove.js +121 -0
  126. package/dist/ops/remove.js.map +1 -0
  127. package/dist/ops/upgrade.d.ts +4 -0
  128. package/dist/ops/upgrade.d.ts.map +1 -0
  129. package/dist/ops/upgrade.js +122 -0
  130. package/dist/ops/upgrade.js.map +1 -0
  131. package/dist/pacman.d.ts +2 -0
  132. package/dist/pacman.d.ts.map +1 -0
  133. package/dist/pacman.js +165 -0
  134. package/dist/pacman.js.map +1 -0
  135. package/dist/query.d.ts +5 -0
  136. package/dist/query.d.ts.map +1 -0
  137. package/dist/query.js +143 -0
  138. package/dist/query.js.map +1 -0
  139. package/dist/remove.d.ts +2 -0
  140. package/dist/remove.d.ts.map +1 -0
  141. package/dist/remove.js +82 -0
  142. package/dist/remove.js.map +1 -0
  143. package/dist/repo/config.d.ts +3 -0
  144. package/dist/repo/config.d.ts.map +1 -0
  145. package/dist/repo/config.js +146 -0
  146. package/dist/repo/config.js.map +1 -0
  147. package/dist/repo/repository.d.ts +10 -0
  148. package/dist/repo/repository.d.ts.map +1 -0
  149. package/dist/repo/repository.js +596 -0
  150. package/dist/repo/repository.js.map +1 -0
  151. package/dist/repository.d.ts +10 -0
  152. package/dist/repository.d.ts.map +1 -0
  153. package/dist/repository.js +175 -0
  154. package/dist/repository.js.map +1 -0
  155. package/dist/scripts/pacman-conf.d.ts +3 -0
  156. package/dist/scripts/pacman-conf.d.ts.map +1 -0
  157. package/dist/scripts/pacman-conf.js +74 -0
  158. package/dist/scripts/pacman-conf.js.map +1 -0
  159. package/dist/scripts/setup.d.ts +3 -0
  160. package/dist/scripts/setup.d.ts.map +1 -0
  161. package/dist/scripts/setup.js +289 -0
  162. package/dist/scripts/setup.js.map +1 -0
  163. package/dist/tar.d.ts +17 -0
  164. package/dist/tar.d.ts.map +1 -0
  165. package/dist/tar.js +148 -0
  166. package/dist/tar.js.map +1 -0
  167. package/dist/types.d.ts +80 -0
  168. package/dist/types.d.ts.map +1 -0
  169. package/dist/types.js +3 -0
  170. package/dist/types.js.map +1 -0
  171. package/dist/ui/colors.d.ts +13 -0
  172. package/dist/ui/colors.d.ts.map +1 -0
  173. package/dist/ui/colors.js +38 -0
  174. package/dist/ui/colors.js.map +1 -0
  175. package/dist/ui/format.d.ts +3 -0
  176. package/dist/ui/format.d.ts.map +1 -0
  177. package/dist/ui/format.js +15 -0
  178. package/dist/ui/format.js.map +1 -0
  179. package/dist/ui/progress.d.ts +8 -0
  180. package/dist/ui/progress.d.ts.map +1 -0
  181. package/dist/ui/progress.js +50 -0
  182. package/dist/ui/progress.js.map +1 -0
  183. package/dist/ui/prompt.d.ts +4 -0
  184. package/dist/ui/prompt.d.ts.map +1 -0
  185. package/dist/ui/prompt.js +60 -0
  186. package/dist/ui/prompt.js.map +1 -0
  187. package/lib/pac4deb/Makefile +26 -0
  188. package/lib/pac4deb/README.md +47 -0
  189. package/lib/pac4deb/include/alpm.h +166 -0
  190. package/lib/pac4deb/include/alpm_list.h +42 -0
  191. package/lib/pac4deb/libalpm.so +0 -0
  192. package/lib/pac4deb/src/alpm_list.c +102 -0
  193. package/lib/pac4deb/src/genstubs.sh +51 -0
  194. package/lib/pac4deb/src/genstubs2.sh +72 -0
  195. package/lib/pac4deb/src/genstubs3.sh +43 -0
  196. package/lib/pac4deb/src/libalpm.c +537 -0
  197. package/lib/pac4deb/src/stubs_manual.c +198 -0
  198. package/lib/pac4deb/stubs.c +6 -0
  199. package/lib/pac4deb/update_header.sh +15 -0
  200. package/package.json +41 -0
  201. package/src/cli/pacman.ts +308 -0
  202. package/src/core/ar.ts +54 -0
  203. package/src/core/compress.ts +27 -0
  204. package/src/core/control.ts +22 -0
  205. package/src/core/deb.ts +47 -0
  206. package/src/core/deps.ts +260 -0
  207. package/src/core/options.ts +20 -0
  208. package/src/core/pkgfile.ts +146 -0
  209. package/src/core/tar.ts +101 -0
  210. package/src/core/types.ts +89 -0
  211. package/src/db/database.ts +102 -0
  212. package/src/db/dpkg-compat.ts +129 -0
  213. package/src/db/localdb.ts +181 -0
  214. package/src/i18n/en.json +114 -0
  215. package/src/i18n/index.ts +32 -0
  216. package/src/i18n/zh-CN.json +114 -0
  217. package/src/index.ts +7 -0
  218. package/src/makepkg/build.ts +351 -0
  219. package/src/makepkg/index.ts +87 -0
  220. package/src/makepkg/pkgbuild.ts +146 -0
  221. package/src/ops/install.ts +260 -0
  222. package/src/ops/query.ts +117 -0
  223. package/src/ops/remove.ts +77 -0
  224. package/src/ops/upgrade.ts +87 -0
  225. package/src/repo/config.ts +96 -0
  226. package/src/repo/repository.ts +520 -0
  227. package/src/scripts/pacman-conf.ts +68 -0
  228. package/src/scripts/setup.ts +261 -0
  229. package/src/ui/colors.ts +40 -0
  230. package/src/ui/format.ts +9 -0
  231. package/src/ui/progress.ts +26 -0
  232. package/src/ui/prompt.ts +21 -0
  233. package/tsconfig.json +19 -0
@@ -0,0 +1,261 @@
1
+ #!/usr/bin/env node
2
+ import * as fs from 'node:fs';
3
+ import * as path from 'node:path';
4
+ import * as readline from 'node:readline';
5
+ import { execSync } from 'node:child_process';
6
+
7
+ const CONFIG_DIR = '/etc/pacman-debian';
8
+ const CONFIG_PATH = path.join(CONFIG_DIR, 'pacman.conf');
9
+ const SYMLINK_PATH = '/etc/pacman';
10
+ const DPKG_STATUS = '/var/lib/dpkg/status';
11
+
12
+ function getPacmanVersion(): string {
13
+ const pkgPath = path.resolve(__dirname, '../../package.json');
14
+ try {
15
+ const pkg = JSON.parse(fs.readFileSync(pkgPath, 'utf8'));
16
+ return pkg.pacmanVersion || '7.1.0';
17
+ } catch { return '7.1.0'; }
18
+ }
19
+
20
+ function ask(query: string, defaultYes = true): Promise<boolean> {
21
+ const rl = readline.createInterface({ input: process.stdin, output: process.stdout });
22
+ const suffix = defaultYes ? '[Y/n]' : '[y/N]';
23
+ return new Promise(resolve => {
24
+ rl.question(`${query} ${suffix} `, answer => {
25
+ rl.close();
26
+ const a = answer.trim().toLowerCase();
27
+ if (a === '') resolve(defaultYes);
28
+ else resolve(a === 'y' || a === 'yes');
29
+ });
30
+ });
31
+ }
32
+
33
+ async function main() {
34
+ if (process.getuid && process.getuid() !== 0) {
35
+ console.log(':: pacman-debian setup');
36
+ console.log('');
37
+ console.log(' This script needs root to create symlinks and config files.');
38
+ console.log(' Run with sudo:');
39
+ console.log(' sudo npm run setup');
40
+ console.log(' sudo pacman-debian-setup');
41
+ console.log('');
42
+ return;
43
+ }
44
+
45
+ console.log(':: pacman-debian setup\n');
46
+
47
+ // Ensure data directories exist
48
+ if (!fs.existsSync(CONFIG_DIR)) fs.mkdirSync(CONFIG_DIR, { recursive: true });
49
+
50
+ // --- Symlink /etc/pacman → /etc/pacman-debian ---
51
+ const linkExists = fs.existsSync(SYMLINK_PATH);
52
+ if (linkExists) {
53
+ const stat = fs.lstatSync(SYMLINK_PATH);
54
+ if (stat.isSymbolicLink()) {
55
+ const target = fs.readlinkSync(SYMLINK_PATH);
56
+ if (target === CONFIG_DIR) {
57
+ console.log(` ${SYMLINK_PATH} → ${CONFIG_DIR} already exists`);
58
+ } else {
59
+ console.log(` ${SYMLINK_PATH} exists but points to ${target} (not ${CONFIG_DIR})`);
60
+ }
61
+ } else {
62
+ console.log(` ${SYMLINK_PATH} exists as a directory/file, skipping symlink`);
63
+ }
64
+ } else {
65
+ if (await ask(`Create symlink ${SYMLINK_PATH} → ${CONFIG_DIR}?`, true)) {
66
+ fs.symlinkSync(CONFIG_DIR, SYMLINK_PATH);
67
+ console.log(` Created: ${SYMLINK_PATH} → ${CONFIG_DIR}`);
68
+ }
69
+ }
70
+
71
+ // --- Symlink /etc/pacman.conf → /etc/pacman-debian/pacman.conf ---
72
+ const pacmanConfLink = '/etc/pacman.conf';
73
+ const confLinkExists = fs.existsSync(pacmanConfLink);
74
+ if (confLinkExists) {
75
+ try {
76
+ const stat = fs.lstatSync(pacmanConfLink);
77
+ if (stat.isSymbolicLink()) {
78
+ const target = fs.readlinkSync(pacmanConfLink);
79
+ if (target === CONFIG_PATH) {
80
+ console.log(` ${pacmanConfLink} → ${CONFIG_PATH} already exists`);
81
+ } else {
82
+ console.log(` ${pacmanConfLink} exists but points to ${target} (not ${CONFIG_PATH})`);
83
+ }
84
+ } else {
85
+ console.log(` ${pacmanConfLink} exists as a real file, skipping symlink`);
86
+ }
87
+ } catch {
88
+ console.log(` ${pacmanConfLink} check failed`);
89
+ }
90
+ } else {
91
+ if (await ask(`Create symlink ${pacmanConfLink} → ${CONFIG_PATH}?`, true)) {
92
+ fs.symlinkSync(CONFIG_PATH, pacmanConfLink);
93
+ console.log(` Created: ${pacmanConfLink} → ${CONFIG_PATH}`);
94
+ }
95
+ }
96
+
97
+ // --- Default config ---
98
+ if (!fs.existsSync(CONFIG_PATH)) {
99
+ if (await ask('Create default pacman.conf?', true)) {
100
+ const arch = process.arch === 'arm64' ? 'arm64' : 'amd64';
101
+ const isDebian = fs.existsSync('/etc/debian_version');
102
+ const content = [
103
+ `# pacman-debian configuration file`,
104
+ `#`,
105
+ `# See /etc/pacman.d/ for mirrorlist examples`,
106
+ ``,
107
+ `[options]`,
108
+ `Architecture = ${arch}`,
109
+ ``,
110
+ ];
111
+
112
+ if (isDebian) {
113
+ content.push(
114
+ `# Include = /etc/pacman.d/debian-bookworm`,
115
+ `# Include = /etc/pacman.d/debian-updates`,
116
+ `# Include = /etc/pacman.d/debian-security`,
117
+ );
118
+ }
119
+
120
+ content.push(
121
+ `# Include = /etc/pacman.d/mirrorlist`,
122
+ '',
123
+ );
124
+
125
+ // Create example include file
126
+ const includeDir = '/etc/pacman.d';
127
+ if (!fs.existsSync(includeDir)) fs.mkdirSync(includeDir, { recursive: true });
128
+
129
+ const exampleDebian = path.join(includeDir, 'debian-bookworm');
130
+ if (!fs.existsSync(exampleDebian)) {
131
+ fs.writeFileSync(exampleDebian, [
132
+ `# Debian Bookworm mirror (清华镜像)`,
133
+ `Server = https://mirrors.tuna.tsinghua.edu.cn/debian`,
134
+ `Type = debian`,
135
+ `Dist = bookworm`,
136
+ `Components = main contrib non-free non-free-firmware`,
137
+ ``,
138
+ ].join('\n'));
139
+ console.log(` Created: ${exampleDebian}`);
140
+ }
141
+
142
+ const exampleArch = path.join(includeDir, 'arch-core');
143
+ if (!fs.existsSync(exampleArch)) {
144
+ fs.writeFileSync(exampleArch, [
145
+ `# Arch Linux ARM core mirror`,
146
+ `Server = http://mirror.archlinuxarm.org/$arch/$repo`,
147
+ `Type = arch`,
148
+ `Architecture = aarch64`,
149
+ ``,
150
+ ].join('\n'));
151
+ console.log(` Created: ${exampleArch}`);
152
+ }
153
+ fs.writeFileSync(CONFIG_PATH, content.join('\n'));
154
+ console.log(` Created: ${CONFIG_PATH}`);
155
+ }
156
+ } else {
157
+ console.log(` ${CONFIG_PATH} already exists`);
158
+ }
159
+
160
+ // --- Global symlinks for pacman and makepkg ---
161
+ const projectDir = path.resolve(__dirname, '../..');
162
+ const commands: [string, string][] = [
163
+ ['pacman', path.join(projectDir, 'dist', 'index.js')],
164
+ ['makepkg', path.join(projectDir, 'dist', 'makepkg', 'index.js')],
165
+ ['pacman-conf', path.join(projectDir, 'dist', 'scripts', 'pacman-conf.js')],
166
+ ];
167
+
168
+ for (const [name, target] of commands) {
169
+ const linkPath = `/usr/local/bin/${name}`;
170
+ const exists = fs.existsSync(linkPath);
171
+ if (exists) {
172
+ try {
173
+ const existing = fs.readlinkSync(linkPath);
174
+ if (existing === target) {
175
+ console.log(` ${linkPath} → ${target} already exists`);
176
+ } else {
177
+ console.log(` ${linkPath} exists but points to ${existing}`);
178
+ if (await ask(` Relink ${linkPath} → ${target}?`, true)) {
179
+ fs.unlinkSync(linkPath);
180
+ fs.symlinkSync(target, linkPath);
181
+ console.log(` Relinked: ${linkPath} → ${target}`);
182
+ }
183
+ }
184
+ } catch {
185
+ console.log(` ${linkPath} is not a symlink, skipping`);
186
+ }
187
+ } else {
188
+ if (await ask(`Create symlink ${linkPath} → ${target}?`, true)) {
189
+ fs.symlinkSync(target, linkPath);
190
+ console.log(` Created: ${linkPath} → ${target}`);
191
+ }
192
+ }
193
+ }
194
+
195
+ // --- Build and install libalpm (C library for AUR helpers) ---
196
+ const libDir = path.join(projectDir, 'lib', 'pac4deb');
197
+ if (fs.existsSync(path.join(libDir, 'Makefile'))) {
198
+ if (await ask('Build and install libalpm.so (required for yay/expac)?', true)) {
199
+ try {
200
+ execSync(`make -C "${libDir}"`, { stdio: 'pipe', timeout: 30000 });
201
+ execSync(`make -C "${libDir}" install`, { stdio: 'pipe', timeout: 10000 });
202
+ // Create versioned symlink (expac etc. look for libalpm.so.16)
203
+ const so16 = '/usr/local/lib/libalpm.so.16';
204
+ if (!fs.existsSync(so16)) {
205
+ fs.symlinkSync('libalpm.so', so16);
206
+ execSync('/sbin/ldconfig', { stdio: 'pipe' });
207
+ }
208
+ console.log(' libalpm.so built and installed to /usr/local/lib/');
209
+ } catch (e: any) {
210
+ console.error(' Warning: libalpm build failed:', e.message);
211
+ }
212
+ }
213
+ }
214
+
215
+ // --- Virtual pacman package for AUR tool compatibility ---
216
+ const pacVersion = getPacmanVersion();
217
+ const hasPacmanPkg = fs.existsSync(DPKG_STATUS) &&
218
+ fs.readFileSync(DPKG_STATUS, 'utf8').includes('\nPackage: pacman\n');
219
+
220
+ if (!hasPacmanPkg) {
221
+ if (await ask(`Create virtual pacman package (v${pacVersion}) in dpkg status?`, true)) {
222
+ const entry = [
223
+ `Package: pacman`,
224
+ `Status: install ok installed`,
225
+ `Priority: optional`,
226
+ `Section: base`,
227
+ `Installed-Size: 1`,
228
+ `Maintainer: pacman-debian`,
229
+ `Architecture: ${process.arch === 'arm64' ? 'arm64' : 'amd64'}`,
230
+ `Version: ${pacVersion}`,
231
+ `Description: Virtual package provided by pacman-debian`,
232
+ ``,
233
+ ].join('\n');
234
+ fs.appendFileSync(DPKG_STATUS, '\n' + entry);
235
+ // Also create .list file to suppress dpkg warnings
236
+ const infoDir = '/var/lib/dpkg/info';
237
+ if (fs.existsSync(infoDir)) {
238
+ fs.writeFileSync(`${infoDir}/pacman.list`, '/usr/local/bin/pacman\n');
239
+ }
240
+ console.log(` Created virtual pacman package v${pacVersion} in dpkg status`);
241
+ }
242
+ } else {
243
+ console.log(` Virtual pacman package already exists in dpkg status`);
244
+ }
245
+
246
+ console.log('');
247
+ console.log(':: Setup complete');
248
+ console.log('');
249
+ console.log('Next steps:');
250
+ console.log(' 1. Edit /etc/pacman-debian/pacman.conf to add your repositories');
251
+ console.log(' 2. Run sudo pacman -Sy to sync');
252
+ console.log(' 3. Run sudo pacman -S <package> to install');
253
+ console.log(' 4. Run makepkg in a directory with PKGBUILD to build packages');
254
+ console.log(' 5. For AUR helper support, build and install libalpm:');
255
+ console.log(' cd lib/pac4deb && make && sudo make install');
256
+ }
257
+
258
+ main().catch(e => {
259
+ console.error(`error: ${e.message}`);
260
+ process.exit(1);
261
+ });
@@ -0,0 +1,40 @@
1
+ // ANSI escape codes matching official pacman colors.
2
+ // sync repos = magenta, local repos = blue, pkg names = green
3
+ // errors = red, warnings = yellow
4
+ // Controlled by `Color` in pacman.conf [options].
5
+
6
+ import { loadConfig } from '../repo/config';
7
+
8
+ const esc = (n: number) => `\x1b[${n}m`;
9
+
10
+ const ansi = {
11
+ magenta: esc(35), green: esc(32), blue: esc(34), red: esc(31),
12
+ yellow: esc(33), cyan: esc(36), dim: esc(2), bold: esc(1), reset: esc(0),
13
+ };
14
+
15
+ let enabled = false;
16
+
17
+ function checkConfig() {
18
+ try {
19
+ const cfg = loadConfig();
20
+ enabled = cfg.color;
21
+ } catch {}
22
+ }
23
+ checkConfig();
24
+
25
+ function c(code: string): (s: string) => string {
26
+ return (s: string) => (enabled ? `${code}${s}${ansi.reset}` : s);
27
+ }
28
+
29
+ export const color = {
30
+ repo: c(ansi.magenta),
31
+ pkg: c(ansi.green),
32
+ local: c(ansi.blue),
33
+ error: c(ansi.bold + ansi.red),
34
+ warn: c(ansi.yellow),
35
+ ok: c(ansi.green),
36
+ muted: c(ansi.dim),
37
+ title: c(ansi.bold),
38
+ size: c(ansi.magenta),
39
+ rate: c(ansi.cyan),
40
+ };
@@ -0,0 +1,9 @@
1
+ export function formatBytes(n: number): string {
2
+ if (n < 1024) return `${n} B`;
3
+ if (n < 1048576) return `${(n / 1024).toFixed(1)} KiB`;
4
+ return `${(n / 1048576).toFixed(2)} MiB`;
5
+ }
6
+
7
+ export function pkgLabel(name: string, version: string): string {
8
+ return `${name}-${version}`;
9
+ }
@@ -0,0 +1,26 @@
1
+ export function humanSize(n: number, dec: number): { val: string; unit: string } {
2
+ const abs = Math.abs(n);
3
+ let v: number, u: string;
4
+ if (abs < 1024) { v = n; u = 'B'; }
5
+ else if (abs < 1048576) { v = n / 1024; u = 'KiB'; }
6
+ else if (abs < 1073741824) { v = n / 1048576; u = 'MiB'; }
7
+ else { v = n / 1073741824; u = 'GiB'; }
8
+ return { val: v.toFixed(dec), unit: u };
9
+ }
10
+
11
+ export function drawProgressBar(pct: number, cols: number): string {
12
+ const barLen = Math.max(Math.floor((cols - 55) * 0.35), 8);
13
+ const hashes = Math.round(pct / 100 * barLen);
14
+ return '#'.repeat(hashes) + '-'.repeat(Math.max(barLen - hashes, 0));
15
+ }
16
+
17
+ export function formatRate(rate: number): string {
18
+ if (rate < 9.995) { const s = humanSize(rate, 2); return `${s.val.padStart(4)} ${s.unit}/s`; }
19
+ if (rate < 99.95) { const s = humanSize(rate, 1); return `${s.val.padStart(4)} ${s.unit}/s`; }
20
+ const s = humanSize(rate, 0); return `${s.val.padStart(4)} ${s.unit}/s`;
21
+ }
22
+
23
+ export function formatETA(eta: number): string {
24
+ if (eta <= 0 || eta >= 7200) return '--:--';
25
+ return `${String(Math.floor(eta / 60)).padStart(2, '0')}:${String(Math.floor(eta % 60)).padStart(2, '0')}`;
26
+ }
@@ -0,0 +1,21 @@
1
+ import * as readline from 'node:readline';
2
+
3
+ export let noconfirm = false;
4
+
5
+ export function setNoConfirm(val: boolean): void {
6
+ noconfirm = val;
7
+ }
8
+
9
+ export function confirm(prompt: string, defaultYes: boolean = true): Promise<boolean> {
10
+ if (noconfirm) return Promise.resolve(defaultYes);
11
+ const rl = readline.createInterface({ input: process.stdin, output: process.stdout });
12
+ const suffix = defaultYes ? '[Y/n]' : '[y/N]';
13
+ return new Promise(resolve => {
14
+ rl.question(`${prompt} ${suffix} `, answer => {
15
+ rl.close();
16
+ const a = answer.trim().toLowerCase();
17
+ if (a === '') resolve(defaultYes);
18
+ else resolve(a === 'y' || a === 'yes');
19
+ });
20
+ });
21
+ }
package/tsconfig.json ADDED
@@ -0,0 +1,19 @@
1
+ {
2
+ "compilerOptions": {
3
+ "target": "ES2022",
4
+ "module": "commonjs",
5
+ "lib": ["ES2022"],
6
+ "outDir": "./dist",
7
+ "rootDir": "./src",
8
+ "strict": true,
9
+ "esModuleInterop": true,
10
+ "skipLibCheck": true,
11
+ "forceConsistentCasingInFileNames": true,
12
+ "resolveJsonModule": true,
13
+ "declaration": true,
14
+ "declarationMap": true,
15
+ "sourceMap": true,
16
+ "types": ["node"]
17
+ },
18
+ "include": ["src/**/*"]
19
+ }