File pdfsam.spec of Package pdfsam

#
# spec file for package pdfsam
#
# Copyright (c) 2010 SUSE LINUX Products GmbH, Nuernberg, Germany.
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
# upon. The license for this file, and modifications and additions to the
# file, is the same license as for the pristine package itself (unless the
# license for the pristine package is not an Open Source License, in which
# case the license is the MIT License). An "Open Source License" is a
# license that conforms to the Open Source Definition (Version 1.9)
# published by the Open Source Initiative.

# Please submit bugfixes or comments via http://bugs.opensuse.org/
#


Name:           pdfsam
Version:        2.2.4
Release:        0
Summary:        PDF split and merge
License:        AGPL-3.0
Group:          Productivity/Graphics/Other
Url:            http://www.pdfsam.org
Source0:        http://heanet.dl.sourceforge.net/sourceforge/pdfsam/pdfsam-%{version}-out-src.zip
BuildRoot:      %{_tmppath}/%{name}-%{version}-build
BuildArch:	    noarch
BuildRequires:  ant
BuildRequires:  unzip
BuildRequires:  java-devel >= 1.8.0 java-devel <= 1.8.0
BuildConflicts:	java-9-openjdk-devel >= 1.9.0
BuildConflicts:	java-10-openjdk-devel >= 1.10.0
BuildConflicts:	java-17-openjdk-devel >= 1.17.0
Requires:       java = 1.8.0

%description
A Java based PDF merge and split tool

%prep
%setup -c %{name}-%{version}
for FILE in *.zip; do
   unzip -o $FILE
done

find . -type f -name "build.xml" -exec sed -i -e 's|compiler="javac1.4"|compiler="javac1.8"|g' {} \;
find . -type f -name "build.xml" -exec sed -i -e 's|source="1.4"|source="1.8"|g' {} \;
find . -type f -name "build.xml" -exec sed -i -e 's|target="1.4"|target="1.8"|g' {} \;
find . -type f -name build.xml -exec sed -i -e 's|compiler="javac1.5"|compiler="javac1.8"|g' {} \;
find . -type f -name build.xml -exec sed -i -e 's|source="1.5"|source="1.8"|g' {} \;
find . -type f -name build.xml -exec sed -i -e 's|target="1.5"|target="1.8"|g' {} \;
find . -type f -name build.xml -exec sed -i -e 's|compiler="javac1.6"|compiler="javac1.8"|g' {} \;
find . -type f -name build.xml -exec sed -i -e 's|source="1.6"|source="1.8"|g' {} \;
find . -type f -name build.xml -exec sed -i -e 's|target="1.6"|target="1.8"|g' {} \;
find . -type f -name build.xml -exec sed -i -e 's|compiler="javac1.7"|compiler="javac1.8"|g' {} \;
find . -type f -name build.xml -exec sed -i -e 's|source="1.7"|source="1.8"|g' {} \;
find . -type f -name build.xml -exec sed -i -e 's|target="1.7"|target="1.8"|g' {} \;


%build
ANTOPTIONS="-Dlibs.dir=$PWD/libraries-2/ \
            -Dpdfsam.release.jar.dir=$PWD/libraries-2/ \
            -Dworkspace.dir=$PWD \
            -Dpdfsam-console.jar.name=pdfsam-console-1.1.5e \
            -Dpdfsam.jar.name=pdfsam-%{version} \
            -Dant.build.javac.source=1.8 \
            -Dant.build.javac.target=1.8"

for DIR in \
	emp4j			\
	jcmdline		\
	pdfsam-maine	\
	pdfsam-split		\
	pdfsam-merge		\
	pdfsam-mix

###pdfsam-console-br1	\
do
cd $DIR/ant
ant $ANTOPTIONS -Dbuild.dir="$PWD/.."
find ../$DIR/dist/ -name "*.jar" -exec cp {} $PWD/libraries-2 \;
cd -

done

%install
# TODO: What to do with install icepdfcreator, jpodrenderercreator?
export NO_BRP_CHECK_BYTECODE_VERSION=true
install -d -m 755 $RPM_BUILD_ROOT%{_bindir}

cat << EOF > $RPM_BUILD_ROOT%{_bindir}/pdfsam
#!/bin/bash
cd %{_datadir}/%{name}
java -jar %{_datadir}/%{name}/pdfsam.jar
EOF

chmod 755 $RPM_BUILD_ROOT%{_bindir}/pdfsam
install -d -m 755 $RPM_BUILD_ROOT%{_datadir}/%{name}/lib
install -m 644 libraries-2/*.jar $RPM_BUILD_ROOT%{_datadir}/%{name}/lib
install -m 644 libraries-ICEpdf/*.jar $RPM_BUILD_ROOT%{_datadir}/%{name}/lib
install -m 644 libraries-jPodRenderer/*.jar $RPM_BUILD_ROOT%{_datadir}/%{name}/lib

mv $RPM_BUILD_ROOT%{_datadir}/%{name}/lib/pdfsam-%{version}.jar $RPM_BUILD_ROOT%{_datadir}/%{name}/
ln -s pdfsam-%{version}.jar $RPM_BUILD_ROOT%{_datadir}/%{name}/pdfsam.jar

rm template-basic-2/*.exe
cp -r template-basic-2/* $RPM_BUILD_ROOT%{_datadir}/%{name}
 
for PLUGIN in mix merge split vcomposer rotate vpagereorder; do
  mv $RPM_BUILD_ROOT%{_datadir}/%{name}/lib/pdfsam-$PLUGIN-*.jar $RPM_BUILD_ROOT%{_datadir}/%{name}/plugins/$PLUGIN
done


%clean
rm -rf "$RPM_BUILD_ROOT"

%files
%defattr(-,root,root)
%{_bindir}/pdfsam
%{_datadir}/%{name}

%changelog



openSUSE Build Service is sponsored by