205db5c2c8509122388df109dde66487af00ff03
[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 ("%s %d\n", (char*) data, percent);
9 }
10
11
12 int
13 main (int argc, char **argv)
14 {
15   opkg_t *opkg;
16   int err;
17   
18   opkg = opkg_new ();
19
20   opkg_set_option (opkg, "offline_root", "/tmp/");
21
22   opkg_read_config_files (opkg);
23
24   err = opkg_update_package_lists (opkg, progress_callback, "Updating...");
25
26   printf ("opkg_update_package_lists returned %d\n", err);
27
28   err = opkg_install_package (opkg, "aspell", progress_callback, "Installing...");
29
30   printf ("opkg_install_package returned %d\n", err);
31
32   err = opkg_remove_package (opkg, "aspell", progress_callback, "Removing...");
33
34   printf ("opkg_remove_package returned %d\n", err);
35
36   opkg_free (opkg);
37 }