diff --git a/0001-Dynamic-link-to-libjsonnet-rather-than-static.patch b/0001-Dynamic-link-to-libjsonnet-rather-than-static.patch new file mode 100644 index 0000000000000000000000000000000000000000..d112f90f4db22a72485f5b96c3f8c025d2f26148 --- /dev/null +++ b/0001-Dynamic-link-to-libjsonnet-rather-than-static.patch @@ -0,0 +1,34 @@ +From d904d586ad312b31acf5d1f011f21e40c985028c Mon Sep 17 00:00:00 2001 +From: Pat Riehecky +Date: Wed, 23 Jun 2021 08:28:33 -0500 +Subject: [PATCH] Dynamic link to libjsonnet rather than static + +--- + setup.py | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +diff --git a/setup.py b/setup.py +index 8cc5ce4..b4cf2ae 100644 +--- a/setup.py ++++ b/setup.py +@@ -60,7 +60,7 @@ def get_version(): + + class BuildJsonnetExt(BuildExt): + def run(self): +- p = Popen(['make'] + LIB_OBJECTS, cwd=DIR) ++ p = Popen(['make', 'libs'] , cwd=DIR) + p.wait() + if p.returncode != 0: + raise Exception('Could not build %s' % (', '.join(LIB_OBJECTS))) +@@ -69,7 +69,7 @@ class BuildJsonnetExt(BuildExt): + jsonnet_ext = Extension( + '_jsonnet', + sources=MODULE_SOURCES, +- extra_objects=LIB_OBJECTS, ++ extra_objects=['libjsonnet.so.0', ], + include_dirs = ['include', 'third_party/md5', 'third_party/json'], + language='c++' + ) +-- +2.31.1 + diff --git a/0002-jsonnet-0.17.0-do-not-override-compiler-flags.patch b/0002-jsonnet-0.17.0-do-not-override-compiler-flags.patch new file mode 100644 index 0000000000000000000000000000000000000000..397f01ec433a750ee389bac156550082c7e5568b --- /dev/null +++ b/0002-jsonnet-0.17.0-do-not-override-compiler-flags.patch @@ -0,0 +1,36 @@ +From 052efc6196c602db6b72f95d09f838cde6070127 Mon Sep 17 00:00:00 2001 +From: Ben Beasley +Date: Wed, 23 Jun 2021 13:20:22 -0500 +Subject: [PATCH] patch CMakeLists.txt to stop overriding build flags + +--- + CMakeLists.txt | 8 +++----- + 1 file changed, 3 insertions(+), 5 deletions(-) + +diff --git a/CMakeLists.txt b/CMakeLists.txt +index 5df20ca..1d6eb73 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -35,16 +35,14 @@ set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${GLOBAL_OUTPUT_PATH}) + # Compiler flags. + if (${CMAKE_CXX_COMPILER_ID} MATCHES "Clang" OR + ${CMAKE_CXX_COMPILER_ID} STREQUAL "GNU") +- set(OPT "-O3") +- set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -g -Wall -Wextra -pedantic -std=c99 -O3 ${OPT}") +- set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g -Wall -Wextra -Woverloaded-virtual -pedantic -std=c++11 -fPIC ${OPT}") ++ set(OPT "") ++ set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -g -Wall -Wextra -pedantic ${OPT}") ++ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g -Wall -Wextra -Woverloaded-virtual -pedantic -fPIC ${OPT}") + else() + # TODO: Windows support. + message(FATAL_ERROR "Compiler ${CMAKE_CXX_COMPILER_ID} not supported") + endif() + +-set(CMAKE_CXX_STANDARD 11) +- + + # Include external googletest project. This runs a CMake sub-script + # (CMakeLists.txt.in) that downloads googletest source. It's then built as part +-- +2.31.1 + diff --git a/jsonnet-0.17.0.tar.gz b/jsonnet-0.17.0.tar.gz new file mode 100644 index 0000000000000000000000000000000000000000..ace569f98e7da74e37e781016f0fa8e6020f28a3 Binary files /dev/null and b/jsonnet-0.17.0.tar.gz differ diff --git a/jsonnet.1 b/jsonnet.1 new file mode 100644 index 0000000000000000000000000000000000000000..561ae9cdcade78cf5775224b77414a20530b0952 --- /dev/null +++ b/jsonnet.1 @@ -0,0 +1,145 @@ +.TH JSONNNET "1" "June 2021" "" "User Commands" +.SH NAME +jsonnet \- jsonnet commandline interpreter +.SH SYNOPSIS +.B jsonnet +.RI [ option \ ...] +.I filename +.SH OPTIONS +In all cases: +.RS +3n +.IP \(bu 2 +.I filename +can be +.B \- +(stdin) +.IP \(bu 2 +Multichar options are expanded e.g. \fB\-abc\fR becomes +.BR \-a\ \-b\ \-c . +.IP \(bu 2 +The +.B \-- +option suppresses option processing for subsequent arguments. +.IP \(bu 2 +Note that since filenames and jsonnet programs can begin with +.BR - , +it is advised to use +.B \-\- +if the argument is unknown, e.g. \fBjsonnet\ \-\-\ "$\fIFILENAME\fB"\fR. +.RE +.SS "AVAILABLE OPTIONS" +.TP +.B \-h\fR,\ \fB\-\-help +Print a usage message +.TP +.B \-e\fR,\ \fB\-\-exec +Treat +.I filename +as code +.TP +.B \-J\fR,\ \fB\-\-jpath \fIdir +Specify an additional library search directory (right-most wins) +.TP +.B \-o\fR,\ \fB\-\-output\-file \fIfile +Write to the output file rather than stdout +.TP +.B \-m\fR,\ \fB\-\-multi \fIdir +Write multiple files to the directory, list files on stdout +.TP +.B \-y\fR,\ \-\-yaml\-stream +Write output as a YAML stream of JSON documents +.TP +.B \-S\fR,\ \-\-string +Expect a string, manifest as plain text +.TP +.B \-s\fR,\ \-\-max\-stack\ \fIn +Number of allowed stack frames +.TP +.B \-t\fR,\ \-\-max\-trace\ \fIn +Max length of stack trace before cropping +.TP +.B \-\-gc\-min\-objects\ \fIn +Do not run garbage collector until this many +.TP +.B \-\-gc\-growth\-trigger\ \fIn +Run garbage collector after this amount of object growth +.TP +.B \-\-version +Print version +.SS "AVAILABLE OPTIONS FOR SPECIFYING VALUES OF \(oqEXTERNAL\(cq VARIABLES" +.P +Provide the value as a string: +.TP +.B \-V\fR,\ \fB-\-ext\-str\ \fIvar\fR[=\fIval\fR] +If +.I val +is omitted, get from environment var +.I var +.PD 0 +.TP +.in +4x +.B \-\-ext\-str\-file\ \fIvar\fR=\fIfile +Read the string from the file +.in +.PD +.P +Provide the value as Jsonnet code: +.TP +.B \-\-ext\-code\ \fIvar\fR[=\fIcode\fR] +If +.I code +is omitted, get from environment var +.I var +.TP +.B \-\-ext\-code\-file\ \fIvar\fR=\fIfile +Read the code from the file +.SS "AVAILABLE OPTIONS FOR SPECIFYING VALUES OF \(oqTOP-LEVEL ARGUMENTS\(cq" +.P +Provide the value as a string: +.TP +.B \-V\fR,\ \fB-\-tla\-str\ \fIvar\fR[=\fIval\fR] +If +.I val +is omitted, get from environment var +.I var +.PD 0 +.TP +.in +4x +.B \-\-tla\-str\-file\ \fIvar\fR=\fIfile +Read the string from the file +.in +.PD +.P +Provide the value as Jsonnet code: +.TP +.B \-\-tla\-code\ \fIvar\fR[=\fIcode\fR] +If +.I code +is omitted, get from environment var +.I var +.TP +.B \-\-tla\-code\-file\ \fIvar\fR=\fIfile +Read the code from the file +.SH ENVIRONMENT +.TP +.B JSONNET_PATH +is a colon (semicolon on Windows) separated list of directories added in +reverse order before the paths specified by +.B \-\-jpath +(i.e. left-most wins) +.IP +E.g. +.in +4n +.EX +.B JSONNET_PATH=a:b\ jsonnet\ \-J\ c\ \-J\ d +.EE +.in +is equivalent to: +.in +4n +.EX +.B JSONNET_PATH=d:c:a:b\ jsonnet +.B jsonnet\ \-J\ b\ \-J\ a\ \-J\ c\ \-J\ d +.EE +.in +.SH "SEE\ ALSO" +.BR jsonnetfmt (1) diff --git a/jsonnet.spec b/jsonnet.spec new file mode 100644 index 0000000000000000000000000000000000000000..0c90bbe678220aabdf0bc4dcbd1941c77c71116e --- /dev/null +++ b/jsonnet.spec @@ -0,0 +1,190 @@ +%global so_version 0 +Name: jsonnet +Version: 0.17.0 +Release: 2%{?dist} +Summary: A data templating language based on JSON + +# The bundled MD5 library is RSA licenced +License: ASL 2.0 and RSA + +URL: https://github.com/google/jsonnet +Source0: %{url}/archive/v%{version}/%{name}-%{version}.tar.gz + +# Downstream man pages in groff_man(7) format +Source1: jsonnet.1 +Source2: jsonnetfmt.1 + +# Upstream wants to build single source wheels +# these benefit from static linking, +# but we want to link to libjsonnet here so we are sharing the lib +Patch0001: 0001-Dynamic-link-to-libjsonnet-rather-than-static.patch +Patch0002: 0002-jsonnet-0.17.0-do-not-override-compiler-flags.patch + + +# Bundled MD5 C++ class with very permissive license (RSA) +# rpmlint must be notified of the unversioned provides +Provides: bundled(md5-thilo) + +BuildRequires: make python3-devel python3-setuptools +BuildRequires: gcc bash gtest-devel + + +BuildRequires: gcc-c++ + +# json is header only, so note the static lib for tracking +BuildRequires: json-devel >= 3.6 +BuildRequires: json-static >= 3.6 + +# Set our toplevel runtime requirements +Requires: %{name}-libs%{?_isa} = %{version}-%{release} + +%global _description %{expand: +A data templating language for app and tool developers based on JSON} +%define buildroot /root/rpmbuild/BUILDROOT/%{name} +%description %{_description} + + +%package -n python3-%{name} +Summary: %{name} Bindings for Python +Requires: %{name}-libs%{?_isa} = %{version}-%{release} + +%description -n python3-%{name} %{_description} + + +%package libs +Summary: Shared Libraries for %{name} + +%description libs %{_description} + + +%package devel +Summary: Development Headers for %{name} +Requires: %{name}-libs%{?_isa} = %{version}-%{release} + +%description devel %{_description} + + +%package doc +Summary: Documentation for %{name} +License: CC-BY +BuildArch: noarch + +%description doc %{_description} + + +%prep +%autosetup + +# use system json lib instead +rm -rfv third_party/json/* + +# don't bundel rapidyaml +rm -rfv third_party/rapidyaml/* + +# don't bundle thirdparty doc resources +# this leaves the doc "unbuilt" but still sorta useful +rm -rf doc/third_party +rm -rf doc/.gitignore + + +%build + +%make_build +%py3_build +#%if 0%{?rhel} == 7 +# required macro drop for EL7 +#%undefine __cmake3_in_source_build +#%endif + + +# FIXME: +# For reasons I'm not following, json-devel isn't added to include by cmake +# +# explicitly set -fPIC so python can pick it up later on +#export CXXFLAGS="%{optflags} -fPIC -I%{_includedir}/nlohmann -std=c++11" + +# setup our build environment +#%cmake3 -DBUILD_SHARED_BINARIES:BOOL=ON -DBUILD_STATIC_LIBS:BOOL=OFF -DUSE_SYSTEM_JSON:BOOL=ON -DUSE_SYSTEM_GTEST:BOOL=ON + +# make tools and headers +#%cmake +#%make_build + +# make python binding + + + +%install +%make_install +%py3_install + +# install python binding +#%{py3_install} + +install -d '%{buildroot}%{_mandir}/man1' +install -t '%{buildroot}%{_mandir}/man1' -p -m 0644 '%{SOURCE1}' '%{SOURCE2}' + + +%check +%{ctest3} + + + +%files +#%{_bindir}/jsonnet +#%{_bindir}/jsonnetfmt +/usr/local/bin/jsonnet +/usr/local/bin/jsonnetfmt +%{_mandir}/man1/jsonnet.1* +%{_mandir}/man1/jsonnetfmt.1* + + +%files libs +%license LICENSE +%doc README.md +#%{_libdir}/lib%{name}.so.%{so_version} +/usr/local/lib/lib%{name}*.so.%{so_version} +#%{_libdir}/lib%{name}.so.%{version} +/usr/local/lib/lib%{name}*.so.%{version} + + +%files devel +#%{_includedir}/lib%{name} +/usr/local/include/lib%{name}* +#%{_libdir}/lib%{name}.so +/usr/local/lib/lib%{name}*.so + +%files -n python3-%{name} +# rpmlint must be notified this is not versioned on purpose +%{python3_sitearch}/_%{name}*.so +#%{python3_sitearch}/%{name}-%{version}-py%{python3_version}.egg-info + +%ifarch x86_64 +%{python3_sitearch}/_jsonnet.cpython-37m-x86_64-linux-gnu.so +%endif +%ifarch aarch64 +%{python3_sitearch}/_jsonnet.cpython-37m-aarch64-linux-gnu.so +%endif +%{python3_sitearch}/%{name}-%{version}-py%{python3_version}.egg-info + +%files doc +%license LICENSE +%doc README.md +%doc CONTRIBUTING +%doc doc +%doc examples +# don't package up the self-check script +#%exclude %{_docdir}/%{name}-doc/examples/*.sh + + +%changelog +* Wed Dec 15 2021 Liying - 0.17.0-2 +- change build and install related macro. +- change path in files + +* Fri Jun 25 2021 Benjamin A. Beasley - 0.17.0-2 +- Add downstream man pages +- Fix Summary + +* Thu Jun 17 2021 Pat Riehecky - 0.17.0-1 +- Initial package. diff --git a/jsonnetfmt.1 b/jsonnetfmt.1 new file mode 100644 index 0000000000000000000000000000000000000000..31f0a0ca42cc4217584dbf84192c9575eeb1f9c9 --- /dev/null +++ b/jsonnetfmt.1 @@ -0,0 +1,90 @@ +.TH JSONNNET "1" "June 2021" "" "User Commands" +.SH NAME +jsonnetfmt \- jsonnet reformatter +.SH SYNOPSIS +.B jsonnetfmt +.RI [ option \ ...] +.RI [ filename ] +.SH OPTIONS +In all cases: +.RS +3n +.IP \(bu 2 +.I filename +can be +.B \- +(stdin) +.IP \(bu 2 +Multichar options are expanded e.g. \fB\-abc\fR becomes +.BR \-a\ \-b\ \-c . +.IP \(bu 2 +The +.B \-- +option suppresses option processing for subsequent arguments. +.IP \(bu 2 +Note that since filenames and jsonnet programs can begin with +.BR - , +it is advised to use +.B \-\- +if the argument is unknown, e.g. \fBjsonnet\ \-\-\ "$\fIFILENAME\fB"\fR. +.RE +.SS "AVAILABLE OPTIONS" +.TP +.B \-h\fR,\ \fB\-\-help +Print a usage message +.TP +.B \-e\fR,\ \fB\-\-exec +Treat +.I filename +as code +.TP +.B \-o\fR,\ \fB\-\-output\-file \fIfile +Write to the output file rather than stdout +.TP +.B \-i\fR,\ \fB\-\-in\-place +Update the Jsonnet file(s) in place +.TP +.B \-\-test +Exit with failure if reformatting changed the file(s) +.TP +.B \-n\fR,\ \-\-indent\ \fIn +Number of spaces to indent by (default +.BR 2 , +.B 0 +means no change) +.TP +.B \-\-string\-style\ \fR[\fBd\fR|\fBs\fR|\fBl\fR] +Enforce +.IR d ouble, +.IR s ingle +(default) quotes or +.RI \(oq l eave\(cq +.TP +.B \-\-comment\-style\ \fR[\fBh\fR|\fBs\fR|\fBl\fR] +.BI #\ ( h )\fR, +.BI //\ ( s ) +(default), or \(oq\fIl\fReave\(cq +.TP +.BR \-\- [ no\- ] pretty\-field\-names +Use syntax sugar for fields and indexing (on by default) +.TP +.BR \-\- [ no\- ] pad\-arrays +.B [\ 1,\ 2,\ 3\ ] +instead of +.B [1,\ 2,\ 3] +.TP +.BR \-\- [ no\- ] pad\-objects +.B {\ x:\ 1,\ y:\ 2\ } +instead of +.B {x:\ 1,\ y:\ 2} +(on by default) +.TP +.BR \-\- [ no\- ] sort\-imports +Sorting of imports (on by default) +.TP +.B \-\-debug\-desugaring +Unparse the desugared AST without executing it +.TP +.B \-\-version +Print version +.SH "SEE\ ALSO" +.BR jsonnet (1)