[PATCH] Add python-pmbootstrap

OpenSubmitted by phodina.
Details
3 participants
  • Sarah Morgensen
  • Maxim Cournoyer
  • phodina
Owner
unassigned
Severity
normal
P
P
phodina wrote on 15 Jul 2021 18:31
(name . guix-patches@gnu.org)(address . guix-patches@gnu.org)
MdOBhls2XZW2lUHnTteaeKJhRlGDu5cpCrPs5rWv5Xfg9FITtzxhWXdUj2AKsw5Phn0mT6MhFizWNJTtXX376A8UXSJT2MtYkU0eYo3_i3U=@protonmail.com
---
index d8c3fbec07..0ccd115416 100644
--- a/gnu/packages/python-xyz.scm
+++ b/gnu/packages/python-xyz.scm
@@ -985,6 +985,31 @@ and URL-safe UUIDs. UUIDs are generated using the built-in Python @code{uuid}
module and then similar looking characters are removed.")
(license license:bsd-3)))

+(define-public python-pmbootstrap
+ (package
+ (name "python-pmbootstrap")
+ (version "1.32.0")
+ (source
+ (origin
+ (method url-fetch)
+ (uri (pypi-uri "pmbootstrap" version))
+ (sha256
+ (base32
+ "1j796f4wrcdrjd7j9m3w3ziiyqq17kskil9bgy893j6sk73fc5q0"))))
+ (build-system python-build-system)
+ ;; TODO: Running tests fails
+ (arguments
+ '(#:tests? #f))
+ (inputs
+ `(("python-pytest" ,python-pytest) ("python-pyopenssl" ,python-pyopenssl)))
+ (propagated-inputs `(("openssl" ,openssl)))
+ (home-page "https://www.postmarketos.org")
+ (synopsis
+ "A sophisticated chroot / build / flash tool to develop and install postmarketOS")
+ (description
+ "A sophisticated chroot / build / flash tool to develop and install postmarketOS")
+ (license #f)))
+
(define-public python-logwrap
(package
(name "python-logwrap")
--
2.31.1
P
P
phodina wrote on 18 Jul 2021 12:35
(name . guix-patches@gnu.org)(address . guix-patches@gnu.org)
ccA3RW4itpcr2ag2aMUShdcr-bBr_vWmOMN5cToA0QccaCYXpENB9_tIrCpWwdMfVUxd2DAZQsyCKReV7oUj2Ts7XpjG4vkeZ2oCTanNcTU=@protonmail.com
Here's updated patch with better package description:

---
index d8c3fbec07..a59d065efa 100644
--- a/gnu/packages/python-xyz.scm
+++ b/gnu/packages/python-xyz.scm
@@ -985,6 +985,44 @@ and URL-safe UUIDs. UUIDs are generated using the built-in Python @code{uuid}
module and then similar looking characters are removed.")
(license license:bsd-3)))

+(define-public python-pmbootstrap
+ (package
+ (name "python-pmbootstrap")
+ (version "1.32.0")
+ (source
+ (origin
+ (method url-fetch)
+ (uri (pypi-uri "pmbootstrap" version))
+ (sha256
+ (base32
+ "1j796f4wrcdrjd7j9m3w3ziiyqq17kskil9bgy893j6sk73fc5q0"))))
+ (build-system python-build-system)
+ ;; TODO: Running tests fails
+ (arguments
+ '(#:tests? #f))
+ (inputs
+ `(("python-pytest" ,python-pytest) ("python-pyopenssl" ,python-pyopenssl)))
+ (propagated-inputs `(("openssl" ,openssl)))
+ (home-page "https://www.postmarketos.org")
+ (synopsis
+ "A sophisticated chroot / build / flash tool to develop and install
+postmarketOS")
+ (description
+ "Bootstrap program that abstracts everything in chroots and therefore
+basically runs on top of any Linux distribution. Features:
+@enumerate
+@item chroot setup (distro-independent QEMU user emulation
+@item clean chroot shutdown (umount) and zapping
+@item build software as packages
+@item cross-compile all armhf-packages
+@item effective caching out of the box (survives chroot zaps)
+@item installation targets
+@item flasher abstractions
+@item logging
+@item security
+@end enumerate")
+ (license #f)))
+
(define-public python-logwrap
(package
(name "python-logwrap")
--
2.31.1
S
S
Sarah Morgensen wrote on 22 Jul 2021 04:18
Re: bug#49577: [PATCH] Add python-pmbootstrap
(name . phodina)(address . phodina@protonmail.com)(address . 49577@debbugs.gnu.org)
86lf5zrt0a.fsf_-_@mgsn.dev
Hi!

Thanks for the patch. I have some suggestions for this one as well.

phodina <phodina@protonmail.com> writes:

Toggle quote (26 lines)
> Here's updated patch with better package description:
>
> ---
> index d8c3fbec07..a59d065efa 100644
> --- a/gnu/packages/python-xyz.scm
> +++ b/gnu/packages/python-xyz.scm
> @@ -985,6 +985,44 @@ and URL-safe UUIDs. UUIDs are generated using the built-in Python @code{uuid}
> module and then similar looking characters are removed.")
> (license license:bsd-3)))
>
> +(define-public python-pmbootstrap
> + (package
> + (name "python-pmbootstrap")
> + (version "1.32.0")
> + (source
> + (origin
> + (method url-fetch)
> + (uri (pypi-uri "pmbootstrap" version))
> + (sha256
> + (base32
> + "1j796f4wrcdrjd7j9m3w3ziiyqq17kskil9bgy893j6sk73fc5q0"))))
> + (build-system python-build-system)
> + ;; TODO: Running tests fails
> + (arguments
> + '(#:tests? #f))

It is not a good idea to skip tests without knowing why they fail, as
there could be subtle bugs in the program even if it seems to run. In
this case, it seems like the reason they're failing is that the pypi
release strips some directories that are required for testing. Perhaps
try from the git repo?

Toggle quote (3 lines)
> + (inputs
> + `(("python-pytest" ,python-pytest) ("python-pyopenssl" ,python-pyopenssl)))

Typically test packages are put in native-inputs rather than inputs.

Toggle quote (2 lines)
> + (propagated-inputs `(("openssl" ,openssl)))

Is this necessary? If pmbootstrap just uses openssl through pyopenssl,
it shouldn't be necessary.

Toggle quote (20 lines)
> + (home-page "https://www.postmarketos.org")
> + (synopsis
> + "A sophisticated chroot / build / flash tool to develop and install
> +postmarketOS")
> + (description
> + "Bootstrap program that abstracts everything in chroots and therefore
> +basically runs on top of any Linux distribution. Features:
> +@enumerate
> +@item chroot setup (distro-independent QEMU user emulation
> +@item clean chroot shutdown (umount) and zapping
> +@item build software as packages
> +@item cross-compile all armhf-packages
> +@item effective caching out of the box (survives chroot zaps)
> +@item installation targets
> +@item flasher abstractions
> +@item logging
> +@item security
> +@end enumerate")
> + (license #f)))

Please make sure not to skip the license field. It looks like this one
is gpl3.

Toggle quote (7 lines)
> +
> (define-public python-logwrap
> (package
> (name "python-logwrap")
> --
> 2.31.1

--
Sarah
M
M
Maxim Cournoyer wrote on 17 May 21:49 +0200
(name . Sarah Morgensen)(address . iskarian@mgsn.dev)
875ym4hrc7.fsf_-_@gmail.com
Hi phodina,

Sarah Morgensen <iskarian@mgsn.dev> writes:

Toggle quote (76 lines)
> Hi!
>
> Thanks for the patch. I have some suggestions for this one as well.
>
> phodina <phodina@protonmail.com> writes:
>
>> Here's updated patch with better package description:
>>
>> ---
>> index d8c3fbec07..a59d065efa 100644
>> --- a/gnu/packages/python-xyz.scm
>> +++ b/gnu/packages/python-xyz.scm
>> @@ -985,6 +985,44 @@ and URL-safe UUIDs. UUIDs are generated using the built-in Python @code{uuid}
>> module and then similar looking characters are removed.")
>> (license license:bsd-3)))
>>
>> +(define-public python-pmbootstrap
>> + (package
>> + (name "python-pmbootstrap")
>> + (version "1.32.0")
>> + (source
>> + (origin
>> + (method url-fetch)
>> + (uri (pypi-uri "pmbootstrap" version))
>> + (sha256
>> + (base32
>> + "1j796f4wrcdrjd7j9m3w3ziiyqq17kskil9bgy893j6sk73fc5q0"))))
>> + (build-system python-build-system)
>> + ;; TODO: Running tests fails
>> + (arguments
>> + '(#:tests? #f))
>
> It is not a good idea to skip tests without knowing why they fail, as
> there could be subtle bugs in the program even if it seems to run. In
> this case, it seems like the reason they're failing is that the pypi
> release strips some directories that are required for testing. Perhaps
> try from the git repo?
>
>> + (inputs
>> + `(("python-pytest" ,python-pytest) ("python-pyopenssl" ,python-pyopenssl)))
>
> Typically test packages are put in native-inputs rather than inputs.
>
>> + (propagated-inputs `(("openssl" ,openssl)))
>
> Is this necessary? If pmbootstrap just uses openssl through pyopenssl,
> it shouldn't be necessary.
>
>> + (home-page "https://www.postmarketos.org")
>> + (synopsis
>> + "A sophisticated chroot / build / flash tool to develop and install
>> +postmarketOS")
>> + (description
>> + "Bootstrap program that abstracts everything in chroots and therefore
>> +basically runs on top of any Linux distribution. Features:
>> +@enumerate
>> +@item chroot setup (distro-independent QEMU user emulation
>> +@item clean chroot shutdown (umount) and zapping
>> +@item build software as packages
>> +@item cross-compile all armhf-packages
>> +@item effective caching out of the box (survives chroot zaps)
>> +@item installation targets
>> +@item flasher abstractions
>> +@item logging
>> +@item security
>> +@end enumerate")
>> + (license #f)))
>
> Please make sure not to skip the license field. It looks like this one
> is gpl3.
>
>> +
>> (define-public python-logwrap
>> (package
>> (name "python-logwrap")

Gentle ping, since the above comments were 42 weeks ago :-)

Thanks,

Maxim
P
P
phodina wrote on 6 Jun 23:07 +0200
(name . Maxim Cournoyer)(address . maxim.cournoyer@gmail.com)
WUfW-YNF6KwD8sb_18og6t9o-GBvFQTqOqnxuKFHFlPqM1BK0MvOFQoL3roKbItbu4Xk3jZUaWqtRkKHBhN7nhdfmgbbMk6Gw7VzKQBjVTI=@protonmail.com
Hi,

here's an updated version of the patch + 2 more tools around PMOS.

However, there is some issue with the sanity-check phase in pmbootstrap which I disabled as I didn't know how to fix it.

----
Petr
From 45fea1b10467dae4310064112b993037b7f827c3 Mon Sep 17 00:00:00 2001
From: Petr Hodina <phodina@protonmail.com>
Date: Mon, 10 Jan 2022 02:54:17 +0100
Subject: [PATCH 3/3] gnu: Add boot-deploy.

* gnu/packages/android.scm (boot-deploy): New variable.

Toggle diff (57 lines)
diff --git a/gnu/packages/android.scm b/gnu/packages/android.scm
index aa9b0e0fe6..0342e30cef 100644
--- a/gnu/packages/android.scm
+++ b/gnu/packages/android.scm
@@ -46,6 +46,7 @@ (define-module (gnu packages android)
   #:use-module ((guix licenses) #:prefix license:)
   #:use-module (gnu packages)
   #:use-module (gnu packages admin)
+  #:use-module (gnu packages algebra)
   #:use-module (gnu packages base)
   #:use-module (gnu packages bash)
   #:use-module (gnu packages check)
@@ -1023,6 +1024,42 @@ (define-public abootimg
 safest way, on a file image.")
     (license license:gpl2+)))
 
+(define-public boot-deploy
+  (package
+    (name "boot-deploy")
+    (version "0.5")
+    (source (origin
+              (method git-fetch)
+              (uri (git-reference
+                    (url "https://gitlab.com/postmarketOS/boot-deploy")
+                    (commit version)))
+              (file-name (git-file-name name version))
+              (sha256
+               (base32
+                "0vh8gjprsyp4zwmpgasf4gyxclm3yyr32pf39bf218690m86fijq"))))
+    (build-system gnu-build-system)
+    (arguments
+     (list #:phases
+           #~(modify-phases %standard-phases
+               (delete 'configure)
+               (delete 'build)
+               (replace 'check
+                 (lambda* (#:key tests? #:allow-other-keys)
+                   (when tests?
+                     (invoke "bash" "test_boot_deploy_functions.sh"))))
+               (replace 'install
+                 (lambda* _
+                   (install-file "boot-deploy"
+                                 (string-append #$output "/bin")))))))
+    (native-inputs (list bc))
+    (inputs (list bash-minimal))
+    (synopsis "Boot deploy for PostmarketOS devices")
+    (description
+     "This package provides tools to generate and deploy images for
+PostmarketOS devices.")
+    (home-page "https://gitlab.com/postmarketOS/boot-deploy")
+    (license license:gpl3+)))
+
 (define-public python-androguard
   (package
     (name "python-androguard")
-- 
2.35.1
From 604e23fe8f2c624a70bdc26cd829dce539778323 Mon Sep 17 00:00:00 2001
From: Petr Hodina <phodina@protonmail.com>
Date: Sun, 18 Jul 2021 12:33:07 +0200
Subject: [PATCH 1/3] gnu: Add pmbootstrap.

* gnu/packages/python-xyz.scm (pmbootstrap): New variable.

Toggle diff (72 lines)
diff --git a/gnu/packages/python-xyz.scm b/gnu/packages/python-xyz.scm
index 6132019a53..8c33364c40 100644
--- a/gnu/packages/python-xyz.scm
+++ b/gnu/packages/python-xyz.scm
@@ -1178,6 +1178,65 @@ (define-public python-shortuuid
 module and then similar looking characters are removed.")
     (license license:bsd-3)))
 
+(define-public pmbootstrap
+  (package
+    (name "pmbootstrap")
+    (version "1.44.1")
+    (source
+     (origin
+       (method url-fetch)
+       (uri (pypi-uri "pmbootstrap" version))
+       (sha256
+        (base32
+         "0hzfgf085b4h2pmbgfkx25sxq9a27m1l77jx7in48vfv8lihmhzh"))))
+    (build-system python-build-system)
+    (arguments
+     (list #:tests? #f
+       #:phases
+       #~(modify-phases %standard-phases
+         (add-after 'unpack 'replace-programs
+           (lambda* (#:key inputs #:allow-other-keys)
+             (substitute* "pmb/chroot/apk_static.py"
+               (("\"openssl\"") (string-append "\"" #$openssl
+                                               "/bin/openssl\"")))
+             (substitute* "pmb/config/__init__.py"
+               (("\"git\"") (string-append "\"" #$git
+                                           "/bin/git\""))
+               (("\"openssl\"") (string-append "\"" #$openssl
+                                               "/bin/openssl\""))
+               (("\"ps\"") (string-append "\"" #$procps
+                                          "/bin/ps\"")))))
+         (replace 'check
+           (lambda* (#:key tests? #:allow-other-keys)
+                                        ;(add-installed-pythonpath inputs outputs)
+             (when tests?
+               ;; To import pmb_test module
+               (setenv "PYTHONPATH"
+                       (string-append (assoc-ref %outputs "out") "/test/pmb_test:"
+                                      (getenv "PYTHONPATH")))
+               (invoke "pytest" "-vv"))))
+         ;; Circular dependency with pmbootstrap
+         (delete 'sanity-check))))
+    (native-inputs (list python-pytest))
+    (inputs (list git procps openssl))
+    (home-page "https://postmarketos.org")
+    (synopsis "Build and flash tool for postmarketOS")
+    (description
+     "Bootstrap program that abstracts everything in chroots and therefore
+basically runs on top of any Linux distribution.  Features:
+@enumerate
+@item chroot setup (distro-independent QEMU user emulation
+@item clean chroot shutdown (umount) and zapping
+@item build software as packages
+@item cross-compile all armhf-packages
+@item effective caching out of the box (survives chroot zaps)
+@item installation targets
+@item flasher abstractions
+@item logging
+@item security
+@end enumerate")
+    (license license:gpl3+)))
+
 (define-public python-logwrap
   (package
     (name "python-logwrap")
-- 
2.35.1
From 8b1c26dfddf10200dbd72be13322fdd835d257aa Mon Sep 17 00:00:00 2001
From: Petr Hodina <phodina@protonmail.com>
Date: Sun, 9 Jan 2022 19:22:51 +0100
Subject: [PATCH 2/3] gnu: Add pmos-installer.

* gnu/packages/android.scm (pmos-installer): New variable.

Toggle diff (106 lines)
diff --git a/gnu/packages/android.scm b/gnu/packages/android.scm
index 04dc4b6499..aa9b0e0fe6 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.
 ;;;
@@ -32,16 +32,25 @@ (define-module (gnu packages android)
   #:use-module (guix packages)
   #:use-module (guix download)
   #:use-module (guix gexp)
+  #:use-module (guix utils)
+  #:use-module (ice-9 match)
+  #:use-module (srfi srfi-1)
+  #:use-module (srfi srfi-26)
   #:use-module (guix git-download)
   #:use-module (guix build-system android-ndk)
   #:use-module (guix build-system gnu)
   #:use-module (guix build-system go)
   #:use-module (guix build-system python)
+  #:use-module (guix build-system copy)
   #:use-module (guix build-system trivial)
   #:use-module ((guix licenses) #:prefix license:)
   #:use-module (gnu packages)
+  #:use-module (gnu packages admin)
+  #:use-module (gnu packages base)
+  #:use-module (gnu packages bash)
   #:use-module (gnu packages check)
   #:use-module (gnu packages compression)
+  #:use-module (gnu packages cpio)
   #:use-module (gnu packages docker)
   #:use-module (gnu packages gcc)
   #:use-module (gnu packages gnupg)
@@ -1268,3 +1277,64 @@ (define-public enjarify
 applications.  Enjarify can translate the Dalvik bytecode back to equivalent
 Java bytecode, which simplifies the analysis of Android applications.")
     (license license:asl2.0)))
+
+(define-public pmos-installer
+  (package
+    (name "pmos-installer")
+    (version "1.0.0")
+    (source (origin
+              (method git-fetch)
+              (uri (git-reference
+                    (url "https://gitlab.com/sdm845-mainline/pmos-installer")
+                    (recursive? #t)
+                    (commit version)))
+              (file-name (git-file-name name version))
+              (sha256
+               (base32
+                "0lbdk2453bywdibys35zyf1j27a1m11a7q8jvmgjf99v77l9rrbx"))))
+    (build-system copy-build-system)
+    (arguments
+     `(#:install-plan '(("makeinstaller.sh" "bin/makeinstaller.sh") ("initrd"
+                                                                     "initrd"))
+       #:phases
+       (modify-phases %standard-phases
+         (add-after 'install 'wrap-shellscript
+           (lambda* (#:key inputs outputs #:allow-other-keys)
+             (let ((out (assoc-ref outputs "out")))
+               (substitute* (string-append out "/bin/makeinstaller.sh")
+                 ;; Typo in name
+                 ;; https://gitlab.com/sdm845-mainline/pmos-installer/-/issues/5
+                 (("vmlinuz-") "vmlinuz")
+                 ;; Path to initrd
+                 (("\"\\$\\(dirname \"\\$0\"\\)\"") (string-append out)))
+               (wrap-program (string-append out "/bin/makeinstaller.sh")
+                             `("PATH" ":" prefix
+                               ,(append (map (lambda (dir)
+                                               (string-append (assoc-ref
+                                                               inputs dir)
+                                                              "/bin"))
+                                             '("coreutils" "cpio"
+                                               "grep"
+                                               "zip"
+                                               "mkbootimg"
+                                               "pmbootstrap"
+                                               "sudo"
+                                               "sed"
+                                               "util-linux"
+                                               "which")))))))))))
+    (inputs (list bash-minimal
+                  coreutils
+                  pmbootstrap
+                  grep
+                  util-linux
+                  mkbootimg
+                  cpio
+                  zip
+                  sed
+                  which
+                  sudo))
+    (home-page "https://gitlab.com/sdm845-mainline/pmos-installer")
+    (synopsis "Flashable installer for postmarketOS")
+    (description "This package provides a flashable installer for
+        postmarketOS.")
+    (license license:gpl3+)))
-- 
2.35.1
?