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 http://bugs.opensuse.org/
#


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
Url:            http://developer.android.com/guide/developing/tools/
# git clone https://android.googlesource.com/platform/system/core.git && 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 https://android.googlesource.com/platform/system/extras.git && cd extras
# git archive android-%{version} --prefix=extras-%{version}/ ext4_utils f2fs_utils | bzip2 > ../extras-%{version}.tar.bz2
#
# git clone https://android.googlesource.com/platform/external/libselinux.git && cd libselinux
# git archive android-%{version} --prefix=libselinux-%{version}/ | bzip2 > ../libselinux-%{version}.tar.bz2
#
# git clone https://android.googlesource.com/platform/external/f2fs-tools.git && cd f2fs-tools
# git archive android-%{version} --prefix=f2fs-tools-%{version}/ | bzip2 > ../f2fs-tools-%{version}.tar.bz2
#
# https://sourceforge.net/projects/adbextractor/
# https://sourceforge.net/projects/adbextractor/files/abe.jar/download
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 }

%description
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.

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

%build
make %{?_smp_mflags}

%install
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
%{?udev_rules_update:%{udev_rules_update}}

%files
%defattr(-,root,root)
%doc adb/OVERVIEW.TXT adb/SERVICES.TXT adb/NOTICE adb/protocol.txt
%{_bindir}/adb
%{_bindir}/fastboot

%files -n %{name}-udev
%defattr(-,root,root)
%{_udevrulesdir}/51-android.rules

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

%changelog