@@ -317,9 +317,12 @@ def get_gnu_data_from_purl(purl):
317
317
"""Generate `Package` object from the `purl` string of gnu type"""
318
318
purl = PackageURL .from_string (purl )
319
319
source_archive_url = f"https://ftp.gnu.org/pub/gnu/{ purl .name } /"
320
- regex = r"^({}-)([\w.-]*)(.tar.gz)$" .format (purl .name )
320
+ version_regex_template = r"^({}-)(?P<version>[\w.-]*)(.tar.gz)$"
321
+ version_regex = re .compile (version_regex_template .format (re .escape (purl .name )))
321
322
322
- yield from extract_packages_from_listing (purl , source_archive_url , regex , [])
323
+ yield from extract_packages_from_listing (
324
+ purl , source_archive_url , version_regex , []
325
+ )
323
326
324
327
325
328
@dataclasses .dataclass
@@ -333,8 +336,8 @@ class DirectoryListedSource:
333
336
"description" : "Flag indicating whether the archives are nested within another directory"
334
337
},
335
338
)
336
- source_archive_regex : str = dataclasses .field (
337
- default = "" ,
339
+ source_archive_regex : re . Pattern = dataclasses .field (
340
+ default = None ,
338
341
metadata = {
339
342
"description" : "Regular expression pattern to match files in the directory listing."
340
343
},
@@ -368,7 +371,9 @@ def get_package_info(cls, package_url):
368
371
class IpkgDirectoryListedSource (DirectoryListedSource ):
369
372
source_url = "https://web.archive.org/web/20090326020239/http://handhelds.org/download/packages/ipkg/"
370
373
is_nested = False
371
- source_archive_regex = r"^(ipkg[-_])([\w.-]*)(_arm.ipk|.tar.gz)$"
374
+ source_archive_regex = re .compile (
375
+ r"^(ipkg[-_])(?P<version>[\w.-]*)(_arm.ipk|.tar.gz)$"
376
+ )
372
377
ignored_files_and_dir = []
373
378
374
379
@classmethod
@@ -398,132 +403,144 @@ def get_package_info(cls, package_url):
398
403
class UtilLinuxDirectoryListedSource (DirectoryListedSource ):
399
404
source_url = "https://mirrors.edge.kernel.org/pub/linux/utils/util-linux/"
400
405
is_nested = True
401
- source_archive_regex = r"^(util-linux-)([\w.-]*)(.tar.gz)$"
406
+ source_archive_regex = re . compile ( r"^(util-linux-)(?P<version> [\w.-]*)(.tar.gz)$" )
402
407
ignored_files_and_dir = []
403
408
404
409
405
410
class BusyBoxDirectoryListedSource (DirectoryListedSource ):
406
411
source_url = "https://www.busybox.net/downloads/"
407
- source_archive_regex = r"^(busybox-)([\w.-]*)(.tar.bz2)$"
412
+ source_archive_regex = re . compile ( r"^(busybox-)(?P<version> [\w.-]*)(.tar.bz2)$" )
408
413
is_nested = False
409
414
ignored_files_and_dir = []
410
415
411
416
412
417
class UclibcDirectoryListedSource (DirectoryListedSource ):
413
418
source_url = "https://www.uclibc.org/downloads/"
414
- source_archive_regex = r"^(uClibc-)([\w.-]*)(.tar.gz)$"
419
+ source_archive_regex = re . compile ( r"^(uClibc-)(?P<version> [\w.-]*)(.tar.gz)$" )
415
420
is_nested = False
416
421
ignored_files_and_dir = []
417
422
418
423
419
424
class UclibcNGDirectoryListedSource (DirectoryListedSource ):
420
425
source_url = "https://downloads.uclibc-ng.org/releases/"
421
- source_archive_regex = r"^(uClibc-ng-)([\w.-]*)(.tar.gz)$"
426
+ source_archive_regex = re . compile ( r"^(uClibc-ng-)(?P<version> [\w.-]*)(.tar.gz)$" )
422
427
is_nested = True
423
428
ignored_files_and_dir = []
424
429
425
430
426
431
class Bzip2DirectoryListedSource (DirectoryListedSource ):
427
432
source_url = "https://sourceware.org/pub/bzip2/"
428
- source_archive_regex = r"^(bzip2-)([\w.-]*)(.tar.gz)$"
433
+ source_archive_regex = re . compile ( r"^(bzip2-)(?P<version> [\w.-]*)(.tar.gz)$" )
429
434
is_nested = False
430
435
ignored_files_and_dir = []
431
436
432
437
433
438
class OpenSSHDirectoryListedSource (DirectoryListedSource ):
434
439
source_url = "https://cdn.openbsd.org/pub/OpenBSD/OpenSSH/"
435
- source_archive_regex = r"^(openssh-)([\w.-]*)(.tgz|.tar.gz)$"
440
+ source_archive_regex = re . compile ( r"^(openssh-)(?P<version> [\w.-]*)(.tgz|.tar.gz)$" )
436
441
is_nested = False
437
442
ignored_files_and_dir = []
438
443
439
444
440
445
class DnsmasqDirectoryListedSource (DirectoryListedSource ):
441
446
source_url = "https://thekelleys.org.uk/dnsmasq/"
442
- source_archive_regex = r"^(dnsmasq-)([\w.-]*)(.tar.xz|.tar.gz)$"
447
+ source_archive_regex = re .compile (
448
+ r"^(dnsmasq-)(?P<version>[\w.-]*)(.tar.xz|.tar.gz)$"
449
+ )
443
450
is_nested = False
444
451
ignored_files_and_dir = []
445
452
446
453
447
454
class EbtablesDirectoryListedSource (DirectoryListedSource ):
448
455
source_url = "https://www.netfilter.org/pub/ebtables/"
449
- source_archive_regex = r"^(ebtables-)([\w.-]*)(.tar.gz)$"
456
+ source_archive_regex = re . compile ( r"^(ebtables-)(?P<version> [\w.-]*)(.tar.gz)$" )
450
457
is_nested = False
451
458
ignored_files_and_dir = []
452
459
453
460
454
461
class HostapdDirectoryListedSource (DirectoryListedSource ):
455
462
source_url = "https://w1.fi/releases/"
456
- source_archive_regex = r"^(hostapd-)([\w.-]*)(.tar.gz)$"
463
+ source_archive_regex = re . compile ( r"^(hostapd-)(?P<version> [\w.-]*)(.tar.gz)$" )
457
464
is_nested = False
458
465
ignored_files_and_dir = []
459
466
460
467
461
468
class Iproute2DirectoryListedSource (DirectoryListedSource ):
462
469
source_url = "https://mirrors.edge.kernel.org/pub/linux/utils/net/iproute2/"
463
- source_archive_regex = r"^(iproute2-)([\w.-]*)(.tar.xz|.tar.gz)$"
470
+ source_archive_regex = re .compile (
471
+ r"^(iproute2-)(?P<version>[\w.-]*)(.tar.xz|.tar.gz)$"
472
+ )
464
473
is_nested = False
465
474
ignored_files_and_dir = []
466
475
467
476
468
477
class IptablesDirectoryListedSource (DirectoryListedSource ):
469
478
source_url = "https://www.netfilter.org/pub/iptables/"
470
- source_archive_regex = r"^(iptables-)([\w.-]*)(.tar.bz2)$"
479
+ source_archive_regex = re . compile ( r"^(iptables-)(?P<version> [\w.-]*)(.tar.bz2)$" )
471
480
is_nested = False
472
481
ignored_files_and_dir = []
473
482
474
483
475
484
class LibnlDirectoryListedSource (DirectoryListedSource ):
476
485
source_url = "https://www.infradead.org/~tgr/libnl/files/"
477
- source_archive_regex = r"^(libnl-)([\w.-]*)(.tar.gz)$"
486
+ source_archive_regex = re . compile ( r"^(libnl-)(?P<version> [\w.-]*)(.tar.gz)$" )
478
487
is_nested = False
479
488
ignored_files_and_dir = []
480
489
481
490
482
491
class LighttpdDirectoryListedSource (DirectoryListedSource ):
483
492
source_url = "https://download.lighttpd.net/lighttpd/releases-1.4.x/"
484
- source_archive_regex = r"^(lighttpd-)([\w.-]*)(.tar.gz)$"
493
+ source_archive_regex = re . compile ( r"^(lighttpd-)(?P<version> [\w.-]*)(.tar.gz)$" )
485
494
is_nested = False
486
495
ignored_files_and_dir = []
487
496
488
497
489
498
class NftablesDirectoryListedSource (DirectoryListedSource ):
490
499
source_url = "https://www.netfilter.org/pub/nftables/"
491
- source_archive_regex = r"^(nftables-)([\w.-]*)(.tar.xz|.tar.bz2)$"
500
+ source_archive_regex = re .compile (
501
+ r"^(nftables-)(?P<version>[\w.-]*)(.tar.xz|.tar.bz2)$"
502
+ )
492
503
is_nested = False
493
504
ignored_files_and_dir = []
494
505
495
506
496
507
class WpaSupplicantDirectoryListedSource (DirectoryListedSource ):
497
508
source_url = "https://w1.fi/releases/"
498
- source_archive_regex = r"^(wpa_supplicant-)([\w.-]*)(.tar.gz)$"
509
+ source_archive_regex = re .compile (
510
+ r"^(wpa_supplicant-)(?P<version>[\w.-]*)(.tar.gz)$"
511
+ )
499
512
is_nested = False
500
513
ignored_files_and_dir = []
501
514
502
515
503
516
class SyslinuxDirectoryListedSource (DirectoryListedSource ):
504
517
source_url = "https://mirrors.edge.kernel.org/pub/linux/utils/boot/syslinux/"
505
- source_archive_regex = r"^(syslinux-)([\w.-]*)(.tar.gz)$"
518
+ source_archive_regex = re . compile ( r"^(syslinux-)(?P<version> [\w.-]*)(.tar.gz)$" )
506
519
is_nested = False
507
520
ignored_files_and_dir = []
508
521
509
522
510
523
class SyslinuxDirectoryListedSource (DirectoryListedSource ):
511
524
source_url = "https://mirrors.edge.kernel.org/pub/linux/utils/boot/syslinux/"
512
- source_archive_regex = r"^(syslinux-)([\w.-]*)(.tar.gz)$"
525
+ source_archive_regex = re . compile ( r"^(syslinux-)(?P<version> [\w.-]*)(.tar.gz)$" )
513
526
is_nested = False
514
527
ignored_files_and_dir = []
515
528
516
529
517
530
class ToyboxDirectoryListedSource (DirectoryListedSource ):
518
531
source_url = "http://www.landley.net/toybox/downloads/"
519
- source_archive_regex = r"^(toybox-)([\w.-]*)(.tar.gz|.tar.bz2)$"
532
+ source_archive_regex = re .compile (
533
+ r"^(toybox-)(?P<version>[\w.-]*)(.tar.gz|.tar.bz2)$"
534
+ )
520
535
is_nested = False
521
536
ignored_files_and_dir = []
522
537
523
538
524
539
class DropbearDirectoryListedSource (DirectoryListedSource ):
525
540
source_url = "https://matt.ucc.asn.au/dropbear/releases/"
526
- source_archive_regex = r"^(dropbear-)([\w.-]*)(.tar.bz2|_i386.deb)$"
541
+ source_archive_regex = re .compile (
542
+ r"^(dropbear-)(?P<version>[\w.-]*)(.tar.bz2|_i386.deb)$"
543
+ )
527
544
is_nested = False
528
545
ignored_files_and_dir = [
529
546
"dropbear-0.44test1.tar.bz2" ,
@@ -539,7 +556,21 @@ class DropbearDirectoryListedSource(DirectoryListedSource):
539
556
540
557
class SambaDirectoryListedSource (DirectoryListedSource ):
541
558
source_url = "https://download.samba.org/pub/samba/stable/"
542
- source_archive_regex = r"^(samba-)([\w.-]*)(.tar.gz)$"
559
+ source_archive_regex = re .compile (r"^(samba-)(?P<version>[\w.-]*)(.tar.gz)$" )
560
+ is_nested = False
561
+ ignored_files_and_dir = []
562
+
563
+
564
+ class MtdUtilsDirectoryListedSource (DirectoryListedSource ):
565
+ source_url = "https://infraroot.at/pub/mtd/"
566
+ source_archive_regex = re .compile (r"^(mtd-utils-)(?P<version>[\w.-]*)(.tar.bz2)$" )
567
+ is_nested = False
568
+ ignored_files_and_dir = []
569
+
570
+
571
+ class BareboxDirectoryListedSource (DirectoryListedSource ):
572
+ source_url = "https://www.barebox.org/download/"
573
+ source_archive_regex = re .compile (r"^(barebox-)(?P<version>[\w.-]*)(.tar.bz2)$" )
543
574
is_nested = False
544
575
ignored_files_and_dir = []
545
576
@@ -566,6 +597,8 @@ class SambaDirectoryListedSource(DirectoryListedSource):
566
597
"pkg:generic/util-linux.*" ,
567
598
"pkg:generic/wpa_supplicant.*" ,
568
599
"pkg:generic/ipkg.*" ,
600
+ "pkg:generic/mtd-utils.*" ,
601
+ "pkg:generic/barebox.*" ,
569
602
]
570
603
571
604
DIR_LISTED_SOURCE_BY_PACKAGE_NAME = {
@@ -589,6 +622,8 @@ class SambaDirectoryListedSource(DirectoryListedSource):
589
622
"util-linux" : UtilLinuxDirectoryListedSource ,
590
623
"wpa_supplicant" : WpaSupplicantDirectoryListedSource ,
591
624
"ipkg" : IpkgDirectoryListedSource ,
625
+ "mtd-utils" : MtdUtilsDirectoryListedSource ,
626
+ "barebox" : BareboxDirectoryListedSource ,
592
627
}
593
628
594
629
@@ -605,16 +640,15 @@ def get_packages_from_listing(purl, source_archive_url, regex, ignored_files_and
605
640
"""
606
641
Return list of package data from a directory listing based on the specified regex.
607
642
"""
608
- pattern = re .compile (regex )
609
643
_ , listing = htmllistparse .fetch_listing (source_archive_url )
610
644
611
645
packages = []
612
646
for file in listing :
613
- if not pattern .match (file .name ) or file .name in ignored_files_and_dir :
647
+ match = regex .match (file .name )
648
+ if not match or file .name in ignored_files_and_dir :
614
649
continue
615
650
616
- match = re .search (regex , file .name )
617
- version = match .group (2 )
651
+ version = match .group ("version" )
618
652
version = version .strip ("v" ).strip ()
619
653
if not version :
620
654
continue
@@ -668,7 +702,7 @@ def extract_package_from_nested_listing(purl, source_url, regex, ignored_files_a
668
702
"""
669
703
_ , listing = htmllistparse .fetch_listing (source_url )
670
704
for directory in listing :
671
- if not directory .name .endswith ("/" ):
705
+ if not directory .name .endswith ("/" ) or directory . name in ignored_files_and_dir :
672
706
continue
673
707
674
708
directory_url = urljoin (source_url , directory .name )
0 commit comments