Name:           proguard
Version:        5.3.3
Release:        6
Summary:        Java class file shrinker, optimizer, obfuscator and preverifier
License:        GPLv2+
URL:            https://www.guardsquare.com/en/proguard
Source0:        http://downloads.sourceforge.net/%{name}/%{name}%{version}.tar.gz
BuildRequires:  jpackage-utils java-devel >= 1:1.6.0 ant
Requires:       jpackage-utils java >= 1:1.6.0
BuildArch:      noarch

%description
ProGuard is an open source command-line tool that shrinks,optimizes and obfuscates
java code.It is able to optimize bytecode as well as detect and remove unused instructions. 
ProGuard is distributed as part of the Android SDK and runs when building the application
in release mode.

%package        help
Summary:        Help documentation for %{name}
Requires:       jpackage-utils
Provides:       %{name}-manual = %{version}-%{release}
Obsoletes:      %{name}-manual < %{version}-%{release}

%description help
Help documentation for %{name}.

%package gui
Summary:        GUI for %{name}
BuildRequires:  ImageMagick desktop-file-utils
Requires:       jpackage-utils %{name} = %{version}-%{release}

%description gui
A GUI for %{name}.

%prep
%autosetup -n %{name}%{version} -p1
find -name '*.jar' -exec rm -f '{}' \;
find -name '*.class' -exec rm -f '{}' \;
sed -i '/class-path/I d' src/%{name}/gui/MANIFEST.MF
sed -i '/class-path/I d' src/%{name}/retrace/MANIFEST.MF
convert docs/favicon.ico %{name}.png
cp -p %{name}-0.png %{name}48.png
cp -p %{name}-1.png %{name}32.png
cp -p %{name}-2.png %{name}16.png

%build
cd buildscripts/
ant -Dant.jar=%{_javadir}/ant.jar basic anttask

%install
mkdir -p ${RPM_BUILD_ROOT}%{_javadir}/%{name}/
cp -p lib/%{name}.jar ${RPM_BUILD_ROOT}%{_javadir}/%{name}/%{name}.jar
cp -p lib/%{name}gui.jar ${RPM_BUILD_ROOT}%{_javadir}/%{name}/%{name}gui.jar
cp -p lib/retrace.jar ${RPM_BUILD_ROOT}%{_javadir}/%{name}/retrace.jar

mkdir -p ${RPM_BUILD_ROOT}%{_bindir}
%jpackage_script proguard.ProGuard "" "" proguard proguard true
%jpackage_script proguard.gui.ProGuardGUI "" "" proguard proguard-gui true
%jpackage_script proguard.retrace.ReTrace "" "" proguard proguard-retrace true
install -Dp %{name}48.png ${RPM_BUILD_ROOT}%{_datadir}/icons/hicolor/48x48/apps/%{name}.png
install -Dp %{name}32.png ${RPM_BUILD_ROOT}%{_datadir}/icons/hicolor/32x32/apps/%{name}.png
install -Dp %{name}16.png ${RPM_BUILD_ROOT}%{_datadir}/icons/hicolor/16x16/apps/%{name}.png

%files
%dir %{_javadir}/%{name}
%{_javadir}/%{name}/{proguard.jar,retrace.jar}
%{_bindir}/{proguard,proguard-retrace}

%files help
%doc docs/* README examples/

%files gui
%{_bindir}/%{name}-gui
%{_javadir}/%{name}/proguardgui.jar
%{_datadir}/icons/*/*/apps/*

%changelog
* Tue Mar 10 2020 shijian <shijian16@huawei.com> - 5.3.3-6
- Package init
