From patchwork Fri Aug 2 11:07:36 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?UmFmYcWCIE1pxYJlY2tp?= X-Patchwork-Id: 1968308 X-Patchwork-Delegate: zajec5@gmail.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; secure) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=bombadil.20210309 header.b=h1SXloKB; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20230601 header.b=FNbmC42p; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.openwrt.org (client-ip=2607:7c80:54:3::133; helo=bombadil.infradead.org; envelope-from=openwrt-devel-bounces+incoming=patchwork.ozlabs.org@lists.openwrt.org; receiver=patchwork.ozlabs.org) Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:3::133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4Wb34q1dQjz1yZl for ; Fri, 2 Aug 2024 21:09:30 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-Id:Date:Subject:Cc :To:From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=hNb7S+aX3LY11y2xXcOZxRPi67Wm9nO3+u+cRSwZnC8=; b=h1SXloKBf2KSV/ +J48CVFp4XJqnk/uUo6umcM2Y3q+TJVXkrNk4Y3Bn0H/nmdgcEEGIO9LE5VyZ3kx56pa3pxzmomJ4 ya8kWct9rCQrZnW6tJfdQVnaJGImnDbq2reNOr080x1uIv+VTsGsy1NQWw4sc1L+r55G/IzUP4VII ToZuz6YF8cHPKuC0YEeRyErf3HgXs17GH2LCpsoyaX+CxZ7dRylTZaAgzKwJFDlr3Pw6habQ5sRpd rvqoiLS1azRACJw819j6kx/4whdbuzgzA96bSDfD08BTIyIaj3IDs7SaKQQ9AHAIGyvH6tSM/jhnJ rdky+oEsUQ+674xVYZ9A==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sZq8T-00000008d11-2Ldk; Fri, 02 Aug 2024 11:07:49 +0000 Received: from mail-lf1-x12d.google.com ([2a00:1450:4864:20::12d]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sZq8P-00000008czn-31n0 for openwrt-devel@lists.openwrt.org; Fri, 02 Aug 2024 11:07:46 +0000 Received: by mail-lf1-x12d.google.com with SMTP id 2adb3069b0e04-52f024f468bso11330235e87.1 for ; Fri, 02 Aug 2024 04:07:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1722596863; x=1723201663; darn=lists.openwrt.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=wCnYRj7K2H3+lui+TuYwTrc9FseHrXZObVph25PVZMo=; b=FNbmC42pLskKrTtK+vX2ic2sr3gI5iB5wfAM2Q0u2+kUTjKigofpeetPxzhMK7DgmY mdzonqise0NR20AZDrJOZLqZdGCnCqcamsUU4fargv2D9nQMze8406oLuJu/Fem5hjff qiyAARAbu1XneV1xIqZW9uPyQVSVOI/+iyixK5QpQNntqR8Pes0WZHusTbOSVDOyMlCe 7Fnw7ZrikNDPEBrIJiYcW/9oRgib4CEFYgItdH5Ve5mLEdZ4RXU9efANx2xvCSJA4Qxj EV2CvrZ7n/B13dZ8rk/kkKLVpvDUAwM+EBMx3uePCJoqZQoXUXKEzRtoTQYqXlrR327Y 4JiA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1722596863; x=1723201663; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=wCnYRj7K2H3+lui+TuYwTrc9FseHrXZObVph25PVZMo=; b=G8WzCQ34veQa+2koNTpHvxKJHdwO65pHrGnKX2zgBSG4hYuyCcR9bqcIg22V0tmNX8 1WxLd0flN2IHoVH2D9RrUghLpYiVJE5GuaJvr4/S/8vlWIzivrAXyO4RzbAFwpWJmqn3 dNZJPQEUNpUDhtQ+66r0exAGYek4iB+iz06Bo43YLAZLj81gsxpjS0911hwYXEJq1/iz OHGvtnFyMxM/YbwA/FzIqdPzYfWvHeT177gTTyZRMPDXtEvZtDBWoP7qyxzFQB9ElY1R rt7d9n9T3eYlnd4s3KokmIFxt5X4wAqj8j/aaKcHVHooGVSbKRDEx93EHXiRRO90GMi7 ndkQ== X-Gm-Message-State: AOJu0YyS+4yutGvuupRm7t1Lp6DCxqyQpghYJ+KvcuCPDA/0nuqCb+4F x5x/kUPzZhx9J6jcDmxbehRWcAnyiy5zbXY9XhAvrCE5/egzvAX6uLDUZQ== X-Google-Smtp-Source: AGHT+IEYXo+/9rDFO3N5LUPK1oDTdl2nP20EMx/HpWDR64QIA7fx1PCQsA37CAGZMsPa6VxhVbmg+Q== X-Received: by 2002:a05:6512:3b06:b0:52e:9dee:a6f5 with SMTP id 2adb3069b0e04-530bb4d7621mr1897946e87.46.1722596862325; Fri, 02 Aug 2024 04:07:42 -0700 (PDT) Received: from localhost.lan (031011218106.poznan.vectranet.pl. [31.11.218.106]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a7dc9c0cbe6sm85576366b.71.2024.08.02.04.07.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 02 Aug 2024 04:07:41 -0700 (PDT) From: =?utf-8?b?UmFmYcWCIE1pxYJlY2tp?= To: openwrt-devel@lists.openwrt.org Cc: =?utf-8?b?UmFmYcWCIE1pxYJlY2tp?= Subject: [PATCH opkg-lede] libopkg: make "info" & "status" return error for no matching packages Date: Fri, 2 Aug 2024 13:07:36 +0200 Message-Id: <20240802110736.14946-1-zajec5@gmail.com> X-Mailer: git-send-email 2.35.3 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240802_040745_789491_6B7AFAC9 X-CRM114-Status: GOOD ( 13.21 ) X-Spam-Score: -1.8 (-) X-Spam-Report: =?unknown-8bit?q?Spam_detection_software=2C_running_on_the_sy?= =?unknown-8bit?q?stem_=22bombadil=2Einfradead=2Eorg=22=2C?= =?unknown-8bit?q?_has_NOT_identified_this_incoming_email_as_spam=2E__The_ori?= =?unknown-8bit?q?ginal?= =?unknown-8bit?q?_message_has_been_attached_to_this_so_you_can_view_it_or_la?= =?unknown-8bit?q?bel?= =?unknown-8bit?q?_similar_future_email=2E__If_you_have_any_questions=2C_see?= =?unknown-8bit?q?_the_administrator_of_that_system_for_details=2E?= =?unknown-8bit?q?_?= =?unknown-8bit?q?_Content_preview=3A__From=3A_Rafa=C5=82_Mi=C5=82ecki_This_m?= =?unknown-8bit?q?akes_checking_for_packages_easier=2E?= =?unknown-8bit?q?_Example=3A_=24_opkg_status_blo0ckd=3B_echo_=24=3F_254_?= =?unknown-8bit?q?_?= =?unknown-8bit?q?_Content_analysis_details=3A___=28-1=2E8_points=2C_5=2E0_re?= =?unknown-8bit?q?quired=29?= =?unknown-8bit?q?_?= =?unknown-8bit?q?_pts_rule_name______________description?= =?unknown-8bit?q?_----_----------------------_------------------------------?= =?unknown-8bit?q?--------------------?= =?unknown-8bit?q?_-0=2E0_RCVD=5FIN=5FDNSWL=5FNONE_____RBL=3A_Sender_listed_a?= =?unknown-8bit?q?t_https=3A//www=2Ednswl=2Eorg/=2C_no?= =?unknown-8bit?q?_trust?= =?unknown-8bit?b?IFsyYTAwOjE0NTA6NDg2NDoyMDowOjA6MDoxMmQgbGlzdGVkIGluXQ==?= =?unknown-8bit?b?IFtsaXN0LmRuc3dsLm9yZ10=?= =?unknown-8bit?q?_-0=2E0_SPF=5FPASS_______________SPF=3A_sender_matches_SPF_?= =?unknown-8bit?q?record?= =?unknown-8bit?q?_0=2E0_SPF=5FHELO=5FNONE__________SPF=3A_HELO_does_not_publ?= =?unknown-8bit?q?ish_an_SPF_Record?= =?unknown-8bit?q?_-0=2E1_DKIM=5FVALID=5FEF__________Message_has_a_valid_DKIM?= =?unknown-8bit?q?_or_DK_signature_from?= =?unknown-8bit?q?_envelope-from_domain?= =?unknown-8bit?q?_-0=2E1_DKIM=5FVALID=5FAU__________Message_has_a_valid_DKIM?= =?unknown-8bit?q?_or_DK_signature_from_author=27s?= =?unknown-8bit?q?_domain?= =?unknown-8bit?q?_0=2E1_DKIM=5FSIGNED____________Message_has_a_DKIM_or_DK_si?= =?unknown-8bit?q?gnature=2C_not_necessarily_valid?= =?unknown-8bit?q?_-0=2E1_DKIM=5FVALID_____________Message_has_at_least_one_v?= =?unknown-8bit?q?alid_DKIM_or_DK_signature?= =?unknown-8bit?q?_-1=2E9_BAYES=5F00_______________BODY=3A_Bayes_spam_probabi?= =?unknown-8bit?q?lity_is_0_to_1=25?= =?unknown-8bit?q?_=5Bscore=3A_0=2E0000=5D?= =?unknown-8bit?q?_0=2E2_FREEMAIL=5FENVFROM=5FEND=5FDIGIT_Envelope-from_freem?= =?unknown-8bit?q?ail_username_ends_in?= =?unknown-8bit?q?_digit?= =?unknown-8bit?q?_=5Bzajec5=28at=29gmail=2Ecom=5D?= =?unknown-8bit?q?_0=2E0_FREEMAIL=5FFROM__________Sender_email_is_commonly_ab?= =?unknown-8bit?q?used_enduser_mail_provider?= =?unknown-8bit?q?_=5Bzajec5=28at=29gmail=2Ecom=5D?= X-BeenThere: openwrt-devel@lists.openwrt.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: OpenWrt Development List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "openwrt-devel" Errors-To: openwrt-devel-bounces+incoming=patchwork.ozlabs.org@lists.openwrt.org From: Rafał Miłecki This makes checking for packages easier. Example: $ opkg status blo0ckd; echo $? 254 Signed-off-by: Rafał Miłecki --- libopkg/opkg_cmd.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/libopkg/opkg_cmd.c b/libopkg/opkg_cmd.c index 6547775..f82e10a 100644 --- a/libopkg/opkg_cmd.c +++ b/libopkg/opkg_cmd.c @@ -795,6 +795,7 @@ static int opkg_info_status_cmd(int argc, char **argv, int installed_only) pkg_t *pkg; char *pkg_name = NULL; conffile_list_t *cl; + int err; if (argc > 0) { pkg_name = argv[0]; @@ -806,11 +807,13 @@ static int opkg_info_status_cmd(int argc, char **argv, int installed_only) else pkg_hash_fetch_available(available); + err = -ENOENT; for (i = 0; i < available->len; i++) { pkg = available->pkgs[i]; if (pkg_name && fnmatch(pkg_name, pkg->name, conf->nocase)) { continue; } + err = 0; pkg_formatted_info(stdout, pkg); @@ -831,7 +834,7 @@ static int opkg_info_status_cmd(int argc, char **argv, int installed_only) } pkg_vec_free(available); - return 0; + return err; } static int opkg_info_cmd(int argc, char **argv)