all messages for Guix-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* [bug#59845] [PATCH 0/4] Add PMB (Integrated Library System)
@ 2022-12-05 21:48 Yarl Baudig
  2022-12-05 21:52 ` [bug#59845] [PATCH 1/4] gnu: php: Add '--enable-soap' configure option Yarl Baudig
                   ` (3 more replies)
  0 siblings, 4 replies; 17+ messages in thread
From: Yarl Baudig @ 2022-12-05 21:48 UTC (permalink / raw)
  To: 59845; +Cc: Yarl Baudig


Yarl Baudig (4):
  gnu: php: Add '--enable-soap' configure option.
  gnu: Add PMB.
  gnu: Add PMB service.
  doc: Add Integrated Library System section.

 doc/guix.texi        | 128 ++++++++++++++++++++++++++++++++++++++++++-
 gnu/local.mk         |   2 +
 gnu/packages/ils.scm |  61 +++++++++++++++++++++
 gnu/packages/php.scm |   3 +-
 gnu/services/ils.scm | 128 +++++++++++++++++++++++++++++++++++++++++++
 5 files changed, 320 insertions(+), 2 deletions(-)
 create mode 100644 gnu/packages/ils.scm
 create mode 100644 gnu/services/ils.scm


base-commit: c3713d53e0bdf1186e08880b9e0ae6dd85f55fc4
-- 
2.38.1







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

* [bug#59845] [PATCH 1/4] gnu: php: Add '--enable-soap' configure option.
  2022-12-05 21:48 [bug#59845] [PATCH 0/4] Add PMB (Integrated Library System) Yarl Baudig
@ 2022-12-05 21:52 ` Yarl Baudig
  2022-12-05 21:52   ` [bug#59845] [PATCH 2/4] gnu: Add PMB Yarl Baudig
                     ` (2 more replies)
  2022-12-09 11:52 ` [bug#59845] V2 yarl baudig
                   ` (2 subsequent siblings)
  3 siblings, 3 replies; 17+ messages in thread
From: Yarl Baudig @ 2022-12-05 21:52 UTC (permalink / raw)
  To: 59845; +Cc: Yarl Baudig

* gnu/packages/php.scm: Add '--enable-soap' configure option.
---
 gnu/packages/php.scm | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/gnu/packages/php.scm b/gnu/packages/php.scm
index 645a8edee1..9bc4af5092 100644
--- a/gnu/packages/php.scm
+++ b/gnu/packages/php.scm
@@ -134,7 +134,8 @@ (define-public php
                "--enable-intl"
                "--enable-mbstring"
                "--enable-pcntl"
-               "--enable-sockets"))
+               "--enable-sockets"
+	       "--enable-soap"))
        #:phases
        (modify-phases %standard-phases
          (add-after 'unpack 'do-not-record-build-flags
-- 
2.38.1







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

* [bug#59845] [PATCH 2/4] gnu: Add PMB.
  2022-12-05 21:52 ` [bug#59845] [PATCH 1/4] gnu: php: Add '--enable-soap' configure option Yarl Baudig
@ 2022-12-05 21:52   ` Yarl Baudig
  2022-12-05 21:52   ` [bug#59845] [PATCH 3/4] gnu: Add PMB service Yarl Baudig
  2022-12-05 21:52   ` [bug#59845] [PATCH 4/4] doc: Add Integrated Library System section Yarl Baudig
  2 siblings, 0 replies; 17+ messages in thread
From: Yarl Baudig @ 2022-12-05 21:52 UTC (permalink / raw)
  To: 59845; +Cc: Yarl Baudig

* gnu/packages/ils.scm: New file.
* gnu/local.mk: Add it.
---
 gnu/local.mk         |  1 +
 gnu/packages/ils.scm | 61 ++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 62 insertions(+)
 create mode 100644 gnu/packages/ils.scm

diff --git a/gnu/local.mk b/gnu/local.mk
index 1bfbe28bde..ff0c86584a 100644
--- a/gnu/local.mk
+++ b/gnu/local.mk
@@ -323,6 +323,7 @@ GNU_SYSTEM_MODULES =				\
   %D%/packages/icu4c.scm			\
   %D%/packages/idris.scm			\
   %D%/packages/idutils.scm			\
+  %D%/packages/ils.scm				\
   %D%/packages/image.scm			\
   %D%/packages/image-processing.scm	\
   %D%/packages/image-viewers.scm	\
diff --git a/gnu/packages/ils.scm b/gnu/packages/ils.scm
new file mode 100644
index 0000000000..3f3eb0705a
--- /dev/null
+++ b/gnu/packages/ils.scm
@@ -0,0 +1,61 @@
+;;; GNU Guix --- Functional package management for GNU
+;;; Copyright © 2022 Yarl Baudig <yarl-baudig@mailoo.org>
+;;;
+;;; This file is part of GNU Guix.
+;;;
+;;; GNU Guix is free software; you can redistribute it and/or modify it
+;;; under the terms of the GNU General Public License as published by
+;;; the Free Software Foundation; either version 3 of the License, or (at
+;;; your option) any later version.
+;;;
+;;; GNU Guix is distributed in the hope that it will be useful, but
+;;; WITHOUT ANY WARRANTY; without even the implied warranty of
+;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+;;; GNU General Public License for more details.
+;;;
+;;; You should have received a copy of the GNU General Public License
+;;; along with GNU Guix.  If not, see <http://www.gnu.org/licenses/>.
+
+(define-module (gnu packages ils)
+  #:use-module (guix packages)
+  #:use-module (guix download)
+  #:use-module (guix build-system copy)
+  #:use-module (guix licenses)
+  #:use-module (gnu packages gawk)
+  #:use-module (gnu packages compression)
+  #:use-module (gnu packages php)
+  #:use-module (gnu packages perl))
+
+;;; Commentary
+;;;
+;;; Integrated Library Systems packages.
+;;;
+;;; Code
+
+(define-public pmb
+  (package
+   (name "pmb")
+   (version "7.4.6")
+   (source (origin
+            (method url-fetch)
+            (uri
+	     (string-append
+	      "https://forge.sigb.net/attachments/download/3968/pmb"
+	      version
+              ".zip"))
+            (sha256
+             (base32
+              "0ana1w8d60n2gznhh1zyjdld4xi4p2pm2hc05m8n7fh2bvlmw0cr"))))
+   (build-system copy-build-system)
+   (arguments '(#:install-plan '(("." "share/http/pmb"))))
+   (native-inputs (list unzip))
+   (propagated-inputs (list php perl))
+   (synopsis "Integrated Library System")
+   (description "PMB is an Integrated Library System for librarians, documentalists and
+information managers.
+
+This contains only the PMB archive (html, php and css files), you will need a web
+server, php and a SQL database server. See the guix pmb service.")
+   (home-page "https://www.sigb.net")
+   (license cecill)))
+
-- 
2.38.1







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

* [bug#59845] [PATCH 3/4] gnu: Add PMB service.
  2022-12-05 21:52 ` [bug#59845] [PATCH 1/4] gnu: php: Add '--enable-soap' configure option Yarl Baudig
  2022-12-05 21:52   ` [bug#59845] [PATCH 2/4] gnu: Add PMB Yarl Baudig
@ 2022-12-05 21:52   ` Yarl Baudig
  2022-12-05 21:52   ` [bug#59845] [PATCH 4/4] doc: Add Integrated Library System section Yarl Baudig
  2 siblings, 0 replies; 17+ messages in thread
From: Yarl Baudig @ 2022-12-05 21:52 UTC (permalink / raw)
  To: 59845; +Cc: Yarl Baudig

* gnu/services/ils.scm: New file.
* gnu/local.mk: Add it.
---
 gnu/local.mk         |   1 +
 gnu/services/ils.scm | 128 +++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 129 insertions(+)
 create mode 100644 gnu/services/ils.scm

diff --git a/gnu/local.mk b/gnu/local.mk
index ff0c86584a..16de11e31e 100644
--- a/gnu/local.mk
+++ b/gnu/local.mk
@@ -670,6 +670,7 @@ GNU_SYSTEM_MODULES =				\
   %D%/services/getmail.scm				\
   %D%/services/guix.scm			\
   %D%/services/hurd.scm				\
+  %D%/services/ils.scm				\
   %D%/services/kerberos.scm			\
   %D%/services/lightdm.scm      		\
   %D%/services/linux.scm			\
diff --git a/gnu/services/ils.scm b/gnu/services/ils.scm
new file mode 100644
index 0000000000..16c0dbab22
--- /dev/null
+++ b/gnu/services/ils.scm
@@ -0,0 +1,128 @@
+;;; GNU Guix --- Functional package management for GNU
+;;; Copyright © 2022 Yarl Baudig <yarl-baudig@mailoo.org>
+;;;
+;;; This file is part of GNU Guix.
+;;;
+;;; GNU Guix is free software; you can redistribute it and/or modify it
+;;; under the terms of the GNU General Public License as published by
+;;; the Free Software Foundation; either version 3 of the License, or (at
+;;; your option) any later version.
+;;;
+;;; GNU Guix is distributed in the hope that it will be useful, but
+;;; WITHOUT ANY WARRANTY; without even the implied warranty of
+;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+;;; GNU General Public License for more details.
+;;;
+;;; You should have received a copy of the GNU General Public License
+;;; along with GNU Guix.  If not, see <http://www.gnu.org/licenses/>.
+
+(define-module (gnu services ils)
+  #:use-module (gnu services)
+  #:use-module (gnu services web)
+  #:use-module (gnu packages ils)
+  #:use-module (guix records)
+  #:use-module (guix utils)
+  #:use-module (guix gexp)
+  #:use-module (ice-9 match)
+  #:use-module (ice-9 format)
+  #:export (pmb-configuration
+	    pmb-service-type
+	    %default-nginx-pmb-location
+	    %default-pmb-php-fpm-configuration
+	    %default-pmb-mysql-configuration-extra-content))
+
+;;; Commentary
+;;;
+;;; Integrated Library Systems services.
+;;;
+;;; Code
+
+(define %default-nginx-pmb-location
+  (let ((base (nginx-php-location)))
+    (nginx-location-configuration
+     (inherit base)
+     (body (cons
+	    "fastcgi_read_timeout 300;"
+	    (nginx-location-configuration-body base))))))
+
+(define %default-pmb-php-fpm-configuration
+  "expose_php=off
+max_execution_time=300
+max_input_vars=50000
+memory_limit=256M
+post_max_size=64M
+upload_max_filesize=64M
+date.timezone=Europe/Paris")
+
+(define %default-pmb-mysql-configuration-extra-content
+  "[server]
+sql_mode=NO_AUTO_CREATE_USER
+collation_server=utf8_unicode_ci
+key_buffer_size=1000001536
+join_buffer_size=4000000")
+
+(define-record-type* <pmb-configuration>
+  pmb-configuration make-pmb-configuration
+  pmb-configuration?
+  (pmb pmb-configuration-pmb (default pmb))
+  (http-directory pmb-configuration-http-directory
+                  (default "/srv/http/pmb"))
+  (php-fpm-user pmb-configuration-php-fpm-user
+		(default "php-fpm"))
+  (php-fpm-group pmb-configuration-php-fpm-group
+		 (default "php-fpm")))
+
+(define (pmb-activation config)
+  (match-record
+   config
+   <pmb-configuration>
+   (pmb http-directory php-fpm-user php-fpm-group)
+   #~(begin
+       (use-modules (guix build utils))
+       (use-modules (ice-9 ftw))
+       (format #t "Copying pmb '~a' to http directory '~a'~%"
+	       (string-append #$pmb "/share/http/pmb")
+	       #$http-directory)
+       (mkdir-p #$http-directory)
+       ;; Please be quiet
+       (call-with-output-file "/dev/null"
+	 (lambda (port)
+	   (with-output-to-port port
+	     (lambda ()
+	       (copy-recursively (string-append #$pmb "/share/http/pmb")
+				 #$http-directory)))))
+       (define (enter? name stat result)
+	 #t)
+       (define (lchown obj)
+	 (let ((user (getpwnam #$php-fpm-user))
+	       (group (getgrnam #$php-fpm-group)))
+	   (chown obj (passwd:uid user) (group:gid group))))
+       (define (leaf name stat result)
+	 (lchown name)
+	 result)
+       (define (down name stat result)
+	 (lchown name)
+	 result)
+       (define (up name stat result) result)
+       (define (skip name stat result) result)
+       (define (error name stat errno result)
+	 (warning (G_ "~a: ~a~%")
+		  name (strerror errno))
+	 result)
+       (file-system-fold enter? leaf down up skip error '() #$http-directory)
+       ;; Those are to hide installation files on a re-activation
+       (if
+	(file-exists? (string-append #$http-directory "/tables/noinstall.php"))
+	(delete-file (string-append #$http-directory "/tables/install.php")))
+       (if
+	(file-exists? (string-append #$http-directory "/tables/noinstall_rep.php"))
+	(delete-file (string-append #$http-directory "/tables/install_rep.php"))))))
+
+(define pmb-service-type
+  (service-type
+   (name 'guix)
+   (extensions
+    (list (service-extension activation-service-type
+			     pmb-activation)))
+   (default-value (pmb-configuration))
+   (description "Install the pmb Integrated Library System")))
-- 
2.38.1







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

* [bug#59845] [PATCH 4/4] doc: Add Integrated Library System section.
  2022-12-05 21:52 ` [bug#59845] [PATCH 1/4] gnu: php: Add '--enable-soap' configure option Yarl Baudig
  2022-12-05 21:52   ` [bug#59845] [PATCH 2/4] gnu: Add PMB Yarl Baudig
  2022-12-05 21:52   ` [bug#59845] [PATCH 3/4] gnu: Add PMB service Yarl Baudig
@ 2022-12-05 21:52   ` Yarl Baudig
  2 siblings, 0 replies; 17+ messages in thread
From: Yarl Baudig @ 2022-12-05 21:52 UTC (permalink / raw)
  To: 59845; +Cc: Yarl Baudig

doc/guix.texi (System Configuration, Services): Add Integrated Library System Services section.
doc/guix.texi (System Configuration, Services, Integrated Library System Services): Add PMB.
---
 doc/guix.texi | 128 +++++++++++++++++++++++++++++++++++++++++++++++++-
 1 file changed, 127 insertions(+), 1 deletion(-)

diff --git a/doc/guix.texi b/doc/guix.texi
index a79b777826..5ec72f9ce7 100644
--- a/doc/guix.texi
+++ b/doc/guix.texi
@@ -109,6 +109,7 @@ Copyright @copyright{} 2022 Reily Siegel@*
 Copyright @copyright{} 2022 Simon Streit@*
 Copyright @copyright{} 2022 (@*
 Copyright @copyright{} 2022 John Kehayias@*
+Copyright @copyright{} 2022 Yarl Baudig
 
 Permission is granted to copy, distribute and/or modify this document
 under the terms of the GNU Free Documentation License, Version 1.3 or
@@ -402,6 +403,7 @@ Services
 * Guix Services::               Services relating specifically to Guix.
 * Linux Services::              Services tied to the Linux kernel.
 * Hurd Services::               Services specific for a Hurd System.
+* Integrated Library System Services::   ILS services.
 * Miscellaneous Services::      Other services.
 
 Defining Services
@@ -17720,6 +17722,7 @@ declaration.
 * Guix Services::               Services relating specifically to Guix.
 * Linux Services::              Services tied to the Linux kernel.
 * Hurd Services::               Services specific for a Hurd System.
+* Integrated Library System Services::   ILS services.
 * Miscellaneous Services::      Other services.
 @end menu
 
@@ -36726,6 +36729,129 @@ An integer specifying the baud rate of the tty.
 @end table
 @end deftp
 
+@node Integrated Library System Services
+@subsection Integrated Library System Services
+
+@cindex PMB Service
+@subsubheading PMB Service
+
+@defvr {Scheme Variable} pmb-service-type
+Service type for the @uref{https://www.sigb.net/,PMB} Integrated Library System.
+The value for this service type is a @code{<pmb-configuration>} record.
+
+The PMB service needs a web server, @code{mariadb}/@code{mysql}, @code{php} and
+is only responsible for copying and changing ownership of files from the
+@code{pmb} package.
+@end defvr
+
+Let's start with a demonstration. Here is a sample system configuration (@file{pmb.scm}):
+
+@lisp
+(use-modules (gnu))
+(use-service-modules ils web networking databases)
+(use-package-modules databases)
+
+(operating-system
+ (host-name "pmb")
+ (timezone "Europe/Paris")
+ (file-systems (cons (file-system
+		      (device (file-system-label "does-not-matter"))
+		      (mount-point "/")
+		      (type "ext4"))
+                     %base-file-systems))
+ (bootloader (bootloader-configuration
+              (bootloader grub-bootloader)
+              (targets '("/dev/sdX"))))
+ (packages (cons* mariadb %base-packages))
+ (services
+  (cons* (service dhcp-client-service-type)
+	 (service php-fpm-service-type
+		  (php-fpm-configuration
+		   (php-ini-file
+		    (plain-file "php.ini"
+				%default-pmb-php-fpm-configuration))))
+	 (service nginx-service-type
+		  (nginx-configuration
+		   (server-blocks
+		    (list (nginx-server-configuration
+			   (locations
+			    (list
+			     %default-nginx-pmb-location))
+			   (listen '("localhost:8080"))
+			   (root "/srv/http/pmb")
+			   (index '("index.php")))))))
+	 (service mysql-service-type
+		  (mysql-configuration
+		   (extra-content
+		    %default-pmb-mysql-configuration-extra-content)))
+	 (service pmb-service-type)
+	 %base-services)))
+@end lisp
+
+The interesting points are as follows.
+We import the @code{mariadb} package so that we will have access to the program
+@command{mysql}. This will be useful to set the password of the database's
+administrator. We declare a @code{php-fpm} service whose @file{php.ini} file
+is set to @code{%default-pmb-php-fpm-configuration}.
+The @code{NGinx} service is declared, with a location set to
+@code{%default-nginx-pmb-location} and a root set to @file{/srv/http/pmb}, which
+is the default for the @code{http-directory} field of @code{<pmb-configuration>}.
+The @code{mysql} service is declared with an @code{extra-content} to its configuration:
+@code{default-pmb-mysql-configuration-extra-content}. Finally the pmb service.
+
+Now let's run @command{guix system container -N pmb.scm} (@pxref{Invoking guix system}).
+Run the resulting @file{/gnu/store/...run-container}.
+Note that we want to keep the state of the database and the php files (because during
+the application setup (see below), the php files will be slightly modified. That is also why
+the PMB files need to be copied (and chowned) outside the store), we need to create
+two folders, say @file{/mnt/data/pmb} and @file{/mnt/data/mysql} and pass @option{--share}
+two times. @command{nsenter} into it to set the database's administrator password.
+
+@example
+# mkdir /mnt/data/mysql /mnt/data/pmb
+# /gnu/store/...run-container --share=/mnt/data/pmb=/srv/http/pmb \
+--share=/mnt/data/mysql=/var/lib/mysql
+# nsenter -a -t <replace-with-pid>
+# mysql
+> SET PASSWORD FOR 'root'@'localhost' = PASSWORD('guixisgreat');
+@end example
+
+Go to @uref{localhost:8080}. Follow the steps. Note that for the database server parameters,
+``localhost'' won't work, it's ``127.0.0.1'' and the user is ``root''.
+Once the installation is complete, you are redirected to the login page. The name is ``admin'',
+the password is ``admin''.
+
+Now lets detail fields.
+
+@defvr {Scheme Variable} %default-pmb-php-fpm-configuration
+This is meant to represent the content of @file{php.ini} for the
+@code{php-fpm} service for a recommended configuration.
+@end defvr
+
+@defvr {Scheme Variable} %default-pmb-mysql-configuration-extra-content
+Extra content to be added to @code{mariadb}/@code{mysql} configuration for recommended configuration.
+@end defvr
+
+@defvr {Scheme Variable} %default-nginx-pmb-location
+Location for nginx based on @code{nginx-php-location}.
+@end defvr
+
+@deftp {Data Type} pmb-configuration
+This data type represents the configuration for PMB.
+
+@table @asis
+@item @code{pmb} (default: @code{pmb})
+
+@item @code{http-directory} (default: @file{/srv/http/pmb})
+Must match a webserver's root.
+
+@item @code{php-fpm-user} (default: @code{php-fpm})
+
+@item @code{php-fpm-group} (default: @code{php-fpm})
+
+@end table
+@end deftp
+
 @node Miscellaneous Services
 @subsection Miscellaneous Services
 
@@ -38369,7 +38495,7 @@ description: Install the given fonts on the specified ttys (fonts are per
 + tty/font pairs.  The font can be the name of a font provided by the `kbd'
 + package or any valid argument to `setfont', as in this example:
 +
-+      '(("tty1" . "LatGrkCyr-8x16")
++     6 '(("tty1" . "LatGrkCyr-8x16")
 +        ("tty2" . (file-append
 +                      font-tamzen
 +                      "/share/kbd/consolefonts/TamzenForPowerline10x20.psf"))
-- 
2.38.1







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

* [bug#59845] V2
  2022-12-05 21:48 [bug#59845] [PATCH 0/4] Add PMB (Integrated Library System) Yarl Baudig
  2022-12-05 21:52 ` [bug#59845] [PATCH 1/4] gnu: php: Add '--enable-soap' configure option Yarl Baudig
@ 2022-12-09 11:52 ` yarl baudig
  2022-12-09 11:53 ` [bug#59845] [PATCH v2 1/4] gnu: php: Add '--enable-soap' configure option Yarl Baudig
  2022-12-22 17:18 ` yarl baudig
  3 siblings, 0 replies; 17+ messages in thread
From: yarl baudig @ 2022-12-09 11:52 UTC (permalink / raw)
  To: 59845

I'm sending a version 2 to clean lint errors (badly configured emacs) + fix some random typo in the manual patch.
I hope this will pass the qa test.







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

* [bug#59845] [PATCH v2 1/4] gnu: php: Add '--enable-soap' configure option.
  2022-12-05 21:48 [bug#59845] [PATCH 0/4] Add PMB (Integrated Library System) Yarl Baudig
  2022-12-05 21:52 ` [bug#59845] [PATCH 1/4] gnu: php: Add '--enable-soap' configure option Yarl Baudig
  2022-12-09 11:52 ` [bug#59845] V2 yarl baudig
@ 2022-12-09 11:53 ` Yarl Baudig
  2022-12-09 11:53   ` [bug#59845] [PATCH v2 2/4] gnu: Add PMB Yarl Baudig
                     ` (2 more replies)
  2022-12-22 17:18 ` yarl baudig
  3 siblings, 3 replies; 17+ messages in thread
From: Yarl Baudig @ 2022-12-09 11:53 UTC (permalink / raw)
  To: 59845; +Cc: Yarl Baudig

* gnu/packages/php.scm: Add '--enable-soap' configure option.
---
 gnu/packages/php.scm | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/gnu/packages/php.scm b/gnu/packages/php.scm
index 645a8edee1..558f5c8521 100644
--- a/gnu/packages/php.scm
+++ b/gnu/packages/php.scm
@@ -134,7 +134,8 @@ (define-public php
                "--enable-intl"
                "--enable-mbstring"
                "--enable-pcntl"
-               "--enable-sockets"))
+               "--enable-sockets"
+               "--enable-soap"))
        #:phases
        (modify-phases %standard-phases
          (add-after 'unpack 'do-not-record-build-flags

base-commit: c3713d53e0bdf1186e08880b9e0ae6dd85f55fc4
-- 
2.38.1







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

* [bug#59845] [PATCH v2 2/4] gnu: Add PMB.
  2022-12-09 11:53 ` [bug#59845] [PATCH v2 1/4] gnu: php: Add '--enable-soap' configure option Yarl Baudig
@ 2022-12-09 11:53   ` Yarl Baudig
  2022-12-20 14:56     ` [bug#59845] [PATCH 0/4] Add PMB (Integrated Library System) Ludovic Courtès
  2022-12-09 11:53   ` [bug#59845] [PATCH v2 3/4] gnu: Add PMB service Yarl Baudig
  2022-12-09 11:53   ` [bug#59845] [PATCH v2 4/4] doc: Add Integrated Library System section Yarl Baudig
  2 siblings, 1 reply; 17+ messages in thread
From: Yarl Baudig @ 2022-12-09 11:53 UTC (permalink / raw)
  To: 59845; +Cc: Yarl Baudig

* gnu/packages/ils.scm: New file.
* gnu/local.mk: Add it.
---
 gnu/local.mk         |  1 +
 gnu/packages/ils.scm | 61 ++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 62 insertions(+)
 create mode 100644 gnu/packages/ils.scm

diff --git a/gnu/local.mk b/gnu/local.mk
index 1bfbe28bde..ff0c86584a 100644
--- a/gnu/local.mk
+++ b/gnu/local.mk
@@ -323,6 +323,7 @@ GNU_SYSTEM_MODULES =				\
   %D%/packages/icu4c.scm			\
   %D%/packages/idris.scm			\
   %D%/packages/idutils.scm			\
+  %D%/packages/ils.scm				\
   %D%/packages/image.scm			\
   %D%/packages/image-processing.scm	\
   %D%/packages/image-viewers.scm	\
diff --git a/gnu/packages/ils.scm b/gnu/packages/ils.scm
new file mode 100644
index 0000000000..61908b06b7
--- /dev/null
+++ b/gnu/packages/ils.scm
@@ -0,0 +1,61 @@
+;;; GNU Guix --- Functional package management for GNU
+;;; Copyright © 2022 Yarl Baudig <yarl-baudig@mailoo.org>
+;;;
+;;; This file is part of GNU Guix.
+;;;
+;;; GNU Guix is free software; you can redistribute it and/or modify it
+;;; under the terms of the GNU General Public License as published by
+;;; the Free Software Foundation; either version 3 of the License, or (at
+;;; your option) any later version.
+;;;
+;;; GNU Guix is distributed in the hope that it will be useful, but
+;;; WITHOUT ANY WARRANTY; without even the implied warranty of
+;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+;;; GNU General Public License for more details.
+;;;
+;;; You should have received a copy of the GNU General Public License
+;;; along with GNU Guix.  If not, see <http://www.gnu.org/licenses/>.
+
+(define-module (gnu packages ils)
+  #:use-module (guix packages)
+  #:use-module (guix download)
+  #:use-module (guix build-system copy)
+  #:use-module (guix licenses)
+  #:use-module (gnu packages gawk)
+  #:use-module (gnu packages compression)
+  #:use-module (gnu packages php)
+  #:use-module (gnu packages perl))
+
+;;; Commentary
+;;;
+;;; Integrated Library Systems packages.
+;;;
+;;; Code
+
+(define-public pmb
+  (package
+    (name "pmb")
+    (version "7.4.6")
+    (source (origin
+              (method url-fetch)
+              (uri
+               (string-append
+                "https://forge.sigb.net/attachments/download/3968/pmb"
+                version
+                ".zip"))
+              (sha256
+               (base32
+                "0ana1w8d60n2gznhh1zyjdld4xi4p2pm2hc05m8n7fh2bvlmw0cr"))))
+    (build-system copy-build-system)
+    (arguments '(#:install-plan '(("." "share/http/pmb"))))
+    (native-inputs (list unzip))
+    (propagated-inputs (list php perl))
+    (synopsis "Integrated Library System")
+    (description "PMB is an Integrated Library System for librarians, documentalists and
+information managers.
+
+This contains only the PMB archive (html, php and css files), you will need a web
+server, php and a SQL database server.  See the guix pmb service.")
+    (home-page "https://www.sigb.net")
+    (license cecill)))
+
-- 
2.38.1







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

* [bug#59845] [PATCH v2 3/4] gnu: Add PMB service.
  2022-12-09 11:53 ` [bug#59845] [PATCH v2 1/4] gnu: php: Add '--enable-soap' configure option Yarl Baudig
  2022-12-09 11:53   ` [bug#59845] [PATCH v2 2/4] gnu: Add PMB Yarl Baudig
@ 2022-12-09 11:53   ` Yarl Baudig
  2022-12-20 15:03     ` [bug#59845] [PATCH 0/4] Add PMB (Integrated Library System) Ludovic Courtès
  2022-12-09 11:53   ` [bug#59845] [PATCH v2 4/4] doc: Add Integrated Library System section Yarl Baudig
  2 siblings, 1 reply; 17+ messages in thread
From: Yarl Baudig @ 2022-12-09 11:53 UTC (permalink / raw)
  To: 59845; +Cc: Yarl Baudig

* gnu/services/ils.scm: New file.
* gnu/local.mk: Add it.
---
 gnu/local.mk         |   1 +
 gnu/services/ils.scm | 128 +++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 129 insertions(+)
 create mode 100644 gnu/services/ils.scm

diff --git a/gnu/local.mk b/gnu/local.mk
index ff0c86584a..16de11e31e 100644
--- a/gnu/local.mk
+++ b/gnu/local.mk
@@ -670,6 +670,7 @@ GNU_SYSTEM_MODULES =				\
   %D%/services/getmail.scm				\
   %D%/services/guix.scm			\
   %D%/services/hurd.scm				\
+  %D%/services/ils.scm				\
   %D%/services/kerberos.scm			\
   %D%/services/lightdm.scm      		\
   %D%/services/linux.scm			\
diff --git a/gnu/services/ils.scm b/gnu/services/ils.scm
new file mode 100644
index 0000000000..5a704d368b
--- /dev/null
+++ b/gnu/services/ils.scm
@@ -0,0 +1,128 @@
+;;; GNU Guix --- Functional package management for GNU
+;;; Copyright © 2022 Yarl Baudig <yarl-baudig@mailoo.org>
+;;;
+;;; This file is part of GNU Guix.
+;;;
+;;; GNU Guix is free software; you can redistribute it and/or modify it
+;;; under the terms of the GNU General Public License as published by
+;;; the Free Software Foundation; either version 3 of the License, or (at
+;;; your option) any later version.
+;;;
+;;; GNU Guix is distributed in the hope that it will be useful, but
+;;; WITHOUT ANY WARRANTY; without even the implied warranty of
+;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+;;; GNU General Public License for more details.
+;;;
+;;; You should have received a copy of the GNU General Public License
+;;; along with GNU Guix.  If not, see <http://www.gnu.org/licenses/>.
+
+(define-module (gnu services ils)
+  #:use-module (gnu services)
+  #:use-module (gnu services web)
+  #:use-module (gnu packages ils)
+  #:use-module (guix records)
+  #:use-module (guix utils)
+  #:use-module (guix gexp)
+  #:use-module (ice-9 match)
+  #:use-module (ice-9 format)
+  #:export (pmb-configuration
+	    pmb-service-type
+	    %default-nginx-pmb-location
+	    %default-pmb-php-fpm-configuration
+	    %default-pmb-mysql-configuration-extra-content))
+
+;;; Commentary
+;;;
+;;; Integrated Library Systems services.
+;;;
+;;; Code
+
+(define %default-nginx-pmb-location
+  (let ((base (nginx-php-location)))
+    (nginx-location-configuration
+     (inherit base)
+     (body (cons
+            "fastcgi_read_timeout 300;"
+            (nginx-location-configuration-body base))))))
+
+(define %default-pmb-php-fpm-configuration
+  "expose_php=off
+max_execution_time=300
+max_input_vars=50000
+memory_limit=256M
+post_max_size=64M
+upload_max_filesize=64M
+date.timezone=Europe/Paris")
+
+(define %default-pmb-mysql-configuration-extra-content
+  "[server]
+sql_mode=NO_AUTO_CREATE_USER
+collation_server=utf8_unicode_ci
+key_buffer_size=1000001536
+join_buffer_size=4000000")
+
+(define-record-type* <pmb-configuration>
+  pmb-configuration make-pmb-configuration
+  pmb-configuration?
+  (pmb pmb-configuration-pmb (default pmb))
+  (http-directory pmb-configuration-http-directory
+                  (default "/srv/http/pmb"))
+  (php-fpm-user pmb-configuration-php-fpm-user
+                (default "php-fpm"))
+  (php-fpm-group pmb-configuration-php-fpm-group
+		 (default "php-fpm")))
+
+(define (pmb-activation config)
+  (match-record
+      config
+      <pmb-configuration>
+    (pmb http-directory php-fpm-user php-fpm-group)
+    #~(begin
+        (use-modules (guix build utils))
+        (use-modules (ice-9 ftw))
+        (format #t "Copying pmb '~a' to http directory '~a'~%"
+                (string-append #$pmb "/share/http/pmb")
+                #$http-directory)
+        (mkdir-p #$http-directory)
+        ;; Please be quiet
+        (call-with-output-file "/dev/null"
+          (lambda (port)
+            (with-output-to-port port
+              (lambda ()
+                (copy-recursively (string-append #$pmb "/share/http/pmb")
+                                  #$http-directory)))))
+        (define (enter? name stat result)
+          #t)
+        (define (lchown obj)
+          (let ((user (getpwnam #$php-fpm-user))
+                (group (getgrnam #$php-fpm-group)))
+            (chown obj (passwd:uid user) (group:gid group))))
+        (define (leaf name stat result)
+          (lchown name)
+          result)
+        (define (down name stat result)
+          (lchown name)
+	  result)
+        (define (up name stat result) result)
+        (define (skip name stat result) result)
+        (define (error name stat errno result)
+          (warning (G_ "~a: ~a~%")
+                   name (strerror errno))
+          result)
+        (file-system-fold enter? leaf down up skip error '() #$http-directory)
+        ;; Those are to hide installation files on a re-activation
+        (if
+         (file-exists? (string-append #$http-directory "/tables/noinstall.php"))
+         (delete-file (string-append #$http-directory "/tables/install.php")))
+        (if
+         (file-exists? (string-append #$http-directory "/tables/noinstall_rep.php"))
+         (delete-file (string-append #$http-directory "/tables/install_rep.php"))))))
+
+(define pmb-service-type
+  (service-type
+   (name 'guix)
+   (extensions
+    (list (service-extension activation-service-type
+                             pmb-activation)))
+   (default-value (pmb-configuration))
+   (description "Install the pmb Integrated Library System")))
-- 
2.38.1







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

* [bug#59845] [PATCH v2 4/4] doc: Add Integrated Library System section.
  2022-12-09 11:53 ` [bug#59845] [PATCH v2 1/4] gnu: php: Add '--enable-soap' configure option Yarl Baudig
  2022-12-09 11:53   ` [bug#59845] [PATCH v2 2/4] gnu: Add PMB Yarl Baudig
  2022-12-09 11:53   ` [bug#59845] [PATCH v2 3/4] gnu: Add PMB service Yarl Baudig
@ 2022-12-09 11:53   ` Yarl Baudig
  2022-12-20 15:13     ` [bug#59845] [PATCH 0/4] Add PMB (Integrated Library System) Ludovic Courtès
  2 siblings, 1 reply; 17+ messages in thread
From: Yarl Baudig @ 2022-12-09 11:53 UTC (permalink / raw)
  To: 59845; +Cc: Yarl Baudig

doc/guix.texi (System Configuration, Services): Add Integrated Library System Services section.
doc/guix.texi (System Configuration, Services, Integrated Library System Services): Add PMB.
---
 doc/guix.texi | 127 ++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 127 insertions(+)

diff --git a/doc/guix.texi b/doc/guix.texi
index a79b777826..60f0072409 100644
--- a/doc/guix.texi
+++ b/doc/guix.texi
@@ -109,6 +109,7 @@ Copyright @copyright{} 2022 Reily Siegel@*
 Copyright @copyright{} 2022 Simon Streit@*
 Copyright @copyright{} 2022 (@*
 Copyright @copyright{} 2022 John Kehayias@*
+Copyright @copyright{} 2022 Yarl Baudig
 
 Permission is granted to copy, distribute and/or modify this document
 under the terms of the GNU Free Documentation License, Version 1.3 or
@@ -402,6 +403,7 @@ Services
 * Guix Services::               Services relating specifically to Guix.
 * Linux Services::              Services tied to the Linux kernel.
 * Hurd Services::               Services specific for a Hurd System.
+* Integrated Library System Services::   ILS services.
 * Miscellaneous Services::      Other services.
 
 Defining Services
@@ -17720,6 +17722,7 @@ declaration.
 * Guix Services::               Services relating specifically to Guix.
 * Linux Services::              Services tied to the Linux kernel.
 * Hurd Services::               Services specific for a Hurd System.
+* Integrated Library System Services::   ILS services.
 * Miscellaneous Services::      Other services.
 @end menu
 
@@ -36726,6 +36729,130 @@ An integer specifying the baud rate of the tty.
 @end table
 @end deftp
 
+@node Integrated Library System Services
+@subsection Integrated Library System Services
+
+@cindex PMB Service
+@subsubheading PMB Service
+
+@defvr {Scheme Variable} pmb-service-type
+Service type for the @uref{https://www.sigb.net/,PMB} Integrated Library System.
+The value for this service type is a @code{<pmb-configuration>} record.
+
+The PMB service needs a web server, @code{mariadb}/@code{mysql}, @code{php} and
+is only responsible for copying and changing ownership of files from the
+@code{pmb} package.
+@end defvr
+
+Let's start with a demonstration. Here is a sample system configuration (@file{pmb.scm}):
+
+@lisp
+(use-modules (gnu))
+(use-service-modules ils web networking databases)
+(use-package-modules databases)
+
+(operating-system
+  (host-name "pmb")
+  (timezone "Europe/Paris")
+  (file-systems (cons
+                 (file-system
+                   (device (file-system-label "does-not-matter"))
+                   (mount-point "/")
+                   (type "ext4"))
+                 %base-file-systems))
+  (bootloader (bootloader-configuration
+               (bootloader grub-bootloader)
+               (targets '("/dev/sdX"))))
+  (packages (cons* mariadb %base-packages))
+  (services
+   (cons* (service dhcp-client-service-type)
+          (service php-fpm-service-type
+                   (php-fpm-configuration
+                    (php-ini-file
+                     (plain-file "php.ini"
+                                 %default-pmb-php-fpm-configuration))))
+          (service nginx-service-type
+                   (nginx-configuration
+                    (server-blocks
+                     (list (nginx-server-configuration
+                            (locations
+                             (list
+                              %default-nginx-pmb-location))
+                            (listen '("localhost:8080"))
+                            (root "/srv/http/pmb")
+                            (index '("index.php")))))))
+          (service mysql-service-type
+                   (mysql-configuration
+                    (extra-content
+                     %default-pmb-mysql-configuration-extra-content)))
+          (service pmb-service-type)
+          %base-services)))
+@end lisp
+
+The interesting points are as follows.
+We import the @code{mariadb} package so that we will have access to the program
+@command{mysql}. This will be useful to set the password of the database's
+administrator. We declare a @code{php-fpm} service whose @file{php.ini} file
+is set to @code{%default-pmb-php-fpm-configuration}.
+The @code{NGinx} service is declared, with a location set to
+@code{%default-nginx-pmb-location} and a root set to @file{/srv/http/pmb}, which
+is the default for the @code{http-directory} field of @code{<pmb-configuration>}.
+The @code{mysql} service is declared with an @code{extra-content} to its configuration:
+@code{default-pmb-mysql-configuration-extra-content}. Finally the pmb service.
+
+Now let's run @command{guix system container -N pmb.scm} (@pxref{Invoking guix system}).
+Run the resulting @file{/gnu/store/...run-container}.
+Note that we want to keep the state of the database and the php files (because during
+the application setup (see below), the php files will be slightly modified. That is also why
+the PMB files need to be copied (and chowned) outside the store), we need to create
+two folders, say @file{/mnt/data/pmb} and @file{/mnt/data/mysql} and pass @option{--share}
+two times. @command{nsenter} into it to set the database's administrator password.
+
+@example
+# mkdir /mnt/data/mysql /mnt/data/pmb
+# /gnu/store/...run-container --share=/mnt/data/pmb=/srv/http/pmb \
+--share=/mnt/data/mysql=/var/lib/mysql
+# nsenter -a -t <replace-with-pid>
+# mysql
+> SET PASSWORD FOR 'root'@'localhost' = PASSWORD('guixisgreat');
+@end example
+
+Go to @uref{localhost:8080}. Follow the steps. Note that for the database server parameters,
+``localhost'' won't work, it's ``127.0.0.1'' and the user is ``root''.
+Once the installation is complete, you are redirected to the login page. The name is ``admin'',
+the password is ``admin''.
+
+Now lets detail fields.
+
+@defvr {Scheme Variable} %default-pmb-php-fpm-configuration
+This is meant to represent the content of @file{php.ini} for the
+@code{php-fpm} service for a recommended configuration.
+@end defvr
+
+@defvr {Scheme Variable} %default-pmb-mysql-configuration-extra-content
+Extra content to be added to @code{mariadb}/@code{mysql} configuration for recommended configuration.
+@end defvr
+
+@defvr {Scheme Variable} %default-nginx-pmb-location
+Location for nginx based on @code{nginx-php-location}.
+@end defvr
+
+@deftp {Data Type} pmb-configuration
+This data type represents the configuration for PMB.
+
+@table @asis
+@item @code{pmb} (default: @code{pmb})
+
+@item @code{http-directory} (default: @file{/srv/http/pmb})
+Must match a webserver's root.
+
+@item @code{php-fpm-user} (default: @code{php-fpm})
+
+@item @code{php-fpm-group} (default: @code{php-fpm})
+
+@end table
+@end deftp
+
 @node Miscellaneous Services
 @subsection Miscellaneous Services
 
-- 
2.38.1







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

* [bug#59845] [PATCH 0/4] Add PMB (Integrated Library System)
  2022-12-09 11:53   ` [bug#59845] [PATCH v2 2/4] gnu: Add PMB Yarl Baudig
@ 2022-12-20 14:56     ` Ludovic Courtès
  0 siblings, 0 replies; 17+ messages in thread
From: Ludovic Courtès @ 2022-12-20 14:56 UTC (permalink / raw)
  To: Yarl Baudig; +Cc: 59845

Hi!

Yarl Baudig <yarl-baudig@mailoo.org> skribis:

> * gnu/packages/ils.scm: New file.
> * gnu/local.mk: Add it.

The gnu/packages changes LGTM and to qa.guix!

Minor suggestions:

> +    (synopsis "Integrated Library System")

Maybe “Integrated library system”?

> +    (description "PMB is an Integrated Library System for librarians, documentalists and

… and “@acronym{ILS, integrated library system}”.

> +information managers.
> +
> +This contains only the PMB archive (html, php and css files), you will need a web
> +server, php and a SQL database server.  See the guix pmb service.")

Please capitalize things: HTML, PHP, CSS.  You can remove “See …” at the
end.

Ludo’.




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

* [bug#59845] [PATCH 0/4] Add PMB (Integrated Library System)
  2022-12-09 11:53   ` [bug#59845] [PATCH v2 3/4] gnu: Add PMB service Yarl Baudig
@ 2022-12-20 15:03     ` Ludovic Courtès
  0 siblings, 0 replies; 17+ messages in thread
From: Ludovic Courtès @ 2022-12-20 15:03 UTC (permalink / raw)
  To: Yarl Baudig; +Cc: 59845

Yarl Baudig <yarl-baudig@mailoo.org> skribis:

> * gnu/services/ils.scm: New file.
> * gnu/local.mk: Add it.

[...]

> +    #~(begin
> +        (use-modules (guix build utils))
> +        (use-modules (ice-9 ftw))
> +        (format #t "Copying pmb '~a' to http directory '~a'~%"
> +                (string-append #$pmb "/share/http/pmb")
> +                #$http-directory)
> +        (mkdir-p #$http-directory)
> +        ;; Please be quiet
> +        (call-with-output-file "/dev/null"
> +          (lambda (port)
> +            (with-output-to-port port
> +              (lambda ()
> +                (copy-recursively (string-append #$pmb "/share/http/pmb")
> +                                  #$http-directory)))))

Do we really need to copy these files?

Keep in mind that activation snippets run each time you boot the system,
and each time you reconfigure.  It’s best to avoid doing too much work
there.

> +        (define (enter? name stat result)
> +          #t)
> +        (define (lchown obj)
> +          (let ((user (getpwnam #$php-fpm-user))
> +                (group (getgrnam #$php-fpm-group)))
> +            (chown obj (passwd:uid user) (group:gid group))))
> +        (define (leaf name stat result)
> +          (lchown name)
> +          result)
> +        (define (down name stat result)
> +          (lchown name)
> +	  result)
> +        (define (up name stat result) result)
> +        (define (skip name stat result) result)
> +        (define (error name stat errno result)
> +          (warning (G_ "~a: ~a~%")
> +                   name (strerror errno))
> +          result)
> +        (file-system-fold enter? leaf down up skip error '() #$http-directory)

This can be simplified along these lines:

  (for-each lchown (find-files #$http-directory #:directories? #t))

But again, that’s a lot of I/O.

> +        ;; Those are to hide installation files on a re-activation
> +        (if
> +         (file-exists? (string-append #$http-directory "/tables/noinstall.php"))
> +         (delete-file (string-append #$http-directory "/tables/install.php")))
> +        (if
> +         (file-exists? (string-append #$http-directory "/tables/noinstall_rep.php"))
> +         (delete-file (string-append #$http-directory "/tables/install_rep.php"))))))

Or just:

  (false-if-exception (delete-file …))

> +(define pmb-service-type
> +  (service-type
> +   (name 'guix)
> +   (extensions
> +    (list (service-extension activation-service-type
> +                             pmb-activation)))
> +   (default-value (pmb-configuration))
> +   (description "Install the pmb Integrated Library System")))

Should it extend ‘nginx-service-type’ with ‘%default-pmb-location’?

Likewise, it looks like it’d be nice to extend ‘mysql-service-type’ with
the extra config.  That’s not currently possible but we should add it.
That way, adding (service pmb-service-type) is all it would take to get
the service up and running.




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

* [bug#59845] [PATCH 0/4] Add PMB (Integrated Library System)
  2022-12-09 11:53   ` [bug#59845] [PATCH v2 4/4] doc: Add Integrated Library System section Yarl Baudig
@ 2022-12-20 15:13     ` Ludovic Courtès
  0 siblings, 0 replies; 17+ messages in thread
From: Ludovic Courtès @ 2022-12-20 15:13 UTC (permalink / raw)
  To: Yarl Baudig; +Cc: 59845

Yarl Baudig <yarl-baudig@mailoo.org> skribis:

> doc/guix.texi (System Configuration, Services): Add Integrated Library System Services section.
> doc/guix.texi (System Configuration, Services, Integrated Library System Services): Add PMB.

Neat!  Note that this should go in the same commit that adds the
service.

Likewise, we also expect system tests for each new service.  This should
also come in the same commit.  Here the system test would check that the
web server is up and running and that PMB correctly responds to basic
HTTP requests.  See ‘gnu/tests’ for example and do not hesitate to ask
on IRC if you have any questions.

> +@node Integrated Library System Services
> +@subsection Integrated Library System Services
> +
> +@cindex PMB Service
> +@subsubheading PMB Service
> +

Please add a couple of introductory sentences to give context.

> +@defvr {Scheme Variable} pmb-service-type
> +Service type for the @uref{https://www.sigb.net/,PMB} Integrated Library System.
> +The value for this service type is a @code{<pmb-configuration>} record.
> +
> +The PMB service needs a web server, @code{mariadb}/@code{mysql}, @code{php} and
> +is only responsible for copying and changing ownership of files from the
> +@code{pmb} package.
> +@end defvr
> +
> +Let's start with a demonstration. Here is a sample system configuration (@file{pmb.scm}):
> +
> +@lisp
> +(use-modules (gnu))
> +(use-service-modules ils web networking databases)
> +(use-package-modules databases)
> +
> +(operating-system
> +  (host-name "pmb")

I think we shouldn’t have to provide full OS declarations to illustrate
use of the service.  But as I wrote in a previous message, it we can
boil down configuration to (service pmb-service-type), then the example
will be much more concise.

> +We import the @code{mariadb} package so that we will have access to the program
> +@command{mysql}. This will be useful to set the password of the database's

Please leave two spaces after end-of-sentence periods (this gives a hint
to Texinfo and to Emacs).

> +Now let's run @command{guix system container -N pmb.scm} (@pxref{Invoking guix system}).
> +Run the resulting @file{/gnu/store/...run-container}.
> +Note that we want to keep the state of the database and the php files (because during
> +the application setup (see below), the php files will be slightly modified. That is also why
> +the PMB files need to be copied (and chowned) outside the store), we need to create
> +two folders, say @file{/mnt/data/pmb} and @file{/mnt/data/mysql} and pass @option{--share}
> +two times. @command{nsenter} into it to set the database's administrator password.
> +
> +@example
> +# mkdir /mnt/data/mysql /mnt/data/pmb
> +# /gnu/store/...run-container --share=/mnt/data/pmb=/srv/http/pmb \
> +--share=/mnt/data/mysql=/var/lib/mysql
> +# nsenter -a -t <replace-with-pid>
> +# mysql
> +> SET PASSWORD FOR 'root'@'localhost' = PASSWORD('guixisgreat');
> +@end example

Neat.  We should clarify that this is in case one wants to run it in a
container (there’s no obligation; one might want to run it on the bare
metal).

WDYT?

Ludo’.




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

* [bug#59845] [PATCH 0/4] Add PMB (Integrated Library System)
  2022-12-05 21:48 [bug#59845] [PATCH 0/4] Add PMB (Integrated Library System) Yarl Baudig
                   ` (2 preceding siblings ...)
  2022-12-09 11:53 ` [bug#59845] [PATCH v2 1/4] gnu: php: Add '--enable-soap' configure option Yarl Baudig
@ 2022-12-22 17:18 ` yarl baudig
  2022-12-22 22:40   ` Ludovic Courtès
  3 siblings, 1 reply; 17+ messages in thread
From: yarl baudig @ 2022-12-22 17:18 UTC (permalink / raw)
  To: ludo; +Cc: 59845

Thank you for all your comments. I will rework this. I have some questions if you will.
I know there is a problem with this package/service. I feel I am sort of breaking the functional paradigm. I also feel the package is "leaking" into the service, because the package is completely useful by itself, I'm not even talking about web server, PHP or MYSQL. The package is only a 'source' for a service. If that makes sense.

> 
> > +        ;; Those are to hide installation files on a re-activation
> > +        (if
> > +         (file-exists? (string-append #$http-directory 
> "/tables/noinstall.php"))
> > +         (delete-file (string-append #$http-directory 
> "/tables/install.php")))
> > +        (if
> > +         (file-exists? (string-append #$http-directory 
> "/tables/noinstall_rep.php"))
> > +         (delete-file (string-append #$http-directory 
> "/tables/install_rep.php"))))))
> 
> Or just:
> 
>   (false-if-exception (delete-file …))
> 

That's not the same thing (check noinstall to remove install). Indeed, after the first service installation, user interaction is required, as explained in the manual : set up of database password then (and that's the problematic part) initialization/configuration of pmb through a web browser by running "install.php".
So, you need install.php. One time. This initialization takes care of (at least) moving install.php to noinstall.php. Same logic for install_rep.php.
This is also the why of the snippet below (the copy), because the application need to be in a read-write directory.
The purpose of the code above is only to differentiate between an installation and an upgrade.
The service keeps state of itself in http-directory, already installed or not, here I break the functional paradigm? Or that's not so bad as it's not a package but a service?

> > +    #~(begin
> > +        (use-modules (guix build utils))
> > +        (use-modules (ice-9 ftw))
> > +        (format #t "Copying pmb '~a' to http directory '~a'~%"
> > +                (string-append #$pmb "/share/http/pmb")
> > +                #$http-directory)
> > +        (mkdir-p #$http-directory)
> > +        ;; Please be quiet
> > +        (call-with-output-file "/dev/null"
> > +          (lambda (port)
> > +            (with-output-to-port port
> > +              (lambda ()
> > +                (copy-recursively (string-append #$pmb 
> "/share/http/pmb")
> > +                                  #$http-directory)))))
> 
> Do we really need to copy these files?
> 
> Keep in mind that activation snippets run each time you boot the system,
> and each time you reconfigure.  It’s best to avoid doing too much work
> there.
>

Now, I see one solution to avoid the copy (and the chown), apart from the very first activation. That's keeping even more state into http-directory : for example a file ".version" with the hash of the pmb package used inside. That way we know if there's really an upgrade. What do you think?







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

* [bug#59845] [PATCH 0/4] Add PMB (Integrated Library System)
  2022-12-22 17:18 ` yarl baudig
@ 2022-12-22 22:40   ` Ludovic Courtès
  2022-12-23  8:17     ` yarl baudig
  0 siblings, 1 reply; 17+ messages in thread
From: Ludovic Courtès @ 2022-12-22 22:40 UTC (permalink / raw)
  To: yarl baudig; +Cc: Julien Lepiller, 59845

Hi,

(Cc: Julien who’s worked on PHP packaging before.)

"yarl baudig" <yarl-baudig@mailoo.org> skribis:

> I know there is a problem with this package/service. I feel I am sort of breaking the functional paradigm. I also feel the package is "leaking" into the service, because the package is completely useful by itself, I'm not even talking about web server, PHP or MYSQL. The package is only a 'source' for a service. If that makes sense.

Hmm, I see what you mean.  But maybe the same can be said of many
(most?) PHP packages?

>> > +        ;; Those are to hide installation files on a re-activation
>> > +        (if
>> > +         (file-exists? (string-append #$http-directory 
>> "/tables/noinstall.php"))
>> > +         (delete-file (string-append #$http-directory 
>> "/tables/install.php")))
>> > +        (if
>> > +         (file-exists? (string-append #$http-directory 
>> "/tables/noinstall_rep.php"))
>> > +         (delete-file (string-append #$http-directory 
>> "/tables/install_rep.php"))))))
>> 
>> Or just:
>> 
>>   (false-if-exception (delete-file …))
>> 
>
> That's not the same thing (check noinstall to remove install).

Oops, my bad, sorry.

> Indeed, after the first service installation, user interaction is
> required, as explained in the manual : set up of database password
> then (and that's the problematic part) initialization/configuration of
> pmb through a web browser by running "install.php".  So, you need
> install.php. One time. This initialization takes care of (at least)
> moving install.php to noinstall.php. Same logic for install_rep.php.
> This is also the why of the snippet below (the copy), because the
> application need to be in a read-write directory.  The purpose of the
> code above is only to differentiate between an installation and an
> upgrade.  The service keeps state of itself in http-directory, already
> installed or not, here I break the functional paradigm? Or that's not
> so bad as it's not a package but a service?

That’s quite unusual, it would be nice for the comment to explain this.

But it’s okay to do it this way; don’t fear the paradigm, it’s here to
serve us, not the other way around.  :-)

>> > +    #~(begin
>> > +        (use-modules (guix build utils))
>> > +        (use-modules (ice-9 ftw))
>> > +        (format #t "Copying pmb '~a' to http directory '~a'~%"
>> > +                (string-append #$pmb "/share/http/pmb")
>> > +                #$http-directory)
>> > +        (mkdir-p #$http-directory)
>> > +        ;; Please be quiet
>> > +        (call-with-output-file "/dev/null"
>> > +          (lambda (port)
>> > +            (with-output-to-port port
>> > +              (lambda ()
>> > +                (copy-recursively (string-append #$pmb 
>> "/share/http/pmb")
>> > +                                  #$http-directory)))))
>> 
>> Do we really need to copy these files?
>> 
>> Keep in mind that activation snippets run each time you boot the system,
>> and each time you reconfigure.  It’s best to avoid doing too much work
>> there.
>>
>
> Now, I see one solution to avoid the copy (and the chown), apart from the very first activation. That's keeping even more state into http-directory : for example a file ".version" with the hash of the pmb package used inside. That way we know if there's really an upgrade. What do you think?

It sounds like it’s going a bit far in terms of complexity.

Why do we need to copy these files every time?  Do they actually have to
be writable?  If not, whatever this copying step is doing could be done
in a ‘computed-file’.

Does that make sense?

Thanks,
Ludo’.




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

* [bug#59845] [PATCH 0/4] Add PMB (Integrated Library System)
  2022-12-22 22:40   ` Ludovic Courtès
@ 2022-12-23  8:17     ` yarl baudig
  2022-12-25 17:26       ` Ludovic Courtès
  0 siblings, 1 reply; 17+ messages in thread
From: yarl baudig @ 2022-12-23  8:17 UTC (permalink / raw)
  To: ludo; +Cc: Julien Lepiller, 59845

> >
> > Now, I see one solution to avoid the copy (and the chown), apart from the 
> very first activation. That's keeping even more state into http-directory : 
> for example a file ".version" with the hash of the pmb package used inside. 
> That way we know if there's really an upgrade. What do you think?
> 
> It sounds like it’s going a bit far in terms of complexity.
> 
> Why do we need to copy these files every time?  Do they actually have to
> be writable?  If not, whatever this copying step is doing could be done
> in a ‘computed-file’.
> 
> Does that make sense?
> 

Hmm no, not really. Yes it has to be writable for the interactive initialization through web browser to take place. At least two operations take place there that need RW :
1/ renaming of both install.php and install_req.php.
2/ saving into a file the url and credentials for connexion to the database.

There is no _need_ to copy every time. I did like this in my first patchs because it was _correct_ (I didn't think about efficiency then).

That's why I am proposing the solution which copy only for the very fist activation and for the first activation after a package upgrade (or downgrade).

I don't see how we could avoid this. I don't think it's a good idea to try to avoid the interactive installation as it gives informations and options on the installation to the user.

Why "computed-file"?







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

* [bug#59845] [PATCH 0/4] Add PMB (Integrated Library System)
  2022-12-23  8:17     ` yarl baudig
@ 2022-12-25 17:26       ` Ludovic Courtès
  0 siblings, 0 replies; 17+ messages in thread
From: Ludovic Courtès @ 2022-12-25 17:26 UTC (permalink / raw)
  To: yarl baudig; +Cc: Julien Lepiller, 59845

Hi,

"yarl baudig" <yarl-baudig@mailoo.org> skribis:

>> >
>> > Now, I see one solution to avoid the copy (and the chown), apart from the 
>> very first activation. That's keeping even more state into http-directory : 
>> for example a file ".version" with the hash of the pmb package used inside. 
>> That way we know if there's really an upgrade. What do you think?
>> 
>> It sounds like it’s going a bit far in terms of complexity.
>> 
>> Why do we need to copy these files every time?  Do they actually have to
>> be writable?  If not, whatever this copying step is doing could be done
>> in a ‘computed-file’.
>> 
>> Does that make sense?
>> 
>
> Hmm no, not really. Yes it has to be writable for the interactive initialization through web browser to take place. At least two operations take place there that need RW :
> 1/ renaming of both install.php and install_req.php.
> 2/ saving into a file the url and credentials for connexion to the database.

Credentials have to be handled out-of-band anyway (keep in mind that
/gnu/store is world-readable so in general we cannot have password in
transit via the store).

> There is no _need_ to copy every time. I did like this in my first patchs because it was _correct_ (I didn't think about efficiency then).
>
> That's why I am proposing the solution which copy only for the very fist activation and for the first activation after a package upgrade (or downgrade).
>
> I don't see how we could avoid this. I don't think it's a good idea to try to avoid the interactive installation as it gives informations and options on the installation to the user.

OK.

> Why "computed-file"?

Take it with a grain of salt because I still have an incomplete
understanding of the initialization process of PMB.

My thought was that, if there’s a “computation” (copying files around,
renaming some) that can be done once and for all, then we could do that
in ‘computed-file’.  But what you’re saying, IIUC, is that this is not
done “once and for all”.

HTH,
Ludo’.




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

end of thread, other threads:[~2022-12-25 17:27 UTC | newest]

Thread overview: 17+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-12-05 21:48 [bug#59845] [PATCH 0/4] Add PMB (Integrated Library System) Yarl Baudig
2022-12-05 21:52 ` [bug#59845] [PATCH 1/4] gnu: php: Add '--enable-soap' configure option Yarl Baudig
2022-12-05 21:52   ` [bug#59845] [PATCH 2/4] gnu: Add PMB Yarl Baudig
2022-12-05 21:52   ` [bug#59845] [PATCH 3/4] gnu: Add PMB service Yarl Baudig
2022-12-05 21:52   ` [bug#59845] [PATCH 4/4] doc: Add Integrated Library System section Yarl Baudig
2022-12-09 11:52 ` [bug#59845] V2 yarl baudig
2022-12-09 11:53 ` [bug#59845] [PATCH v2 1/4] gnu: php: Add '--enable-soap' configure option Yarl Baudig
2022-12-09 11:53   ` [bug#59845] [PATCH v2 2/4] gnu: Add PMB Yarl Baudig
2022-12-20 14:56     ` [bug#59845] [PATCH 0/4] Add PMB (Integrated Library System) Ludovic Courtès
2022-12-09 11:53   ` [bug#59845] [PATCH v2 3/4] gnu: Add PMB service Yarl Baudig
2022-12-20 15:03     ` [bug#59845] [PATCH 0/4] Add PMB (Integrated Library System) Ludovic Courtès
2022-12-09 11:53   ` [bug#59845] [PATCH v2 4/4] doc: Add Integrated Library System section Yarl Baudig
2022-12-20 15:13     ` [bug#59845] [PATCH 0/4] Add PMB (Integrated Library System) Ludovic Courtès
2022-12-22 17:18 ` yarl baudig
2022-12-22 22:40   ` Ludovic Courtès
2022-12-23  8:17     ` yarl baudig
2022-12-25 17:26       ` Ludovic Courtès

Code repositories for project(s) associated with this external index

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

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.