diff options
author | Rob Austein <sra@hactrn.net> | 2019-02-14 21:11:14 +0000 |
---|---|---|
committer | Rob Austein <sra@hactrn.net> | 2019-02-14 21:11:14 +0000 |
commit | f7bd5d48daaff0980fcccefcfbb884db611448a8 (patch) | |
tree | 19099c1a5320dbb65fc14b9accbc82e8caa79cf6 | |
parent | 1310e0b5635ee2bd4215a2fbfaa23b7d15e0377c (diff) |
Different theory for license manager problem
-rw-r--r-- | .dockerignore | 2 | ||||
-rwxr-xr-x | Builder (renamed from Builder1) | 15 | ||||
-rwxr-xr-x | Builder2 | 9 | ||||
-rw-r--r-- | Makefile | 18 | ||||
-rwxr-xr-x | Ratinox | 96 | ||||
-rwxr-xr-x | ratinox | 128 |
6 files changed, 111 insertions, 157 deletions
diff --git a/.dockerignore b/.dockerignore index 79fc6cc..7acbd49 100644 --- a/.dockerignore +++ b/.dockerignore @@ -1,4 +1,4 @@ -Builder? +Builder .git .gitignore *.log @@ -5,8 +5,6 @@ set -ex sed -i '/mount -t proc /d; /mount -t sysfs /d' /debootstrap/functions /debootstrap/debootstrap --second-stage -ln -sf /bin/bash /bin/sh - apt-get update apt-get install -y \ @@ -16,9 +14,14 @@ apt-get install -y \ ratpoison \ sudo -/cryptech-builder/ratinox ise-install - -rm -rf /Xilinx_ISE_DS_Lin_14.7_1015_1 - adduser --disabled-password --gecos 'Cryptech Build Bot' --shell /bin/sh builder + echo >/etc/sudoers.d/builder 'builder ALL = (ALL) NOPASSWD: SETENV: ALL' + +install -o builder -g builder /cryptech-builder/Xilinx.lic /home/builder/Xilinx.lic + +ln -sf /bin/bash /bin/sh + +/cryptech-builder/Ratinox + +rm -rf /Xilinx_ISE_DS_Lin_14.7_1015_1 /home/builder/Xilinx.lic diff --git a/Builder2 b/Builder2 deleted file mode 100755 index fdbb7fb..0000000 --- a/Builder2 +++ /dev/null @@ -1,9 +0,0 @@ -#!/bin/sh - - -set -ex - -install -o builder -g builder /cryptech-builder/Xilinx.lic /home/builder/Xilinx.lic - -sudo -u builder /cryptech-builder/ratinox license-user - -rm $HOME/builder/Xilinx.lic @@ -8,27 +8,19 @@ stage0.stamp: sudo rm -rf fs touch $@ -stage1.stamp: stage0.stamp Builder1 +stage1.stamp: stage0.stamp Builder Ratinox docker run -it --name cryptech-builder-stage1 \ --mount type=bind,source=$(abspath .),target=/cryptech-builder \ cryptech-builder:stage0 \ - /cryptech-builder/Builder1 + /cryptech-builder/Builder docker commit cryptech-builder-stage1 cryptech-builder:stage1 docker container rm cryptech-builder-stage1 touch $@ -stage2.stamp: stage1.stamp Builder2 - docker run -it --name cryptech-builder-stage2 \ - --mount type=bind,source=$(abspath .),target=/cryptech-builder \ - cryptech-builder:stage1 \ - /cryptech-builder/Builder2 - docker commit cryptech-builder-stage2 cryptech-builder:stage2 - docker container rm cryptech-builder-stage2 - touch $@ - -stage3.stamp: stage2.stamp Dockerfile +stage2.stamp: stage1.stamp Dockerfile docker build -t cryptech-builder . touch $@ clean: - rm -f *.stamp + rm -f *.stamp Xvfb_screen* + @@ -0,0 +1,96 @@ +#!/usr/bin/env python + +""" +Perform demented installation tasks with blind rodents. +""" + +import subprocess, os, time, xvfbwrapper, shutil, argparse + +screencap_dir = "/cryptech-builder" + +screencap_file = os.path.join(screencap_dir, "Xvfb_screen0") + +def snooze(how_long = 15): + time.sleep(how_long) + +def click(*coordinates): + assert len(coordinates) in (0, 2) + if coordinates: + subprocess.check_call(("ratpoison", "-c", "ratwarp {:d} {:d}".format(*coordinates))) + shutil.copy(screencap_file, "{}.{:f}".format(screencap_file, time.time())) + subprocess.check_call(("ratpoison", "-c", "ratclick")) + +with xvfbwrapper.Xvfb(fbdir = screencap_dir): + print("DISPLAY={}".format(os.getenv("DISPLAY"))) + + print("Starting rodent-free window manager") + rat = subprocess.Popen(("ratpoison",)) + time.sleep(0.5) + + snooze() + print("Starting XiLinx installer") + xsetup = subprocess.Popen(("./xsetup",), cwd = "/Xilinx_ISE_DS_Lin_14.7_1015_1") + + snooze() + print("First screen") + click(650, 610) + + snooze() + print("Second screen") + click(250, 420) + click(250, 444) + click(650, 610) + + snooze() + print("Third screen") + click(600, 560) + click(650, 610) + + snooze() + print("Fourth screen") + click(300, 100) + click(650, 610) + + for ith in ("Fifth", "Sixth", "Seventh"): + snooze() + print(ith + " screen") + click() + + print("Waiting half an hour for XiLinx installer to run, ^C if you get bored") + snooze(1800) + + # In theory we could use visgrep to check for the "finish" button. + # In practice ... this is such a kludge, what's one more, let's just + # try blindly clicking where the finish button should be and see + # if that results in a usable image. + + print("Blindly clicking where finish button should be") + click(720, 610) + + print("xsetup exited with status {}".format(xsetup.wait())) + + snooze() + print("Starting XiLinx license manager") + xlcm = subprocess.Popen(". /opt/Xilinx/14.7/ISE_DS/settings64.sh; /opt/Xilinx/14.7/ISE_DS/common/bin/lin64/xlcm -manage", + shell = True, cwd = "/home/builder", env = dict(os.environ, USER = "builder", HOME = "/home/builder")) + + snooze() + print("First screen") + click(100, 116) + + snooze() + print("Second screen") + click(220, 170) + click(680, 490) + + snooze() + print("Third screen") + click(400, 360) + click(750, 650) + + print("xlcm exited with status {}".format(xlcm.wait())) + + print("Shutting down") + subprocess.check_call(("ratpoison", "-c", "quit")) + + print("ratpoison exited with status {}".format(rat.wait())) diff --git a/ratinox b/ratinox deleted file mode 100755 index 6cdad09..0000000 --- a/ratinox +++ /dev/null @@ -1,128 +0,0 @@ -#!/usr/bin/env python - -""" -Perform demented tasks with blind rodents. -""" - -import subprocess, os, time, xvfbwrapper, shutil, argparse - -class Ratinox(xvfbwrapper.Xvfb): - - xvfb_screen_name = "Xvfb_screen0" - - def __init__(self, **kwargs): - if kwargs.pop("screencap", True) and "fbdir" in kwargs: - self.screencap_file = os.path.join(kwargs["fbdir"], self.xvfb_screen_name) - else: - self.screencap_file = None - xvfbwrapper.Xvfb.__init__(self, **kwargs) - - def __enter__(self): - result = xvfbwrapper.Xvfb.__enter__(self) - self.wm = subprocess.Popen(("ratpoison",)) - time.sleep(0.5) - return result - - def __exit__(self, exc_type, exc_val, exc_tb): - subprocess.check_call(("ratpoison", "-c", "quit")) - self.wm.wait() - self.wm = None - xvfbwrapper.Xvfb.__exit__(self, exc_type, exc_val, exc_tb) - - def click(self, *coordinates): - assert len(coordinates) in (0, 2) - if coordinates: - subprocess.check_call(("ratpoison", "-c", "ratwarp {:d} {:d}".format(*coordinates))) - if self.screencap_file: - shutil.copy(self.screencap_file, "{}.{}".format(self.screencap_file, time.time())) - subprocess.check_call(("ratpoison", "-c", "ratclick")) - -def snooze(how_long = 15): - time.sleep(how_long) - -def installer(): - - with Ratinox(fbdir = "/cryptech-builder") as rat: - print("DISPLAY={}".format(os.getenv("DISPLAY"))) - - snooze() - print("Starting XiLinx installer") - xsetup = subprocess.Popen(("./xsetup",), cwd = "/Xilinx_ISE_DS_Lin_14.7_1015_1") - - snooze() - print("First screen") - rat.click(650, 610) - - snooze() - print("Second screen") - rat.click(250, 420) - rat.click(250, 444) - rat.click(650, 610) - - snooze() - print("Third screen") - rat.click(600, 560) - rat.click(650, 610) - - snooze() - print("Fourth screen") - rat.click(300, 100) - rat.click(650, 610) - - for ith in ("Fifth", "Sixth", "Seventh"): - snooze() - print(ith + " screen") - rat.click() - - print("Waiting half an hour for XiLinx installer to run, ^C if you get bored") - snooze(1800) - - # In theory we could use visgrep to check for the "finish" button. - # In practice ... this is such a kludge, what's one more, let's just - # try blindly clicking where the finish button should be and see - # if that results in a usable image. - - print("Blindly clicking where finish button should be") - rat.click(720, 610) - - print("xsetup exited with status {}".format(xsetup.wait())) - -def licenser(): - - with Ratinox(fbdir = "/cryptech-builder") as rat: - print("DISPLAY={}".format(os.getenv("DISPLAY"))) - - snooze() - print("Starting XiLinx license manager") - xlcm = ". /opt/Xilinx/14.7/ISE_DS/settings64.sh; /opt/Xilinx/14.7/ISE_DS/common/bin/lin64/xlcm -manage" - xlcm = subprocess.Popen(xlcm, shell = True) - - snooze() - print("First screen") - rat.click(100, 116) - - snooze() - print("Second screen") - rat.click(220, 170) - rat.click(680, 490) - - snooze() - print("Third screen") - rat.click(400, 360) - rat.click(750, 650) - - print("xlcm exited with status {}".format(xlcm.wait())) - -def main(): - - dispatch = {"ise-install" : installer, - "license-user" : licenser } - - ap = argparse.ArgumentParser(description = __doc__) - ap.add_argument("command", choices = tuple(sorted(dispatch))) - args = ap.parse_args() - - dispatch[args.command]() - -if __name__ == "__main__": - main() |