From 9bec2556b1dab938e5b0386112f046a0f56cc610 Mon Sep 17 00:00:00 2001
From: Sylvester Joosten <sjoosten@anl.gov>
Date: Mon, 25 Apr 2022 23:37:57 +0000
Subject: [PATCH] Resolve "Use new eic-n0 docker runner"

---
 .gitlab-ci.yml                    |  2 +-
 containers/jug/dev.Dockerfile     |  5 ++---
 spack/packages/dawn/package.py    |  3 +--
 spack/packages/dawncut/package.py | 31 +++++++++++++++++++++++++------
 4 files changed, 29 insertions(+), 12 deletions(-)

diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index d3c51ecec..00caeac96 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -156,7 +156,7 @@ version:
   resource_group: build
   ## Use docker runner for docker builds
   tags:
-    - docker
+    - docker-new
   ## cookie-cutter docker push code, to be included at the
   ## end of the regular job scripts
   script:
diff --git a/containers/jug/dev.Dockerfile b/containers/jug/dev.Dockerfile
index 3e5ae2432..064e3604e 100644
--- a/containers/jug/dev.Dockerfile
+++ b/containers/jug/dev.Dockerfile
@@ -14,6 +14,7 @@ RUN --mount=type=cache,target=/var/cache/apt                            \
  && apt-get -yqq update                                                 \
  && apt-get -yqq install --no-install-recommends                        \
         python3                                                         \
+        python3-dev                                                     \
         python3-distutils                                               \
         python-is-python3                                               \
  && rm -rf /var/lib/apt/lists/*
@@ -69,9 +70,6 @@ SHELL ["docker-shell"]
 ## a backup mirror on the internal B010 network
 RUN --mount=type=cache,target=/var/cache/spack-mirror                   \
     export PATH=$PATH:$SPACK_ROOT/bin                                   \
- && wget 10.10.241.24/spack-mirror/sodium.pub --no-check-certificate    \
- && spack gpg trust sodium.pub                                          \
- && spack mirror add silicon http://10.10.241.24/spack-mirror           \
  && spack mirror add docker /var/cache/spack-mirror                     \
  && spack mirror list
 
@@ -114,6 +112,7 @@ RUN --mount=type=cache,target=/var/cache/spack-mirror                   \
     || status=$?                                                        \
  && [ -z "${CACHE_NUKE}" ]                                              \
     || rm -rf /var/cache/spack-mirror/build_cache/*                     \
+ && mkdir -p /var/cache/spack-mirror/build_cache                        \
  && spack buildcache update-index -d /var/cache/spack-mirror            \
  && spack buildcache list --allarch --very-long                         \
     | sed '/^$/d;/^--/d;s/@.\+//;s/\([a-z0-9]*\) \(.*\)/\2\/\1/'        \
diff --git a/spack/packages/dawn/package.py b/spack/packages/dawn/package.py
index 703a134b3..52da825cc 100644
--- a/spack/packages/dawn/package.py
+++ b/spack/packages/dawn/package.py
@@ -32,8 +32,7 @@ class Dawn(MakefilePackage):
 
     # Note: Dawn homepage not available anymore...
     homepage = "https://geant4.kek.jp/~tanaka"
-    #url      = "http://geant4.kek.jp/~tanaka/src/dawn_3_91a.tgz"
-    url      = "http://10.10.241.24/software/dawn_3_91a.tgz"
+    url      = "http://geant4.kek.jp/~tanaka/src/dawn_3_91a.tgz"
 
     maintainers = ['sly2j']
 
diff --git a/spack/packages/dawncut/package.py b/spack/packages/dawncut/package.py
index 56727106c..ffe9adfa3 100644
--- a/spack/packages/dawncut/package.py
+++ b/spack/packages/dawncut/package.py
@@ -15,17 +15,36 @@ class Dawncut(MakefilePackage):
 
     # dawn webpage not available anymore
     homepage = "https://geant4.kek.jp/~tanaka"
-    url = "http://10.10.241.24/software/dawncut_1_54a.tar.gz"
+    url = "http://geant4.kek.jp/~tanaka/src/dawncut_1_54a.taz"
     maintainers = ['sly2j']
 
     version('1_54a',
-            sha256='17d7ccd2ff863e2f3700cc3e751cfca37a1425abfa0edc3b8f6497d8746ddcf4')
+            url='http://geant4.kek.jp/~tanaka/src/dawncut_1_54a.taz',
+            sha256='531e1f0e2ed35de3e2b1803108c0efb732d83a0c676f14083bd41a71346b4fa9',
+            expand=False)
 
-    # FIXME: Add dependencies if required.
-    # depends_on('foo')
+    phases = ['unpack', 'repatch', 'edit', 'build', 'install']
 
-    ## Patch to add install directive to Makefile
-    patch('install.patch')
+    def unpack(self, spec, prefix):
+        # Untar inner tar files
+        def members(tf, tld):
+            l = len(tld)
+            for member in tf.getmembers():
+                if member.path.startswith(tld):
+                    member.path = member.path[l:]
+                    yield member
+
+        with working_dir(self.stage.source_path):
+            import tarfile
+            install_tar = tarfile.open('dawncut_1_54a.taz')
+            install_tar.extractall(members=members(install_tar, 'dawncut_1_54a/'))
+
+    def repatch(self, spec, prefix):
+        # Patch to add install directive to Makefile
+        src = self.stage.source_path
+        patches = self.package_dir
+        which('patch')('-N', '-l', '-p1',
+                       '-i', join_path(patches, 'install.patch'))
 
     def edit(self, spec, prefix):
         makefile = FileFilter("Makefile")
-- 
GitLab