third_party: replace jq with gojq

Building jq portably is annoying, and the way we were doing it (which we
iirc stole from some google project?) sucked. Let's use a Go jq clone
instead.

This is an alternative for 1535. jq is currently used only in one
script, which could really be replaced by a Go program, but let's keep
it simple for now.

Change-Id: Ie25dffadd545df143490f510e9b75a74adf81492
Reviewed-on: https://gerrit.hackerspace.pl/c/hscloud/+/1540
Reviewed-by: palid <palid@hackerspace.pl>
diff --git a/third_party/go/repositories.bzl b/third_party/go/repositories.bzl
index aadb84a..3c8d789 100644
--- a/third_party/go/repositories.bzl
+++ b/third_party/go/repositories.bzl
@@ -824,12 +824,6 @@
         sum = "h1:hsms1Qyu0jgnwNXIxa+/V/PDsU6CfLf6CNO8H7IWoS4=",
         version = "v1.4.9",
     )
-    go_repository(
-        name = "ml_vbom_util",
-        importpath = "github.com/fvbommel/util",
-        sum = "h1:/uQiVCCb9QGbBGf51tcx2D6Poi+Op2UpU+6qGP5nEdk=",
-        version = "v0.0.3",
-    )
 
     go_repository(
         name = "com_github_gabriel_vasile_mimetype",
@@ -1446,6 +1440,21 @@
     )
 
     go_repository(
+        name = "com_github_itchyny_gojq",
+        build_naming_convention = "go_default_library",
+        importpath = "github.com/itchyny/gojq",
+        sum = "h1:IxyYlHYIlspQHHTE0f3cJF0NKDMfajxViuhBLnHd/QU=",
+        version = "v0.12.13",
+    )
+
+    go_repository(
+        name = "com_github_itchyny_timefmt_go",
+        build_naming_convention = "go_default_library",
+        importpath = "github.com/itchyny/timefmt-go",
+        sum = "h1:G0INE2la8S6ru/ZI5JecgyzbbJNs5lG1RcBqa7Jm6GE=",
+        version = "v0.1.5",
+    )
+    go_repository(
         name = "com_github_jackc_pgx",
         commit = "6954c15ad0bd3c9aa6dd1b190732b020379beb28",
         importpath = "github.com/jackc/pgx",
@@ -3036,6 +3045,12 @@
         sum = "h1:k1MczvYDUvJBe93bYd7wrZLLUEcLZAuF824/I4e5Xr4=",
         version = "v0.1.1",
     )
+    go_repository(
+        name = "ml_vbom_util",
+        importpath = "github.com/fvbommel/util",
+        sum = "h1:/uQiVCCb9QGbBGf51tcx2D6Poi+Op2UpU+6qGP5nEdk=",
+        version = "v0.0.3",
+    )
 
     go_repository(
         name = "ml_vbom_util_sortorder",
@@ -3330,6 +3345,7 @@
     )
     go_repository(
         name = "tools_gotest_v3",
+        build_naming_convention = "go_default_library",
         importpath = "gotest.tools/v3",
         replace = "gotest.tools/v3",
         sum = "h1:kG1BFyqVHuQoVQiR1bWGnfz/fmHvvuiSPIV7rvl360E=",
diff --git a/third_party/jq/BUILD b/third_party/jq/BUILD
deleted file mode 100644
index e69de29..0000000
--- a/third_party/jq/BUILD
+++ /dev/null
diff --git a/third_party/jq/BUILD.external b/third_party/jq/BUILD.external
deleted file mode 100644
index e26c0fb..0000000
--- a/third_party/jq/BUILD.external
+++ /dev/null
@@ -1,78 +0,0 @@
-# Copyright 2019 Google LLC
-# Copyright 2020 Sergiusz 'q3k' Bazanski
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-#     https://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-# The jq binary.
-cc_binary(
-    name = "jq",
-    srcs = [
-        ":source_files",
-    ],
-    copts = [
-        "-Iexternal/com_github_kkos_oniguruma/src",
-        "-Wno-cpp",
-        "-Wno-unused-function",
-        "-Wno-unused-variable",
-    ],
-    visibility = ["//visibility:public"],
-    deps = [
-        "@com_github_kkos_oniguruma//:oniguruma",
-    ],
-)
-
-# Generate the source files.
-# This will run ./configure and extract a host-dependent confdefs.h file, then
-# prefix each .h acd .c file with '#include "confdefs.h"'.
-genrule(
-    name = "source_files",
-    srcs = glob(["**"]),
-    outs = ["build/" + f for f in glob(
-        [
-            "src/*.h",
-            "src/*.c",
-        ],
-        exclude = [
-            "src/inject_errors.c",
-        ],
-    )] + [
-        # The extracted confdefs.h.
-        "build/src/confdefs.h",
-        # The generated builtin.inc.
-        "build/src/builtin.inc",
-    ],
-    cmd =
-        # Run ./configure && make src/builtin.inc.
-        "( " +
-        "  cd external/com_github_stedolan_jq; " +
-        "  ./configure > /dev/null 2> /dev/null; " +
-        "  make src/builtin.inc > /dev/null; " +
-        "); " +
-        # Extract confdefs.h from config.log.
-        "grep '^/\\* confdefs.h \\*/$$' external/com_github_stedolan_jq/config.log -A1000 " +
-        "  | head -n -1 > \"$(@D)\"/build/src/confdefs.h; " +
-        # Prefix each output file with an include of confdefs.h.
-        "OUTS=\"$(OUTS)\"; for FILE in $$OUTS; do " +
-        "  touch \"$$FILE\"; " +
-        "  BASENAME=\"$$(basename $$FILE)\"; " +
-        "  if [ \"$$BASENAME\" != \"confdefs.h\" ]; then " +
-        "    echo '#include \"confdefs.h\"' > \"$$FILE\"; " +
-        "  cat external/com_github_stedolan_jq/src/\"$$BASENAME\" >> \"$$FILE\"; " +
-        "  fi; " +
-        # Replace non-relative references.
-        "  sed -e 's|^#include \"src/|#include \"|g' -i \"$$FILE\"; " +
-        "done; " +
-        # Copy builtin.inc and version.h without modificaitons.
-        "cp external/com_github_stedolan_jq/src/builtin.inc \"$(@D)\"/build/src/builtin.inc; ",
-)
-
diff --git a/third_party/jq/README.md b/third_party/jq/README.md
deleted file mode 100644
index 223de52..0000000
--- a/third_party/jq/README.md
+++ /dev/null
@@ -1,6 +0,0 @@
-third\_party: jq
-================
-
-Upstream: https://github.com/stedolan/jq
-
-Pulled in by WORKSPACE (com\_github\_stedolan\_jq), BUILD.external used as root BUILDfile for external repository.