unofficial mirror of guix-patches@gnu.org 
 help / color / mirror / code / Atom feed
* [bug#56664] [PATCH] gnu: Add qtscrcpy.
@ 2022-07-20 13:20 phodina via Guix-patches via
  2022-07-20 13:48 ` Maxime Devos
  0 siblings, 1 reply; 7+ messages in thread
From: phodina via Guix-patches via @ 2022-07-20 13:20 UTC (permalink / raw)
  To: 56664


[-- Attachment #1.1: Type: text/plain, Size: 370 bytes --]

Hi,

this patch adds support for screen mirroring Android phones on the desktops.

There are 2 remarks:

- The Android part scrcpy-server is prebuild due to Guix not supporting gradle and Android builds. Without this the tool does not work.

-  I've currently hardcoded the x86 architecture in the install phase. Not sure how to make it architecture agnostic.

----
Petr

[-- Attachment #1.2: Type: text/html, Size: 861 bytes --]

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-gnu-Add-qtscrcpy.patch --]
[-- Type: text/x-patch; name=0001-gnu-Add-qtscrcpy.patch, Size: 7071 bytes --]

From 3ec453db1bc1c6b5d75242ae2491f0bd36f5a26a Mon Sep 17 00:00:00 2001
From: Petr Hodina <phodina@protonmail.com>
Date: Tue, 11 Jan 2022 03:14:03 +0100
Subject: [PATCH] gnu: Add qtscrcpy.

* gnu/packages/android.scm (qtscrcpy): New variable.

diff --git a/gnu/packages/android.scm b/gnu/packages/android.scm
index 04dc4b6499..15f96ba294 100644
--- a/gnu/packages/android.scm
+++ b/gnu/packages/android.scm
@@ -11,7 +11,7 @@
 ;;; Copyright © 2019 Ricardo Wurmus <rekado@elephly.net>
 ;;; Copyright © 2020 Sergey Trofimov <sarg@sarg.org.ru>
 ;;; Copyright © 2021 Guillaume Le Vaillant <glv@posteo.net>
-;;; Copyright © 2021 Petr Hodina <phodina@protonmail.com>
+;;; Copyright © 2021, 2022 Petr Hodina <phodina@protonmail.com>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -34,6 +34,7 @@ (define-module (gnu packages android)
   #:use-module (guix gexp)
   #:use-module (guix git-download)
   #:use-module (guix build-system android-ndk)
+  #:use-module (guix build-system cmake)
   #:use-module (guix build-system gnu)
   #:use-module (guix build-system go)
   #:use-module (guix build-system python)
@@ -49,7 +50,9 @@ (define-module (gnu packages android)
   #:use-module (gnu packages image)
   #:use-module (gnu packages java)
   #:use-module (gnu packages linux)
+  #:use-module (gnu packages qt)
   #:use-module (gnu packages pcre)
+  #:use-module (gnu packages pkg-config)
   #:use-module (gnu packages python)
   #:use-module (gnu packages python-crypto)
   #:use-module (gnu packages python-web)
@@ -61,6 +64,7 @@ (define-module (gnu packages android)
   #:use-module (gnu packages time)
   #:use-module (gnu packages tls)
   #:use-module (gnu packages version-control)
+  #:use-module (gnu packages video)
   #:use-module (gnu packages virtualization)
   #:use-module (gnu packages xdisorg)
   #:use-module (gnu packages xml))
@@ -1133,6 +1137,90 @@ (define-public python-miio
 for communicating with Xiaomi smart appliances over miIO and MIoT protocols.")
     (license license:gpl3+)))
 
+(define-public qtscrcpy
+  ;; this tracks the QtScrcpyCore submodule
+  (let ((commit "3004e63935fe8a3e57b91e117a91c1a6aa68ae42")
+        (revision "1"))
+    (package
+      (name "qtscrcpy")
+      (version "2.0.1")
+      (source (origin
+                (method git-fetch)
+                (uri (git-reference
+                      (url "https://github.com/barry-ran/QtScrcpy")
+                      (commit (string-append "v" version))))
+                (file-name (git-file-name name version))
+                (sha256
+                 (base32
+                  "1l3l6z4snzfljzzywf6yxw0fc1c0kkkcw3477rmfkrd7rapwxndl"))))
+      (build-system cmake-build-system)
+      (arguments
+       (list #:tests? #f
+             #:phases #~(modify-phases %standard-phases
+                          (add-after 'unpack 'download-qtscrcpycore
+                            (lambda* _
+                              (copy-recursively (string-append #$(origin
+                                                                   (method
+                                                                    git-fetch)
+                                                                   (uri (git-reference
+                                                                         (url
+                                                                          "https://github.com/barry-ran/QtScrcpyCore")
+                                                                         (commit
+                                                                          commit)))
+                                                                   (file-name (git-file-name
+                                                                               name
+                                                                               version))
+                                                                   (sha256 (base32
+                                                                            "0x57vv1la27m67dgvbll24h7amqmxjs8xik4qyizx5qjxhylw93c")))
+                                                               "/")
+                                                "QtScrcpy/QtScrcpyCore")
+                              (substitute* "QtScrcpy/QtScrcpyCore/CMakeLists.txt"
+                                ((".*/src/third_party/adb/linux/adb.*")
+                                 ""))
+                              (delete-file-recursively
+                               "QtScrcpy/QtScrcpyCore/src/third_party/adb")
+                              (delete-file-recursively
+                               "QtScrcpy/QtScrcpyCore/src/third_party/ffmpeg")))
+                          (add-after 'unpack 'fix-adb-path
+                            (lambda* (#:key inputs #:allow-other-keys)
+                              (substitute* "QtScrcpy/main.cpp"
+                                (("\"\\..*linux/adb")
+                                 (string-append "\""
+                                                (assoc-ref inputs "adb")
+                                                "/bin/adb")))))
+                          (replace 'install
+                            (lambda* (#:key outputs #:allow-other-keys)
+                              (let* ((bin (string-append #$output "/bin"))
+                                     (build (string-append (getenv "PWD")
+                                             "/source/output/x64/RelWithDebInfo"))
+                                     (qtscrcpy (string-append build
+                                                              "/QtScrcpy"))
+                                     (scrcpy-server (string-append build
+                                                     "/scrcpy-server"))
+                                     (config (string-append #$output
+                                                            "/etc/qtscrcpy"))
+                                     (ini (string-append (getenv "PWD")
+                                           "/source/config/config.ini")))
+                                (mkdir-p bin)
+                                (mkdir-p config)
+                                (install-file qtscrcpy bin)
+                                (install-file scrcpy-server bin)
+                                (install-file ini config)))))))
+      (native-inputs (list qttools pkg-config))
+      (inputs (list adb
+                    ffmpeg
+                    qtx11extras
+                    qtmultimedia
+                    qtbase-5
+                    zlib))
+      (synopsis "Android real-time display control software")
+      (description
+       "This package provides QtScrcpy which connects to Android
+devices via USB (or via TCP/IP) for display and control.  It does NOT require
+the root privileges.  Supports up to 16 Android device connections at the same time.")
+      (home-page "https://github.com/DanielOgorchock/joycond")
+      (license license:asl2.0))))
+
 (define-public fdroidserver
   (package
     (name "fdroidserver")
-- 
2.37.0


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [bug#56664] [PATCH] gnu: Add qtscrcpy.
  2022-07-20 13:20 [bug#56664] [PATCH] gnu: Add qtscrcpy phodina via Guix-patches via
@ 2022-07-20 13:48 ` Maxime Devos
  2022-07-20 15:03   ` phodina via Guix-patches via
  0 siblings, 1 reply; 7+ messages in thread
From: Maxime Devos @ 2022-07-20 13:48 UTC (permalink / raw)
  To: phodina, 56664


[-- Attachment #1.1.1.1: Type: text/plain, Size: 1422 bytes --]


On 20-07-2022 15:20, phodina via Guix-patches via wrote:
> Hi,
>
> this patch adds support for screen mirroring Android phones on the 
> desktops.
>
> There are 2 remarks:
>
>  1. The Android part scrcpy-server is prebuild due to Guix not
>     supporting gradle and Android builds. Without this the tool does
>     not work.
>
OK, though then this is a draft patch that's blocked by supporting 
gradle and Android; Guix is a build-from-source distro (there are some 
bootstrap seeds, but the idea is to reduce them, not enlarge them).

Someone else has been looking into supporting Android (something about a 
longsoon-build-system), maybe you can test that, and I don't know if 
anyone has been looking at addressing the gradle problems.

Also, from a cursory look, I'm not seeing gradle there and neither am I 
seeing Android builds, maybe all that's needed is adding the adb package 
(which is packaged in Guix), no gradle or Android support needed, or I 
didn't look in the right places?

>  I've currently hardcoded the x86 architecture in the install phase. 
> Not sure how to make it architecture agnostic.

When building from source this is usually automatic, though I don't know 
if this applies to Gradle.

Also, why are tests disabled?

> NOT require

We are not restricted to plain text in descriptions, you can use Texinfo 
markup like @emph.

Greetings,
Maxime.


[-- Attachment #1.1.1.2: Type: text/html, Size: 2545 bytes --]

[-- Attachment #1.1.2: OpenPGP public key --]
[-- Type: application/pgp-keys, Size: 929 bytes --]

[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 236 bytes --]

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [bug#56664] [PATCH] gnu: Add qtscrcpy.
  2022-07-20 13:48 ` Maxime Devos
@ 2022-07-20 15:03   ` phodina via Guix-patches via
  2022-07-20 15:10     ` Maxime Devos
  2022-07-20 15:17     ` Maxime Devos
  0 siblings, 2 replies; 7+ messages in thread
From: phodina via Guix-patches via @ 2022-07-20 15:03 UTC (permalink / raw)
  To: Maxime Devos; +Cc: 56664, Julien Lepiller

[-- Attachment #1: Type: text/plain, Size: 2200 bytes --]

Hi Maxime,

> - The Android part scrcpy-server is prebuild due to Guix not supporting gradle and Android builds. Without this the tool does not work.
>
> OK, though then this is a draft patch that's blocked by supporting gradle and Android; Guix is a build-from-source distro (there are some bootstrap seeds, but the idea is to reduce them, not enlarge them).

I understand that the aim is to reduce the prebuild stuff not vice versa that's why I labeled it here. One solution could be to replace the location by specifying some env variable and the user would supply either the prebuild version from the repo or build it themself e.g. in Docker.

This way the package would not have any prebuild files. Would that be okay?

> Someone else has been looking into supporting Android (something about a longsoon-build-system), maybe you can test that, and I don't know if anyone has been looking at addressing the gradle problems.

Do you mean the work of Julien Lepiller [1]?

> Also, from a cursory look, I'm not seeing gradle there and neither am I seeing Android builds, maybe all that's needed is adding the adb package (which is packaged in Guix), no gradle or Android support needed, or I didn't look in the right places?

Android sources are located under the directory server [2]. There's also meson build file but it will still need Android build environment to create the executable out of the java files.

> I've currently hardcoded the x86 architecture in the install phase. Not sure how to make it architecture agnostic.

Here I'm refering to the CMake which places the output in 'output/x86/...' directory. Unfortunately the CMakeLists.txt does not specify how to install the files so it has to be done manually.

Could you suggest some package which I could use as an example to write Guile code that will make it independent of the machine arch?

> Also, why are tests disabled?

Haven't found any. Will add note about no test suite.

> We are not restricted to plain text in descriptions, you can use Texinfo markup like @emph.

Thanks, will use more the markup :-)

[1] https://framagit.org/tyreunom/guix-android
[2] https://github.com/barry-ran/QtScrcpy/tree/v2.0.1/server

----
Petr

[-- Attachment #2: Type: text/html, Size: 5365 bytes --]

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [bug#56664] [PATCH] gnu: Add qtscrcpy.
  2022-07-20 15:03   ` phodina via Guix-patches via
@ 2022-07-20 15:10     ` Maxime Devos
  2022-07-20 15:18       ` Maxime Devos
  2022-07-20 15:17     ` Maxime Devos
  1 sibling, 1 reply; 7+ messages in thread
From: Maxime Devos @ 2022-07-20 15:10 UTC (permalink / raw)
  To: phodina; +Cc: 56664, Julien Lepiller


[-- Attachment #1.1.1: Type: text/plain, Size: 455 bytes --]

On 20-07-2022 17:03, phodina wrote:

> Could you suggest some package which I could use as an example to 
> write Guile code that will make it independent of the machine arch?

Maybe look for target-x86-64?, target-aarch64?, etc, and do something 
like #$(cond ((target-x86-32?) "x86") ...).

As an example, maybe openssl, though it's not ideal given that it does 
string-prefix? and not target-specific subdirectories.

Greetings,
Maxime.


[-- Attachment #1.1.2: OpenPGP public key --]
[-- Type: application/pgp-keys, Size: 929 bytes --]

[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 236 bytes --]

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [bug#56664] [PATCH] gnu: Add qtscrcpy.
  2022-07-20 15:03   ` phodina via Guix-patches via
  2022-07-20 15:10     ` Maxime Devos
@ 2022-07-20 15:17     ` Maxime Devos
  2022-07-20 15:32       ` phodina via Guix-patches via
  1 sibling, 1 reply; 7+ messages in thread
From: Maxime Devos @ 2022-07-20 15:17 UTC (permalink / raw)
  To: phodina; +Cc: 56664, Julien Lepiller


[-- Attachment #1.1.1.1: Type: text/plain, Size: 1472 bytes --]


On 20-07-2022 17:03, phodina wrote:
>
>     OK, though then this is a draft patch that's blocked by supporting
>     gradle and Android; Guix is a build-from-source distro (there are
>     some bootstrap seeds, but the idea is to reduce them, not enlarge
>     them).
>
> I understand that the aim is to reduce the prebuild stuff not vice 
> versa that's why I labeled it here. One solution could be to replace 
> the location by specifying some env variable and the user would supply 
> either the prebuild version from the repo or build it themself e.g. in 
> Docker.
>
> This way the package would not have any prebuild files. Would that be 
> okay?
>
The package would not have prebuild files, but the user will have to 
download some prebuild files anyway, so effectively the problem of 
prebuild files remains (the user has to trust some random download 
location to have an unbackdoored binary, that they can not inspect, and 
while they can modify the source code, it's useless because they can't 
compile it; Guix cannot exercise freedom 1).

Also, one of the primary tasks of a package manager is to keep track of 
dependencies, automatically installing the (non-optional) dependencies, 
which seems incompatible with telling a user to grab a dependency from 
outside the package manager.

As such, I believe this not to be okay, and that it is required to make 
gradle & Android things functional first.

Greetings,
Maxime.


[-- Attachment #1.1.1.2: Type: text/html, Size: 2400 bytes --]

[-- Attachment #1.1.2: OpenPGP public key --]
[-- Type: application/pgp-keys, Size: 929 bytes --]

[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 236 bytes --]

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [bug#56664] [PATCH] gnu: Add qtscrcpy.
  2022-07-20 15:10     ` Maxime Devos
@ 2022-07-20 15:18       ` Maxime Devos
  0 siblings, 0 replies; 7+ messages in thread
From: Maxime Devos @ 2022-07-20 15:18 UTC (permalink / raw)
  To: phodina; +Cc: 56664, Julien Lepiller


[-- Attachment #1.1.1: Type: text/plain, Size: 557 bytes --]


On 20-07-2022 17:10, Maxime Devos wrote:
> On 20-07-2022 17:03, phodina wrote:
>
>> Could you suggest some package which I could use as an example to 
>> write Guile code that will make it independent of the machine arch?
>
> Maybe look for target-x86-64?, target-aarch64?, etc, and do something 
> like #$(cond ((target-x86-32?) "x86") ...).
>
> As an example, maybe openssl, though it's not ideal given that it does 
> string-prefix? and not target-specific subdirectories.


IIRC, gcrypt-error (or gnupg-error?) does something similar.


[-- Attachment #1.1.2: OpenPGP public key --]
[-- Type: application/pgp-keys, Size: 929 bytes --]

[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 236 bytes --]

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [bug#56664] [PATCH] gnu: Add qtscrcpy.
  2022-07-20 15:17     ` Maxime Devos
@ 2022-07-20 15:32       ` phodina via Guix-patches via
  0 siblings, 0 replies; 7+ messages in thread
From: phodina via Guix-patches via @ 2022-07-20 15:32 UTC (permalink / raw)
  To: Maxime Devos; +Cc: 56664, Julien Lepiller

[-- Attachment #1: Type: text/plain, Size: 1800 bytes --]

> On 20-07-2022 17:03, phodina wrote:
>
>>> OK, though then this is a draft patch that's blocked by supporting gradle and Android; Guix is a build-from-source distro (there are some bootstrap seeds, but the idea is to reduce them, not enlarge them).
>>
>> I understand that the aim is to reduce the prebuild stuff not vice versa that's why I labeled it here. One solution could be to replace the location by specifying some env variable and the user would supply either the prebuild version from the repo or build it themself e.g. in Docker.
>>
>> This way the package would not have any prebuild files. Would that be okay?
>
> The package would not have prebuild files, but the user will have to download some prebuild files anyway, so effectively the problem of prebuild files remains (the user has to trust some random download location to have an unbackdoored binary, that they can not inspect, and while they can modify the source code, it's useless because they can't compile it; Guix cannot exercise freedom 1).
>
> Also, one of the primary tasks of a package manager is to keep track of dependencies, automatically installing the (non-optional) dependencies, which seems incompatible with telling a user to grab a dependency from outside the package manager.
>
> As such, I believe this not to be okay, and that it is required to make gradle & Android things functional first.

I also don't want to trust unknown sources and prefer to run executables build from sources. That's why I'm interested in Guix.

It's true that the task of the package manager should be to track down dependencies and leaving it to runtime check is reciepe for disaster.

So this package has to be labeled as a draft until Android build system is provided and the server binary can be reproducibly built.

----
Petr

[-- Attachment #2: Type: text/html, Size: 2901 bytes --]

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2022-07-20 15:35 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-07-20 13:20 [bug#56664] [PATCH] gnu: Add qtscrcpy phodina via Guix-patches via
2022-07-20 13:48 ` Maxime Devos
2022-07-20 15:03   ` phodina via Guix-patches via
2022-07-20 15:10     ` Maxime Devos
2022-07-20 15:18       ` Maxime Devos
2022-07-20 15:17     ` Maxime Devos
2022-07-20 15:32       ` phodina via Guix-patches via

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/guix.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).