From 9bb4337aca9c71b18d6dbd9c11032aba68d09d27 Mon Sep 17 00:00:00 2001 From: Nathan Rossi Date: Mon, 21 Aug 2017 18:57:47 +1000 Subject: xilinx-fetch-restricted.bbclass: Custom fetch task for restricted files This class overrides the default fetch task available from base.bbclass. This overridden task prevents the downloading from URLs that match against the 'xilinx.com/member/forms/download' which require user credentials and may require agreement with EULAs, licenses, export compliance, etc. The overridden task does however allow fetching from PREMIRRORs, which allows for pre-downloaded content to be accessed in an automated way. When attempting to fetch the non-accessible files the fetch task will error and present the user with a message informing them that they need to manually download the content and the url which to download the content from. The purpose of this is to reduce the reliance on manual documentation and or processes which instruct users to complete manual steps which can be error prone, ambiguous and or just tedious. This also aims to make automation easier by allowing use of pre-downloaded content or user PREMIRRORs to access downloads. Signed-off-by: Nathan Rossi Tested-by: Alistair Francis Acked-by: Alistair Francis Acked-by: Manjukumar Matha --- classes/xilinx-fetch-restricted.bbclass | 35 +++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 classes/xilinx-fetch-restricted.bbclass (limited to 'classes/xilinx-fetch-restricted.bbclass') diff --git a/classes/xilinx-fetch-restricted.bbclass b/classes/xilinx-fetch-restricted.bbclass new file mode 100644 index 00000000..a778ec7d --- /dev/null +++ b/classes/xilinx-fetch-restricted.bbclass @@ -0,0 +1,35 @@ +# This class is setup to override the default fetching for the target recipe. +# When fetching it forces PREMIRROR only fetching so that no attempts are made +# to fetch the Xilinx downloads that are restricted to authenticated users only. +# +# The purpose of this class is to allow for automatation with pre-downloaded +# content or content that is available with curated/user defined pre-mirrors +# and or pre-populated downloads/ directories. + +python do_fetch() { + xilinx_restricted_url = "xilinx.com/member/forms/download" + + src_uri = (d.getVar('SRC_URI') or "").split() + if len(src_uri) == 0: + return + + for i in src_uri: + if xilinx_restricted_url in i: + # force the use of premirrors only, do not attempt download from xilinx.com + d.setVar("BB_FETCH_PREMIRRORONLY", "1") + break + + try: + fetcher = bb.fetch2.Fetch(src_uri, d) + fetcher.download() + except bb.fetch2.NetworkAccess as e: + if xilinx_restricted_url in e.url: + # fatal on access to xilinx.com restricted downloads, print the url for manual download + bb.fatal("The following download cannot be fetched automatically. " \ + "Please manually download the file and place it in the 'downloads' directory (or on an available PREMIRROR).\n" \ + " %s" % (e.url.split(";")[0])) + else: + bb.fatal(str(e)) + except bb.fetch2.BBFetchException as e: + bb.fatal(str(e)) +} -- cgit v1.2.3-54-g00ecf