From dd72cb295db460e15a4ebfd736ff6b662acdf632 Mon Sep 17 00:00:00 2001 From: Juan RP Date: Sat, 26 Feb 2011 11:15:17 +0100 Subject: [PATCH] xbps-uhelper: added two new targets 'setsource' and 'fromsource'. Both targets will be used by some upcoming changes in xbps-src, therefore they shouldn't be used manually by the user. --- bin/xbps-uhelper/main.c | 39 +++++++++++++++++++++++++++++++++++++-- 1 file changed, 37 insertions(+), 2 deletions(-) diff --git a/bin/xbps-uhelper/main.c b/bin/xbps-uhelper/main.c index 73cb1a3f..d35db9cb 100644 --- a/bin/xbps-uhelper/main.c +++ b/bin/xbps-uhelper/main.c @@ -108,10 +108,11 @@ main(int argc, char **argv) { struct xbps_handle xh; struct xbps_fetch_progress_data xfpd; - prop_dictionary_t dict; + prop_dictionary_t dict, pkgd; + prop_array_t array; const char *version, *rootdir = NULL; char *plist, *pkgname, *pkgver, *in_chroot_env, *hash; - bool debug = false, in_chroot = false; + bool fromsrc = false, debug = false, in_chroot = false; int i, c, rv = 0; while ((c = getopt(argc, argv, "Vdr:")) != -1) { @@ -198,6 +199,7 @@ main(int argc, char **argv) MSG_NORMAL, in_chroot ? "[chroot] " : "", argv[1], argv[2], MSG_RESET); } + prop_object_release(dict); } else if (strcasecmp(argv[0], "unregister") == 0) { /* Unregisters a package from the database */ @@ -220,6 +222,39 @@ main(int argc, char **argv) MSG_NORMAL, in_chroot ? "[chroot] " : "", argv[1], argv[2], MSG_RESET); + } else if (strcasecmp(argv[0], "setsource") == 0) { + if (argc != 2) + usage(); + + dict = prop_dictionary_internalize_from_zfile(plist); + if (dict == NULL) + exit(EXIT_FAILURE); + + array = prop_dictionary_get(dict, "packages"); + if (array == NULL) + exit(EXIT_FAILURE); + + pkgd = xbps_find_pkg_in_array_by_name(array, argv[1]); + if (pkgd == NULL) + exit(EXIT_FAILURE); + + prop_dictionary_set_bool(pkgd, "installed-from-source", true); + write_plist_file(dict, plist); + + } else if (strcasecmp(argv[0], "fromsource") == 0) { + if (argc != 2) + usage(); + + dict = xbps_find_pkg_dict_installed(argv[1], false); + if (dict == NULL) + exit(EXIT_FAILURE); + + fromsrc = false; + prop_dictionary_get_bool(dict, "installed-from-source", + &fromsrc); + printf("%s\n", fromsrc ? "yes" : "no"); + prop_object_release(dict); + } else if (strcasecmp(argv[0], "version") == 0) { /* Prints version of an installed package */ if (argc != 2)