install_jsonc.py 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. import sys
  2. import os
  3. import os.path
  4. import sh
  5. from sh import git, cd, make, rm, sudo, cp
  6. def write_output(line):
  7. sys.stdout.write(line)
  8. curl = sh.Command("curl")
  9. tar = sh.Command("tar")
  10. install_env = os.environ.copy()
  11. install_env['CC'] = "gcc"
  12. directory = os.path.dirname(os.path.realpath(__file__))
  13. json_c_dir = os.path.join(directory, "json-c-json-c-0.12-20140410")
  14. rm("-r", "-f", json_c_dir)
  15. cd(directory)
  16. tar(curl(
  17. "-L",
  18. "https://github.com/json-c/json-c/archive/json-c-0.12-20140410.tar.gz",
  19. _piped=True
  20. ), "-xz")
  21. # Replace the Makefile.am.inc with one without -Werror
  22. replacement_amfile = os.path.join(directory, "json_c_new_Makefile.am.inc")
  23. original_amfile = os.path.join(json_c_dir, "Makefile.am.inc")
  24. cp(replacement_amfile, original_amfile)
  25. # Build it
  26. cd(json_c_dir)
  27. autogen_location = os.path.join(json_c_dir, "autogen.sh")
  28. autogen = sh.Command(autogen_location)
  29. autogen(prefix="/usr", _out=write_output, _env=install_env)
  30. make(_out=write_output, _env=install_env)
  31. if os.environ.get("ZMAP_TRAVIS_BUILD", None):
  32. print("Installing...")
  33. with sudo:
  34. make.install(_out=write_output, _env=install_env)
  35. print("Done.")