pacman-debian 7.3.21 → 7.3.23
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/lib/pac4deb/src/alpm_list.c +22 -0
- package/lib/pac4deb/src/libalpm.c +64 -38
- package/package.json +1 -1
|
@@ -20,6 +20,28 @@ alpm_list_t *alpm_list_add(alpm_list_t *list, void *data) {
|
|
|
20
20
|
return list;
|
|
21
21
|
}
|
|
22
22
|
|
|
23
|
+
/* Fast append: returns the new tail for subsequent calls */
|
|
24
|
+
alpm_list_t *alpm_list_add_last(alpm_list_t *list, alpm_list_t *tail, void *data) {
|
|
25
|
+
alpm_list_t *lp = malloc(sizeof(alpm_list_t));
|
|
26
|
+
if (!lp) return NULL;
|
|
27
|
+
lp->data = data;
|
|
28
|
+
lp->prev = NULL;
|
|
29
|
+
lp->next = NULL;
|
|
30
|
+
if (!list) { list = lp; tail = lp; return tail ? tail : list; }
|
|
31
|
+
// If we have a valid tail, use it directly
|
|
32
|
+
if (tail) {
|
|
33
|
+
tail->next = lp;
|
|
34
|
+
lp->prev = tail;
|
|
35
|
+
return lp;
|
|
36
|
+
}
|
|
37
|
+
// Fallback: find tail
|
|
38
|
+
alpm_list_t *ptr = list;
|
|
39
|
+
while (ptr->next) ptr = ptr->next;
|
|
40
|
+
ptr->next = lp;
|
|
41
|
+
lp->prev = ptr;
|
|
42
|
+
return lp;
|
|
43
|
+
}
|
|
44
|
+
|
|
23
45
|
void alpm_list_free(alpm_list_t *list) {
|
|
24
46
|
alpm_list_t *it = list;
|
|
25
47
|
while (it) { alpm_list_t *next = it->next; free(it); it = next; }
|
|
@@ -118,6 +118,7 @@ struct __alpm_handle_t {
|
|
|
118
118
|
char *confpath;
|
|
119
119
|
alpm_db_t *localdb;
|
|
120
120
|
alpm_list_t *syncdbs;
|
|
121
|
+
int released;
|
|
121
122
|
};
|
|
122
123
|
|
|
123
124
|
alpm_handle_t *alpm_initialize(const char *root, const char *dbpath, alpm_errno_t *err) {
|
|
@@ -135,11 +136,15 @@ alpm_handle_t *alpm_initialize(const char *root, const char *dbpath, alpm_errno_
|
|
|
135
136
|
|
|
136
137
|
int alpm_release(alpm_handle_t *handle) {
|
|
137
138
|
if (!handle) return -1;
|
|
139
|
+
if (handle->released) return 0;
|
|
138
140
|
alpm_db_unregister_all(handle);
|
|
139
141
|
free(handle->dbpath); handle->dbpath = NULL;
|
|
140
142
|
free(handle->logfile); handle->logfile = NULL;
|
|
141
143
|
free(handle->confpath); handle->confpath = NULL;
|
|
142
|
-
|
|
144
|
+
handle->released = 1;
|
|
145
|
+
handle->err = ALPM_ERR_OK;
|
|
146
|
+
// Don't free handle itself — dyalpm calls alpm_errno after alpm_release
|
|
147
|
+
// (use-after-free bug in dyalpm v0.1.3). Memory leak is negligible.
|
|
143
148
|
return 0;
|
|
144
149
|
}
|
|
145
150
|
|
|
@@ -197,7 +202,7 @@ static pkg_internal *json_to_pkg(json_ctx *j) {
|
|
|
197
202
|
|
|
198
203
|
/* Load JSONL file (one flat JSON object per line) */
|
|
199
204
|
alpm_list_t *load_jsonl_file(const char *filepath) {
|
|
200
|
-
alpm_list_t *pkgs = NULL;
|
|
205
|
+
alpm_list_t *pkgs = NULL, *tail = NULL;
|
|
201
206
|
int fd = open(filepath, O_RDONLY);
|
|
202
207
|
if (fd < 0) return NULL;
|
|
203
208
|
struct stat st;
|
|
@@ -219,7 +224,14 @@ alpm_list_t *load_jsonl_file(const char *filepath) {
|
|
|
219
224
|
pkg_internal *p = json_to_pkg(&j);
|
|
220
225
|
if (p->name && *(p->name)) {
|
|
221
226
|
p->origin = ALPM_PKG_FROM_SYNCDB;
|
|
222
|
-
|
|
227
|
+
alpm_list_t *lp = malloc(sizeof(alpm_list_t));
|
|
228
|
+
if (lp) {
|
|
229
|
+
lp->data = p; lp->next = NULL; lp->prev = tail;
|
|
230
|
+
if (tail) tail->next = lp; else pkgs = lp;
|
|
231
|
+
tail = lp;
|
|
232
|
+
} else {
|
|
233
|
+
pkg_free(p);
|
|
234
|
+
}
|
|
223
235
|
} else {
|
|
224
236
|
pkg_free(p);
|
|
225
237
|
}
|
|
@@ -255,7 +267,7 @@ static alpm_list_t *load_json_file(const char *filepath) {
|
|
|
255
267
|
|
|
256
268
|
/* Load packages from dpkg status file */
|
|
257
269
|
static alpm_list_t *load_dpkg_status(const char *path) {
|
|
258
|
-
alpm_list_t *pkgs = NULL;
|
|
270
|
+
alpm_list_t *pkgs = NULL, *tail = NULL;
|
|
259
271
|
FILE *f = fopen(path, "r");
|
|
260
272
|
if (!f) return NULL;
|
|
261
273
|
fseek(f, 0, SEEK_END);
|
|
@@ -312,8 +324,15 @@ static alpm_list_t *load_dpkg_status(const char *path) {
|
|
|
312
324
|
pkg->depends = strdup(depends);
|
|
313
325
|
pkg->provides = strdup(provides[0] ? provides : "");
|
|
314
326
|
pkg->reason = ALPM_PKG_REASON_EXPLICIT;
|
|
315
|
-
|
|
316
|
-
|
|
327
|
+
alpm_list_t *lp = malloc(sizeof(alpm_list_t));
|
|
328
|
+
if (lp) {
|
|
329
|
+
lp->data = pkg; lp->next = NULL; lp->prev = tail;
|
|
330
|
+
if (tail) tail->next = lp; else pkgs = lp;
|
|
331
|
+
tail = lp;
|
|
332
|
+
} else {
|
|
333
|
+
pkg_free(pkg);
|
|
334
|
+
}
|
|
335
|
+
}
|
|
317
336
|
p = end ? end + 2 : NULL;
|
|
318
337
|
}
|
|
319
338
|
free(buf);
|
|
@@ -321,38 +340,45 @@ static alpm_list_t *load_dpkg_status(const char *path) {
|
|
|
321
340
|
}
|
|
322
341
|
|
|
323
342
|
/* Load all packages from local DB directory (each subdir has a desc file) */
|
|
324
|
-
static alpm_list_t *load_localdb_dir(const char *dirpath) {
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
}
|
|
343
|
+
static alpm_list_t *load_localdb_dir(const char *dirpath) {
|
|
344
|
+
alpm_list_t *pkgs = NULL, *tail = NULL;
|
|
345
|
+
DIR *d = opendir(dirpath);
|
|
346
|
+
if (!d) return NULL;
|
|
347
|
+
struct dirent *entry;
|
|
348
|
+
while ((entry = readdir(d)) != NULL) {
|
|
349
|
+
if (entry->d_name[0] == '.') continue;
|
|
350
|
+
if (strcmp(entry->d_name, "by-name") == 0) continue;
|
|
351
|
+
char path[4096];
|
|
352
|
+
snprintf(path, sizeof(path), "%s/%s/desc", dirpath, entry->d_name);
|
|
353
|
+
int fd = open(path, O_RDONLY);
|
|
354
|
+
if (fd < 0) continue;
|
|
355
|
+
struct stat st;
|
|
356
|
+
if (fstat(fd, &st) < 0 || st.st_size == 0) { close(fd); continue; }
|
|
357
|
+
char *buf = mmap(NULL, st.st_size, PROT_READ, MAP_PRIVATE, fd, 0);
|
|
358
|
+
close(fd);
|
|
359
|
+
if (buf == MAP_FAILED) continue;
|
|
360
|
+
json_ctx j;
|
|
361
|
+
json_init(&j, buf);
|
|
362
|
+
if (json_next(&j) != '{') { munmap(buf, st.st_size); continue; }
|
|
363
|
+
pkg_internal *p = json_to_pkg(&j);
|
|
364
|
+
if (p->name && *(p->name)) {
|
|
365
|
+
p->origin = ALPM_PKG_FROM_LOCALDB;
|
|
366
|
+
alpm_list_t *lp = malloc(sizeof(alpm_list_t));
|
|
367
|
+
if (lp) {
|
|
368
|
+
lp->data = p; lp->next = NULL; lp->prev = tail;
|
|
369
|
+
if (tail) tail->next = lp; else pkgs = lp;
|
|
370
|
+
tail = lp;
|
|
371
|
+
} else {
|
|
372
|
+
pkg_free(p);
|
|
373
|
+
}
|
|
374
|
+
} else {
|
|
375
|
+
pkg_free(p);
|
|
376
|
+
}
|
|
377
|
+
munmap(buf, st.st_size);
|
|
378
|
+
}
|
|
379
|
+
closedir(d);
|
|
380
|
+
return pkgs;
|
|
381
|
+
}
|
|
356
382
|
|
|
357
383
|
/* Resolve Debian alternatives: readlink /bin/<cmd> to find real binary,
|
|
358
384
|
then map its package name back to the virtual provide name.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pacman-debian",
|
|
3
|
-
"version": "7.3.
|
|
3
|
+
"version": "7.3.23",
|
|
4
4
|
"description": "A Debian/Ubuntu package manager using Arch Linux pacman syntax. Manages .deb packages at dpkg level, supports Arch .pkg.tar.zst, AUR helpers (yay), and makepkg. Configurable multi-repo setup.",
|
|
5
5
|
"pacmanVersion": "7.1.0",
|
|
6
6
|
"main": "dist/index.js",
|