X-Git-Url: https://git.draconx.ca/gitweb/upkg.git/blobdiff_plain/95cd2b3a5599955317d1f80d515c0d5d5c568c7d..0a55ae84545c5e5a45e2240c06bd77a1917f7d3e:/src/upkg.c diff --git a/src/upkg.c b/src/upkg.c index 2c268b4..d3a946b 100644 --- a/src/upkg.c +++ b/src/upkg.c @@ -29,6 +29,7 @@ #include #include #include +#include enum { MODE_INFO, @@ -286,7 +287,8 @@ int package_export(struct upkg *pkg) int main(int argc, char **argv) { - UPkg *upkg; + GTypeModule *pkg; + const char *pkgname; unsigned mode = MODE_INFO; int opt, rc = EXIT_FAILURE; @@ -320,25 +322,39 @@ int main(int argc, char **argv) return EXIT_FAILURE; } + if (u_pkg_vfs_init() != 0) + return EXIT_FAILURE; if (u_object_module_init() != 0) return EXIT_FAILURE; - upkg = U_PKG(u_pkg_new_by_file(argv[optind])); - if (!upkg) { + pkgname = u_pkg_vfs_add_local(NULL, argv[optind]); + if (!pkgname) { + fprintf(stderr, "failed to add package `%s'.\n", argv[optind]); + return EXIT_FAILURE; + } + + pkg = u_pkg_open(pkgname); + if (!pkg) { fprintf(stderr, "failed to open package!\n"); return EXIT_FAILURE; } + if (!g_type_module_use(pkg)) { + fprintf(stderr, "failed to load package: %s\n", pkg->name); + return EXIT_FAILURE; + } + switch (mode) { case MODE_INFO: - rc = package_info(upkg->pkg); + rc = package_info(U_PKG(pkg)->pkg); break; case MODE_EXPORT: - rc = package_export(upkg->pkg); + rc = package_export(U_PKG(pkg)->pkg); break; } - g_object_unref(upkg); + g_object_unref(pkg); u_object_module_exit(); + u_pkg_vfs_exit(); return rc; }