79e33ab9ffe750750da3b3fb06b7aa48b3947021
[oweals/opkg-lede.git] / tests / libopkg_test.c
1 #include <opkg.h>
2 #include <stdlib.h>
3 #include <stdio.h>
4
5 void
6 progress_callback (opkg_t *opkg, int percent, void *data)
7 {
8   printf ("\r%s %3d%%", (char*) data, percent);
9   fflush (stdout);
10 }
11
12
13 int
14 main (int argc, char **argv)
15 {
16   opkg_t *opkg;
17   int err;
18   
19   opkg = opkg_new ();
20
21   opkg_set_option (opkg, "offline_root", "/tmp/");
22
23   opkg_read_config_files (opkg);
24
25   err = opkg_update_package_lists (opkg, progress_callback, "Updating...");
26   printf ("\nopkg_update_package_lists returned %d\n", err);
27
28   err = opkg_install_package (opkg, "aspell", progress_callback, "Installing...");
29   printf ("\nopkg_install_package returned %d\n", err);
30
31   err = opkg_upgrade_package (opkg, "aspell", progress_callback, "Upgrading...");
32   printf ("\nopkg_upgrade_package returned %d\n", err);
33
34   err = opkg_upgrade_all (opkg, progress_callback, "Upgrading all...");
35   printf ("\nopkg_upgrade_package returned %d\n", err);
36
37   err = opkg_remove_package (opkg, "aspell", progress_callback, "Removing...");
38   printf ("\nopkg_remove_package returned %d\n", err);
39
40   opkg_free (opkg);
41 }