Skip to content

Commit

Permalink
#122 - Update link references of ownership from nexB to aboutcode-org
Browse files Browse the repository at this point in the history
Signed-off-by: Chin Yeung Li <[email protected]>
  • Loading branch information
chinyeungli committed Aug 14, 2024
1 parent b06c4b4 commit 8b2125c
Show file tree
Hide file tree
Showing 21 changed files with 410 additions and 318 deletions.
2 changes: 1 addition & 1 deletion NOTICE
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# Copyright (c) nexB Inc. and others.
# SPDX-License-Identifier: Apache-2.0
#
# Visit https://aboutcode.org and https://github.com/nexB/ for support and download.
# Visit https://aboutcode.org and https://github.com/aboutcode-org/ for support and download.
# ScanCode is a trademark of nexB Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
Expand Down
8 changes: 4 additions & 4 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ systems. It can work using plain HTTP and FTP URLs, as well as
as used in Python pip and as specified in `SPDX Package Download Location
<https://spdx.github.io/spdx-spec/3-package-information/#37-package-download-location>`_

Homepage and support: https://github.com/nexB/fetchcode
Homepage and support: https://github.com/aboutcode-org/fetchcode


Why FetchCode?
Expand All @@ -24,7 +24,7 @@ Development installation

Clone the repo::

git clone https://github.com/nexB/fetchcode
git clone https://github.com/aboutcode-org/fetchcode

Then install all the requirements using this command (on POSIX)::

Expand All @@ -45,13 +45,13 @@ Usage
Fetch a code archive and get a ``fetchcode.fetch.Response`` object back::

>>> from fetchcode import fetch
>>> f = fetch('https://github.com/nexB/fetchcode/archive/ab65b2e645c889887227ea49eb3332d885fd0a54.zip')
>>> f = fetch('https://github.com/aboutcode-org/fetchcode/archive/ab65b2e645c889887227ea49eb3332d885fd0a54.zip')
>>> f.location
'/tmp/tmp_cm02xsg'
>>> f.content_type
'application/zip'
>>> f.url
'https://github.com/nexB/fetchcode/archive/ab65b2e645c889887227ea49eb3332d885fd0a54.zip'
'https://github.com/aboutcode-org/fetchcode/archive/ab65b2e645c889887227ea49eb3332d885fd0a54.zip'

Fetch some package metadata and get a ``fetchcode.packagedcode_models.Package`` object back::

Expand Down
2 changes: 1 addition & 1 deletion configure
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# Copyright (c) nexB Inc. and others. All rights reserved.
# SPDX-License-Identifier: Apache-2.0
# See http://www.apache.org/licenses/LICENSE-2.0 for the license text.
# See https://github.com/nexB/ for support or download.
# See https://github.com/aboutcode-org/ for support or download.
# See https://aboutcode.org for more information about nexB OSS projects.
#

Expand Down
2 changes: 1 addition & 1 deletion configure.bat
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
@rem Copyright (c) nexB Inc. and others. All rights reserved.
@rem SPDX-License-Identifier: Apache-2.0
@rem See http://www.apache.org/licenses/LICENSE-2.0 for the license text.
@rem See https://github.com/nexB/ for support or download.
@rem See https://github.com/aboutcode-org/ for support or download.
@rem See https://aboutcode.org for more information about nexB OSS projects.


Expand Down
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ license = Apache-2.0
description = fetchcode is a library to reliably fetch code via HTTP, FTP and version control systems.
long_description = file:README.rst
long_description_content_type = text/x-rst
url = https://github.com/nexB/fetchcode
url = https://github.com/aboutcode-org/fetchcode

