From patchwork Fri Mar 17 08:19:14 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?b?RnLDqWTDqXJpYyBNYXJ0aW5zb25z?= X-Patchwork-Id: 21128 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id 243A4C74A5B for ; Fri, 17 Mar 2023 08:19:37 +0000 (UTC) Received: from mail-wm1-f49.google.com (mail-wm1-f49.google.com [209.85.128.49]) by mx.groups.io with SMTP id smtpd.web10.14421.1679041171843108404 for ; Fri, 17 Mar 2023 01:19:32 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@gmail.com header.s=20210112 header.b=OOoAaEbi; spf=pass (domain: gmail.com, ip: 209.85.128.49, mailfrom: frederic.martinsons@gmail.com) Received: by mail-wm1-f49.google.com with SMTP id r19-20020a05600c459300b003eb3e2a5e7bso2746545wmo.0 for ; Fri, 17 Mar 2023 01:19:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1679041170; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=lSByCSFAw/oVU1Yr2RHDris4wKib9wDuatqZlqERMNM=; b=OOoAaEbiEclmC5KxMsfWODJlyhxWLk+wDukVEGL1aTdhHLkaPjMd9COnDtjIV969A5 nym+oe/2DkEtelB/DVx04uiUfl/sNn60GESneGRCedSGoZqjg/dIWo3QCtQGu3SVzijb L7xsbkcarZ09U4UrROBPRtDWRns4cNU/3mp7krRz7x9uPBbaBE0IQ6f8t7XcS0XaFPa0 a6KfvzIhljKQofl/cuXQx2C9jDI7fCd7gkCeoe47accVmFK5U19aD30CoPXuu+9vkkH3 uvaTvtX67UgyHjyLZKCxGt7lzqMKW2n1jM3RfM8fcpBjk/ooqhJaazKvMuOcuNEAp2tE 9Z3g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1679041170; 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=lSByCSFAw/oVU1Yr2RHDris4wKib9wDuatqZlqERMNM=; b=DF4ljCMjf4RDzPniZIAhjeWFM9EtEmOGPAjDIPVdYYYzHCwVro7KcJfED2+tgKG/C9 osDU3/Xz0wmZZ8SyJCdcZLkzEZtAIhwsXw8H4FtZNprpsloaaAwOc/rhyMLTv60LLTjH p+jNbO/xCN62lyW2Sya23Vo5iIP+VBCX4ivErI5ia4fuuPs4qH4/pdoZmk5t++JnR71i wWTeQd6wPabDcS+AFp4Jba12SJHeM6HaH6SzRsRHjXql52vGfpURdaUvUOwInzzn19AS 9Kz2i8WlXCuVYgxfGHZ5tISGJImwitcxZ3KpCk3TgKtRZrs9Z5OEez4/B50s0hVgLrpY 5uDQ== X-Gm-Message-State: AO0yUKUQzV9tf5ofz1H/57H5DaUl6eKMLWZgitFF2GuHUvfM9nScXTxD mF4AWkszC1sXuWnmTqc9JXdbt6FsQkU= X-Google-Smtp-Source: AK7set+iF/KHHU5N1pLu9ac2HeaLBifTCh08LR5uLfU9XinGsu7RV7rh8NLid8lQFwZpZqfZ7EGHIg== X-Received: by 2002:a7b:cb98:0:b0:3ed:8360:e54 with SMTP id m24-20020a7bcb98000000b003ed83600e54mr990302wmi.8.1679041169732; Fri, 17 Mar 2023 01:19:29 -0700 (PDT) Received: from work-pc.. ([2a01:e0a:8d5:c6c0:7a1:ff32:1d50:1429]) by smtp.gmail.com with ESMTPSA id c24-20020a05600c0ad800b003e22508a343sm1293819wmr.12.2023.03.17.01.19.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 17 Mar 2023 01:19:29 -0700 (PDT) From: frederic.martinsons@gmail.com To: bitbake-devel@lists.openembedded.org Cc: Frederic Martinsons Subject: [bitbake-devel][PATCH v2 1/3] fetch2: Add checksum capability for crate fetcher Date: Fri, 17 Mar 2023 09:19:14 +0100 Message-Id: <20230317081916.1857201-1-frederic.martinsons@gmail.com> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 List-Id: X-Webhook-Received: from li982-79.members.linode.com [45.33.32.79] by aws-us-west-2-korg-lkml-1.web.codeaurora.org with HTTPS for ; Fri, 17 Mar 2023 08:19:37 -0000 X-Groupsio-URL: https://lists.openembedded.org/g/bitbake-devel/message/14602 From: Frederic Martinsons This change brings checksum verification of each crate in a recipe, e.g | SRC_URI += " \ | crate://crates.io/aho-corasick/0.7.20 \ | crate://crates.io/atomic-waker/1.1.0 \ | crate://crates.io/cc/1.0.79 \ | " | | SRC_URI[aho-corasick.sha256sum] = "cc936419f96fa211c1b9166887b38e5e40b19958e5b895be7c1f93adec7071ac" | SRC_URI[atomic-waker.sha256sum] = "debc29dde2e69f9e47506b525f639ed42300fc014a3e007832592448fa8e4599" | SRC_URI[cc.sha256sum] = "50d30906286121d95be3d479533b458f87493b30a4b5f79a607db8f5d11aa91f" That will require to move the checksum initialization after the possible call to urldata_init method in order for the crate fetcher to parse the url. Another way of doing could have been implementing a decodeurl method that would have been specific for each fetcher class. Signed-off-by: Frederic Martinsons --- lib/bb/fetch2/__init__.py | 12 ++++++------ lib/bb/tests/fetch.py | 32 ++++++++++++++++++++++++++++++++ 2 files changed, 38 insertions(+), 6 deletions(-) diff --git a/lib/bb/fetch2/__init__.py b/lib/bb/fetch2/__init__.py index cf65727a..3ae83fa8 100644 --- a/lib/bb/fetch2/__init__.py +++ b/lib/bb/fetch2/__init__.py @@ -1291,18 +1291,13 @@ class FetchData(object): if checksum_name in self.parm: checksum_expected = self.parm[checksum_name] - elif self.type not in ["http", "https", "ftp", "ftps", "sftp", "s3", "az"]: + elif self.type not in ["http", "https", "ftp", "ftps", "sftp", "s3", "az", "crate"]: checksum_expected = None else: checksum_expected = d.getVarFlag("SRC_URI", checksum_name) setattr(self, "%s_expected" % checksum_id, checksum_expected) - for checksum_id in CHECKSUM_LIST: - configure_checksum(checksum_id) - - self.ignore_checksums = False - self.names = self.parm.get("name",'default').split(',') self.method = None @@ -1324,6 +1319,11 @@ class FetchData(object): if hasattr(self.method, "urldata_init"): self.method.urldata_init(self, d) + for checksum_id in CHECKSUM_LIST: + configure_checksum(checksum_id) + + self.ignore_checksums = False + if "localpath" in self.parm: # if user sets localpath for file, use it instead. self.localpath = self.parm["localpath"] diff --git a/lib/bb/tests/fetch.py b/lib/bb/tests/fetch.py index 73eefc59..fd089bc8 100644 --- a/lib/bb/tests/fetch.py +++ b/lib/bb/tests/fetch.py @@ -2377,6 +2377,13 @@ class CrateTest(FetcherTest): d = self.d fetcher = bb.fetch2.Fetch(uris, self.d) + ud = fetcher.ud[fetcher.urls[0]] + + self.assertIn("name", ud.parm) + self.assertEqual(ud.parm["name"], "glob") + self.assertIn("downloadfilename", ud.parm) + self.assertEqual(ud.parm["downloadfilename"], "glob-0.2.11.crate") + fetcher.download() fetcher.unpack(self.tempdir) self.assertEqual(sorted(os.listdir(self.tempdir)), ['cargo_home', 'download' , 'unpacked']) @@ -2394,6 +2401,19 @@ class CrateTest(FetcherTest): d = self.d fetcher = bb.fetch2.Fetch(uris, self.d) + ud = fetcher.ud[fetcher.urls[0]] + + self.assertIn("name", ud.parm) + self.assertEqual(ud.parm["name"], "glob") + self.assertIn("downloadfilename", ud.parm) + self.assertEqual(ud.parm["downloadfilename"], "glob-0.2.11.crate") + + ud = fetcher.ud[fetcher.urls[1]] + self.assertIn("name", ud.parm) + self.assertEqual(ud.parm["name"], "time") + self.assertIn("downloadfilename", ud.parm) + self.assertEqual(ud.parm["downloadfilename"], "time-0.1.35.crate") + fetcher.download() fetcher.unpack(self.tempdir) self.assertEqual(sorted(os.listdir(self.tempdir)), ['cargo_home', 'download' , 'unpacked']) @@ -2403,6 +2423,18 @@ class CrateTest(FetcherTest): self.assertTrue(os.path.exists(self.tempdir + "/cargo_home/bitbake/time-0.1.35/.cargo-checksum.json")) self.assertTrue(os.path.exists(self.tempdir + "/cargo_home/bitbake/time-0.1.35/src/lib.rs")) + @skipIfNoNetwork() + def test_crate_incorrect_cksum(self): + uri = "crate://crates.io/aho-corasick/0.7.20" + self.d.setVar('SRC_URI', uri) + self.d.setVarFlag("SRC_URI", "aho-corasick.sha256sum", hashlib.sha256("Invalid".encode("utf-8")).hexdigest()) + + uris = self.d.getVar('SRC_URI').split() + + fetcher = bb.fetch2.Fetch(uris, self.d) + with self.assertRaisesRegexp(bb.fetch2.FetchError, "Fetcher failure for URL"): + fetcher.download() + class NPMTest(FetcherTest): def skipIfNoNpm(): import shutil From patchwork Fri Mar 17 08:19:15 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?b?RnLDqWTDqXJpYyBNYXJ0aW5zb25z?= X-Patchwork-Id: 21129 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id 233BDC7618A for ; Fri, 17 Mar 2023 08:19:57 +0000 (UTC) Received: from mail-wm1-f47.google.com (mail-wm1-f47.google.com [209.85.128.47]) by mx.groups.io with SMTP id smtpd.web11.14339.1679041187919582364 for ; Fri, 17 Mar 2023 01:19:48 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@gmail.com header.s=20210112 header.b=KPr3ufze; spf=pass (domain: gmail.com, ip: 209.85.128.47, mailfrom: frederic.martinsons@gmail.com) Received: by mail-wm1-f47.google.com with SMTP id w11so1723876wmo.2 for ; Fri, 17 Mar 2023 01:19:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1679041186; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=urIUkXOviiJ2tcviX9xw4r0BPbg7agQh5pZ2+uOaYvw=; b=KPr3ufze+wVPbNZNOfapWQ7KI6alDBFU7ATklX41x/7itoqr2ElxFGYnsUfh+giUz2 vxcxWRj4rSbhxubnOi6jTwtnoQTVkrNIkBi0ix8fb+SgZ3Of+E7x2wp5JjykboO00xvE /F6oD5VmZsh69oDFYsZBQ35WzSGTTEhpHkjZPbNp6TDj85uI9vONX6Vut+Eqks4YDqKc sZk21vt2I0hwWeektfMzwxvJpVBQPP2Nny0XhHt5ULyZKcBujLI5Kt5VU+JwEBE/wZtx 9fUy7lITuK/l2pJX5td6FOSzBkIPLd5d4CoKEycbWO1RTAMYcICGfwSbZnROIEHT+6QK 41+Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1679041186; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=urIUkXOviiJ2tcviX9xw4r0BPbg7agQh5pZ2+uOaYvw=; b=cP+QN0mn+PqOS8XUPl6AI/4TOhWKMCDtb10X69CXHJaUqiJly2jOg1AplyqrXYOOKN biQw5TkKnQCOaOSyY+9ZekPGR0WpBt/7GuDF8OiE/EeUtrQatDPS3GDdC8i2cj3QJgVN bqnfTd5k/WrWnNb12wkCw/XrSo0GoNnqdHCh4qiTEJ7Zm/gia8iYsqi0dZLsBI389Nxi asqB1bdd+r5zu+sjOcgaVr9JG7/0LfNRv8PznIHehy1NKQK7O5tqgkB094/zwvlwKZeP lJh+YXzYU/3fYT50r7K2pHOVDMsMCjOL5VrvgC2Jl8ubCRHx4bd0dPVxHzunijMpyEPU emtw== X-Gm-Message-State: AO0yUKUlNphVJ40IWYSPsvK+trEOWTx+4a6HbmZxDjSqr+/3+bmmZOa5 MbddEmZqWyKw3khI+NVGITtTe7+f+FM= X-Google-Smtp-Source: AK7set98lE/JLZ32Z+quZ9qid9Ozid76xMpmOVMWtRli4rzaSc5EaD8x6PTPC97GU8Wdn53Lt9+MBQ== X-Received: by 2002:a05:600c:a4c:b0:3e2:589:2512 with SMTP id c12-20020a05600c0a4c00b003e205892512mr23501002wmq.21.1679041186083; Fri, 17 Mar 2023 01:19:46 -0700 (PDT) Received: from work-pc.. ([2a01:e0a:8d5:c6c0:7a1:ff32:1d50:1429]) by smtp.gmail.com with ESMTPSA id c24-20020a05600c0ad800b003e22508a343sm1293819wmr.12.2023.03.17.01.19.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 17 Mar 2023 01:19:45 -0700 (PDT) From: frederic.martinsons@gmail.com To: bitbake-devel@lists.openembedded.org Cc: Frederic Martinsons Subject: [bitbake-devel][PATCH v2 2/3] crate.py: make checksum verification mandatory Date: Fri, 17 Mar 2023 09:19:15 +0100 Message-Id: <20230317081916.1857201-2-frederic.martinsons@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230317081916.1857201-1-frederic.martinsons@gmail.com> References: <20230317081916.1857201-1-frederic.martinsons@gmail.com> MIME-Version: 1.0 List-Id: X-Webhook-Received: from li982-79.members.linode.com [45.33.32.79] by aws-us-west-2-korg-lkml-1.web.codeaurora.org with HTTPS for ; Fri, 17 Mar 2023 08:19:57 -0000 X-Groupsio-URL: https://lists.openembedded.org/g/bitbake-devel/message/14603 From: Frederic Martinsons Signed-off-by: Frederic Martinsons --- lib/bb/fetch2/crate.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/bb/fetch2/crate.py b/lib/bb/fetch2/crate.py index f091200d..f8367ed3 100644 --- a/lib/bb/fetch2/crate.py +++ b/lib/bb/fetch2/crate.py @@ -33,7 +33,7 @@ class Crate(Wget): return ud.type in ['crate'] def recommends_checksum(self, urldata): - return False + return True def urldata_init(self, ud, d): """ From patchwork Fri Mar 17 08:19:16 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?b?RnLDqWTDqXJpYyBNYXJ0aW5zb25z?= X-Patchwork-Id: 21130 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id 22417C6FD1D for ; Fri, 17 Mar 2023 08:19:57 +0000 (UTC) Received: from mail-wm1-f44.google.com (mail-wm1-f44.google.com [209.85.128.44]) by mx.groups.io with SMTP id smtpd.web11.14342.1679041193638173708 for ; Fri, 17 Mar 2023 01:19:53 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@gmail.com header.s=20210112 header.b=Zy113i00; spf=pass (domain: gmail.com, ip: 209.85.128.44, mailfrom: frederic.martinsons@gmail.com) Received: by mail-wm1-f44.google.com with SMTP id j42-20020a05600c1c2a00b003ed363619ddso2938317wms.1 for ; Fri, 17 Mar 2023 01:19:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1679041192; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=EBhVZ9P81FOLkf4KxzOUM17YuVgEmsYSvOQPUVHGf0Y=; b=Zy113i000qOrQOrfIHaqYE4Le6xQ70yk2w/rKoaa0UY+I/ngpHkfItM+6Q/GS7/H8D S6vjMJIZOoYdHh0RRrl3VJHrXKsdEEIcMRo459H4yKRojr81t2wy+uK+tjREY8L5KfJg 6TfvSVnhWDwk3zCZI9BiJyPvDODAuABwyfbGQe3WfTDdZvZUr/LiBbY/rCkHVuGDsDBQ BeFGfb4Hmto9HATBbilv8N9LmLfZYp9Igq7zbvi6LYQjsd7M1budUDKGkvwNlbfoDaed zGmkTUS3Kp+LLXI+W7dKZ0rYB1WkxsiddvTEK8hqNXTnwq7FcKZqIWiUxTa1/pvtRGHj rK+A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1679041192; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=EBhVZ9P81FOLkf4KxzOUM17YuVgEmsYSvOQPUVHGf0Y=; b=YzOcwN0oDmLK6qLeEZmluz3M2c51VoYJuIsOvSHc3dD2bssueARTpSnE2gHcjI1MFL HtzFoMmXB5O88owRNnj9IA+ThR8d+K2VVdRr21e1y1YgyjilGWgilNfk7KQogE83KDMt 5P4/sDa+f2F+QFtd6fbzm6j/TTmY1oCcSgb0c3GQPsF90yI03sUyFB0FFZC2L9erMNlK OnEV/iuaCWDxMxph0lk3K+RbONRgkZCM6JvvXr0lI37zU9XFQRTaQtt5O2c+i/hCEzSn jIxLPUMJzFcXSFf/livu39FUOlnDXA21LJWgtDMQltBrBEdbh01wlb6WRYBsJERdeb3T IhMA== X-Gm-Message-State: AO0yUKW9eAuoyKkNNmGSOdoz/YCBd5oMa0v3oESxV5vdY/78DwixnD4v od2QdlDSSF+O/UJv5YpdnpK2MbYbfpo= X-Google-Smtp-Source: AK7set/STotdOV0dBtvm48+qfpUK9nNdIXKfWrbLbdi7eewxHj8B9ld6Z3I7Pagldn7d/Rr6yuS8Pw== X-Received: by 2002:a05:600c:2185:b0:3ed:8780:f27b with SMTP id e5-20020a05600c218500b003ed8780f27bmr774166wme.16.1679041191588; Fri, 17 Mar 2023 01:19:51 -0700 (PDT) Received: from work-pc.. ([2a01:e0a:8d5:c6c0:7a1:ff32:1d50:1429]) by smtp.gmail.com with ESMTPSA id c24-20020a05600c0ad800b003e22508a343sm1293819wmr.12.2023.03.17.01.19.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 17 Mar 2023 01:19:51 -0700 (PDT) From: frederic.martinsons@gmail.com To: bitbake-devel@lists.openembedded.org Cc: Frederic Martinsons Subject: [bitbake-devel][PATCH v2 3/3] crate.py: authorize crate url with parameters Date: Fri, 17 Mar 2023 09:19:16 +0100 Message-Id: <20230317081916.1857201-3-frederic.martinsons@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230317081916.1857201-1-frederic.martinsons@gmail.com> References: <20230317081916.1857201-1-frederic.martinsons@gmail.com> MIME-Version: 1.0 List-Id: X-Webhook-Received: from li982-79.members.linode.com [45.33.32.79] by aws-us-west-2-korg-lkml-1.web.codeaurora.org with HTTPS for ; Fri, 17 Mar 2023 08:19:57 -0000 X-Groupsio-URL: https://lists.openembedded.org/g/bitbake-devel/message/14604 From: Frederic Martinsons This allow to have classic fetch parameters (like destsuffix, sha256, name ...) not being considered by crate fetcher itself (and so mess up its download) Moreover, it allow to overload the name of the downloaded crate (maybe usefull if there is a naming clash between two crates coming from different repositories) Signed-off-by: Frederic Martinsons --- lib/bb/fetch2/crate.py | 9 ++++++--- lib/bb/tests/fetch.py | 24 ++++++++++++++++++++++++ 2 files changed, 30 insertions(+), 3 deletions(-) diff --git a/lib/bb/fetch2/crate.py b/lib/bb/fetch2/crate.py index f8367ed3..590dc9c1 100644 --- a/lib/bb/fetch2/crate.py +++ b/lib/bb/fetch2/crate.py @@ -56,8 +56,10 @@ class Crate(Wget): if len(parts) < 5: raise bb.fetch2.ParameterError("Invalid URL: Must be crate://HOST/NAME/VERSION", ud.url) - # last field is version - version = parts[len(parts) - 1] + # version is expected to be the last token + # but ignore possible url parameters which will be used + # by the top fetcher class + version, _, _ = parts[len(parts) -1].partition(";") # second to last field is name name = parts[len(parts) - 2] # host (this is to allow custom crate registries to be specified @@ -69,7 +71,8 @@ class Crate(Wget): ud.url = "https://%s/%s/%s/download" % (host, name, version) ud.parm['downloadfilename'] = "%s-%s.crate" % (name, version) - ud.parm['name'] = name + if 'name' not in ud.parm: + ud.parm['name'] = name logger.debug2("Fetching %s to %s" % (ud.url, ud.parm['downloadfilename'])) diff --git a/lib/bb/tests/fetch.py b/lib/bb/tests/fetch.py index fd089bc8..85cf25e7 100644 --- a/lib/bb/tests/fetch.py +++ b/lib/bb/tests/fetch.py @@ -2423,6 +2423,30 @@ class CrateTest(FetcherTest): self.assertTrue(os.path.exists(self.tempdir + "/cargo_home/bitbake/time-0.1.35/.cargo-checksum.json")) self.assertTrue(os.path.exists(self.tempdir + "/cargo_home/bitbake/time-0.1.35/src/lib.rs")) + @skipIfNoNetwork() + def test_crate_url_params(self): + + uri = "crate://crates.io/aho-corasick/0.7.20;name=aho-corasick-renamed" + self.d.setVar('SRC_URI', uri) + + uris = self.d.getVar('SRC_URI').split() + d = self.d + + fetcher = bb.fetch2.Fetch(uris, self.d) + ud = fetcher.ud[fetcher.urls[0]] + + self.assertIn("name", ud.parm) + self.assertEqual(ud.parm["name"], "aho-corasick-renamed") + self.assertIn("downloadfilename", ud.parm) + self.assertEqual(ud.parm["downloadfilename"], "aho-corasick-0.7.20.crate") + + fetcher.download() + fetcher.unpack(self.tempdir) + self.assertEqual(sorted(os.listdir(self.tempdir)), ['cargo_home', 'download' , 'unpacked']) + self.assertEqual(sorted(os.listdir(self.tempdir + "/download")), ['aho-corasick-0.7.20.crate', 'aho-corasick-0.7.20.crate.done']) + self.assertTrue(os.path.exists(self.tempdir + "/cargo_home/bitbake/aho-corasick-0.7.20/.cargo-checksum.json")) + self.assertTrue(os.path.exists(self.tempdir + "/cargo_home/bitbake/aho-corasick-0.7.20/src/lib.rs")) + @skipIfNoNetwork() def test_crate_incorrect_cksum(self): uri = "crate://crates.io/aho-corasick/0.7.20"