From patchwork Sat Nov 14 20:08:08 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tim Orling X-Patchwork-Id: 104068 Received: from mail-pj1-f41.google.com (mail-pj1-f41.google.com [209.85.216.41]) by mx.groups.io with SMTP id smtpd.msgproc02-g2.3563.1794686916689630989 for ; Sat, 14 Nov 2026 12:08:36 -0800 Authentication-Results: mx.groups.io; dkim=pass header.i=@gmail.com header.s=20260707 header.b=OlarRG4u; spf=pass (domain: gmail.com, ip: 209.85.216.41, mailfrom: ticotimo@gmail.com) Received: by mail-pj1-f41.google.com with SMTP id 98e67ed59e1d1-3b155f50c24so3335735a91.3 for ; Sat, 14 Nov 2026 12:08:36 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20260707; t=1794686916; x=1795291716; darn=lists.openembedded.org; 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:content-type; bh=JYn6BSHe7BJtJSEPGbMy8ChAdIVTICc83M5zQfExSCY=; b=OlarRG4uYFK6eCZVZJtpFDEuLw9JmPTkQOZE76H4Uv0jg01fSiQiS0f8TawVSXBOf4 dtJ22DwVsip5l6QTMEXgHsLhd8ixBMTBQsieCIXI2y82B5NABQQqgocqCfJ7Z5enaVCn x2z5tSMtR4ZbH+iF8dC3+AsxVZZeNinOr2sQi3EA0TbSB+x8xXay/p2T/EeNAXh2otrk AAMp6BiOoFhGa+uxCE9KAJgO9cItTYZX5bQXCqG+jslYGYshPXtMw7az6JtCScsoHEG0 U2sXZMznqd0rlb42wts3RPbhG82wK0XPq+NzWggoTUtCrjTGwgWVEnUeQTT4QxCmbI4u wzQA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1794686916; x=1795291716; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=JYn6BSHe7BJtJSEPGbMy8ChAdIVTICc83M5zQfExSCY=; b=HOcqK5H4mw0AJ11/vqMdOX/7pOJrZy4An9XGrMI8dWL85HONDs5byfHelk6lkwWYTM /vacWfB69afU5pQ3goR8TB/A5IiKm/AUXwWZaZqDGDq6BqwqsU2rzHiG+lzEu6mCQ6dn IMs472hH7dG5mUU5pdT1550bnmHGmlGGpsV9ElneNbLgxyEP0vipNb6q64vDNjUT7J1x pJdV9+zXY9jiY2iqWyymfVqRKoxWaZrxd17jA/ouoICcoFzLtKdtlD1jYrcm8xOZKdxZ hwXsiDKDaQxGaV4zwWdG3e45rPiimJRXRZ3UX8A29smAQelIvvr7JVASBw85Usl3ZD6G eNRA== X-Gm-Message-State: APuU4Z+dvWp5bG13cCThMmP8Zicc5qxj5wV33J2m9CIsTp+wVYf7Hmmy Ii6/NZFBx3+TISyiotA//YbsyiBRbCyZlTqVA56DsFRLDUzbSbGXsvfosqUx35Uj X-Gm-Gg: AYBFou21iRWdeINZIJE6pD71+A3A1VyuO0jzWxZle2l5nsv4wj0HLc9BgO5bYhREQVm Cj598t8ccpgbAX9/pCyJADDwWRQc7z7aSNd6xUgKsyerd3NWP6pafiPj3Fzc4Jw4N0xfBSGWcK4 pQbVfdDPxuK0m+EEvgd5mpwIHy9KCxU1jWv356vF6oUnZDSuPa1iFmQs15AW1CdROsCr03J6/98 o4owt8+lT8ooo0xA0Bj79Z4Vdh4rcaEDP3/bPr0Ld1vXUVpzKPnfncl2XBf7WSlUt038ftMesxB wLIOEC1DS4CFqD8GRonOztbQgO8iCVgwY2ipGmglDzEnccUlD9wvOhfBKAJ4OPACiyASrn0oPgG M2Neqq4lcTsfw0Cfdw1prIdYu4JgU/aMCWGUzszG2HLcc5AeOupVLBSaAkJsNWzhT25u3Mtp2jV 5xt8hpQcyqtHql5xnLTrErG/X+8q3Y+PPGD+DbAcPlV2a+kVjbM99NH0o2eM7uZHgJ0CZvnztQq Q58B+omc05/zz9py0lvRfaImUN99GCjGV2bWUZmM9OTuvBnCGVl31fU2Y7P59R2jBiVprlBE7AR HY6+grDwjv5Jj7ZoQQCa9ZI983KFztqwXDJyAOFtwk9vhYryI8HrkkyG4E3U6Q== X-Received: by 2002:a17:90b:1fc4:b0:3ab:188b:c5bf with SMTP id 98e67ed59e1d1-3b1b0b57dc8mr6194333a91.18.1794686915960; Sat, 14 Nov 2026 12:08:35 -0800 (PST) Return-Path: Received: from localhost.localdomain ([69.9.132.159]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-3b197b76ccesm14965358a91.0.2026.11.14.12.08.32 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Sat, 14 Nov 2026 12:08:34 -0800 (PST) From: Tim Orling X-Google-Original-From: Tim Orling To: openembedded-core@lists.openembedded.org Cc: Tim Orling Subject: [PATCH 1/3] lib/oe/distro_check: skip a distro whose package list can't be fetched Date: Sat, 14 Nov 2026 12:08:08 -0800 Message-ID: <20261114200810.31078-2-tim.orling@konsulko.com> X-Mailer: git-send-email 2.56.1 In-Reply-To: <20261114200810.31078-1-tim.orling@konsulko.com> References: <20261114200810.31078-1-tim.orling@konsulko.com> MIME-Version: 1.0 List-Id: X-Webhook-Received: from 45-33-107-173.ip.linodeusercontent.com [45.33.107.173] by lin-tor-korg-lkml-alma10-1 with HTTPS for ; Sat, 14 Nov 2026 20:08:45 -0000 X-Groupsio-URL: https://lists.openembedded.org/g/openembedded-core/message/250209 When a fetcher raised, create_distro_packages_list() only warned and then used release and package_list anyway, failing with UnboundLocalError on the first distro, so no package lists were written at all. Move on to the next distro instead. Tested by making the Debian fetcher raise: the other four package lists are written. [YOCTO #16503] AI-Generated: Claude Opus 5.5 Signed-off-by: Tim Orling --- meta/lib/oe/distro_check.py | 1 + 1 file changed, 1 insertion(+) diff --git a/meta/lib/oe/distro_check.py b/meta/lib/oe/distro_check.py index 1d78348ff3..56f81e630d 100644 --- a/meta/lib/oe/distro_check.py +++ b/meta/lib/oe/distro_check.py @@ -170,6 +170,7 @@ def create_distro_packages_list(distro_check_dir, d): release, package_list = fetcher_func(d) except Exception as e: bb.warn("Cannot fetch packages for %s: %s" % (name, e)) + continue bb.note("Distro: %s, Latest Release: %s, # src packages: %d" % (name, release, len(package_list))) if len(package_list) == 0: bb.error("Didn't fetch any packages for %s %s" % (name, release)) From patchwork Sat Nov 14 20:08:09 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tim Orling X-Patchwork-Id: 104067 Received: from mail-pj1-f53.google.com (mail-pj1-f53.google.com [209.85.216.53]) by mx.groups.io with SMTP id smtpd.msgproc01-g2.3642.1794686921674785475 for ; Sat, 14 Nov 2026 12:08:41 -0800 Authentication-Results: mx.groups.io; dkim=pass header.i=@gmail.com header.s=20260707 header.b=KycDZhS8; spf=pass (domain: gmail.com, ip: 209.85.216.53, mailfrom: ticotimo@gmail.com) Received: by mail-pj1-f53.google.com with SMTP id 98e67ed59e1d1-3ae7626d14aso1128593a91.2 for ; Sat, 14 Nov 2026 12:08:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20260707; t=1794686921; x=1795291721; darn=lists.openembedded.org; 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:content-type; bh=OLHI9y96IcICVxv7DO3bSA6pkDMewLIAB98vMYmbZC0=; b=KycDZhS8OF1PMK0ZGOvEzdQSXIo2zpOIedARtBDfcbjJBjDaL55wiLqqrMUn/2qMSx e7SdVLR4ht2wTXwz0AOdPa10xyy+Km9LpZ2Wixxsw6mPH/cekBC7i0j1DCF33sMHPP/3 0+KAt6fjOrMMjkqk6r/dxTiwYV+mSTH1PKVW0Ym+tEfA8861ElvxNmcInG37p2d1QiGw f8HpRQ9oUWiZOhSkZ2fA2kOaZQwV/w2LWzGvS2yqu0BEum7Qn34dXbfvD6oyQjF2LRpF BmS730QTFy5ANFS02jThtINhyHGqCtfcQdOD9yfOZXykZ2kLnjKEEUwvYdnT6JOyuqDG PNaA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1794686921; x=1795291721; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=OLHI9y96IcICVxv7DO3bSA6pkDMewLIAB98vMYmbZC0=; b=oBPh/p9/nqowkraNPmPKOXxsUPvhPyG20BzAygaAGYk9bSyVlkYy3jlr/kugI5vIEI jg15igzcYLtkP1aOn6pSbKLUKbl09RnwqgZbPpUl0baw+qtxclZtLWeAiw3Cyyd4fuTF D5U18spb4rab85rlZTrR3L8q78HZDKbNvAnQe1W/xl/cGccYNkZc9G2g16GIo+nXT65Z yg34D08d6/0GSJuo+YNLv7mZfQNpNUcqq++oZHzBzoh09omEhmqa3WG4ZRCpVMuzzi5b ZRQzLIWeH9gI9DEwUItW6BFCV+c3cO1RgJHhvSORJExnH5kxklNnWboVRTJYIjbXRpB1 eSVw== X-Gm-Message-State: APuU4Z8KVUZ20LJ077e+2shoIpjTP390a4ASZ/PI59aKLG2vm4kAU1QY nRpMvutLaBrjbGF/J80hu5NobPnQWE+BP8qWhpJHxSZt7HtzS+QHwUKVQdyyoFXq X-Gm-Gg: AYBFou12ePDERJ0LR+Oki1lbsyKtEGNrmw5fSuYZMBO9KKJrkkuFhUq/xT7h26uA5+I m4Lwgv9czvES7bAiFzQsDZqoOQEQ94ZRBAjGLllh6R3oxNVJukQrPDkUKEa1RrL8PORZhx3Hjsx rjf2HgYOF4KVB+Vpwl7682fV3Z5aNu2ldHNsctTLUpa2MnZr/hWawVDQWFmQYiTAoqwJmx9+Hja 6ttPt2x4KkPLSilbuIH1jSRT1AlFo6xaidtJEk2hETMyQQ6LOBUGYDF7EA1PLTimMqPtaTdilm0 YpsOvIMk97HSJKzHLdv6Rvo4gDK3KBCB2X7zZ1zVUhDPDvfdDBolDBHtsqp7C8gz5PhMDwPHqXk ws02yZjqSXbCuLHbcjPBaAckZwXUWW3qLjQqkRXboMUXvqCN9AoI86+//2IjzSMHA9mpPMI00Gx GKfDvDL3MHerPFIlAJxreOdmHGOgt2lS8Fo2tvkX3cuG755e73WxLV3eABqPEIKtG0fCeeNXgMq 25hz/MgT4Vrj1ViIWIXnv7rwvudKQqlGu//+Tcy/39ftnqQPQ652vhtm4464z76fTjYTDblks0H qu8WtFh0wP8h6KkCkqKn7kONaJDcLDaFbDwf6GHEjGwV8AELm2Q9DYZQQprmDkVPlGtKiVR8Loe kAlh+NDI= X-Received: by 2002:a17:90b:3b8a:b0:3b0:9f53:e8a8 with SMTP id 98e67ed59e1d1-3b1b0b5f2c1mr6195872a91.52.1794686920569; Sat, 14 Nov 2026 12:08:40 -0800 (PST) Return-Path: Received: from localhost.localdomain ([69.9.132.159]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-3b197b76ccesm14965358a91.0.2026.11.14.12.08.37 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Sat, 14 Nov 2026 12:08:38 -0800 (PST) From: Tim Orling X-Google-Original-From: Tim Orling To: openembedded-core@lists.openembedded.org Cc: Tim Orling Subject: [PATCH 2/3] lib/oe/distro_check: fetch Debian updates from stable-updates Date: Sat, 14 Nov 2026 12:08:09 -0800 Message-ID: <20261114200810.31078-3-tim.orling@konsulko.com> X-Mailer: git-send-email 2.56.1 In-Reply-To: <20261114200810.31078-1-tim.orling@konsulko.com> References: <20261114200810.31078-1-tim.orling@konsulko.com> MIME-Version: 1.0 List-Id: X-Webhook-Received: from 45-33-107-173.ip.linodeusercontent.com [45.33.107.173] by lin-tor-korg-lkml-alma10-1 with HTTPS for ; Sat, 14 Nov 2026 20:08:45 -0000 X-Groupsio-URL: https://lists.openembedded.org/g/openembedded-core/message/250210 ftp.debian.org no longer has dists/stable-proposed-updates, so the Debian package list always failed with HTTP 404. Use stable-updates, the equivalent of Ubuntu's -updates, which is only published as Sources.xz, so read .xz files with lzma. Tested against ftp.debian.org: the Debian list is fetched again, with both main and updates packages. [YOCTO #16503] AI-Generated: Claude Opus 5.5 Signed-off-by: Tim Orling --- meta/lib/oe/distro_check.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/meta/lib/oe/distro_check.py b/meta/lib/oe/distro_check.py index 56f81e630d..223bed2ec2 100644 --- a/meta/lib/oe/distro_check.py +++ b/meta/lib/oe/distro_check.py @@ -110,11 +110,13 @@ def find_latest_debian_release(url, d): return "_NotFound_" def get_debian_style_source_package_list(url, section, d): - "Return the list of package-names stored in the debian style Sources.gz file" + "Return the list of package-names stored in the debian style Sources.gz or Sources.xz file" import gzip + import lzma + opener = lzma.open if url.endswith(".xz") else gzip.open package_names = set() - for line in gzip.open(create_socket(url, d), mode="rt"): + for line in opener(create_socket(url, d), mode="rt"): if line.startswith("Package:"): pkg = line.split(":", 1)[1].strip() package_names.add(pkg + ":" + section) @@ -125,7 +127,7 @@ def get_latest_released_debian_source_package_list(d): latest = find_latest_debian_release("http://ftp.debian.org/debian/dists/", d) url = "http://ftp.debian.org/debian/dists/stable/main/source/Sources.gz" package_names = get_debian_style_source_package_list(url, "main", d) - url = "http://ftp.debian.org/debian/dists/stable-proposed-updates/main/source/Sources.gz" + url = "http://ftp.debian.org/debian/dists/stable-updates/main/source/Sources.xz" package_names |= get_debian_style_source_package_list(url, "updates", d) return latest, package_names From patchwork Sat Nov 14 20:08:10 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tim Orling X-Patchwork-Id: 104069 Received: from mail-pj1-f51.google.com (mail-pj1-f51.google.com [209.85.216.51]) by mx.groups.io with SMTP id smtpd.msgproc01-g2.3643.1794686925549986490 for ; Sat, 14 Nov 2026 12:08:45 -0800 Authentication-Results: mx.groups.io; dkim=pass header.i=@gmail.com header.s=20260707 header.b=zjoR/J3v; spf=pass (domain: gmail.com, ip: 209.85.216.51, mailfrom: ticotimo@gmail.com) Received: by mail-pj1-f51.google.com with SMTP id 98e67ed59e1d1-3adac5b29ebso2054860a91.2 for ; Sat, 14 Nov 2026 12:08:45 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20260707; t=1794686925; x=1795291725; darn=lists.openembedded.org; 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:content-type; bh=PKdBYuYtMErKZBzgWkSszVoKKBaaXaVfH5Z3XNe43K0=; b=zjoR/J3vTt88EEF8qlMGYbj0/UDEMxtqtx2xr754JHSKTERP2ssvHROVeaOOZLoMPw YSDHsoYvweGRLfdVcvp7exHjDOhWg0fv3EWRRcouREBW/5Kwf9x59l3IzI6CbxbsywU4 6CQTKxKhlAlDevP77EGC+MO5wDJPpfrILagO1vhMg86yMrQC7aWOcTMdicQyDkjUhA1c SBIHjjiUuYAcLfDn/4pSCzm8jjEJH8BbTJ3XRXKmccffV5lkGk5+C0h+YGSl3tR6MXE7 ET/hLReQmgL3YbhlEe48bUkx3NvELjNF2ngUzmg1H+xCn1kHY/Tb0G8A/SlQNgRimFoE lZjw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1794686925; x=1795291725; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=PKdBYuYtMErKZBzgWkSszVoKKBaaXaVfH5Z3XNe43K0=; b=cRHNEES3Sj2coDPIfFMScRZFh5amz3J52EVq4kxvAC7Io9OzwUiAVQ/z70nJ9aq2f7 t8Agis2gmLoyGRZvDGbLFK9ZQKaJNL+EHR4CB8JHRhwEHluWKGBeTyE0MFMTK4bjn838 8X4e3sLwLCpx+qqm3f2P/lNhKphJaoTFR60gTGuM/+EmBdFxe7Ui2+pdgA3DZOHtbY09 QWHqvAjMa0hC+5JEzct0hO4WOAvVMikrS8ooatpeOoU5gOOUUHy8nmqB7pH9+I6JinY6 l43YQi2C/TLPfxlZIAp4Tykt2kJyGnZAOdu850a9T+vEC9GoY1WD86SiZb6T2OB/JceT lSzw== X-Gm-Message-State: APuU4Z8tXy5pcBKNFWoeMHopoCup0wfw/sC2UT+vlIvULkR+6B9EkCZN 99VbrnWLB8qT+ljaL1s+be+9WemdBDiXoOZs66lEkpZCvxvIEyMfZBa2l3i0MM3z X-Gm-Gg: AYBFou24O2MiuFRWAL3fS7xlrH0VEUyucuCZpxQH8x/rewGoM4HduFVCj4BrPc2tBsV ius0WYP7euEHtxhwU9KoVJZfDv3zF+Nq+F5A5eswJs5cxZhmd3R2fhaRx/L0repvkb/z3iBLvMu r+Pk/zzvFHr44QjgHllfQfr3VtC2R/Hvh4Pefm8wGoGfD4oNi0yMesKBdm4bjYkaFyj4I/URDis ug68DmIEYx7siKLXXZcWKgIqNewg/xxOvo9pwcSIteXvNfNC2EY7H7tyC03wVAnFo8Xls44/7oQ oTyW0QA3KrB/yDF6XQ+pN2Ev74xn33KNKf+dpMieW9r4+Tq2gH06y9nPlvYtD8GwVWuwnSJ4oUH k95aN+mnua9IV95rUY4RoejX1mywRVflNGO5/Tai/f3Pg449AYWINy7dziQOREXh5D8/Zs8y8Ug gpYg4qVW0Y6wldxinef0kM7B7ipEVZFacVGprkdOdSmpukgwBz91RjxghwLTC9izD9IwcktJGe0 KM+lUZu8564J8+7Fu43/cI8JFHhSdX2dPVIentnuTG7HlONBcEVRtuTYUgD4Tl/zx5ck68iM5xK tGG3FhEcUCzsOjsbHcwNMg9xdPRdKgXD5eXduZG1m+COa/cN41Y3hYQMy2a7HA== X-Received: by 2002:a17:90a:e7cc:b0:3a8:59d3:5317 with SMTP id 98e67ed59e1d1-3b1b0a1000dmr6423122a91.32.1794686924794; Sat, 14 Nov 2026 12:08:44 -0800 (PST) Return-Path: Received: from localhost.localdomain ([69.9.132.159]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-3b197b76ccesm14965358a91.0.2026.11.14.12.08.42 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Sat, 14 Nov 2026 12:08:44 -0800 (PST) From: Tim Orling X-Google-Original-From: Tim Orling To: openembedded-core@lists.openembedded.org Cc: Tim Orling Subject: [PATCH 3/3] oeqa/selftest/oelib: add tests for oe.distro_check Date: Sat, 14 Nov 2026 12:08:10 -0800 Message-ID: <20261114200810.31078-4-tim.orling@konsulko.com> X-Mailer: git-send-email 2.56.1 In-Reply-To: <20261114200810.31078-1-tim.orling@konsulko.com> References: <20261114200810.31078-1-tim.orling@konsulko.com> MIME-Version: 1.0 List-Id: X-Webhook-Received: from 45-33-107-173.ip.linodeusercontent.com [45.33.107.173] by lin-tor-korg-lkml-alma10-1 with HTTPS for ; Sat, 14 Nov 2026 20:08:55 -0000 X-Groupsio-URL: https://lists.openembedded.org/g/openembedded-core/message/250211 Nothing in OE-Core uses oe.distro_check any more (its user is the Recipe Reporting System on the layer index), so nothing exercised it. Test, without network access, that create_distro_packages_list() skips a distro whose fetch fails and that Debian style Sources lists are read from both .gz and .xz files. Without the two previous changes the skip and .xz tests fail. [YOCTO #16503] AI-Generated: Claude Opus 5.5 Signed-off-by: Tim Orling --- .../oeqa/selftest/cases/oelib/distro_check.py | 59 +++++++++++++++++++ 1 file changed, 59 insertions(+) create mode 100644 meta/lib/oeqa/selftest/cases/oelib/distro_check.py diff --git a/meta/lib/oeqa/selftest/cases/oelib/distro_check.py b/meta/lib/oeqa/selftest/cases/oelib/distro_check.py new file mode 100644 index 0000000000..f47d1dd4a4 --- /dev/null +++ b/meta/lib/oeqa/selftest/cases/oelib/distro_check.py @@ -0,0 +1,59 @@ +# +# Copyright OpenEmbedded Contributors +# +# SPDX-License-Identifier: MIT +# + +import gzip +import io +import lzma +import os +import tempfile +from unittest import mock +from unittest.case import TestCase + +import bb +# oe.distro_check uses bb as a builtin, which bb.build sets up +import bb.build +import oe.distro_check + +SOURCES = b"Package: foo\nVersion: 1.0\n\nPackage: bar\nVersion: 2.0\n" + +class TestDebianStyleSourcePackageList(TestCase): + def check(self, url, data): + with mock.patch.object(oe.distro_check, "create_socket", return_value=io.BytesIO(data)): + names = oe.distro_check.get_debian_style_source_package_list(url, "main", None) + self.assertEqual(names, {"foo:main", "bar:main"}) + + def test_gzip(self): + self.check("http://example.com/Sources.gz", gzip.compress(SOURCES)) + + def test_xz(self): + self.check("http://example.com/Sources.xz", lzma.compress(SOURCES)) + +class TestCreateDistroPackagesList(TestCase): + def test_skip_failed_distro(self): + """ + A distro whose package list can't be fetched is skipped, and the + other distros' lists are still written. + """ + def fail(d): + raise OSError("HTTP Error 404: Not Found") + + def ok(d): + return "1.0", {"foo:main"} + + fetchers = {"get_latest_released_%s_source_package_list" % name: ok + for name in ("ubuntu", "fedora", "opensuse", "clear")} + fetchers["get_latest_released_debian_source_package_list"] = fail + + with tempfile.TemporaryDirectory() as tmpdir, \ + mock.patch.multiple(oe.distro_check, **fetchers), \ + mock.patch.object(bb, "note"), \ + mock.patch.object(bb, "warn") as warn: + oe.distro_check.create_distro_packages_list(tmpdir, None) + lists = sorted(os.listdir(os.path.join(tmpdir, "package_lists"))) + + self.assertEqual(lists, ["Clear-1.0", "Fedora-1.0", "Ubuntu-1.0", "openSUSE-1.0"]) + warn.assert_called_once() + self.assertIn("Debian", warn.call_args[0][0])