Package android-tools: Specfile

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
# requires pandoc
%def_enable docs
%global llvm_version 17.0

Name: android-tools
Version: 34.0.4
Release: alt3

Summary: Android Debug CLI tools
License: APL
Group: Development/Tools

Url: https://developer.android.com/studio/releases/platform-tools
# Debian's package: https://salsa.debian.org/android-tools-team/android-platform-tools.git
#
# fetching upstream sources (~/.gitconfig will be temporary backed-up as ~/.gitconfig.get-orig-source):
# PLATFORM_TOOLS_VERSION="34.0.4" DEB_SOURCE="deb" debian/get-orig-source
#
# repo tool is needed, see https://gerrit.googlesource.com/git-repo/+/refs/heads/main/README.md

Source: %name-%version-%release.tar

# Debian core patches
Patch0: Revert-Remove-mips-build.patch
Patch1: Revert-Remove-mips-support-fr.patch
Patch2: Revert-Remove-a-file-we-haven-t-built-since-2013.patch
Patch3: support-mips.patch
Patch4: Revert-Order-events-returned-by-fdevent_epoll.patch
Patch5: Revert-3-Add-rust-demangling.patch
Patch6: stdatomic.patch
Patch7: workaround__builtin_available.patch
Patch8: Nullable.patch
Patch9: unwindstack-porting.patch
Patch10: move-log-file-to-proper-dir.patch
Patch11: Added-missing-headers.patch
Patch12: libusb-header-path.patch
Patch13: throw-exception-on-unknown-os.patch
Patch14: hard-code-build-number.patch
Patch15: stub-out-fastdeploy.patch
Patch16: Implement-const_iterator-operator.patch
Patch17: Update_casting_type.patch
Patch18: typos.patch

# Debian, from boringssl package
Patch100: Revert-Remove-support-for-ppc64le.patch

# LoongArch
Patch3500: boringssl-loongarch64.patch
Patch3501: libunwindstack-loongarch64.patch

%ifarch loongarch64
# XXX: as of LLVM 17 lld supports only a subset of LoongArch relocations.
# Thus lld is unable to use libraries built with GNU ld (including libc).
%def_without lld
%else
%def_with lld
%endif

Requires: udev-android

BuildRequires: clang%{llvm_version} clang%{llvm_version}-support
%if_with lld
BuildRequires: lld%{llvm_version}
%endif
BuildRequires: llvm%{llvm_version}-devel
BuildRequires: libstdc++-devel

BuildRequires: liblzma-devel
BuildRequires: zlib-devel libselinux-devel
BuildRequires: libusb-devel libgtest-devel libsafe-iop-devel
BuildRequires: libunwind-devel
BuildRequires: protobuf-compiler libprotobuf-devel
BuildRequires: squashfuse-devel
BuildRequires: libbrotli-devel
BuildRequires: liblz4-devel
BuildRequires: libzstd-devel
BuildRequires: libpng-devel

%if_enabled docs
BuildRequires: pandoc
%endif

BuildRequires: rpm-build-python3

%description
This package contains following utilities:

Android Debug Bridge (adb) -- it is a versatile command line tool, which lets
you communicate with an emulator instance or connected Android-powered device.

fastboot -- a command line tool for flashing an Android device, boot an Android
device to fastboot mode, etc.

mkbootimg -- creates Android boot images that includes kernel image and ramdisk,
in a special format which can be used with fastboot.

Command line tools to create sparse images for usage with Android devices.
Includes sim2img, img2simg, simg2simg and append2simg tools.

etc1tool -- a command line utility that lets you encode PNG images to the ETC1
compression standard and decode ETC1 compressed images back to PNG. It is part
of the Android SDK for working with media files for game apps. The standard for
the ETC1 texture format is here:
http://www.khronos.org/registry/gles/extensions/OES/OES_compressed_ETC1_RGB8_texture.txt

hprof-conv -- converts the HPROF file that is generated by the Android SDK tools
to a standard format so you can view the file in a profiling tool of your
choice.

%prep
%setup
# applying Debian patches
%patch0 -p1
%patch1 -p1
%patch2 -p1
%patch3 -p1
%patch4 -p1
%patch5 -p1
%patch6 -p1
%patch7 -p1
%patch8 -p1
%patch9 -p1
%patch10 -p1
%patch11 -p1
%patch12 -p1
%patch13 -p1
%patch14 -p1
%patch15 -p1
%patch16 -p1
%patch17 -p1
%patch18 -p1

pushd external/boringssl
%patch100 -p1
popd
%patch3500 -p1
%patch3501 -p1

rm -rf development/[a-s]* development/v* development/testrunner

for proto in packages/modules/adb/fastdeploy/proto packages/modules/adb/proto; do
		(cd $proto && find . -name '*.proto' -printf 'Regenerate %%p\n' -exec protoc --cpp_out=. {} \;)
done

%build

%if_with lld
# XXX: only LLD supports thin LTO
%define optflags_lto -flto=thin
%else
%define optflags_lto %nil
%endif

