summaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authorHDK <[email protected]>2023-12-25 19:27:12 +0800
committerHDK <[email protected]>2023-12-25 19:27:12 +0800
commitc260fb41a0c7b8a1d438da40b9f73f03d48b8bb3 (patch)
treef1375989bc253dfe66dbd7eda1ab724e30744320 /scripts
parent6e0b3fd724495855a766af4d2c189dc8a99955c4 (diff)
初始化提交
Diffstat (limited to 'scripts')
-rw-r--r--scripts/README.md6
-rw-r--r--scripts/check_manfile.py33
-rw-r--r--scripts/cmake_install_checksum1
-rw-r--r--scripts/install_cmake.py50
-rw-r--r--scripts/install_jsonc.py46
-rw-r--r--scripts/install_mongo.py38
-rw-r--r--scripts/json_c_new_Makefile.am.inc1
-rw-r--r--scripts/uninstall.cmake24
8 files changed, 199 insertions, 0 deletions
diff --git a/scripts/README.md b/scripts/README.md
new file mode 100644
index 0000000..5cdb0de
--- /dev/null
+++ b/scripts/README.md
@@ -0,0 +1,6 @@
+These scripts are used by Travis CI to prepare the build environment.
+
+If you run them on your system, you should both
+
+1. Trust me, because they need sudo
+2. Run them from the parent directory, e.g. `./scripts/install_cmake.sh`
diff --git a/scripts/check_manfile.py b/scripts/check_manfile.py
new file mode 100644
index 0000000..5e477ad
--- /dev/null
+++ b/scripts/check_manfile.py
@@ -0,0 +1,33 @@
+#!/usr/bin/env python
+#
+# CI runs this script to verify that options appearing in XTools' ggo.in files also appear in their .ronn files.
+# It does not check that `make manpages` has actually been run.
+#
+# This script assumes it's being run from the root of the xmap repository.
+#
+
+import sys
+
+checks = [
+ ("xopt.ggo.in", "xmap.1.ronn")
+]
+
+failures = False
+
+for ggo, ronn in checks:
+ options = []
+ with open("src/" + ggo) as fd:
+ for l in fd:
+ if l.startswith("option "):
+ option = l.split()[1].lstrip('"').rstrip('"')
+ options.append(option)
+
+ man = open("src/" + ronn).read()
+
+ for option in options:
+ if option not in man:
+ failures = True
+ sys.stderr.write("option %s is present in %s but missing from man file %s\n" % (option, ggo, ronn))
+
+if failures:
+ sys.exit(1)
diff --git a/scripts/cmake_install_checksum b/scripts/cmake_install_checksum
new file mode 100644
index 0000000..6fd3167
--- /dev/null
+++ b/scripts/cmake_install_checksum
@@ -0,0 +1 @@
+d0f8f9a6c921ba4927e69c68aa95a9a3 cmake_installer.sh
diff --git a/scripts/install_cmake.py b/scripts/install_cmake.py
new file mode 100644
index 0000000..fef8be0
--- /dev/null
+++ b/scripts/install_cmake.py
@@ -0,0 +1,50 @@
+import sys
+import os
+import os.path
+
+import sh
+from sh import git, cd, make, rm, sudo, cp, chmod, mkdir
+
+def write_output(line):
+ sys.stdout.write(line)
+
+curl = sh.Command("curl")
+tar = sh.Command("tar")
+
+install_env = os.environ.copy()
+install_env['CC'] = "gcc"
+
+directory = os.path.dirname(os.path.realpath(__file__))
+
+# Download it
+cd(directory)
+curl(
+ "-L",
+ "http://www.cmake.org/files/v3.2/cmake-3.2.2-Linux-x86_64.sh",
+ _out="cmake_installer.sh"
+)
+
+# Set up the installer
+installer_path = os.path.join(directory, "cmake_installer.sh")
+chmod("a+x", installer_path)
+cmake_installer = sh.Command(installer_path)
+
+# Verify the download
+sum_str = sh.Command("openssl").sha1(installer_path)
+expected_sum = "925e6185e94b717760453427b857fc4f2a4c2149"
+if sum_str.split()[1] != expected_sum:
+ raise Exception
+
+# Install it
+print("Installing...")
+if os.environ.get("XMAP_TRAVIS_BUILD", None):
+ print("Travis CI build, installing to /opt")
+ with sudo:
+ cmake_installer(prefix="/opt", exclude_subdir=True)
+else:
+ prefix = os.path.join(directory, "cmake")
+ mkdir(prefix)
+ print("Installing to {}".format(prefix))
+ cmake_installer(prefix=prefix, exclude_subdir=True)
+
+print("Done.")
diff --git a/scripts/install_jsonc.py b/scripts/install_jsonc.py
new file mode 100644
index 0000000..14a5a82
--- /dev/null
+++ b/scripts/install_jsonc.py
@@ -0,0 +1,46 @@
+import sys
+import os
+import os.path
+
+import sh
+from sh import git, cd, make, rm, sudo, cp
+
+def write_output(line):
+ sys.stdout.write(line)
+
+curl = sh.Command("curl")
+tar = sh.Command("tar")
+
+install_env = os.environ.copy()
+install_env['CC'] = "gcc"
+
+directory = os.path.dirname(os.path.realpath(__file__))
+
+json_c_dir = os.path.join(directory, "json-c-json-c-0.12-20140410")
+rm("-r", "-f", json_c_dir)
+
+cd(directory)
+tar(curl(
+ "-L",
+ "https://github.com/json-c/json-c/archive/json-c-0.15-20200726.tar.gz",
+ _piped=True
+), "-xz")
+
+# Replace the Makefile.am.inc with one without -Werror
+replacement_amfile = os.path.join(directory, "json_c_new_Makefile.am.inc")
+original_amfile = os.path.join(json_c_dir, "Makefile.am.inc")
+cp(replacement_amfile, original_amfile)
+
+# Build it
+cd(json_c_dir)
+autogen_location = os.path.join(json_c_dir, "autogen.sh")
+autogen = sh.Command(autogen_location)
+autogen(prefix="/usr", _out=write_output, _env=install_env)
+make(_out=write_output, _env=install_env)
+
+if os.environ.get("XMAP_TRAVIS_BUILD", None):
+ print("Installing...")
+ with sudo:
+ make.install(_out=write_output, _env=install_env)
+
+print("Done.")
diff --git a/scripts/install_mongo.py b/scripts/install_mongo.py
new file mode 100644
index 0000000..62b8e43
--- /dev/null
+++ b/scripts/install_mongo.py
@@ -0,0 +1,38 @@
+import sys
+import os
+import os.path
+
+import sh
+from sh import git, cd, make, rm, sudo
+
+def write_output(line):
+ sys.stdout.write(line)
+
+install_env = os.environ.copy()
+install_env['CC'] = "gcc"
+
+directory = os.path.dirname(os.path.realpath(__file__))
+
+mongo_c_driver = os.path.join(directory, "mongo-c-driver")
+
+rm("-r", "-f", mongo_c_driver)
+autogen_location = os.path.join(mongo_c_driver, "autogen.sh")
+
+git.clone("https://github.com/mongodb/mongo-c-driver.git",
+ mongo_c_driver,
+ branch="1.17.4",
+ depth="1",
+ _out=write_output,
+ )
+
+cd(mongo_c_driver)
+autogen = sh.Command(autogen_location)
+autogen(prefix="/usr", _out=write_output, _env=install_env)
+make(_out=write_output, _env=install_env)
+
+if os.environ.get("XMAP_TRAVIS_BUILD", None):
+ print("Installing...")
+ with sudo:
+ make.install(_out=write_output, _env=install_env)
+
+print("Done.")
diff --git a/scripts/json_c_new_Makefile.am.inc b/scripts/json_c_new_Makefile.am.inc
new file mode 100644
index 0000000..c1fac9a
--- /dev/null
+++ b/scripts/json_c_new_Makefile.am.inc
@@ -0,0 +1 @@
+AM_CFLAGS = -Wall -Wno-error=deprecated-declarations -Wextra -Wwrite-strings -Wno-unused-parameter -std=gnu99 -D_GNU_SOURCE -D_REENTRANT
diff --git a/scripts/uninstall.cmake b/scripts/uninstall.cmake
new file mode 100644
index 0000000..a303d93
--- /dev/null
+++ b/scripts/uninstall.cmake
@@ -0,0 +1,24 @@
+set(MANIFEST "${CMAKE_CURRENT_BINARY_DIR}/install_manifest.txt")
+
+if(NOT EXISTS ${MANIFEST})
+ message(FATAL_ERROR "Cannot find install manifest: '${MANIFEST}'")
+endif()
+
+file(STRINGS ${MANIFEST} files)
+foreach(file ${files})
+ if(EXISTS ${file})
+ message(STATUS "Removing file: '${file}'")
+
+ exec_program(
+ ${CMAKE_COMMAND} ARGS "-E remove ${file}"
+ OUTPUT_VARIABLE stdout
+ RETURN_VALUE result
+ )
+
+ if(NOT "${result}" STREQUAL 0)
+ message(FATAL_ERROR "Failed to remove file: '${file}'.")
+ endif()
+ else()
+ MESSAGE(STATUS "File '${file}' does not exist.")
+ endif()
+endforeach(file) \ No newline at end of file