[meta-xilinx] [PATCH 2/4] xilinx-fetch-restricted.bbclass: Custom fetch task for restricted files

Nathan Rossi nathan at nathanrossi.com
Mon Aug 21 05:43:51 PDT 2017


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 <nathan at nathanrossi.com>
---
 classes/xilinx-fetch-restricted.bbclass | 35 +++++++++++++++++++++++++++++++++
 1 file changed, 35 insertions(+)
 create mode 100644 classes/xilinx-fetch-restricted.bbclass

diff --git a/classes/xilinx-fetch-restricted.bbclass b/classes/xilinx-fetch-restricted.bbclass
new file mode 100644
index 0000000000..a778ec7dc5
--- /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))
+}
-- 
2.14.1




More information about the meta-xilinx mailing list