CI: Revert apt-get in build script; support perl credential server
diff --git a/ci/scripts/build.linux.script.sh b/ci/scripts/build.linux.script.sh
index ecd1292..c37d98b 100755
--- a/ci/scripts/build.linux.script.sh
+++ b/ci/scripts/build.linux.script.sh
@@ -30,16 +30,6 @@
 compiler_launcher=""
 
 if [[ "${EIGEN_CI_CCACHE}" == "on" ]]; then
-  # Ensure sccache prerequisites (python3, curl) exist in slim images if apt-get is available
-  if [[ "${EIGEN_CI_SCCACHE:-on}" != "off" ]]; then
-    if ! command -v python3 >/dev/null 2>&1 || ! command -v curl >/dev/null 2>&1; then
-      if command -v apt-get >/dev/null 2>&1 && [[ "$(id -u)" -eq 0 ]]; then
-        DEBIAN_FRONTEND=noninteractive apt-get update -qq >/dev/null 2>&1 || true
-        DEBIAN_FRONTEND=noninteractive apt-get install -y -qq --no-install-recommends python3 curl ca-certificates >/dev/null 2>&1 || true
-      fi
-    fi
-  fi
-
   . "${rootdir}/ci/scripts/install_compiler_cache.sh"
 
   if [[ "${EIGEN_CI_SCCACHE:-on}" != "off" && -n "${sccache_bin}" ]]; then
@@ -61,7 +51,8 @@
         export SCCACHE_GCS_RW_MODE="READ_ONLY"
       fi
       cred_port="$((8200 + (${CI_JOB_ID:-0} % 1000)))"
-      python3 -c "
+      if command -v python3 >/dev/null 2>&1; then
+        python3 -c "
 import http.server, json, sys
 token = sys.argv[1]
 class H(http.server.BaseHTTPRequestHandler):
@@ -73,13 +64,26 @@
     def log_message(self, *a): pass
 http.server.HTTPServer(('127.0.0.1', int(sys.argv[2])), H).serve_forever()
 " "${gcs_token}" "${cred_port}" &
-      sccache_cred_server_pid=$!
+        sccache_cred_server_pid=$!
+      elif command -v perl >/dev/null 2>&1; then
+        perl -MIO::Socket::INET -e '
+my $s = IO::Socket::INET->new(Listen => 5, LocalAddr => "127.0.0.1", LocalPort => $ARGV[1], Reuse => 1) or exit 1;
+my $resp = "{\"access_token\":\"$ARGV[0]\",\"token_type\":\"Bearer\",\"expires_in\":3600}";
+my $len = length($resp);
+while (my $c = $s->accept()) {
+  $c->recv(my $buf, 1024);
+  print $c "HTTP/1.1 200 OK\r\nContent-Type: application/json\r\nContent-Length: $len\r\nConnection: close\r\n\r\n$resp";
+  close $c;
+}
+' "${gcs_token}" "${cred_port}" &
+        sccache_cred_server_pid=$!
+      fi
       export SCCACHE_GCS_CREDENTIALS_URL="http://127.0.0.1:${cred_port}/token"
       trap '[[ -n "${sccache_cred_server_pid}" ]] && kill "${sccache_cred_server_pid}" 2>/dev/null || true' EXIT
 
       # Wait up to 1 second for local credential server to be ready
       for _ in {1..20}; do
-        if curl -s "http://127.0.0.1:${cred_port}/token" >/dev/null 2>&1; then break; fi
+        if (echo > "/dev/tcp/127.0.0.1/${cred_port}") 2>/dev/null; then break; fi
         sleep 0.05
       done
     fi