pacman-debian 7.3.22 → 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.
@@ -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; }
@@ -202,7 +202,7 @@ static pkg_internal *json_to_pkg(json_ctx *j) {
202
202
 
203
203
  /* Load JSONL file (one flat JSON object per line) */
204
204
  alpm_list_t *load_jsonl_file(const char *filepath) {
205
- alpm_list_t *pkgs = NULL;
205
+ alpm_list_t *pkgs = NULL, *tail = NULL;
206
206
  int fd = open(filepath, O_RDONLY);
207
207
  if (fd < 0) return NULL;
208
208
  struct stat st;
@@ -224,7 +224,14 @@ alpm_list_t *load_jsonl_file(const char *filepath) {
224
224
  pkg_internal *p = json_to_pkg(&j);
225
225
  if (p->name && *(p->name)) {
226
226
  p->origin = ALPM_PKG_FROM_SYNCDB;
227
- pkgs = alpm_list_add(pkgs, p);
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
+ }
228
235
  } else {
229
236
  pkg_free(p);
230
237
  }
@@ -260,7 +267,7 @@ static alpm_list_t *load_json_file(const char *filepath) {
260
267
 
261
268
  /* Load packages from dpkg status file */
262
269
  static alpm_list_t *load_dpkg_status(const char *path) {
263
- alpm_list_t *pkgs = NULL;
270
+ alpm_list_t *pkgs = NULL, *tail = NULL;
264
271
  FILE *f = fopen(path, "r");
265
272
  if (!f) return NULL;
266
273
  fseek(f, 0, SEEK_END);
@@ -317,8 +324,15 @@ static alpm_list_t *load_dpkg_status(const char *path) {
317
324
  pkg->depends = strdup(depends);
318
325
  pkg->provides = strdup(provides[0] ? provides : "");
319
326
  pkg->reason = ALPM_PKG_REASON_EXPLICIT;
320
- pkgs = alpm_list_add(pkgs, pkg);
321
- }
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
+ }
322
336
  p = end ? end + 2 : NULL;
323
337
  }
324
338
  free(buf);
@@ -326,38 +340,45 @@ static alpm_list_t *load_dpkg_status(const char *path) {
326
340
  }
327
341
 
328
342
  /* Load all packages from local DB directory (each subdir has a desc file) */
329
- static alpm_list_t *load_localdb_dir(const char *dirpath) {
330
- alpm_list_t *pkgs = NULL;
331
- DIR *d = opendir(dirpath);
332
- if (!d) return NULL;
333
- struct dirent *entry;
334
- while ((entry = readdir(d)) != NULL) {
335
- if (entry->d_name[0] == '.') continue;
336
- if (strcmp(entry->d_name, "by-name") == 0) continue;
337
- char path[4096];
338
- snprintf(path, sizeof(path), "%s/%s/desc", dirpath, entry->d_name);
339
- int fd = open(path, O_RDONLY);
340
- if (fd < 0) continue;
341
- struct stat st;
342
- if (fstat(fd, &st) < 0 || st.st_size == 0) { close(fd); continue; }
343
- char *buf = mmap(NULL, st.st_size, PROT_READ, MAP_PRIVATE, fd, 0);
344
- close(fd);
345
- if (buf == MAP_FAILED) continue;
346
- json_ctx j;
347
- json_init(&j, buf);
348
- if (json_next(&j) != '{') { munmap(buf, st.st_size); continue; }
349
- pkg_internal *p = json_to_pkg(&j);
350
- if (p->name && *(p->name)) {
351
- p->origin = ALPM_PKG_FROM_LOCALDB;
352
- pkgs = alpm_list_add(pkgs, p);
353
- } else {
354
- pkg_free(p);
355
- }
356
- munmap(buf, st.st_size);
357
- }
358
- closedir(d);
359
- return pkgs;
360
- }
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
+ }
361
382
 
362
383
  /* Resolve Debian alternatives: readlink /bin/<cmd> to find real binary,
363
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.22",
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",