%add_optflags %optflags_shared

%define makefilesdir %_builddir/%name-%version/debian/makefiles
%define outbindir %_builddir/%name-%version/out_bin
%define outlibdir %_builddir/%name-%version/out_lib
%define outmandir %_builddir/%name-%version/out_man

%define aprefix %_libdir/android

case %_arch in
    "aarch64")
        DEB_HOST_ARCH="arm64"
        ;;
    "armh")
        DEB_HOST_ARCH="armhf"
        ;;
    "i586")
        DEB_HOST_ARCH="i386"
        ;;
    "x86_64")
        DEB_HOST_ARCH="amd64"
        ;;
    "ppc64le")
        DEB_HOST_ARCH="ppc64el"
        ;;
    "mipsel")
        DEB_HOST_ARCH="mipsel"
        ;;
    "loongarch64")
        DEB_HOST_ARCH="loong64"
        ;;
    *)
        false
        ;;
esac

CC="clang"
CXX="clang++"

CFLAGS+=" %optflags -std=gnu17 -gdwarf-4"

CPPFLAGS+=" %optflags -DNDEBUG -UDEBUG -fmessage-length=0 -fno-exceptions"
CPPFLAGS+=" -fno-strict-aliasing -no-canonical-prefixes"
CPPFLAGS+=" -Wno-c99-designator -Wno-gnu-designator -Wno-gnu-folding-constant"
CPPFLAGS+=" $(getconf LFS_CFLAGS)"

CXXFLAGS+=" -std=gnu++2a -gdwarf-4"
%if_with lld
LDFLAGS+=" -fuse-ld=lld"
%endif

LDFLAGS+=" -Wl,--build-id=sha1 -Wl,-rpath,%aprefix/lib -L%outlibdir"

export LLVM_LIBDIR=`llvm-config --libdir`
export CLANG_MAJVER=`echo %llvm_version | cut -d. -f1`
export CLANG_INCDIR="${LLVM_LIBDIR}/clang/${CLANG_MAJVER}/include/"

CXXFLAGS+=" -I${CLANG_INCDIR}" # for stdbool.h and alike
CPPFLAGS+=" -I${CLANG_INCDIR}" # for stddef.h and alike

DEB_VERSION=%version
export CC CXX CFLAGS CPPFLAGS CXXFLAGS LDFLAGS DEB_VERSION DEB_HOST_ARCH

mkdir -p %outbindir
mkdir -p %outlibdir
mkdir -p %outmandir

# building boringssl
pushd external/boringssl
OUT_DIR=%outlibdir MAKEFILES_DIR=%makefilesdir make -j$(nproc) -f %makefilesdir/libcrypto.mk
OUT_DIR=%outlibdir MAKEFILES_DIR=%makefilesdir make -j$(nproc) -f %makefilesdir/libssl.mk
popd

extras_components_libs=" \
        libcpu_features \
        liblzma \
		    libext4_utils \
        libETC1"

core_components_libs=" \
		    liblog \
		    libbase \
		    libcutils \
 		    libbacktrace \
		    libsparse \
		    libutils \
		    libziparchive \
		    libcrypto_utils \
        libnativehelper"

core_simg_tools=" \
		    simg2img \
		    simg2simg \
		    img2simg \
		    append2simg"

core_tools="adb fastboot"

misc_tools="etc1tool hprof-conv"

# building extra libraries
for i in $extras_components_libs; do
    OUT_DIR=%outlibdir make -j$(nproc) -f %makefilesdir/$i.mk
done

# building core libraries
for i in $core_components_libs; do
    OUT_DIR=%outlibdir make -j$(nproc) -f %makefilesdir/$i.mk
done

# libadb requires a bit more variables
OUT_DIR=%outlibdir \
    PLATFORM_TOOLS_VERSION=%version \
    DEB_VERSION=%version-%release \
    make -j$(nproc) -f %makefilesdir/libadb.mk

# building core tools
for i in $core_tools; do
    OUT_DIR=%outbindir \
        OUT_LIBS_DIR=%outlibdir \
        DEB_VERSION=%version-%release \
        PLATFORM_TOOLS_VERSION=%version \
        make -j$(nproc) -f %makefilesdir/$i.mk
done

# simg tools
for i in $core_simg_tools; do
    OUT_DIR=%outbindir \
        make -j$(nproc) -f %makefilesdir/$i.mk
done

# misc tools
for i in $misc_tools; do
    OUT_DIR=%outbindir \
        OUT_LIBS_DIR=%outlibdir \
        make -j$(nproc) -f %makefilesdir/$i.mk
done

# building man pages
%if_enabled docs
for i in adb fastboot etc1tool; do
    pandoc -s -o %outmandir/$i.1 debian/$i.1.md
done
%endif

# do not forget about mkbootimg
cp system/tools/mkbootimg/mkbootimg.py %outbindir/mkbootimg
cp system/tools/mkbootimg/unpack_bootimg.py %outbindir/unpack_bootimg
cp system/tools/mkbootimg/repack_bootimg.py %outbindir/repack_bootimg