author = nexB. Inc. and others
author_email = [email protected]
Expand Down
12 changes: 7 additions & 5 deletions src/fetchcode/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# fetchcode is a free software tool from nexB Inc. and others.
# Visit https://github.com/nexB/fetchcode for support and download.
# Visit https://github.com/aboutcode-org/fetchcode for support and download.
#
# Copyright (c) nexB Inc. and others. All rights reserved.
# http://nexb.com and http://aboutcode.org
Expand Down Expand Up @@ -41,7 +41,7 @@ def __init__(self, location, content_type, size, url):
def fetch_http(url, location):
"""
Return a `Response` object built from fetching the content at a HTTP/HTTPS based `url` URL string
saving the content in a file at `location`
saving the content in a file at `location`
"""
r = requests.get(url)
with open(location, 'wb') as f:
Expand All @@ -51,15 +51,16 @@ def fetch_http(url, location):
size = r.headers.get('content-length')
size = int(size) if size else None

resp = Response(location=location, content_type=content_type, size=size, url=url)
resp = Response(location=location,
content_type=content_type, size=size, url=url)

return resp


def fetch_ftp(url, location):
"""
Return a `Response` object built from fetching the content at a FTP based `url` URL string
saving the content in a file at `location`
saving the content in a file at `location`
"""
url_parts = urlparse(url)

Expand All @@ -84,7 +85,8 @@ def fetch_ftp(url, location):
ftp.retrbinary(file, f.write)
ftp.close()

resp = Response(location=location, content_type=content_type, size=size, url=url)
resp = Response(location=location,
content_type=content_type, size=size, url=url)
return resp


Expand Down
62 changes: 41 additions & 21 deletions src/fetchcode/package.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# fetchcode is a free software tool from nexB Inc. and others.
# Visit https://github.com/nexB/fetchcode for support and download.
# Visit https://github.com/aboutcode-org/fetchcode for support and download.
#
# Copyright (c) nexB Inc. and others. All rights reserved.
# http://nexb.com and http://aboutcode.org
Expand Down Expand Up @@ -92,7 +92,8 @@ def get_cargo_data_from_purl(purl):
)
versions = response.get("versions", [])
for version in versions:
version_purl = PackageURL(type=purl.type, name=name, version=version.get("num"))
version_purl = PackageURL(
type=purl.type, name=name, version=version.get("num"))
dl_path = version.get("dl_path")
if dl_path:
download_url = f"{base_url}/{dl_path}"
Expand Down Expand Up @@ -355,7 +356,8 @@ def get_gnu_data_from_purl(purl):
purl = PackageURL.from_string(purl)
source_archive_url = f"https://ftp.gnu.org/pub/gnu/{purl.name}/"
version_regex_template = r"^({}-)(?P<version>[\w.-]*)(.tar.gz)$"
version_regex = re.compile(version_regex_template.format(re.escape(purl.name)))
version_regex = re.compile(
version_regex_template.format(re.escape(purl.name)))

