File android-tools.spec of Package android-tools

# spec file for package android-tools
# 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

Name:           android-tools
Version:        5.1.1_r8
Release:        0
Summary:        Android platform tools (adb, fastboot)
License:        Apache-2.0 and BSD-3-Clause
Group:          Hardware/Mobile
# git clone && cd core
# git archive android-%{version} --prefix=core-%{version}/ adb fastboot libzipfile libcutils libmincrypt libsparse mkbootimg include/cutils include/utils include/private include/zipfile include/mincrypt | bzip2 > ../core-%{version}.tar.bz2
# git clone && cd extras
# git archive android-%{version} --prefix=extras-%{version}/ ext4_utils f2fs_utils | bzip2 > ../extras-%{version}.tar.bz2
# git clone && cd libselinux
# git archive android-%{version} --prefix=libselinux-%{version}/ | bzip2 > ../libselinux-%{version}.tar.bz2
# git clone && cd f2fs-tools
# git archive android-%{version} --prefix=f2fs-tools-%{version}/ | bzip2 > ../f2fs-tools-%{version}.tar.bz2
Source0:        core-%{version}.tar.bz2
Source1:        extras-%{version}.tar.bz2
Source2:        libselinux-%{version}.tar.bz2
Source3:        f2fs-tools-%{version}.tar.bz2
Source4:        core-Makefile
Source5:        adb-Makefile
Source6:        fastboot-Makefile
Source7:        51-android.rules
Source8:        abe.jar
Source9:        abe
# PATCh-FIX-OPENSUSE f2fs-tools-implicit-definitions.patch -- fix implicit definition
Patch0:         f2fs-tools-implicit-definitions.patch
BuildRequires:  openssl-devel
BuildRequires:  zlib-devel
BuildRequires:  pkgconfig(libpcre)
BuildRequires:  pkgconfig(udev)
Requires:       libmtp-udev
%{!?_udevrulesdir: %global _udevrulesdir %(pkg-config --variable=udevdir udev)/rules.d }

Android Debug Bridge (adb) is a command-line tool used to communicate with and control
Android device over a USB link from a computer. Fastboot is a command line tool used
to directly flash the filesystem in Android devices from a host via USB.

%package     -n %{name}-udev
Summary:        Udev rules for accessing Android devices
License:        Apache-2.0 and BSD-3-Clause
Group:          Hardware/Mobile
Requires:       udev

%description -n %{name}-udev
This package contains additional udev rules that allow Android Debug Bridge (adb) access to
Android based devices.

Warning! By default adb uses udev rules from libmtp-udev package. This package can conflict
with other udev rules for different devices.

%package     -n %{name}-backup-extractor
Summary:        Java tool to extract Android Backups
License:        Apache-2.0
Group:          Hardware/Mobile
Requires:       java

%description -n %{name}-backup-extractor
This package contains additional Java based tool to extract, pack, or unpack Android Backup
files, usually with the .ab file extension.

%setup -q -a1 -a2 -a3 -n core-%{version}
mv extras-%{version} extras
mv libselinux-%{version} libselinux
mv f2fs-tools-%{version} f2fs-tools
cp -p %{SOURCE4} Makefile
cp -p %{SOURCE5} adb/Makefile
cp -p %{SOURCE6} fastboot/Makefile

make %{?_smp_mflags}

install -d -m 0755 %{buildroot}%{_bindir}
install -D -m 0644 %{SOURCE7} %{buildroot}%{_udevrulesdir}/51-android.rules
install -d -m 0755 %{buildroot}%{_datadir}/%{name}
make install DESTDIR=%{buildroot} BINDIR=%{_bindir}
install -m 0644 %{S:8} %{buildroot}%{_datadir}/%{name}/
install -m 0755 %{S:9} %{buildroot}%{_bindir}/

%post -n %{name}-udev

%doc adb/OVERVIEW.TXT adb/SERVICES.TXT adb/NOTICE adb/protocol.txt

%files -n %{name}-udev

%files -n %{name}-backup-extractor
%attr(0755,root,root) %{_bindir}/abe
%dir %{_datadir}/%{name}/