%install

mkdir -p %buildroot%_bindir %buildroot%aprefix/bin %buildroot%aprefix/lib %buildroot%_man1dir

for i in adb fastboot mkbootimg unpack_bootimg repack_bootimg; do
    install -pm0755 %outbindir/$i %buildroot%_bindir/$i
done
for i in append2simg img2simg simg2img simg2simg etc1tool hprof-conv; do
    install -pm0755 %outbindir/$i %buildroot%aprefix/bin
done

cp -a %outlibdir/*.so %buildroot%aprefix/lib
cp -a %outlibdir/*.so.* %buildroot%aprefix/lib

for i in adb fastboot etc1tool; do
    install -pm0644 %outmandir/$i.1 %buildroot%_man1dir
done

mkdir -p %buildroot%_sysconfdir/bash_completion.d
for i in adb fastboot; do
    install -pm0644 debian/bash_completion.d/$i %buildroot%_sysconfdir/bash_completion.d
done

%add_findreq_skiplist	%_bindir/mkbootimg
%add_findreq_skiplist	%_bindir/unpack_bootimg
%add_findreq_skiplist	%_bindir/repack_bootimg

%files
%_bindir/*
%_man1dir/*
%_sysconfdir/bash_completion.d/*
%aprefix

%changelog
* Mon Mar 11 2024 Alexey Sheplyakov <asheplyakov@altlinux.org> 34.0.4-alt3
- NMU: fixed FTBFS on LoongArch for real:
  + libunwindstack: implemented AsmGetRegs for LoongArch. Makes ELF symbol
    check happy (and is pointless otherwise).

* Sun Mar 10 2024 Alexey Sheplyakov <asheplyakov@altlinux.org> 34.0.4-alt2
- NMU: fixed FTBFS on LoongArch:
  + boringssl: explain that LoongArch (lp64d) is 64-bit
  + spec: use GNU linker on LoongArch

* Sat Mar 09 2024 Pavel Nakonechnyi <zorg@altlinux.org> 34.0.4-alt1
- Platform 34.0.4
- Built with Clang
- More tools added

* Sun Nov 27 2022 Pavel Nakonechnyi <zorg@altlinux.org> 10.0.0-alt5.r36
- Fix build failure with new Linux kernel headers
  See https://github.com/torvalds/linux/commit/94dfc73e7cf4a31da66b8843f0b9283ddd6b8381
  https://github.com/nmeum/android-tools/issues/74

* Sat Mar 19 2022 Pavel Nakonechnyi <zorg@altlinux.org> 10.0.0-alt4.r36
- remove p7zip from link dependencies: replacing it with llzma (from Debian)

* Sat Oct 16 2021 Pavel Nakonechnyi <zorg@altlinux.org> 10.0.0-alt3.r36
- fix build on the update toolchain
- backport some Debian buildfiles updates

* Mon May 03 2021 Pavel Nakonechnyi <zorg@altlinux.org> 10.0.0-alt2.r36
- add rpm-build-python3 as a build requirement

* Fri Dec 18 2020 Pavel Nakonechnyi <zorg@altlinux.org> 10.0.0-alt1.r36
- updated to 10.0.0_r36
- debian/create-snapshot updated
- Debian patches refreshed
- Debian makefiles refreshed
- Debian 7z includes updated
- f2fs is not used anymore
- ext4* tools are not used anymore
- documentation and bash completion updated
- minor spec cleanup

* Fri Jun 19 2020 Ivan A. Melnikov <iv@altlinux.org> 8.1.0-alt3.r23
- mipsel support

* Sun Oct 06 2019 Pavel Nakonechnyi <zorg@altlinux.org> 8.1.0-alt2.r23
- udev-android added as a requirement (closes #37284)

* Tue Aug 06 2019 Pavel Nakonechnyi <zorg@altlinux.org> 8.1.0-alt1.r23
- updated to 8.1.0_r23

* Sat Jul 06 2019 Gleb F-Malinovskiy <glebfm@altlinux.org> 5.1.1-alt4
- Fixed build on ppc64le (tnx to Hans Boehm for stdatomic patch).

* Tue Sep 04 2018 Pavel Nakonechnyi <zorg@altlinux.org> 5.1.1-alt3
- rebuilt with OpenSSL 1.1.x

* Tue Aug 21 2018 Pavel Nakonechnyi <zorg@altlinux.org> 5.1.1-alt2
- patches to support OpenSSL 1.1.x are enabled
- fixed bash completions installation

* Wed Mar 15 2017 Pavel Nakonechnyi <zorg@altlinux.org> 5.1.1-alt1
- updated to Debian 5.1.1_r38 release

* Tue Jun 04 2013 Sergey Bolshakov <sbolshakov@altlinux.ru> 4.2.2-alt1
- 4.2.2 released

* Mon Mar 04 2013 Sergey Bolshakov <sbolshakov@altlinux.ru> 4.1.1-alt1
- initial