Name:		swidval-binary
Version:	0.5.0
Release:	1%{?dist}
Summary:	NIST Software Identification (SWID) Tag Validator

Group:		System Environment/Base
License:	Public Domain
URL:		https://csrc.nist.gov/Projects/Software-Identification-SWID/resources#swid-validation-tool
Source0:	https://csrc.nist.gov/CSRC/media/Projects/Software-Identification-SWID/tools/swidval-0.5.0-swidval.zip
Source1:	swidval.sh

BuildArch:	noarch

Requires:	java-1.8.0-headless
%if 0%{?fedora} || 0%{?rhel} > 7
Requires:	log4j >= 2
Requires:	jdom2
Requires:	apache-commons-cli
%else
Requires:	%{name}-log4j
Requires:	%{name}-jdom2
Requires:	%{name}-commons-cli
%endif
Requires:	xerces-j2
Requires:	xml-commons-apis
Requires:	xml-commons-resolver
Requires:	%{name}-saxon

%description
The SWID Tag Validator is a Java 8 application that checks
that a provided SWID tag conforms to requirements from
the ISO/IEC 19770-2:2015 [1] and NIST Internal Report (NISTIR) 8060 [2].

[1] http://www.iso.org/iso/catalogue_detail?csnumber=65666
[2] https://dx.doi.org/10.6028/NIST.IR.8060

Beware: Redistributing the binary provided by NIST, *not* built from source.

%package saxon
Summary:	Saxon-HE-9.7.0 shipped by swidval
License:	MPLv2.0

%description saxon
Saxon-HE-9.7.0, in separate rpm from swidval due to different license.

%if 0%{?rhel} == 7
%package jdom2
Summary:	JDOM 2 shipped by swidval
License:	ASL 1.1 or BSD

%description jdom2
JDOM 2, in separate rpm from swidval due to different license.

%package log4j
Summary:	Log4j 2 shipped by swidval
License:	ASL 2.0

%description log4j
Log4j 2, in separate rpm from swidval due to different license.

%package commons-cli
Summary:	commons-cli-1.4 shipped by swidval
License:	ASL 2.0

%description commons-cli
commons-cli-1.4, in separate rpm from swidval due to different license.
%endif

%prep
%setup -c -n %{name}-%{version}

%build

%install
install -d %{buildroot}%{_bindir}
install -m 755 %{SOURCE1} %{buildroot}%{_bindir}/swidval
install -d %{buildroot}%{_javadir}
install -m 644 swidval-%{version}.jar %{buildroot}%{_javadir}
install -m 644 lib/decima-*.jar %{buildroot}%{_javadir}
install -m 644 lib/Saxon-HE-9.7.0-2.jar	%{buildroot}%{_javadir}
install -d %{buildroot}%{_datadir}/swidval/bootstrap/{css,fonts,js}
install -m 644 bootstrap/css/* %{buildroot}%{_datadir}/swidval/bootstrap/css
install -m 644 bootstrap/fonts/* %{buildroot}%{_datadir}/swidval/bootstrap/fonts
install -m 644 bootstrap/js/* %{buildroot}%{_datadir}/swidval/bootstrap/js

%if 0%{?rhel} == 7
install -d %{buildroot}%{_javadir}/jdom2
install -m 644 lib/jdom2-2.0.6.jar %{buildroot}%{_javadir}/jdom2/jdom2.jar
install -d %{buildroot}%{_javadir}/log4j
install -m 644 lib/log4j-api-2.8.2.jar %{buildroot}%{_javadir}/log4j/log4j-api.jar
install -m 644 lib/log4j-core-2.8.2.jar %{buildroot}%{_javadir}/log4j/log4j-core.jar
install -m 644 lib/commons-cli-1.4.jar %{buildroot}%{_javadir}/apache-commons-cli.jar
%endif

%files
%{_bindir}/swidval
%{_javadir}/swidval-%{version}.jar
%{_javadir}/decima-*.jar
%{_datadir}/swidval/
%doc README.txt
%license NOTICE.txt

%files saxon
%{_javadir}/Saxon-HE-9.7.0-2.jar

%if 0%{?rhel} == 7
%files jdom2
%{_javadir}/jdom2/jdom2.jar

%files log4j
%{_javadir}/log4j/log4j-api.jar
%{_javadir}/log4j/log4j-core.jar

%files commons-cli
%{_javadir}/apache-commons-cli.jar
%endif

%changelog
* Mon Jun 04 2018 Jan Pazdziora <jpazdziora@redhat.com> - 0.5.0-1
- Initial packaging of swidval-0.5.0.