File toybox.spec of Package toybox

#
# spec file for package toybox
#
# Copyright (c) 2022 SUSE LLC
#
# 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 https://bugs.opensuse.org/
#


Name:           toybox
Version:        0.8.8
Release:        0
Summary:        Common Linux command line utilities in a single executable
License:        0BSD
URL:            https://landley.net/%{name}/
Source0:        %{URL}/downloads/%{name}-%{version}.tar.gz
BuildRequires:  gcc >= 4.4
BuildRequires:  glibc-devel-static
BuildRequires:  pkgconfig
BuildRequires:  pkgconfig(libssl)

%description
Toybox combines common Linux command line utilities together into a single
BSD-licensed executable that's simple, small, fast, reasonably
standards-compliant, and powerful enough to turn Android into a development
environment.

%package static
Summary:        Statically linked version of toybox
Conflicts:      %{name}
RemovePathPostfixes: .static
# required for getaddrinfo et.al.
Requires:       glibc

%description static
Statically linked version of toybox.

%package symlinks
Summary:        symlinks for %{name}

%description symlinks
Toybox combines common Linux command line utilities together into a single
BSD-licensed executable that's simple, small, fast, reasonably
standards-compliant, and powerful enough to turn Android into a development
environment.

This package contains compat symlinks.

%prep
%autosetup

%build
%{set_build_flags}
%make_build defconfig
%make_build toybox
# need to hide the binary to protect it from distclean
# ensure that we use the unstripped version to keep debuginfo
mv generated/unstripped/%{name} .%{name}.dyn

%make_build distclean
export CFLAGS="$CFLAGS --static"
%make_build defconfig
%make_build toybox
mv generated/unstripped/%{name} %{name}.static

%install
PREFIX=%{buildroot} %make_install
mv %{name}.static %{buildroot}/bin/%{name}.static
mv .%{name}.dyn %{buildroot}/bin/%{name}

%files
/bin/%{name}

%files static
/bin/%{name}.static

%files symlinks
%license LICENSE
%doc README
/bin/*
/sbin/*
%{_bindir}/*
%{_sbindir}/*
%exclude /bin/%{name}

%changelog
openSUSE Build Service is sponsored by