File upx.spec of Package upx

#
# spec file for package upx
#
# Copyright (c) 2017 SUSE LINUX 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:           upx
Version:        3.94
Release:        0
Summary:        The Ultimate Packer for eXecutables
License:        GPL-2.0+
Group:          Development/Tools/Other
Url:            https://upx.github.io/

Source:         https://github.com/upx/upx/releases/download/v%{version}/upx-%{version}-src.tar.xz
Source1:        http://downloads.sf.net/sevenzip/lzma922.tar.bz2
BuildRequires:  gcc-c++
BuildRequires:  libucl1-devel
BuildRequires:  zlib-devel
BuildRoot:      %{_tmppath}/%{name}-%{version}-build
Patch0:         upx-aarch64.patch
Patch1:         upx-endiantests.patch
Patch2:         lzma-x-endian.patch
Patch3:         0001-Protect-against-bad-crafted-input.patch
Patch4:         0002-Protect-against-bad-crafted-input.patch
Patch5:         0001-Mach-o-defend-against-bad-crafted-input.patch

%description
UPX is a free, portable, extendable, high-performance executable packer
for several different executable formats. It achieves an excellent
compression ratio and offers very fast decompression. Your executables
suffer no memory overhead or other drawbacks.

%prep
%setup -q -n %{name}-%{version}-src
%patch0 -p1
%patch1 -p1
mkdir "%_builddir/lzma-x"
pushd "%_builddir/lzma-x"
tar -xf "%{S:1}"
%patch2 -p1
popd
%patch3 -p1
%patch4 -p1
%patch5 -p1

# BSD-4 clause licensed file, remove just in case bnc#753791
rm src/stub/src/i386-dos32.djgpp2-stubify.asm

%build
export UPX_LZMADIR="%{_builddir}/lzma-x"
export UPX_LZMA_VERSION=0x922
export UPX_UCLDIR=%{_prefix}
export CXX=g++
# silly whitespace checker runs over all files and chokes on upx.out
make %{?_smp_mflags} -C src CHECK_WHITESPACE=/bin/true \
	CXXFLAGS_OPTIMIZE="%{optflags} -fvisibility=hidden -fvisibility-inlines-hidden"
make -C doc

%install
install -D -m 0755 src/upx.out %{buildroot}%{_bindir}/upx
install -D -m 0644 doc/upx.1 %{buildroot}%{_mandir}/man1/upx.1

%files
%defattr(-, root, root)
%doc BUGS COPYING LICENSE NEWS PROJECTS README README.SRC THANKS
%doc doc/upx.html
%doc %{_mandir}/man1/*
%{_bindir}/*

%changelog
openSUSE Build Service is sponsored by