[PATCH 0/4] Add PMB (Integrated Library System)

  • Open
  • quality assurance status badge
Details
2 participants
  • Ludovic Courtès
  • Yarl Baudig
Owner
unassigned
Submitted by
Yarl Baudig
Severity
normal
Y
Y
Yarl Baudig wrote on 5 Dec 2022 22:48
[PATCH 0/4] Add PMB (Integrated Library System)
(address . guix-patches@gnu.org)(name . Yarl Baudig)(address . yarl-baudig@mailoo.org)
20221205214838.27594-1-yarl-baudig@mailoo.org
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
Y
Y
Yarl Baudig wrote on 5 Dec 2022 22:52
[PATCH 1/4] gnu: php: Add '--enable-soap' configure option.
(address . 59845@debbugs.gnu.org)(name . Yarl Baudig)(address . yarl-baudig@mailoo.org)
20221205215224.27623-1-yarl-baudig@mailoo.org
* gnu/packages/php.scm: Add '--enable-soap' configure option.
---
gnu/packages/php.scm | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)

Toggle diff (16 lines)
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
Y
Y
Yarl Baudig wrote on 5 Dec 2022 22:52
[PATCH 2/4] gnu: Add PMB.
(address . 59845@debbugs.gnu.org)(name . Yarl Baudig)(address . yarl-baudig@mailoo.org)
20221205215224.27623-2-yarl-baudig@mailoo.org
* 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

Toggle diff (81 lines)
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
Y
Y
Yarl Baudig wrote on 5 Dec 2022 22:52
[PATCH 3/4] gnu: Add PMB service.
(address . 59845@debbugs.gnu.org)(name . Yarl Baudig)(address . yarl-baudig@mailoo.org)
20221205215224.27623-3-yarl-baudig@mailoo.org
* 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

Toggle diff (148 lines)
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
Y
Y
Yarl Baudig wrote on 5 Dec 2022 22:52
[PATCH 4/4] doc: Add Integrated Library System section.
(address . 59845@debbugs.gnu.org)(name . Yarl Baudig)(address . yarl-baudig@mailoo.org)
20221205215224.27623-4-yarl-baudig@mailoo.org
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(-)

Toggle diff (169 lines)
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
Y
Y
yarl baudig wrote on 9 Dec 2022 12:52
V2
(address . 59845@debbugs.gnu.org)
ea-mime-6393218f-7e20-7ce54077@www.mailo.com
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.
Y
Y
Yarl Baudig wrote on 9 Dec 2022 12:53
[PATCH v2 1/4] gnu: php: Add '--enable-soap' configure option.
(address . 59845@debbugs.gnu.org)(name . Yarl Baudig)(address . yarl-baudig@mailoo.org)
20221209115349.5821-1-yarl-baudig@mailoo.org
* gnu/packages/php.scm: Add '--enable-soap' configure option.
---
gnu/packages/php.scm | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)

Toggle diff (18 lines)
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
Y
Y
Yarl Baudig wrote on 9 Dec 2022 12:53
[PATCH v2 2/4] gnu: Add PMB.
(address . 59845@debbugs.gnu.org)(name . Yarl Baudig)(address . yarl-baudig@mailoo.org)
20221209115349.5821-2-yarl-baudig@mailoo.org
* 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

Toggle diff (81 lines)
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
Y
Y
Yarl Baudig wrote on 9 Dec 2022 12:53
[PATCH v2 3/4] gnu: Add PMB service.
(address . 59845@debbugs.gnu.org)(name . Yarl Baudig)(address . yarl-baudig@mailoo.org)
20221209115349.5821-3-yarl-baudig@mailoo.org
* 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

Toggle diff (148 lines)
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
Y
Y
Yarl Baudig wrote on 9 Dec 2022 12:53
[PATCH v2 4/4] doc: Add Integrated Library System section.
(address . 59845@debbugs.gnu.org)(name . Yarl Baudig)(address . yarl-baudig@mailoo.org)
20221209115349.5821-4-yarl-baudig@mailoo.org
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(+)

