File android-tools.spec of Package android-tools

# spec file for package android-tools
# Copyright (c) 2024 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

%define _pyver 3
%if 0%{?sle_version} == 150500 || 0%{?sle_version} == 150600
%define _pyver 311
%if 0%{?sle_version} == 150400
%define _pyver 310

Name:           android-tools
Version:        35.0.1
Release:        0
Summary:        Android platform tools
License:        Apache-2.0 AND MIT
Source2:        man-pages.tar.gz
# PATCH-FIX-OPENSUSE fix-install-completion.patch boo#1185883 -- Simplify completion
Patch0:         fix-install-completion.patch
BuildRequires:  clang
BuildRequires:  cmake >= 3.12
BuildRequires:  go
BuildRequires:  llvm-gold
BuildRequires:  ninja
BuildRequires:  pkgconfig
BuildRequires:  python%{_pyver}
BuildRequires:  pkgconfig(gtest)
BuildRequires:  pkgconfig(libbrotlicommon)
BuildRequires:  pkgconfig(liblz4)
BuildRequires:  pkgconfig(libpcre2-8)
BuildRequires:  pkgconfig(libunwind-generic)
BuildRequires:  pkgconfig(libusb-1.0)
BuildRequires:  pkgconfig(libzstd)
BuildRequires:  pkgconfig(protobuf)
Requires:       android-udev-rules
Suggests:       %{name}-mkbootimg = %{version}
Suggests:       %{name}-partition = %{version}
Provides:       %{name}-python3 = %{version}-%{release}
Obsoletes:      %{name}-python3 < %{version}-%{release}
ExcludeArch:    s390x
%if 0%{?suse_version} <= 1500
BuildRequires:  gcc11-c++

Android SDK Platform-Tools is a component for the Android SDK.
It includes tools that interface with the Android platform.

%package mkbootimg
Summary:        Android boot.img manipulation tools
Requires:       %{name} = %{version}
BuildArch:      noarch

%description mkbootimg
This package contains the Android boot.img manipulation tools.

%package partition
Summary:        Android dynamic partition tools
Requires:       %{name} = %{version}

%description partition
This package contains the Android dynamic partition tools.

%package bash-completion
Summary:        Bash completion for android-tools
BuildRequires:  bash-completion
Requires:       bash-completion
Supplements:    (%{name} and bash-completion)
BuildArch:      noarch

%description bash-completion
Bash command line completion support for android-tools.

%autosetup -a2 -p1

%define __builder ninja
export GOFLAGS="-buildmode=pie -trimpath -ldflags=-buildid="

%cmake \


# fix env-script-interpreter (Leap requires special handling)
%if 0%{?suse_version} <= 1500
%define python3_fix_shebang_path(+abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_-=) \
myargs="%{**}" \
for f in ${myargs}; do \
  [ -f $f ] && sed -i "1s@#\\!.*python.*@#\\!$(realpath %{expand:%{__python%{_pyver}}})@" $f \
%python3_fix_shebang_path %{buildroot}%{_bindir}/*
%python3_fix_shebang_path %{buildroot}%{_datadir}/%{name}/mkbootimg/*
%python3_fix_shebang_path %{buildroot}%{_datadir}/%{name}/mkbootimg/gki/*

# fix non-executable-script
chmod 0755 %{buildroot}%{_datadir}/%{name}/mkbootimg/gki/

# man pages
install -d -m 0755 %{buildroot}%{_mandir}
cp -a man/man1 %{buildroot}%{_mandir}

# call some tools to test python3 compatibility
export PATH=%{buildroot}%{_bindir}:$PATH
avbtool version
mkbootimg --help

%license LICENSE

%files mkbootimg
%license LICENSE
%dir %{_datadir}/%{name}

%files partition
%license LICENSE
%doc vendor/extras/partition_tools/

%files bash-completion

openSUSE Build Service is sponsored by