From patchwork Fri Dec 17 22:34:17 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Schwinge X-Patchwork-Id: 49075 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 216B53858025 for ; Fri, 17 Dec 2021 22:34:31 +0000 (GMT) X-Original-To: libabigail@sourceware.org Delivered-To: libabigail@sourceware.org Received: from smtprelay06.ispgateway.de (smtprelay06.ispgateway.de [80.67.18.29]) by sourceware.org (Postfix) with ESMTPS id 4EBC23858407 for ; Fri, 17 Dec 2021 22:34:27 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 4EBC23858407 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=codesourcery.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=schwinge.name Received: from [192.94.31.2] (helo=dem-tschwing-1.ger.mentorg.com) by smtprelay06.ispgateway.de with esmtpsa (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1myLnj-0001Sx-GK; Fri, 17 Dec 2021 23:34:07 +0100 Received: (nullmailer pid 2542836 invoked by uid 1000); Fri, 17 Dec 2021 22:34:25 -0000 From: Thomas Schwinge To: libabigail@sourceware.org Subject: [PATCH] fedabipkgdiff: Also accept MIME type 'application/x-redhat-package-manager' for RPM files Date: Fri, 17 Dec 2021 23:34:17 +0100 Message-Id: <20211217223417.2542789-1-thomas@codesourcery.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 X-Df-Sender: b3V0Z29pbmdAc2Nod2luZ2UubmFtZQ== X-Spam-Status: No, score=-11.8 required=5.0 tests=BAYES_00, GIT_PATCH_0, HEADER_FROM_DIFFERENT_DOMAINS, KAM_DMARC_STATUS, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, SPF_HELO_PASS, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: libabigail@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Mailing list of the Libabigail project List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , Cc: Thomas Schwinge Errors-To: libabigail-bounces+patchwork=sourceware.org@sourceware.org Sender: "Libabigail" ... as that's what a few Debian and Ubuntu systems are using, that I just sampled: $ awk '$2 ~ /rpm/' < /etc/mime.types application/x-redhat-package-manager rpm $ dpkg -S /etc/mime.types media-types: /etc/mime.types $ apt policy media-types media-types: Installed: 4.0.0 Candidate: 4.0.0 Version table: *** 4.0.0 900 900 http://ftp.de.debian.org/debian testing/main amd64 Packages 900 http://ftp.de.debian.org/debian testing/main i386 Packages 800 http://ftp.de.debian.org/debian unstable/main amd64 Packages 800 http://ftp.de.debian.org/debian unstable/main i386 Packages 100 /var/lib/dpkg/status $ awk '$2 ~ /rpm/' < /etc/mime.types application/x-redhat-package-manager rpm $ dpkg -S /etc/mime.types mime-support: /etc/mime.types $ apt policy mime-support mime-support: Installed: 3.64ubuntu1 Candidate: 3.64ubuntu1 Version table: *** 3.64ubuntu1 500 500 http://de.archive.ubuntu.com/ubuntu focal/main amd64 Packages 500 http://de.archive.ubuntu.com/ubuntu focal/main i386 Packages 100 /var/lib/dpkg/status $ awk '$2 ~ /rpm/' < /etc/mime.types application/x-redhat-package-manager rpm $ dpkg -S /etc/mime.types mime-support: /etc/mime.types $ apt-cache policy mime-support mime-support: Installed: 3.54ubuntu1.1 Candidate: 3.54ubuntu1.1 Version table: *** 3.54ubuntu1.1 0 500 http://us.archive.ubuntu.com/ubuntu/ trusty-updates/main amd64 Packages 500 http://us.archive.ubuntu.com/ubuntu/ trusty-security/main amd64 Packages 100 /var/lib/dpkg/status 3.54ubuntu1 0 500 http://us.archive.ubuntu.com/ubuntu/ trusty/main amd64 Packages Otherwise, 'is_rpm_file' fails, resulting in a few test cases failing with an unhelpful 'Unknown arguments. Please refer to --help.' message (similar to what had been observed in PR22077 "runtestfedabipkgdiff.py fails on centos-x86_64"). * tools/fedabipkgdiff (is_rpm_file): Also accept MIME type 'application/x-redhat-package-manager' for RPM files. CC: Chenxiong Qi Signed-off-by: Thomas Schwinge --- tools/fedabipkgdiff | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/tools/fedabipkgdiff b/tools/fedabipkgdiff index be4182b2..dc80a6ef 100755 --- a/tools/fedabipkgdiff +++ b/tools/fedabipkgdiff @@ -209,8 +209,13 @@ def match_nvra(s): def is_rpm_file(filename): """Return if a file is a RPM""" - return os.path.isfile(filename) and \ - mimetypes.guess_type(filename)[0] == 'application/x-rpm' + isfile = os.path.isfile(filename) + mimetype = mimetypes.guess_type(filename)[0] if isfile else None + isrpm = (mimetype == 'application/x-redhat-package-manager' + or mimetype == 'application/x-rpm') + logger.debug('is_rpm_file(\'%s\'): isfile=%s, mimetype=\'%s\', isrpm=%s', + filename, isfile, mimetype, isrpm) + return isrpm def cmp_nvr(left, right):