yield from extract_packages_from_listing(
purl, source_archive_url, version_regex, []
Expand Down Expand Up @@ -427,7 +429,8 @@ def get_package_info(cls, package_url):

else:
for version, data in UDHCP_RELEASES.items():
purl = PackageURL(type="generic", name="udhcp", version=version)
purl = PackageURL(
type="generic", name="udhcp", version=version)
yield Package(
homepage_url=cls.source_url,
download_url=data["url"],
Expand Down Expand Up @@ -481,39 +484,44 @@ class UtilLinuxDirectoryListedSource(DirectoryListedSource):
class BusyBoxDirectoryListedSource(DirectoryListedSource):
source_url = "https://www.busybox.net/downloads/"
# Source archive ex: busybox-1.2.3.tar.bz2
source_archive_regex = re.compile(r"^(busybox-)(?P<version>[\w.-]*)(.tar.bz2)$")
source_archive_regex = re.compile(
r"^(busybox-)(?P<version>[\w.-]*)(.tar.bz2)$")
is_nested = False
ignored_files_and_dir = []


class UclibcDirectoryListedSource(DirectoryListedSource):
source_url = "https://www.uclibc.org/downloads/"
# Source archive ex: uClibc-1.2.3.tar.gz
source_archive_regex = re.compile(r"^(uClibc-)(?P<version>[\w.-]*)(.tar.gz)$")
source_archive_regex = re.compile(
r"^(uClibc-)(?P<version>[\w.-]*)(.tar.gz)$")
is_nested = False
ignored_files_and_dir = []


class UclibcNGDirectoryListedSource(DirectoryListedSource):
source_url = "https://downloads.uclibc-ng.org/releases/"
# Source archive ex: uClibc-ng-1.2.3.tar.gz
source_archive_regex = re.compile(r"^(uClibc-ng-)(?P<version>[\w.-]*)(.tar.gz)$")
source_archive_regex = re.compile(
r"^(uClibc-ng-)(?P<version>[\w.-]*)(.tar.gz)$")
is_nested = True
ignored_files_and_dir = []


class Bzip2DirectoryListedSource(DirectoryListedSource):
source_url = "https://sourceware.org/pub/bzip2/"
# Source archive ex: bzip2-1.2.3.tar.gz
source_archive_regex = re.compile(r"^(bzip2-)(?P<version>[\w.-]*)(.tar.gz)$")
source_archive_regex = re.compile(
r"^(bzip2-)(?P<version>[\w.-]*)(.tar.gz)$")
is_nested = False
ignored_files_and_dir = []


class OpenSSHDirectoryListedSource(DirectoryListedSource):
source_url = "https://cdn.openbsd.org/pub/OpenBSD/OpenSSH/"
# Source archive ex: openssh-1.2.3.tar.gz
source_archive_regex = re.compile(r"^(openssh-)(?P<version>[\w.-]*)(.tgz|.tar.gz)$")
source_archive_regex = re.compile(
r"^(openssh-)(?P<version>[\w.-]*)(.tgz|.tar.gz)$")
is_nested = False
ignored_files_and_dir = []

Expand All @@ -531,15 +539,17 @@ class DnsmasqDirectoryListedSource(DirectoryListedSource):
class EbtablesDirectoryListedSource(DirectoryListedSource):
source_url = "https://www.netfilter.org/pub/ebtables/"
# Source archive ex: ebtables-1.2.3.tar.gz
source_archive_regex = re.compile(r"^(ebtables-)(?P<version>[\w.-]*)(.tar.gz)$")
source_archive_regex = re.compile(
r"^(ebtables-)(?P<version>[\w.-]*)(.tar.gz)$")
is_nested = False
ignored_files_and_dir = []


class HostapdDirectoryListedSource(DirectoryListedSource):
source_url = "https://w1.fi/releases/"
# Source archive ex: hostapd-1.2.3.tar.gz
source_archive_regex = re.compile(r"^(hostapd-)(?P<version>[\w.-]*)(.tar.gz)$")
source_archive_regex = re.compile(
r"^(hostapd-)(?P<version>[\w.-]*)(.tar.gz)$")
is_nested = False
ignored_files_and_dir = []

Expand All @@ -557,23 +567,26 @@ class Iproute2DirectoryListedSource(DirectoryListedSource):
class IptablesDirectoryListedSource(DirectoryListedSource):
source_url = "https://www.netfilter.org/pub/iptables/"
# Source archive ex: iptables-1.2.3.tar.bz2
source_archive_regex = re.compile(r"^(iptables-)(?P<version>[\w.-]*)(.tar.bz2)$")
source_archive_regex = re.compile(
r"^(iptables-)(?P<version>[\w.-]*)(.tar.bz2)$")
is_nested = False
ignored_files_and_dir = []


class LibnlDirectoryListedSource(DirectoryListedSource):
source_url = "https://www.infradead.org/~tgr/libnl/files/"
# Source archive ex: libnl-1.2.3.tar.gz
source_archive_regex = re.compile(r"^(libnl-)(?P<version>[\w.-]*)(.tar.gz)$")
source_archive_regex = re.compile(
r"^(libnl-)(?P<version>[\w.-]*)(.tar.gz)$")
is_nested = False
ignored_files_and_dir = []


class LighttpdDirectoryListedSource(DirectoryListedSource):
source_url = "https://download.lighttpd.net/lighttpd/releases-1.4.x/"
# Source archive ex: lighttpd-1.2.3.tar.gz
source_archive_regex = re.compile(r"^(lighttpd-)(?P<version>[\w.-]*)(.tar.gz)$")
source_archive_regex = re.compile(
r"^(lighttpd-)(?P<version>[\w.-]*)(.tar.gz)$")
is_nested = False
ignored_files_and_dir = []

Expand Down Expand Up @@ -601,15 +614,17 @@ class WpaSupplicantDirectoryListedSource(DirectoryListedSource):
class SyslinuxDirectoryListedSource(DirectoryListedSource):
source_url = "https://mirrors.edge.kernel.org/pub/linux/utils/boot/syslinux/"
# Source archive ex: syslinux-1.2.3.tar.gz
source_archive_regex = re.compile(r"^(syslinux-)(?P<version>[\w.-]*)(.tar.gz)$")
source_archive_regex = re.compile(
r"^(syslinux-)(?P<version>[\w.-]*)(.tar.gz)$")
is_nested = False
ignored_files_and_dir = []


class SyslinuxDirectoryListedSource(DirectoryListedSource):
source_url = "https://mirrors.edge.kernel.org/pub/linux/utils/boot/syslinux/"
# Source archive ex: syslinux-1.2.3.tar.gz
source_archive_regex = re.compile(r"^(syslinux-)(?P<version>[\w.-]*)(.tar.gz)$")
source_archive_regex = re.compile(
r"^(syslinux-)(?P<version>[\w.-]*)(.tar.gz)$")
is_nested = False
ignored_files_and_dir = []

Expand Down Expand Up @@ -646,31 +661,35 @@ class DropbearDirectoryListedSource(DirectoryListedSource):
class SambaDirectoryListedSource(DirectoryListedSource):
source_url = "https://download.samba.org/pub/samba/stable/"
# Source archive ex: samba-1.2.3.tar.gz
source_archive_regex = re.compile(r"^(samba-)(?P<version>[\w.-]*)(.tar.gz)$")
source_archive_regex = re.compile(
r"^(samba-)(?P<version>[\w.-]*)(.tar.gz)$")
is_nested = False
ignored_files_and_dir = []


class MtdUtilsDirectoryListedSource(DirectoryListedSource):
source_url = "https://infraroot.at/pub/mtd/"
# Source archive ex: mtd-utils-1.2.3.tar.bz2
source_archive_regex = re.compile(r"^(mtd-utils-)(?P<version>[\w.-]*)(.tar.bz2)$")
source_archive_regex = re.compile(
r"^(mtd-utils-)(?P<version>[\w.-]*)(.tar.bz2)$")
is_nested = False
ignored_files_and_dir = []


class BareboxDirectoryListedSource(DirectoryListedSource):
source_url = "https://www.barebox.org/download/"
# Source archive ex: barebox-1.2.3.tar.bz2
source_archive_regex = re.compile(r"^(barebox-)(?P<version>[\w.-]*)(.tar.bz2)$")
source_archive_regex = re.compile(
r"^(barebox-)(?P<version>[\w.-]*)(.tar.bz2)$")
is_nested = False
ignored_files_and_dir = []


class LinuxDirectoryListedSource(DirectoryListedSource):
source_url = "https://mirrors.edge.kernel.org/pub/linux/kernel/"
# Source archive ex: linux-1.2.3.tar.gz
source_archive_regex = re.compile(r"^(linux-)(?P<version>[\w.-]*)(.tar.gz)$")
source_archive_regex = re.compile(
r"^(linux-)(?P<version>[\w.-]*)(.tar.gz)$")
is_nested = True
ignored_files_and_dir = [
"Historic/",
Expand All @@ -692,7 +711,8 @@ class E2fsprogsDirectoryListedSource(DirectoryListedSource):
"https://mirrors.edge.kernel.org/pub/linux/kernel/people/tytso/e2fsprogs/"
)
# Source archive ex: e2fsprogs-1.2.3.tar.gz
source_archive_regex = re.compile(r"^(e2fsprogs-)(?P<version>[\w.-]*)(.tar.gz)$")
source_archive_regex = re.compile(
r"^(e2fsprogs-)(?P<version>[\w.-]*)(.tar.gz)$")
is_nested = True
ignored_files_and_dir = ["testing/"]

Expand Down
11 changes: 7 additions & 4 deletions src/fetchcode/package_util.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# fetchcode is a free software tool from nexB Inc. and others.
# Visit https://github.com/nexB/fetchcode for support and download.
# Visit https://github.com/aboutcode-org/fetchcode for support and download.
#
# Copyright (c) nexB Inc. and others. All rights reserved.
# http://nexb.com and http://aboutcode.org
Expand Down Expand Up @@ -165,7 +165,8 @@ class SquashfsToolsGitHubSource(GitHubSource):


class PupnpGitHubSource(GitHubSource):
version_regex = re.compile(r"\brelease-?(?P<version>(?:\d+(\.\d+){1,2}))\b")
version_regex = re.compile(
r"\brelease-?(?P<version>(?:\d+(\.\d+){1,2}))\b")
ignored_tag_regex = None


Expand All @@ -180,7 +181,8 @@ class BpftoolGitHubSource(GitHubSource):


class SqliteGitHubSource(GitHubSource):
version_regex = re.compile(r"\bversion-?(?P<version>(?:\d+(\.\d+){1,2}))\b")
version_regex = re.compile(
r"\bversion-?(?P<version>(?:\d+(\.\d+){1,2}))\b")
ignored_tag_regex = None


Expand All @@ -190,7 +192,8 @@ class LlvmGitHubSource(GitHubSource):


class RpmGitHubSource(GitHubSource):
version_regex = re.compile(r"rpm-(?P<version>[^-]+(?:-(?!release).*)?|-release)")
version_regex = re.compile(
r"rpm-(?P<version>[^-]+(?:-(?!release).*)?|-release)")
ignored_tag_regex = None


Expand Down
10 changes: 6 additions & 4 deletions src/fetchcode/package_versions.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# fetchcode is a free software tool from nexB Inc. and others.
# Visit https://github.com/nexB/fetchcode for support and download.
# Visit https://github.com/aboutcode-org/fetchcode for support and download.
#
# Copyright (c) nexB Inc. and others. All rights reserved.
# http://nexb.com and http://aboutcode.org
Expand Down Expand Up @@ -317,7 +317,8 @@ def get_golang_versions_from_purl(purl):
break

if response is None or escaped_pkg is None or trimmed_pkg is None:
logger.error(f"Error while fetching versions for {package_slug!r} from goproxy")
logger.error(
f"Error while fetching versions for {package_slug!r} from goproxy")
return

for version_info in response.split("\n"):
Expand Down Expand Up @@ -347,7 +348,7 @@ def trim_go_url_path(url_path: str) -> Optional[str]:
# some advisories contains this prefix in package name, e.g. https://github.com/advisories/GHSA-7h6j-2268-fhcm
go_url_prefix = "https://pkg.go.dev/"
if url_path.startswith(go_url_prefix):
url_path = url_path[len(go_url_prefix) :]
url_path = url_path[len(go_url_prefix):]

parsed_url_path = urlparse(url_path)
path = parsed_url_path.path
Expand Down Expand Up @@ -408,7 +409,8 @@ def fetch_version_info(version_info: str, escaped_pkg: str) -> Optional[PackageV
f"Error while fetching version info for {escaped_pkg}/{escaped_ver} "
f"from goproxy:\n{traceback.format_exc()}"
)
release_date = dateparser.parse(response.get("Time", "")) if response else None
release_date = dateparser.parse(
response.get("Time", "")) if response else None

return PackageVersion(value=version, release_date=release_date)

Expand Down
Loading

0 comments on commit 8b2125c

Please sign in to comment.