android.scm 43 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061
  1. ;;; GNU Guix --- Functional package management for GNU
  2. ;;; Copyright © 2012 Stefan Handschuh <handschuh.stefan@googlemail.com>
  3. ;;; Copyright © 2015 Kai-Chung Yan <seamlikok@gmail.com>
  4. ;;; Copyright © 2016, 2020 Marius Bakke <mbakke@fastmail.com>
  5. ;;; Copyright © 2017 Julien Lepiller <julien@lepiller.eu>
  6. ;;; Copyright © 2017 Hartmut Goebel <h.goebel@crazy-compilers.com>
  7. ;;; Copyright © 2017, 2021 Maxim Cournoyer <maxim.cournoyer@gmail.com>
  8. ;;; Copyright © 2018, 2019, 2020 Tobias Geerinckx-Rice <me@tobias.gr>
  9. ;;; Copyright © 2018 Efraim Flashner <efraim@flashner.co.il>
  10. ;;; Copyright © 2019, 2020 Andreas Enge <andreas@enge.fr>
  11. ;;; Copyright © 2019 Ricardo Wurmus <rekado@elephly.net>
  12. ;;; Copyright © 2020 Maxim Cournoyer <maxim.cournoyer@gmail.com>
  13. ;;; Copyright © 2020 Sergey Trofimov <sarg@sarg.org.ru>
  14. ;;; Copyright © 2021 Guillaume Le Vaillant <glv@posteo.net>
  15. ;;;
  16. ;;; This file is part of GNU Guix.
  17. ;;;
  18. ;;; GNU Guix is free software; you can redistribute it and/or modify it
  19. ;;; under the terms of the GNU General Public License as published by
  20. ;;; the Free Software Foundation; either version 3 of the License, or (at
  21. ;;; your option) any later version.
  22. ;;;
  23. ;;; GNU Guix is distributed in the hope that it will be useful, but
  24. ;;; WITHOUT ANY WARRANTY; without even the implied warranty of
  25. ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  26. ;;; GNU General Public License for more details.
  27. ;;;
  28. ;;; You should have received a copy of the GNU General Public License
  29. ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
  30. (define-module (gnu packages android)
  31. #:use-module (guix packages)
  32. #:use-module (guix download)
  33. #:use-module (guix gexp)
  34. #:use-module (guix git-download)
  35. #:use-module (guix build-system android-ndk)
  36. #:use-module (guix build-system gnu)
  37. #:use-module (guix build-system go)
  38. #:use-module (guix build-system python)
  39. #:use-module (guix build-system trivial)
  40. #:use-module ((guix licenses) #:prefix license:)
  41. #:use-module (gnu packages)
  42. #:use-module (gnu packages check)
  43. #:use-module (gnu packages compression)
  44. #:use-module (gnu packages docker)
  45. #:use-module (gnu packages gcc)
  46. #:use-module (gnu packages gnupg)
  47. #:use-module (gnu packages golang)
  48. #:use-module (gnu packages java)
  49. #:use-module (gnu packages linux)
  50. #:use-module (gnu packages pcre)
  51. #:use-module (gnu packages python)
  52. #:use-module (gnu packages python-crypto)
  53. #:use-module (gnu packages python-web)
  54. #:use-module (gnu packages python-xyz)
  55. #:use-module (gnu packages selinux)
  56. #:use-module (gnu packages serialization)
  57. #:use-module (gnu packages ssh)
  58. #:use-module (gnu packages tls)
  59. #:use-module (gnu packages version-control)
  60. #:use-module (gnu packages virtualization)
  61. #:use-module (gnu packages xdisorg)
  62. #:use-module (gnu packages xml))
  63. (define-public android-make-stub
  64. (package
  65. (name "android-make-stub")
  66. (version "0.6.0")
  67. (source
  68. (origin
  69. (method git-fetch)
  70. (uri (git-reference
  71. (url "https://github.com/daym/android-make-stub")
  72. (commit (string-append "v" version))))
  73. (file-name (string-append "android-make-stub-"
  74. version "-checkout"))
  75. (sha256
  76. (base32
  77. "0y1b2x96d37n6f1bp6dcx08bn08zac0cylmbfsx6mf2nahc02fhc"))))
  78. (build-system gnu-build-system)
  79. (arguments
  80. `(#:tests? #f ; None exist.
  81. #:phases
  82. (modify-phases %standard-phases
  83. (delete 'configure)
  84. (delete 'build)
  85. (replace 'install
  86. (lambda* (#:key outputs #:allow-other-keys)
  87. (let* ((out (assoc-ref outputs "out")))
  88. (invoke "make" (string-append "prefix=" out) "install")
  89. #t))))))
  90. (home-page "https://github.com/daym/android-make-stub")
  91. (synopsis "Stubs for the @command{make} system of the Android platform")
  92. (description "@code{android-make-stub} provides stubs for the
  93. @command{make} system of the Android platform. This allows us to
  94. use their packages mostly unmodified in our Android NDK build system.")
  95. (license license:asl2.0)))
  96. (define-public android-googletest
  97. (package (inherit googletest)
  98. (name "android-googletest")
  99. (version "1.8.0")
  100. (source
  101. (origin
  102. (method git-fetch)
  103. (uri (git-reference
  104. (url "https://github.com/google/googletest")
  105. (commit (string-append "release-" version))))
  106. (file-name (git-file-name name version))
  107. (sha256
  108. (base32
  109. "0bjlljmbf8glnd9qjabx73w6pd7ibv43yiyngqvmvgxsabzr8399"))))
  110. (arguments
  111. `(#:configure-flags '("-DBUILD_SHARED_LIBS=ON")
  112. #:phases
  113. (modify-phases %standard-phases
  114. (add-after 'install 'install-host-libraries
  115. (lambda* (#:key outputs #:allow-other-keys)
  116. (let* ((out (assoc-ref outputs "out"))
  117. (lib (string-append out "/lib")))
  118. (symlink "libgtest.so"
  119. (string-append lib "/libgtest_host.so"))
  120. (symlink "libgmock.so"
  121. (string-append lib "/libgmock_host.so"))
  122. #t))))))))
  123. ;; The Makefiles that we add are largely based on the Debian
  124. ;; packages. They are licensed under GPL-2 and have copyright:
  125. ;; 2012, Stefan Handschuh <handschuh.stefan@googlemail.com>
  126. ;; 2015, Kai-Chung Yan <seamlikok@gmail.com>
  127. ;; Big thanks to them for laying the groundwork.
  128. ;; The version tag is consistent between all repositories.
  129. (define-public (android-platform-version) "7.1.2_r36")
  130. (define-public (android-platform-system-core version)
  131. (origin
  132. (method git-fetch)
  133. (uri (git-reference
  134. (url "https://android.googlesource.com/platform/system/core")
  135. (commit (string-append "android-" version))))
  136. (file-name (string-append "android-platform-system-core-"
  137. version "-checkout"))
  138. (sha256
  139. (base32
  140. "1krnc2b9zfkzpdgs1dcbji59nszlx2qr723pg89m52622czc06hg"))
  141. (patches
  142. (search-patches "libbase-use-own-logging.patch"
  143. "libbase-fix-includes.patch"
  144. "libutils-remove-damaging-includes.patch"
  145. "libutils-add-includes.patch"
  146. "adb-add-libraries.patch"
  147. "adb-libssl_11-compatibility.patch"
  148. "libziparchive-add-includes.patch"))))
  149. (define (android-platform-system-extras version)
  150. (origin
  151. (method git-fetch)
  152. (uri (git-reference
  153. (url "https://android.googlesource.com/platform/system/extras")
  154. (commit (string-append "android-" version))))
  155. (file-name (string-append "android-platform-system-extras-"
  156. version "-checkout"))
  157. (sha256
  158. (base32
  159. "18130c23ybqcpgjc5v6f8kdbv2xn39hyiaj17dzldjb9rlwzcyy9"))))
  160. (define (android-platform-bionic version)
  161. (origin
  162. (method git-fetch)
  163. (uri (git-reference
  164. (url "https://android.googlesource.com/platform/bionic")
  165. (commit (string-append "android-" version))))
  166. (file-name (string-append "android-platform-bionic-"
  167. version "-checkout"))
  168. (sha256
  169. (base32
  170. "15r4s20d7vw022f8vrc3jbghmqwdcqzprl7i2bfvdkz8z76wc1ps"))))
  171. (define (android-platform-external version subdirectory checksum)
  172. (origin
  173. (method git-fetch)
  174. (uri (git-reference
  175. (url
  176. (string-append "https://android.googlesource.com/platform/external/"
  177. subdirectory))
  178. (commit (string-append "android-" version))))
  179. (file-name (string-append "android-platform-system-external-" subdirectory "-"
  180. version "-checkout"))
  181. (sha256
  182. (base32
  183. checksum))))
  184. (define-public android-liblog
  185. (package
  186. (name "android-liblog")
  187. (version (android-platform-version))
  188. (source (android-platform-system-core version))
  189. (build-system android-ndk-build-system)
  190. (arguments
  191. `(#:make-flags '("LDLIBS=-lpthread")
  192. #:phases
  193. (modify-phases %standard-phases
  194. (add-after 'unpack 'enter-source
  195. (lambda _ (chdir "liblog") #t))
  196. (add-after 'install 'ldconfig
  197. (lambda* (#:key outputs #:allow-other-keys)
  198. (let ((out (assoc-ref outputs "out")))
  199. (symlink "liblog.so.0" (string-append out "/lib/liblog.so"))
  200. #t)))
  201. (add-after 'install 'install-headers
  202. (lambda* (#:key outputs #:allow-other-keys)
  203. (let ((out (assoc-ref outputs "out")))
  204. (copy-recursively
  205. "../include/log" (string-append out "/include/log"))
  206. ;; For android/log.h, the only header in the android directory.
  207. (copy-recursively
  208. "../include/android" (string-append out "/include/android")))
  209. #t)))))
  210. (home-page "https://developer.android.com/")
  211. (synopsis "Logging library from the Android platform.")
  212. (description "@code{liblog} represents an interface to the volatile Android
  213. Logging system for NDK (Native) applications and libraries and contain
  214. interfaces for either writing or reading logs. The log buffers are divided up
  215. in Main, System, Radio and Events sub-logs.")
  216. (license license:asl2.0)))
  217. (define android-libbase
  218. (package
  219. (name "android-libbase")
  220. (version (android-platform-version))
  221. (source (android-platform-system-core version))
  222. (build-system android-ndk-build-system)
  223. (arguments
  224. `(#:tests? #f ; Test failure: logging.UNIMPLEMENTED
  225. #:phases
  226. (modify-phases %standard-phases
  227. (add-after 'unpack 'enter-source
  228. (lambda _ (chdir "base") #t)))))
  229. (inputs `(("android-liblog" ,android-liblog)))
  230. (home-page "https://developer.android.com/")
  231. (synopsis "Android platform base library")
  232. (description "@code{libbase} is a library in common use by the
  233. various Android core host applications.")
  234. (license license:asl2.0)))
  235. (define-public android-libcutils
  236. (package
  237. (name "android-libcutils")
  238. (version (android-platform-version))
  239. (source (android-platform-system-core version))
  240. (build-system gnu-build-system)
  241. (arguments
  242. `(#:tests? #f ; TODO.
  243. #:phases
  244. (modify-phases %standard-phases
  245. (add-after 'unpack 'enter-source
  246. (lambda _ (chdir "libcutils") #t))
  247. (add-after 'enter-source 'create-Makefile
  248. (lambda _
  249. ;; No useful makefile is shipped, so we create one.
  250. (with-output-to-file "Makefile"
  251. (lambda _
  252. (display
  253. (string-append
  254. "NAME = libcutils\n"
  255. "SOURCES = load_file.o socket_local_client_unix.o"
  256. " socket_loopback_client_unix.o socket_network_client_unix.o"
  257. " socket_loopback_server_unix.o socket_local_server_unix.o"
  258. " sockets_unix.o socket_inaddr_any_server_unix.o"
  259. " sockets.o\n"
  260. "CC = gcc\n"
  261. "CFLAGS += -fPIC\n"
  262. "CXXFLAGS += -fPIC\n"
  263. "CPPFLAGS += -Iinclude -I../include\n"
  264. "LDFLAGS += -shared -Wl,-soname,$(NAME).so.0\n"
  265. "build: $(SOURCES)\n"
  266. " $(CXX) $^ -o $(NAME).so.0 $(CXXFLAGS) $(CPPFLAGS)"
  267. " $(LDFLAGS)\n"))
  268. #t))))
  269. (delete 'configure)
  270. (replace 'install
  271. (lambda* (#:key outputs #:allow-other-keys)
  272. (let* ((out (assoc-ref outputs "out"))
  273. (lib (string-append out "/lib"))
  274. (include (string-append out "/include")))
  275. (install-file "libcutils.so.0" lib)
  276. (with-directory-excursion lib
  277. (symlink "libcutils.so.0" "libcutils.so"))
  278. (copy-recursively "../include/cutils"
  279. (string-append include "/cutils"))
  280. #t))))))
  281. (home-page "https://developer.android.com/")
  282. (synopsis "Android platform c utils library")
  283. (description "@code{libcutils} is a library in common use by the
  284. various Android core host applications.")
  285. (license license:asl2.0)))
  286. (define-public android-libsparse
  287. (package
  288. (name "android-libsparse")
  289. (version (android-platform-version))
  290. (source (android-platform-system-core version))
  291. (build-system android-ndk-build-system)
  292. (arguments
  293. `(#:make-flags '("CFLAGS=-Wno-error"
  294. "CXXFLAGS=-fpermissive -Wno-error")
  295. #:phases
  296. (modify-phases %standard-phases
  297. (add-after 'unpack 'enter-source
  298. (lambda _ (chdir "libsparse") #t)))))
  299. (inputs
  300. `(("zlib" ,zlib)))
  301. (home-page "https://developer.android.com/")
  302. (synopsis "Android platform sparse library")
  303. (description "@code{android-libsparse} is a library in common use by the
  304. various Android core host applications.")
  305. (license license:asl2.0)))
  306. (define-public android-libziparchive
  307. (package
  308. (name "android-libziparchive")
  309. (version (android-platform-version))
  310. (source (android-platform-system-core version))
  311. (build-system android-ndk-build-system)
  312. (arguments
  313. `(#:make-flags '("CFLAGS=-Wno-error"
  314. "CXXFLAGS=-fpermissive -Wno-error")
  315. #:phases
  316. (modify-phases %standard-phases
  317. (add-after 'unpack 'enter-source
  318. (lambda _ (chdir "libziparchive") #t))
  319. (add-before 'check 'setenv
  320. (lambda _
  321. (setenv "ziparchive_tests_host_PARAMS" "--test_data_dir=testdata")
  322. #t))
  323. (add-after 'install 'install-headers
  324. (lambda* (#:key inputs outputs #:allow-other-keys)
  325. (let ((out (assoc-ref outputs "out")))
  326. (copy-recursively "../include/ziparchive"
  327. (string-append out "/include/ziparchive"))
  328. #t))))))
  329. (inputs
  330. `(("zlib" ,zlib)))
  331. (native-inputs
  332. `(("android-libbase" ,android-libbase)
  333. ("android-libutils" ,android-libutils)
  334. ("android-liblog" ,android-liblog)))
  335. (home-page "https://developer.android.com/")
  336. (synopsis "Android platform ZIP library")
  337. (description "@code{android-libziparchive} is a library in common use by the
  338. various Android core host applications.")
  339. (license license:asl2.0)))
  340. (define-public adb
  341. (package
  342. (name "adb")
  343. (version (android-platform-version))
  344. (source (android-platform-system-core version))
  345. (build-system android-ndk-build-system)
  346. (arguments
  347. `(#:tests? #f ; Test failure: sysdeps_poll.fd_count
  348. #:make-flags
  349. ,#~(list
  350. "CFLAGS=-Wno-error"
  351. "CXXFLAGS=-fpermissive -Wno-error -std=gnu++14 -D_Nonnull= -D_Nullable= -I ."
  352. (string-append
  353. "LDFLAGS=-Wl,-rpath=" #$output "/lib "
  354. "-Wl,-rpath=" #$(this-package-input "openssl") "/lib -L ."))
  355. #:phases
  356. (modify-phases %standard-phases
  357. (add-after 'unpack 'enter-source
  358. (lambda _ (chdir "adb") #t))
  359. (add-after 'enter-source 'glibc-compat
  360. (lambda _
  361. ;; Include sysmacros.h for "major" and "minor" in Glibc 2.28.
  362. (substitute* "usb_linux.cpp"
  363. (("#include <sys/types.h>" all)
  364. (string-append all "\n#include <sys/sysmacros.h>\n")))
  365. #t))
  366. (add-after 'enter-source 'make-libs-available
  367. (lambda* (#:key inputs outputs #:allow-other-keys)
  368. (substitute* "Android.mk"
  369. (("libcrypto_static") "libcrypto"))
  370. #t))
  371. (add-after 'install 'install-headers
  372. (lambda* (#:key inputs outputs #:allow-other-keys)
  373. (install-file "diagnose_usb.h" (string-append (assoc-ref outputs "out") "/include"))
  374. #t)))))
  375. (inputs
  376. `(("android-libbase" ,android-libbase)
  377. ("android-libcutils" ,android-libcutils)
  378. ("android-liblog" ,android-liblog)
  379. ("openssl" ,openssl)))
  380. (home-page "https://developer.android.com/studio/command-line/adb.html")
  381. (synopsis "Android Debug Bridge")
  382. (description
  383. "@command{adb} is a versatile command line tool that lets you communicate
  384. with an emulator instance or connected Android device. It facilitates a variety
  385. of device actions, such as installing and debugging apps, and it provides access
  386. to a Unix shell that can run commands on the connected device or emulator.")
  387. (license license:asl2.0)))
  388. (define-public mkbootimg
  389. (package
  390. (name "mkbootimg")
  391. (version (android-platform-version))
  392. (source (origin
  393. (inherit (android-platform-system-core version))))
  394. (build-system python-build-system)
  395. (arguments
  396. `(#:tests? #f
  397. #:phases
  398. (modify-phases %standard-phases
  399. (add-after 'unpack 'enter-source
  400. (lambda _ (chdir "mkbootimg") #t))
  401. (delete 'configure)
  402. (delete 'build)
  403. (replace 'install
  404. (lambda* (#:key outputs #:allow-other-keys)
  405. (let* ((out (assoc-ref outputs "out"))
  406. (bin (string-append out "/bin"))
  407. (include (string-append out "/include")))
  408. (install-file "mkbootimg" bin)
  409. (install-file "bootimg.h" include)
  410. #t))))))
  411. (home-page "https://developer.android.com/studio/command-line/adb.html")
  412. (synopsis "Tool to create Android boot images")
  413. (description "This package provides a tool to create Android Boot
  414. Images.")
  415. (license license:asl2.0)))
  416. (define-public android-safe-iop
  417. (package
  418. (name "android-safe-iop")
  419. (version (android-platform-version))
  420. (source (android-platform-external version "safe-iop"
  421. "1nyyrs463advjhlq8xx1lm37m4g5afv7gy0csxrj7biwwl0v13qw"))
  422. (build-system android-ndk-build-system)
  423. (arguments
  424. `(#:make-flags '("CXXFLAGS=-fpermissive -Wno-error")
  425. #:phases
  426. (modify-phases %standard-phases
  427. (add-before 'build 'patch-host
  428. (lambda _
  429. ;; TODO: Cross-compile.
  430. (substitute* "Android.mk"
  431. (("BUILD_STATIC_LIBRARY") "BUILD_HOST_STATIC_LIBRARY"))
  432. #t)))))
  433. (home-page "https://developer.android.com/")
  434. (synopsis "Safe integers in C")
  435. (description "@code{android-safe-iop} provides a set of functions for
  436. performing and checking safe integer operations. Ensure that integer
  437. operations do not result in silent overflow.")
  438. (license license:bsd-2)))
  439. (define-public android-bionic-uapi
  440. (package
  441. (name "android-bionic-uapi")
  442. (version (android-platform-version))
  443. (source (android-platform-bionic version))
  444. (build-system android-ndk-build-system)
  445. (arguments
  446. `(#:phases
  447. (modify-phases %standard-phases
  448. (add-after 'unpack 'enter-source
  449. (lambda _ (chdir "libc") #t))
  450. (replace 'check
  451. (const #t))
  452. (replace 'build
  453. (const #t))
  454. (replace 'install
  455. (lambda* (#:key outputs #:allow-other-keys)
  456. (let* ((out (assoc-ref outputs "out"))
  457. (out-sys (string-append out "/include/sys")))
  458. (mkdir-p out-sys)
  459. (install-file "include/sys/system_properties.h" out-sys)
  460. (install-file "include/sys/_system_properties.h" out-sys)
  461. (copy-recursively "kernel/uapi" (string-append out "/include"))
  462. #t))))))
  463. (home-page "https://developer.android.com/")
  464. (synopsis "Android Linux API that is safe for user space")
  465. (description "@code{android-bionic-uapi} provides the part of the Linux API
  466. that is safe to use for user space. It also includes
  467. @code{system_properties.h} and @code{_system_properties.h}.")
  468. (license license:asl2.0)))
  469. (define-public android-libselinux
  470. (package
  471. (name "android-libselinux")
  472. (version (android-platform-version))
  473. (source
  474. (android-platform-external version "libselinux"
  475. "13m2q32gzdcs5d0zj1nwasjy1j8vsxsgbjg7m5sa9lfcjaj7nkm7"))
  476. (build-system android-ndk-build-system)
  477. (arguments
  478. ;; See logd/Android.mk for the *_LOG_TAG values.
  479. `(#:make-flags (list (string-append "CFLAGS=-Wno-error "
  480. "-I core/include "
  481. "-I core/libpackagelistparser/include "
  482. "-DAUDITD_LOG_TAG=1003 "
  483. "-DLOGD_LOG_TAG=1004 -D_GNU_SOURCE")
  484. "LDFLAGS=-L . -lpcre")
  485. #:phases
  486. (modify-phases %standard-phases
  487. (add-after 'unpack-core 'patch-HOST
  488. (lambda _
  489. ;; gettid duplicates otherwise.
  490. (substitute* "src/procattr.c"
  491. (("#ifdef HOST") "#ifdef XXX"))
  492. #t)))))
  493. (inputs
  494. `(("openssl" ,openssl)))
  495. (native-inputs
  496. `(("android-bionic-uapi" ,android-bionic-uapi)
  497. ;; pcre is inlined by our package.
  498. ("pcre" ,pcre)))
  499. (home-page "https://developer.android.com/")
  500. (synopsis "Android version of the SELinux libraries and utilities")
  501. (description
  502. "The libselinux library provides an API for SELinux applications to get
  503. and set process and file security contexts, and to obtain security policy
  504. decisions. It is required for any applications that use the SELinux API, and
  505. used by all applications that are SELinux-aware. This package also includes
  506. the core SELinux management utilities.")
  507. (license license:public-domain)))
  508. (define-public android-ext4-utils
  509. (package
  510. (name "android-ext4-utils")
  511. (version (android-platform-version))
  512. (source (android-platform-system-extras version))
  513. (build-system android-ndk-build-system)
  514. (arguments
  515. `(#:make-flags
  516. ,#~(list
  517. (string-append
  518. "CPPFLAGS="
  519. ;"-Wno-error "
  520. "-I " #$(this-package-input "android-libselinux") "/include "
  521. "-I " #$(this-package-input "android-libsparse") "/include "
  522. "-I " #$(this-package-input "android-libcutils") "/include "
  523. "-I " #$(this-package-input "android-liblog") "/include "
  524. "-I ../core/include")
  525. "CFLAGS=-Wno-error"
  526. "install-libext4_utils_host.a"
  527. (string-append "prefix=" #$output))
  528. #:phases
  529. (modify-phases %standard-phases
  530. (add-after 'unpack 'unpack-core
  531. (lambda* (#:key inputs #:allow-other-keys)
  532. (mkdir-p "core")
  533. (copy-recursively (assoc-ref inputs "android-core")
  534. "core")))
  535. (add-after 'unpack-core 'enter-source
  536. (lambda _ (chdir "ext4_utils") #t))
  537. (replace 'install
  538. (lambda* (#:key inputs outputs #:allow-other-keys)
  539. (let ((out (assoc-ref outputs "out")))
  540. (copy-recursively "." (string-append out "/include")))
  541. #t)))))
  542. (inputs
  543. `(("android-libcutils" ,android-libcutils)
  544. ("android-liblog" ,android-liblog)
  545. ("android-libselinux" ,android-libselinux)
  546. ("android-libsparse" ,android-libsparse)
  547. ("zlib" ,zlib)))
  548. (native-inputs
  549. `(("android-core" ,(android-platform-system-core version))))
  550. (home-page "https://developer.android.com/")
  551. (synopsis "Android ext4 file system utilities")
  552. (description "@code{android-ext4-utils} is a library in common use by the
  553. Android core.")
  554. (license license:asl2.0)))
  555. (define-public android-f2fs-utils
  556. (package
  557. (name "android-f2fs-utils")
  558. (version (android-platform-version))
  559. (source (android-platform-system-extras version))
  560. (build-system android-ndk-build-system)
  561. (arguments
  562. `(#:phases
  563. (modify-phases %standard-phases
  564. (add-after 'unpack 'enter-source
  565. (lambda _ (chdir "f2fs_utils") #t))
  566. (add-before 'build 'set-compilation-flags
  567. (lambda _
  568. (setenv "CFLAGS" "-fcommon")))
  569. (add-after 'install 'install-headers
  570. (lambda* (#:key inputs outputs #:allow-other-keys)
  571. (copy-recursively "." (string-append (assoc-ref outputs "out")
  572. "/include"))
  573. #t))
  574. (add-after 'install 'install-shell-scripts
  575. (lambda* (#:key outputs #:allow-other-keys)
  576. (let* ((out (assoc-ref outputs "out"))
  577. (bin (string-append out "/bin")))
  578. (patch-shebang "mkf2fsuserimg.sh")
  579. (substitute* "mkf2fsuserimg.sh"
  580. (("make_f2fs") (string-append bin "/make_f2fs")))
  581. (install-file "mkf2fsuserimg.sh" bin)
  582. #t))))))
  583. (inputs
  584. `(("f2fs-tools" ,f2fs-tools-1.7)
  585. ("android-libselinux" ,android-libselinux)
  586. ("android-libsparse" ,android-libsparse)
  587. ("android-libcutils" ,android-libcutils)
  588. ("zlib" ,zlib)))
  589. (home-page "https://developer.android.com/")
  590. (synopsis "Android f2fs utils")
  591. (description "@code{android-f2fs-utils} is a library in common use by the
  592. Android core. It allows the user to create images for the @code{f2fs} Flash
  593. file system.")
  594. (license license:asl2.0)))
  595. (define-public android-libutils
  596. (package
  597. (name "android-libutils")
  598. (version (android-platform-version))
  599. (source (android-platform-system-core version))
  600. (build-system android-ndk-build-system)
  601. (arguments
  602. `(#:tests? #f ; TODO
  603. #:make-flags '("CXXFLAGS=-std=gnu++11 -Wno-error")
  604. #:phases
  605. (modify-phases %standard-phases
  606. (add-after 'set-paths 'augment-CPLUS_INCLUDE_PATH
  607. (lambda* (#:key inputs #:allow-other-keys)
  608. ;; Hide the default GCC from CPLUS_INCLUDE_PATH to prevent it from
  609. ;; shadowing the version of GCC provided in native-inputs.
  610. (let ((gcc (assoc-ref inputs "gcc")))
  611. (setenv "CPLUS_INCLUDE_PATH"
  612. (string-join
  613. (delete (string-append gcc "/include/c++")
  614. (string-split (getenv "CPLUS_INCLUDE_PATH")
  615. #\:))
  616. ":"))
  617. #t)))
  618. (add-after 'unpack 'enter-source
  619. (lambda _ (chdir "libutils") #t))
  620. (add-after 'install 'install-headers
  621. (lambda* (#:key inputs outputs #:allow-other-keys)
  622. (copy-recursively "../include/utils" (string-append (assoc-ref outputs "out") "/include/utils")))))))
  623. (inputs
  624. `(("android-safe-iop" ,android-safe-iop)
  625. ("android-libcutils" ,android-libcutils)))
  626. (native-inputs
  627. `(("android-bionic-uapi" ,android-bionic-uapi)
  628. ("android-liblog" ,android-liblog)
  629. ("gcc@5" ,gcc-5))) ; XXX: fails to build with GCC 7
  630. (home-page "https://developer.android.com/")
  631. (synopsis "Android utility library")
  632. (description "@code{android-libutils} provides utilities for Android NDK developers.")
  633. (license license:asl2.0)))
  634. (define-public fastboot
  635. (package
  636. (name "fastboot")
  637. (version (android-platform-version))
  638. (source (android-platform-system-core version))
  639. (build-system android-ndk-build-system)
  640. (arguments
  641. `(#:phases
  642. (modify-phases %standard-phases
  643. (add-after 'unpack 'enter-source
  644. (lambda _
  645. (chdir "fastboot")
  646. #t))
  647. (add-after 'enter-source 'patch-source
  648. (lambda _
  649. (substitute* "Android.mk"
  650. (("libext4_utils_host") "libext4_utils_host libselinux libpcre"))
  651. #t))
  652. (replace 'install
  653. (lambda* (#:key outputs #:allow-other-keys)
  654. (let* ((out (assoc-ref outputs "out"))
  655. (lib (string-append out "/lib"))
  656. (bin (string-append out "/bin")))
  657. (install-file "fastboot" bin)
  658. #t))))))
  659. (inputs
  660. `(("adb" ,adb)
  661. ("android-safe-iop" ,android-safe-iop)
  662. ("android-ext4-utils" ,android-ext4-utils)
  663. ("android-f2fs-utils" ,android-f2fs-utils)
  664. ("android-libbase" ,android-libbase)
  665. ("android-libcutils" ,android-libcutils)
  666. ("android-liblog" ,android-liblog)
  667. ("android-libutils" ,android-libutils)
  668. ("android-libsparse" ,android-libsparse)
  669. ("android-libziparchive" ,android-libziparchive)
  670. ("android-libselinux" ,android-libselinux)
  671. ("pcre" ,pcre)
  672. ("mkbootimg" ,mkbootimg)
  673. ("zlib" ,zlib)))
  674. (native-inputs
  675. `(("xz" ,xz)))
  676. (home-page "https://developer.android.com/studio/command-line/")
  677. (synopsis "Android image flasher")
  678. (description
  679. "This package provides @command{fastboot}, a tool to upload file system images to Android devices.")
  680. (license license:asl2.0)))
  681. (define-public android-udev-rules
  682. (package
  683. (name "android-udev-rules")
  684. (version "20200613")
  685. (source
  686. (origin
  687. (method git-fetch)
  688. (uri (git-reference
  689. (url "https://github.com/M0Rf30/android-udev-rules")
  690. (commit version)))
  691. (file-name (git-file-name name version))
  692. (sha256
  693. (base32 "0cf5br8x6iwxc1cifv0i1klw7skgs8hghdx6qlqby68kyqg81bb2"))))
  694. (build-system trivial-build-system)
  695. (native-inputs `(("source" ,source)))
  696. (arguments
  697. '(#:modules ((guix build utils))
  698. #:builder
  699. (begin
  700. (use-modules (guix build utils))
  701. (let ((source (assoc-ref %build-inputs "source")))
  702. (install-file (string-append source "/51-android.rules")
  703. (string-append %output "/lib/udev/rules.d"))
  704. #t))))
  705. (home-page "https://github.com/M0Rf30/android-udev-rules")
  706. (synopsis "udev rules for Android devices")
  707. (description "Provides a set of udev rules to allow using Android devices
  708. with tools such as @command{adb} and @command{fastboot} without root
  709. privileges. This package is intended to be added as a rule to the
  710. @code{udev-service-type} in your @code{operating-system} configuration.
  711. Additionally, an @code{adbusers} group must be defined and your user added to
  712. it.
  713. @emph{Simply installing this package will not have any effect.} It is meant
  714. to be passed to the @code{udev} service.")
  715. (license license:gpl3+)))
  716. (define-public git-repo
  717. (package
  718. (name "git-repo")
  719. (version "2.4.1")
  720. (source
  721. (origin
  722. (method git-fetch)
  723. (uri (git-reference
  724. (url "https://gerrit.googlesource.com/git-repo")
  725. (commit (string-append "v" version))))
  726. (file-name (string-append "git-repo-" version "-checkout"))
  727. (sha256
  728. (base32 "0khg1731927gvin73dcbw1657kbfq4k7agla5rpzqcnwkk5agzg3"))))
  729. (build-system python-build-system)
  730. (arguments
  731. `(#:phases
  732. (modify-phases %standard-phases
  733. (add-before 'build 'set-executable-paths
  734. (lambda* (#:key inputs outputs #:allow-other-keys)
  735. (let* ((out (assoc-ref outputs "out"))
  736. (git (assoc-ref inputs "git"))
  737. (ssh (assoc-ref inputs "ssh")))
  738. (substitute* '("repo" "git_command.py")
  739. (("^GIT = 'git'")
  740. (string-append "GIT = '" git "/bin/git'")))
  741. (substitute* "git_config.py"
  742. ((" command_base = \\['ssh',")
  743. (string-append " command_base = ['" ssh "/bin/ssh',")))
  744. #t)))
  745. (add-before 'build 'do-not-self-update
  746. (lambda* (#:key outputs #:allow-other-keys)
  747. ;; Setting the REPO_MAIN variable to an absolute file name is
  748. ;; enough to have _FindRepo return the store main.py file. The
  749. ;; self update mechanism is activated with the call to _Init() in
  750. ;; main(), so we bypass it.
  751. ;; Ticket requesting upstream to provide a mean to disable the
  752. ;; self update mechanism:
  753. ;; https://bugs.chromium.org/p/gerrit/issues/detail?id=12407.
  754. (let* ((out (assoc-ref outputs "out"))
  755. (repo-main (string-append out "/share/git-repo/main.py")))
  756. (substitute* "repo"
  757. (("^REPO_MAIN = .*")
  758. (format #f "REPO_MAIN = ~s~%" repo-main))
  759. ((" _Init\\(args, gitc_init=\\(cmd ==.*" all)
  760. (string-append "True #" all)))
  761. ;; Prevent repo from trying to git describe its version from
  762. ;; the (disabled) self updated copy.
  763. (substitute* "git_command.py"
  764. (("ver = getattr\\(RepoSourceVersion.*")
  765. (format #f "ver = ~s~%" ,version)))
  766. (substitute* "subcmds/version.py"
  767. (("rp_ver = .*")
  768. (format #f "rp_ver = ~s~%" ,version)))
  769. ;; Prevent repo from adding its (disabled) self update copy to
  770. ;; the list of projects to fetch when using 'repo sync'.
  771. (substitute* "subcmds/sync.py"
  772. (("to_fetch\\.extend\\(all_projects\\).*" all)
  773. (string-append "#" all))
  774. (("self\\._Fetch\\(to_fetch")
  775. "self._Fetch(all_projects")
  776. (("_PostRepoFetch\\(rp, opt\\.repo_verify).*" all)
  777. (string-append "#" all))))))
  778. (delete 'build) ; nothing to build
  779. (add-before 'check 'configure-git
  780. (lambda _
  781. (setenv "HOME" (getcwd))
  782. (invoke "git" "config" "--global" "user.email" "you@example.com")
  783. (invoke "git" "config" "--global" "user.name" "Your Name")))
  784. (replace 'check
  785. (lambda _
  786. (invoke "./run_tests")))
  787. (replace 'install
  788. (lambda* (#:key outputs #:allow-other-keys)
  789. (let* ((out (assoc-ref outputs "out"))
  790. (bin-dir (string-append out "/bin"))
  791. (repo-dir (string-append out "/share/" ,name)))
  792. (mkdir-p bin-dir)
  793. (mkdir-p repo-dir)
  794. (copy-recursively "." repo-dir)
  795. (delete-file-recursively (string-append repo-dir "/tests"))
  796. (symlink (string-append repo-dir "/repo")
  797. (string-append bin-dir "/repo"))
  798. #t))))))
  799. (inputs
  800. ;; TODO: Add git-remote-persistent-https once it is available in guix
  801. `(("git" ,git)
  802. ("ssh" ,openssh)))
  803. (native-inputs
  804. `(("pytest" ,python-pytest)))
  805. (home-page "https://code.google.com/p/git-repo/")
  806. (synopsis "Helps to manage many Git repositories.")
  807. (description "Repo is a tool built on top of Git. Repo helps manage many
  808. Git repositories, does the uploads to revision control systems, and automates
  809. parts of the development workflow. Repo is not meant to replace Git, only to
  810. make it easier to work with Git. The repo command is an executable Python
  811. script that you can put anywhere in your path.")
  812. (license license:asl2.0)))
  813. (define-public abootimg
  814. (package
  815. (name "abootimg")
  816. (version "0.6")
  817. (source
  818. (origin
  819. (method url-fetch)
  820. (uri (string-append "http://http.debian.net/debian/pool/main/a/abootimg/"
  821. "abootimg_" version ".orig.tar.gz"))
  822. (sha256
  823. (base32 "0sfc2k011l1ymv97821w89391gnqdh8pp0haz4sdcm5hx0axv2ba"))))
  824. (build-system gnu-build-system)
  825. (arguments
  826. `(#:tests? #f
  827. #:phases
  828. (modify-phases %standard-phases
  829. (replace 'configure
  830. (lambda _
  831. (setenv "CC" "gcc")
  832. #t))
  833. (replace 'install
  834. (lambda* (#:key outputs #:allow-other-keys)
  835. (let* ((out (assoc-ref outputs "out"))
  836. (bin (string-append out "/bin")))
  837. (install-file "abootimg" bin)
  838. #t))))))
  839. (inputs
  840. `(("libblkid" ,util-linux "lib")))
  841. (home-page "https://ac100.grandou.net/abootimg")
  842. (synopsis "Tool for manipulating Android Boot Images")
  843. (description "This package provides a tool for manipulating old Android
  844. Boot Images. @code{abootimg} can work directly on block devices, or, the
  845. safest way, on a file image.")
  846. (license license:gpl2+)))
  847. (define-public python-androguard
  848. (package
  849. (name "python-androguard")
  850. (version "3.2.1")
  851. (source
  852. (origin
  853. ;; The pypi release doesn't have the tests, but the tests use
  854. ;; packaged binaries, so we skip them.
  855. (method url-fetch)
  856. (uri (pypi-uri "androguard" version))
  857. (sha256
  858. (base32
  859. "0ndsw00pkyda4i2s3wi5ap8gbk6a9d23xhhxpdbk02padv8sxkfv"))))
  860. (build-system python-build-system)
  861. (arguments
  862. '(#:phases
  863. (modify-phases %standard-phases
  864. (replace 'check
  865. ;; Adapted from .travis.yml
  866. (lambda _
  867. (invoke "nosetests" "--with-coverage" "--with-timer"
  868. "--timer-top-n" "50"))))))
  869. (native-inputs
  870. `(("python-codecov" ,python-codecov)
  871. ("python-coverage" ,python-coverage)
  872. ("python-mock" ,python-mock)
  873. ("python-nose" ,python-nose)
  874. ("python-nose-timer" ,python-nose-timer)))
  875. (propagated-inputs
  876. `(("python-asn1crypto" ,python-asn1crypto)
  877. ("python-colorama" ,python-colorama)
  878. ("python-future" ,python-future)
  879. ("python-ipython" ,python-ipython)
  880. ("python-lxml" ,python-lxml)
  881. ("python-matplotlib" ,python-matplotlib)
  882. ("python-networkx" ,python-networkx)
  883. ("python-pygments" ,python-pygments)
  884. ("python-pyperclip" ,python-pyperclip)))
  885. (home-page "https://github.com/androguard/androguard")
  886. (synopsis "Python tool to play with Android files")
  887. (description
  888. "Androguard is a full Python tool to manipulate Android files. It is
  889. useful for reverse engineering, analysis of Android applications and more.")
  890. (license license:asl2.0)))
  891. (define-public fdroidserver
  892. (package
  893. (name "fdroidserver")
  894. (version "1.1.9")
  895. (source
  896. (origin
  897. (method url-fetch)
  898. (uri (pypi-uri "fdroidserver" version))
  899. (sha256
  900. (base32
  901. "0m07f791z45w7r2dzx4yb6s54b3c3wykm3w9hn25p2jcyax082a2"))))
  902. (build-system python-build-system)
  903. (arguments
  904. `(#:phases
  905. (modify-phases %standard-phases
  906. (add-after 'unpack 'fix-versioning
  907. (lambda _
  908. (substitute* "setup.py"
  909. (("0.2.1") ,(package-version python-pyasn1-modules))
  910. ;; The dependency on docker has been removed upstream by
  911. ;; a fairly large patch:
  912. ;; https://gitlab.com/fdroid/fdroidserver/-/commit/89614851250c79a05db84070feca6dea033af334
  913. ;; that is not in a release yet. It appears we can compile with
  914. ;; a newer version.
  915. (("docker-py >= 1.9, < 2.0") "docker >= 1.9"))
  916. #t)))))
  917. (propagated-inputs
  918. `(("python-androguard" ,python-androguard)
  919. ("python-apache-libcloud" ,python-apache-libcloud)
  920. ("python-clint" ,python-clint)
  921. ("python-defusedxml" ,python-defusedxml)
  922. ("python-docker" ,python-docker)
  923. ("python-gitpython" ,python-gitpython)
  924. ("python-mwclient" ,python-mwclient)
  925. ("python-paramiko" ,python-paramiko)
  926. ("python-pillow" ,python-pillow)
  927. ("python-pyasn1" ,python-pyasn1)
  928. ("python-pyasn1-modules" ,python-pyasn1-modules)
  929. ("python-pyyaml" ,python-pyyaml)
  930. ("python-qrcode" ,python-qrcode)
  931. ("python-ruamel.yaml" ,python-ruamel.yaml)
  932. ("python-requests" ,python-requests)
  933. ("python-vagrant" ,python-vagrant)))
  934. (native-inputs
  935. `(("python-babel" ,python-babel)
  936. ("python-bcrypt" ,python-bcrypt)
  937. ("python-docker-pycreds" ,python-docker-pycreds)
  938. ("python-pynacl" ,python-pynacl)
  939. ("python-websocket-client" ,python-websocket-client)))
  940. (home-page "https://f-droid.org")
  941. (synopsis "F-Droid server tools")
  942. (description
  943. "The F-Droid server tools provide various scripts and tools that are used
  944. to maintain F-Droid, the repository of free Android applications. You can use
  945. these same tools to create your own additional or alternative repository for
  946. publishing, or to assist in creating, testing and submitting metadata to the
  947. main repository.")
  948. (license license:agpl3+)))
  949. (define-public fdroidcl
  950. (package
  951. (name "fdroidcl")
  952. (version "0.5.0")
  953. (source (origin
  954. (method git-fetch)
  955. (uri (git-reference
  956. (url "https://github.com/mvdan/fdroidcl")
  957. (commit (string-append "v" version))))
  958. (file-name (git-file-name name version))
  959. (sha256
  960. (base32 "1rxcdyy2j34z0ql9d62w7ivsch9xihjnpb1z9kgy9q46vl8zhhy0"))))
  961. (build-system go-build-system)
  962. (arguments
  963. `(#:import-path "mvdan.cc/fdroidcl"
  964. #:tests? #f ; TODO: Inputs missing.
  965. #:install-source? #f))
  966. (inputs
  967. `(("go-github-com-kr-pretty" ,go-github-com-kr-pretty)))
  968. ;(native-inputs
  969. ; `(("go-github-com-rogpeppe-go-internal-testscript"
  970. ; ,go-github-com-rogpeppe-go-internal-testscript)))
  971. (synopsis "F-Droid desktop client")
  972. (description
  973. "While the Android client integrates with the system with regular update
  974. checks and notifications, this is a simple command line client that talks to
  975. connected devices via ADB.")
  976. (home-page "https://github.com/mvdan/fdroidcl")
  977. (license license:bsd-3)))
  978. (define-public enjarify
  979. (package
  980. (name "enjarify")
  981. (version "1.0.3")
  982. (home-page "https://github.com/Storyyeller/enjarify")
  983. (source
  984. (origin
  985. (method git-fetch)
  986. (uri (git-reference
  987. (url home-page)
  988. (commit version)))
  989. (file-name (git-file-name name version))
  990. (patches
  991. (search-patches "enjarify-setup-py.patch"))
  992. (sha256
  993. (base32
  994. "1nam7h1g4f1h6jla4qcjjagnyvd24dv6d5445w04q8hx07nxdapk"))))
  995. (build-system python-build-system)
  996. (arguments
  997. `(#:phases
  998. (modify-phases %standard-phases
  999. (add-before 'check 'fixup-expected-test-results
  1000. ;; Upstream adjusted this test in commit:
  1001. ;; 3ae884a6485af82d300515813f537685b08dd800
  1002. (lambda _
  1003. (substitute* "tests/test2/expected.txt"
  1004. (("^20") "0"))
  1005. #t))
  1006. (add-before 'check 'drop-java-xss-argument
  1007. ;; Upstream removed this argument in order to support 32-bit
  1008. ;; architectures. commit: 4be0111d879aa95fdc0d9f24fe529f8c664d4093
  1009. (lambda _
  1010. (substitute* "enjarify/runtests.py"
  1011. (("java -Xss515m") "java "))
  1012. #t))
  1013. (add-after 'install 'install-enjarify-wrapper
  1014. (lambda* (#:key outputs #:allow-other-keys)
  1015. (let* ((out (assoc-ref outputs "out")))
  1016. (mkdir-p (string-append out "/bin/"))
  1017. (copy-file "enjarify.sh" (string-append out "/bin/enjarify"))
  1018. #t))))))
  1019. (native-inputs `(("openjdk" ,openjdk12)))
  1020. (synopsis "Translate Dalvik bytecode to equivalent Java bytecode")
  1021. (description "Android applications are Java programs that run on a
  1022. customized virtual machine, which is part of the Android operating system, the
  1023. Dalvik VM. Their bytecode differs from the bytecode of normal Java
  1024. applications. Enjarify can translate the Dalvik bytecode back to equivalent
  1025. Java bytecode, which simplifies the analysis of Android applications.")
  1026. (license license:asl2.0)))