From patchwork Fri Mar 6 02:10:38 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sebastian Jakubiak X-Patchwork-Id: 1540 Return-Path: Delivered-To: patchwork@archlinux.org Received: from apollo.archlinux.org (localhost [127.0.0.1]) by apollo.archlinux.org (Postfix) with ESMTP id 8F2BD1774A971 for ; Fri, 6 Mar 2020 02:13:03 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on apollo.archlinux.org X-Spam-Level: X-Spam-Status: No, score=-1.7 required=5.0 tests=DKIM_ADSP_CUSTOM_MED=0.001, DKIM_INVALID=1,DKIM_SIGNED=0.1,FREEMAIL_FROM=0.5,MAILING_LIST_MULTI=-1, RCVD_IN_DNSWL_MED=-2.3,SPF_HELO_NONE=0.001,T_DMARC_POLICY_NONE=0.01, T_DMARC_SIMPLE_DKIM=0.01 autolearn=ham autolearn_force=no version=3.4.4 X-Spam-BL-Results: [127.0.9.2] Received: from orion.archlinux.org (orion.archlinux.org [88.198.91.70]) by apollo.archlinux.org (Postfix) with ESMTPS for ; Fri, 6 Mar 2020 02:13:03 +0000 (UTC) Received: from orion.archlinux.org (localhost [127.0.0.1]) by orion.archlinux.org (Postfix) with ESMTP id 2D3DF19B5B910E; Fri, 6 Mar 2020 02:12:57 +0000 (UTC) Received: from luna.archlinux.org (luna.archlinux.org [5.9.250.164]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-384) server-signature RSA-PSS (4096 bits)) (No client certificate requested) (Authenticated sender: luna) by orion.archlinux.org (Postfix) with ESMTPSA id E2EF319B5B910A; Fri, 6 Mar 2020 02:12:56 +0000 (UTC) Authentication-Results: orion.archlinux.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=Gp31DYLj Received: from luna.archlinux.org (luna.archlinux.org [127.0.0.1]) by luna.archlinux.org (Postfix) with ESMTP id DA53D29D05; Fri, 6 Mar 2020 02:12:56 +0000 (UTC) Authentication-Results: luna.archlinux.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=Gp31DYLj Received: from luna.archlinux.org (luna.archlinux.org [127.0.0.1]) by luna.archlinux.org (Postfix) with ESMTP id 3559129D03 for ; Fri, 6 Mar 2020 02:12:54 +0000 (UTC) Received: from mail-ed1-x541.google.com (mail-ed1-x541.google.com [IPv6:2a00:1450:4864:20::541]) by luna.archlinux.org (Postfix) with ESMTPS for ; Fri, 6 Mar 2020 02:12:54 +0000 (UTC) Received: by mail-ed1-x541.google.com with SMTP id a13so619197edu.7 for ; Thu, 05 Mar 2020 18:12:54 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=rYqPYJbw9zONsp8V8E1hkryWm1iIQ52efohBHpp3XTw=; b=Gp31DYLje2qhooOuwCAT8Slz8raEyUVKY4kFgUVQA1s6lGBqDJU1x1TDwBGBKMsPEZ TYSDdqUCNE7TFo35XNo202hHlI1NSy4D7LR/a7rmzrq0xFv74URBggMwV9QcTzAn5UZ5 sN0sJ/qLGhyqP3bCttuSSgdvwRYS98deAoFmms7fxYOeb6XMakIhBOl1Hq2fnQzpaD6c 7O0GOAfQcuYm138pWlfz6CuzNKg1dg+P9QWQD/HFxMSM7ozKN7pG9D3ut/smPGvti3yA 7v0YKMhhmQXQstNpjS4oGNjRBK6QHHIGtLPX4837wIIbioVVaSjHr8+62IxoN4BYolYr 0p9A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=rYqPYJbw9zONsp8V8E1hkryWm1iIQ52efohBHpp3XTw=; b=PyIZfEC2P0rZW4LQkQtat6Ib+KMxnIQcXoUVu9M+HJNLemBpjO5XwmVb4TLj1kk61d cIA0k5brlnTByD8kFo65IBQ0milan5aw0VZS9eBUoPsSW9C2eILgyYWXxilJ2KmdgxnP yzz6FS60PJM18iWMH7TbMaRHAW04CrGDqzJZzUMOZbL7+s2w8hNakDAvejC59DoZXFzP 3oeV+zzSNYG0IOcC106ViDw/QPcB3QkCfyYcLHDn/jJvqBlfCWBhoy9/2XhkHiw/fP4W baMBhKnu/p1f23FyQ6J8ZZ67dfXHh5qSdXfbGqvwqYtjBeJzFqpSdWUQQUVES8RFXrBD XL1A== X-Gm-Message-State: ANhLgQ1jV4DpUz/NSgpoto4ixrY6cXmVGtUScfw4b8TVSUQSh/Fkw1fC legq4PJAXlvhoN18ajmkVmH/dgFEBRY= X-Google-Smtp-Source: ADFU+vv6I2iBd/0c19F2bpAPn2Lap6NrQdM7vbU3xcsSpflI4xXtSpfW6FHaTFh2YxXneOtVOoacHg== X-Received: by 2002:a17:906:5604:: with SMTP id f4mr786154ejq.255.1583460773530; Thu, 05 Mar 2020 18:12:53 -0800 (PST) Received: from localhost ([185.165.241.36]) by smtp.gmail.com with ESMTPSA id u13sm1683967ejt.1.2020.03.05.18.12.52 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 05 Mar 2020 18:12:53 -0800 (PST) From: Sebastian Jakubiak To: pacman-contrib@lists.archlinux.org Subject: [PATCH] pactree: Implement handling of multiple packages Date: Fri, 6 Mar 2020 03:10:38 +0100 Message-Id: <20200306021037.66811-2-jakseb.dev@gmail.com> X-Mailer: git-send-email 2.25.0 In-Reply-To: <20200306021037.66811-1-jakseb.dev@gmail.com> References: <20200306021037.66811-1-jakseb.dev@gmail.com> MIME-Version: 1.0 X-BeenThere: pacman-contrib@lists.archlinux.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Discussion list for pacman-contrib development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: pacman-contrib-bounces@lists.archlinux.org Sender: "pacman-contrib" Make it possible to invoke pactree for multiple packages at once. Signed-off-by: Sebastian Jakubiak --- This patch is designed to be applied on top of the one from the parent message. src/pactree.c | 51 ++++++++++++++++++++++++++++++++------------------- 1 file changed, 32 insertions(+), 19 deletions(-) diff --git a/src/pactree.c b/src/pactree.c index 9f074fe..1775587 100644 --- a/src/pactree.c +++ b/src/pactree.c @@ -354,7 +354,7 @@ static int parse_options(int argc, char *argv[]) } } - if(!argv[optind] || argv[optind + 1]) { + if(!argv[optind]) { usage(); return 1; } @@ -430,12 +430,18 @@ static void print(const char *parentname, const char *pkgname, } } -static void print_start(const char *pkgname, const char *provname) +static void print_start(void) { if(graphviz) { printf("digraph G { START [color=red, style=filled];\n" - "node [style=filled, color=green];\n" - " \"START\" -> \"%s\";\n", pkgname); + "node [style=filled, color=green];\n"); + } +} + +static void print_target(const char *pkgname, const char *provname) +{ + if(graphviz) { + printf(" \"START\" -> \"%s\";\n", pkgname); } else { tdepth d = { NULL, @@ -526,7 +532,7 @@ static void walk_deps(alpm_list_t *dblist, alpm_pkg_t *pkg, tdepth *depth, int r int main(int argc, char *argv[]) { - int freelist = 0, ret; + int freelist = 0, ret, target_ind; alpm_errno_t err; const char *target_name; alpm_pkg_t *pkg; @@ -560,23 +566,30 @@ int main(int argc, char *argv[]) freelist = 1; } - /* we only care about the first non option arg for walking */ - target_name = argv[optind]; - - pkg = alpm_find_dbs_satisfier(handle, dblist, target_name); - if(!pkg) { - fprintf(stderr, "error: package '%s' not found\n", target_name); - cleanup(1); - } + for(target_ind = optind; argv[target_ind]; ++target_ind) { + target_name = argv[target_ind]; + pkg = alpm_find_dbs_satisfier(handle, dblist, target_name); + if(!pkg) { + fprintf(stderr, "error: package '%s' not found\n", target_name); + cleanup(1); + } + } + print_start(); + - print_start(alpm_pkg_get_name(pkg), target_name); - - tdepth d = { - NULL, - NULL, - 1 - }; - walk_deps(dblist, pkg, &d, reverse); + for(target_ind = optind; argv[target_ind]; ++target_ind) { + target_name = argv[target_ind]; + pkg = alpm_find_dbs_satisfier(handle, dblist, target_name); + + print_target(alpm_pkg_get_name(pkg), target_name); + + tdepth d = { + NULL, + NULL, + 1 + }; + walk_deps(dblist, pkg, &d, reverse); + } print_end();