Toggle diff (161 lines)
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
L
L
Ludovic Courtès wrote on 20 Dec 2022 15:56
Re: bug#59845: [PATCH 0/4] Add PMB (Integrated Library System)
(name . Yarl Baudig)(address . yarl-baudig@mailoo.org)(address . 59845@debbugs.gnu.org)
87a63i6s3y.fsf_-_@gnu.org
Hi!

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

Toggle quote (3 lines)
> * gnu/packages/ils.scm: New file.
> * gnu/local.mk: Add it.

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

Minor suggestions:

Toggle quote (2 lines)
> + (synopsis "Integrated Library System")

Maybe “Integrated library system”?

Toggle quote (2 lines)
> + (description "PMB is an Integrated Library System for librarians, documentalists and

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

Toggle quote (5 lines)
> +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’.
L
L
Ludovic Courtès wrote on 20 Dec 2022 16:03
(name . Yarl Baudig)(address . yarl-baudig@mailoo.org)(address . 59845@debbugs.gnu.org)
87359a6rsz.fsf_-_@gnu.org
Yarl Baudig <yarl-baudig@mailoo.org> skribis:

Toggle quote (3 lines)
> * gnu/services/ils.scm: New file.
> * gnu/local.mk: Add it.

[...]

Toggle quote (15 lines)
> + #~(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.

Toggle quote (20 lines)
> + (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.

Toggle quote (8 lines)
> + ;; 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 …))

Toggle quote (9 lines)
> +(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.
L
L
Ludovic Courtès wrote on 20 Dec 2022 16:13
(name . Yarl Baudig)(address . yarl-baudig@mailoo.org)(address . 59845@debbugs.gnu.org)
87tu1q5cs6.fsf_-_@gnu.org
Yarl Baudig <yarl-baudig@mailoo.org> skribis:

Toggle quote (3 lines)
> 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.

Toggle quote (7 lines)
> +@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.

Toggle quote (19 lines)
> +@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.

Toggle quote (3 lines)
> +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).

Toggle quote (17 lines)
> +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’.
Y
Y
yarl baudig wrote on 22 Dec 2022 18:18
Re: bug#59845: [PATCH 0/4] Add PMB (Integrated Library System)
(address . ludo@gnu.org)(address . 59845@debbugs.gnu.org)
ea-mime-63a49151-25d2-14de0e0e@www.mailo.com
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.

Toggle quote (18 lines)
>
> > + ;; 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?

Toggle quote (23 lines)
> > + #~(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?
L
L
Ludovic Courtès wrote on 22 Dec 2022 23:40
(name . yarl baudig)(address . yarl-baudig@mailoo.org)
87bknv12q3.fsf@gnu.org
Hi,

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

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

Toggle quote (2 lines)
> 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?

Toggle quote (19 lines)
>> > + ;; 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.

Toggle quote (13 lines)
> 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. :-)

Toggle quote (25 lines)
>> > + #~(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’.
Y
Y
yarl baudig wrote on 23 Dec 2022 09:17
(address . ludo@gnu.org)
ea-mime-63a56432-4d4d-141e6f09@www.mailo.com
Toggle quote (15 lines)
> >
> > 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"?
L
L
Ludovic Courtès wrote on 25 Dec 2022 18:26
(name . yarl baudig)(address . yarl-baudig@mailoo.org)
87pmc7wg1q.fsf@gnu.org
Hi,

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

Toggle quote (19 lines)
>> >
>> > 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).

Toggle quote (6 lines)
> 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.

Toggle quote (2 lines)
> 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’.
L
L
Ludovic Courtès wrote on 8 Jan 2023 15:32
control message for bug #59845
(address . control@debbugs.gnu.org)
87358lw0zg.fsf@gnu.org
tags 59845 + moreinfo
quit
?