aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRob Austein <sra@hactrn.net>2015-05-03 23:15:33 -0400
committerRob Austein <sra@hactrn.net>2015-05-03 23:18:55 -0400
commit5206bcd72f52bece3ff35268a2284ec4e84c6109 (patch)
tree5c067dd6d63f30da22ca0915e30f6548888efa85
Initial commit of my silly build script collection.
-rwxr-xr-xBuild-Xilinx.sh28
-rw-r--r--README.md6
-rwxr-xr-xhttp-sync-repos.py86
-rwxr-xr-xhttp-what-repos.py58
-rwxr-xr-xssh-sync-repos.py27
-rwxr-xr-xssh-what-repos.py15
6 files changed, 220 insertions, 0 deletions
diff --git a/Build-Xilinx.sh b/Build-Xilinx.sh
new file mode 100755
index 0000000..c9ac7f3
--- /dev/null
+++ b/Build-Xilinx.sh
@@ -0,0 +1,28 @@
+#!/bin/sh -
+
+# Wrapper script for building Xilinx images on Caerbannog (32-bit Debian Wheezy VM).
+
+# Pick a target:
+
+#TARGET=core/platform/novena/i2c/build
+TARGET=core/platform/novena/eim/build
+
+# Pull fresh copies of all the repositories
+
+$HOME/http-sync-repos.py
+
+# Move to the target's build area
+
+cd $HOME/Cryptech/$TARGET
+
+# Run command line version of the Xilinx build environment (thanks, Paul!)
+#
+# Since Paul was developing this on a 64-bit VM and I'm using a 32-bit
+# VM, I need to override a few settings on the make command line.
+
+make isedir='/opt/Xilinx/14.7/ISE_DS' xil_env='. $(isedir)/settings32.sh'
+
+# At this point, if all went well, there should be a .bit file, which
+# I can now move to my Novena board.
+
+scp -p novena_eim.bit tym:
diff --git a/README.md b/README.md
new file mode 100644
index 0000000..9eb39e2
--- /dev/null
+++ b/README.md
@@ -0,0 +1,6 @@
+Build tools
+===========
+
+A collection of scripts I find useful when working with the Cryptech
+git repositories. YMMV. No warantee expressed or implied. If one of
+these scripts breaks, you get to keep both pieces.
diff --git a/http-sync-repos.py b/http-sync-repos.py
new file mode 100755
index 0000000..97e3d7f
--- /dev/null
+++ b/http-sync-repos.py
@@ -0,0 +1,86 @@
+#!/usr/bin/env python
+
+# Synchronize Cryptech git repositories by scraping URLs from the
+# automatically generated Trac page. Yes, we know too much about how
+# the generation script and Trac format this page, c'est la vie.
+#
+# Python's built-in support for HTTPS is a bit primative, we could do
+# better with something like PyCURL, but we want this to run with just
+# the standard Python libraries, so we're stranded in kludge city.
+
+from urllib import urlopen
+from xml.etree.ElementTree import ElementTree
+from subprocess import check_call
+from tempfile import NamedTemporaryFile
+import sys
+import os
+
+# URL for automatically generated Trac page listing repositories.
+
+trac_page = "https://wiki.cryptech.is/wiki/GitRepositories"
+
+# PEM-encoded CA certificate covering Cryptech web services.
+
+cacert = '''\
+-----BEGIN CERTIFICATE-----
+MIIERzCCAy+gAwIBAgIBADANBgkqhkiG9w0BAQUFADB1MQswCQYDVQQGEwJVUzEL
+MAkGA1UECBMCTUExEDAOBgNVBAcTB1JlYWRpbmcxITAfBgNVBAoTGEdydW5jaHdl
+YXRoZXIgQXNzb2NpYXRlczEkMCIGCSqGSIb3DQEJARYVcG9zdG1hc3RlckBoYWN0
+cm4ubmV0MCAXDTEwMDkyNTA1MzQ0MloYDzIxMDkwOTI1MDUzNDQyWjB1MQswCQYD
+VQQGEwJVUzELMAkGA1UECBMCTUExEDAOBgNVBAcTB1JlYWRpbmcxITAfBgNVBAoT
+GEdydW5jaHdlYXRoZXIgQXNzb2NpYXRlczEkMCIGCSqGSIb3DQEJARYVcG9zdG1h
+c3RlckBoYWN0cm4ubmV0MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA
+wf723VEaWozuyJCytEgFkEMXDd17RTChb4RCpqFrlswbKEk4/Vw7IvBeLYNfl5F8
+1hx6ca7CU4qD+4tVkanJ7dJhT9a1jWPKjx/Xz8rpZBSDzgiDZNlgX4giDHjG3Ju8
+QcT9Elpx4SEBxeaVEl2AXXsShv1PrSpCt9WUdS+0NQkA7z3cXASNPOBFoITM37pC
+21nuQuocpjFTaGXw5s3/FhVgcKSUHmQN5UdYK5N2w7pcn7UV2v92UFYSG9cEjQL5
+DfPqzJeLemzmUl+XBqSfY/gPCyJdAPOudflnFyptVv3BrmMQYEyJBeRnt2o5aYWd
+q1w2wB2HPsEglm1K19gEoQIDAQABo4HfMIHcMAwGA1UdEwQFMAMBAf8wCwYDVR0P
+BAQDAgEGMB0GA1UdDgQWBBQkrUZV1MeYpBcTnpsuT60UPRjCZjCBnwYDVR0jBIGX
+MIGUgBQkrUZV1MeYpBcTnpsuT60UPRjCZqF5pHcwdTELMAkGA1UEBhMCVVMxCzAJ
+BgNVBAgTAk1BMRAwDgYDVQQHEwdSZWFkaW5nMSEwHwYDVQQKExhHcnVuY2h3ZWF0
+aGVyIEFzc29jaWF0ZXMxJDAiBgkqhkiG9w0BCQEWFXBvc3RtYXN0ZXJAaGFjdHJu
+Lm5ldIIBADANBgkqhkiG9w0BAQUFAAOCAQEAMeBzm4x6hlwbcrR8AcjSP4S/8+pW
+4WsmkuKlZMyP/E4rc2DpVBi9WRnLtQoQ+FDU47VkG1D97i+HYx1Ky7W8oU4YB3Xr
+ptoAenVmiQOVnbMluuQlxBa8JbOizt+BzL0NJEC6gHvCYT5SmFFsJgXBQZNPpRJb
+cDzuilf3b6vCFtRL+hD75VFLkljQWUWt59cNPGhtBItsq3q72LZ2ftPgk9ufC2h3
+whlvaaZldSFGnPRcFgXYYUootSh0yUW2lIHn52s/tPRN6XXnrdz+cLUCCchSkPOi
+Q9q/UFgaXUetsqlb56PINOrLZUpAfqC4xFBVVo2oI0ubFq173QlATQpn/w==
+-----END CERTIFICATE-----
+'''
+
+try:
+ ssl_cert_file = NamedTemporaryFile("w")
+ ssl_cert_file.write(cacert)
+ ssl_cert_file.flush()
+ try:
+ os.fchmod(ssl_cert_file.fileno(), 0600)
+ except:
+ pass
+ os.environ["SSL_CERT_FILE"] = ssl_cert_file.name # OpenSSL looks for this
+ os.environ["GIT_SSL_CAINFO"] = ssl_cert_file.name # Git looks for this
+
+ head = "https://git.cryptech.is/"
+ tail = ".git"
+ errs = 0
+
+ for elt in ElementTree(file = urlopen(trac_page)).iter("{http://www.w3.org/1999/xhtml}tt"):
+ if elt.text.startswith(head) and elt.text.endswith(tail):
+ url = elt.text
+ repo = url[len(head):-len(tail)]
+ pull = os.path.isdir(repo)
+ print
+ print url
+ try:
+ if pull:
+ check_call(("git", "pull"), cwd = repo)
+ else:
+ check_call(("git", "clone", url, repo))
+ except:
+ print "** Error", "pulling" if pull else "cloning", repo
+ errs += 1
+
+finally:
+ ssl_cert_file.close()
+
+sys.exit(errs)
diff --git a/http-what-repos.py b/http-what-repos.py
new file mode 100755
index 0000000..27125bd
--- /dev/null
+++ b/http-what-repos.py
@@ -0,0 +1,58 @@
+#!/usr/bin/env python
+
+# List Cryptech git repository URLs by scraping them from the
+# automatically generated Trac page. Yes, we know too much about how
+# the generation script and Trac format this page, c'est la vie.
+
+from urllib import urlopen
+from xml.etree.ElementTree import ElementTree
+from tempfile import NamedTemporaryFile
+from os import environ, fchmod
+
+url = "https://wiki.cryptech.is/wiki/GitRepositories"
+
+cacert = '''\
+-----BEGIN CERTIFICATE-----
+MIIERzCCAy+gAwIBAgIBADANBgkqhkiG9w0BAQUFADB1MQswCQYDVQQGEwJVUzEL
+MAkGA1UECBMCTUExEDAOBgNVBAcTB1JlYWRpbmcxITAfBgNVBAoTGEdydW5jaHdl
+YXRoZXIgQXNzb2NpYXRlczEkMCIGCSqGSIb3DQEJARYVcG9zdG1hc3RlckBoYWN0
+cm4ubmV0MCAXDTEwMDkyNTA1MzQ0MloYDzIxMDkwOTI1MDUzNDQyWjB1MQswCQYD
+VQQGEwJVUzELMAkGA1UECBMCTUExEDAOBgNVBAcTB1JlYWRpbmcxITAfBgNVBAoT
+GEdydW5jaHdlYXRoZXIgQXNzb2NpYXRlczEkMCIGCSqGSIb3DQEJARYVcG9zdG1h
+c3RlckBoYWN0cm4ubmV0MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA
+wf723VEaWozuyJCytEgFkEMXDd17RTChb4R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aryFile("w")
+ ssl_cert_file.write(cacert)
+ ssl_cert_file.flush()
+ try:
+ fchmod(ssl_cert_file.fileno(), 0600)
+ except:
+ pass
+ environ["SSL_CERT_FILE"] = ssl_cert_file.name # OpenSSL looks for this
+ environ["GIT_SSL_CAINFO"] = ssl_cert_file.name # Git looks for this
+
+ for x in ElementTree(file = urlopen(url)).iter("{http://www.w3.org/1999/xhtml}tt"):
+ if x.text.startswith("https://git.cryptech.is/") and x.text.endswith(".git"):
+ print x.text
+
+finally:
+ ssl_cert_file.close()
diff --git a/ssh-sync-repos.py b/ssh-sync-repos.py
new file mode 100755
index 0000000..803f65a
--- /dev/null
+++ b/ssh-sync-repos.py
@@ -0,0 +1,27 @@
+#!/usr/bin/env python
+#
+# Synchronize Cryptech git repositories via SSH by asking gitolite for a JSON
+# listing of repositories. Not useful unless you have an SSH account, sorry.
+
+import json, subprocess, os.path, sys
+
+user = "git@git.cryptech.is"
+cmd = "ssh %s info -json -lc" % user
+info = json.loads(subprocess.check_output(cmd.split()))
+errs = 0
+
+for repo in sorted(info["repos"]):
+ try:
+ if all(c not in repo for c in "*?[]"):
+ print
+ print repo
+ pull = os.path.isdir(repo)
+ if pull:
+ subprocess.check_call(("git", "pull"), cwd = repo)
+ else:
+ subprocess.check_call(("git", "clone", "%s:%s.git" % (user, repo), repo))
+ except:
+ print "** Error", "pulling" if pull else "cloning", repo
+ errs += 1
+
+sys.exit(errs)
diff --git a/ssh-what-repos.py b/ssh-what-repos.py
new file mode 100755
index 0000000..3e09720
--- /dev/null
+++ b/ssh-what-repos.py
@@ -0,0 +1,15 @@
+#!/usr/bin/env python
+#
+# List Cryptech git repositories via SSH by asking gitolite for a JSON
+# listing. Not useful unless you have an SSH account, sorry, and not
+# really all that much more interesting than normal gitolite output.
+
+import json, subprocess
+
+cmd = "ssh git@git.cryptech.is info -json -lc"
+
+info = json.loads(subprocess.check_output(cmd.split()))
+
+for name in sorted(info["repos"]):
+ if name != "gitolite-admin" and not any(c in name for c in "*?[]"):
+ print name