[linux] jq 1.5 release – build RPM

jq 란 ?

lightweight and flexible command-line JSON processor.

api 호출등에 데이터를 주고받는데 있어, 최근 json포멧을 사용하는 경우가 많습니다.

커멘드라인을 이용해서 curl등의 도구를 이용해서 데이터를 가져오는 경우 해당 데이터를 json 포멧등으로 (일반적으로 pretty form) 변환 하거나 sed, awk , grep 등 다양한 데이터 파싱이 가능한 도구입니다.

 

최근 …(이래도 2015년 8월 15일) 1.5버전이 릴리즈 되어 있으니, 이걸 RPM 으로 빌드하고, 사용해봅시다.

 

 

https://stedolan.github.io/jq/download/

최신버전 1.5를 빌드 하기 위해 해당 사이트를 방문하여 최신버전의 소스 파일을 다운 받습니다.

 

wget https://github.com/stedolan/jq/releases/download/jq-1.5/jq-1.5.tar.gz

 

SPEC 생성

빌드뤼카이어, valgrind 설치

1.5 버전 에서   bison 3.0이하의 버전에서는 아래와 같이 컨피그 옵션을 수정합니다.
빌드 하는 환경은 cent6 이므로, 2.7 버전이 설치되어 있습니다.

./configure –disable-maintainer-mode

 

추가로 make check 가 진행될 때 setup.sh 에서 참조하는 것중

PASS: tests/mantestPASS: tests/jqtestFAIL: tests/onigtestPASS: tests/shtest

 

위에 onigtest 가 실패하는 것은  테스트 작업 설정시 oniguruma.h 를 참조하기 때문인데요.

이는 setup.sh를 수정하여 리패키징 하거나, oniguruma-devel 패키지를 설치하여, 해당 해더를 위치시킨후 처리가능합니다.

 

또한 1.5서 추가되는 라이브러리 패스가 추가되어 https://github.com/stedolan/jq/blob/master/jq.spec 처럼 %{_libdir} 을 추가할 필요가 있습니다.

 

 

rpm 명세서.

Name:           jq

Version:        1.5

Release:        1%{?dist}

Summary:        Command-line JSON processor

License:        MIT and ASL 2.0 and CC-BY and GPLv3

URL:            http://stedolan.github.io/jq/

Source0:        http://stedolan.github.io/%{name}/download/source/%{name}-%{version}.tar.gz

BuildRequires:  flex

BuildRequires:  bison

%ifarch %{ix86} x86_64

BuildRequires:  valgrind

%endif

%description

lightweight and flexible command-line JSON processor

 jq is like sed for JSON data – you can use it to slice

 and filter and map and transform structured data with

 the same ease that sed, awk, grep and friends let you

 play with text.

 It is written in portable C, and it has zero runtime

 dependencies.

 jq can mangle the data format that you have into the

 one that you want with very little effort, and the

 program to do so is often shorter and simpler than

 you'd expect.

%prep

%setup -qn %{name}-%{version}

%build

%configure --disable-maintainer-mode

make %{?_smp_mflags}

# Docs already shipped in jq's tarball.

# In order to build the manual page, it

# is necessary to install rake, rubygem-ronn

# and do the following steps:

#

# # yum install rake rubygem-ronn

# $ cd docs/

# $ curl -L https://get.rvm.io | bash -s stable --ruby=1.9.3

# $ source $HOME/.rvm/scripts/rvm

# $ bundle install

# $ cd ..

# $ ./configure

# $ make real_docs

%install

make DESTDIR=%{buildroot} install

%check

# Valgrind used, so restrict architectures for check

%ifarch %{ix86} x86_64

make check

%endif

%files

%{_bindir}/%{name}

%{_datadir}/man/man1/jq.1.gz

%{_datadir}/doc/jq/AUTHORS

%{_datadir}/doc/jq/COPYING

%{_datadir}/doc/jq/README

%{_datadir}/doc/jq/README.md

%{_includedir}/jq.h

%{_includedir}/jv.h

%{_libdir}/libjq.a

%{_libdir}/libjq.la

%{_libdir}/libjq.so

%{_libdir}/libjq.so.1

%{_libdir}/libjq.so.1.0.4

%changelog

* Wed Nov 30 2016 Sungho Hong <nic2hong@jinstalk.com> - 1.5-1

- Initial package release for 1.5 jq.

글쓴이