Last active
April 15, 2017 20:04
-
-
Save nikibobi/f4351e91488736377284dafbf5ade7f9 to your computer and use it in GitHub Desktop.
minimalistic arch package manager
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <stdlib.h> | |
#include <alpm.h> | |
#include <alpm_list.h> | |
int main(void) { | |
alpm_errno_t *err; | |
alpm_handle_t *alpm = alpm_initialize("/", "/var/lib/pacman/", err); | |
if (alpm == NULL) { | |
printf("%s\n", alpm_strerror(*err)); | |
exit(EXIT_FAILURE); | |
} | |
/* get the local db */ | |
alpm_db_t *db = alpm_get_localdb(alpm); | |
/* get and print all installed packages */ | |
for (alpm_list_t *l = alpm_db_get_pkgcache(db); l; l = alpm_list_next(l)) { | |
alpm_pkg_t *pkg = l->data; | |
const char *name = alpm_pkg_get_name(pkg); | |
printf("%s\n", name); | |
} | |
alpm_release(alpm); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment