Description: Do not fetch example files from Github during build
 The guide attempts to download example files from Github at build
 time. Debian package builds should not attempt to access external
 network resources.
 .
 This will break fetching from other remote repositories, e.g.,
 mltonlib, which happens in a few places in the guide. However,
 the next upstream release (expected this month) removes these
 remote fetches.
Author: Ryan Kavanagh <rak@debian.org>
Forwarded: no
Last-Update: 2022-01-03
---
This patch header follows DEP-3: http://dep.debian.net/deps/dep3/
Index: mlton/doc/guide/bin/InclGitFile.py
===================================================================
--- mlton.orig/doc/guide/bin/InclGitFile.py	2021-12-19 21:30:36.000000000 -0500
+++ mlton/doc/guide/bin/InclGitFile.py	2021-12-19 21:42:52.164868746 -0500
@@ -1,34 +1,20 @@
-#!/usr/bin/env python3
+#!/bin/sh
+#
+# Invocation:
+# ${SRCDIR}/doc/guide/bin/InclGitFile.py repo branch src
+# Outputs the contents of
+# url = 'https://raw.github.com/MLton/' + repo + '/' + branch + '/' + src
+#
+# We don't want to fetch from github during Debian builds,
+# so we instead just use the local version of the file.
 
-import sys
-import urllib.request
-import re
-
-i = 1
-repo = sys.argv[i]
-i += 1
-branch = sys.argv[i]
-i += 1
-src = sys.argv[i]
-i += 1
-url = 'https://raw.github.com/MLton/' + repo + '/' + branch + '/' + src
-response = urllib.request.urlopen(url)
-buff = response.readlines()
-
-if len(sys.argv) > i:
-    newbuff = []
-    while len(sys.argv) > i:
-        lines = sys.argv[i]
-        match = re.compile(r"^\s*(?P<start>-?[0-9]+)?:(?P<end>-?[0-9]+)?\s*$").match(lines)
-        start = match.group('start')
-        if start:
-            start = int(start)
-        end = match.group('end')
-        if end:
-            end = int(end)
-        newbuff.extend(buff[start:end])
-        i += 1
-    buff = newbuff
-
-sys.stdout.buffer.writelines(buff)
-sys.stdout.flush()
+if test "x${1}" != "xmlton"; then
+    echo "InclGitFile.py invoked with repo ${1}; expected mlton." > /dev/stderr
+    exit 1
+elif test "x${2}" != "xmaster"; then
+    echo "InclGitFile.py invoked with branch ${1}; expected master." > /dev/stderr
+    exit 1
+else
+    # The path src is relative to ${SRCDIR}
+    cat $(dirname "$0")/../../../$3
+fi
