From: Georgi Kirilov <kirilov.georgi.s@gmail.com>
To: guix-devel@gnu.org
Subject: Re: A postinst equivalent in Guix?
Date: Sat, 21 Jan 2017 16:39:23 +0200 [thread overview]
Message-ID: <20170121143923.vdmmljvc3ngksuze@gmail.com> (raw)
In-Reply-To: <87efzxakmi.fsf@gnu.org>
[-- Attachment #1: Type: text/plain, Size: 2011 bytes --]
On Fri, Jan 20, 2017 at 03:09:25PM +0100, Ludovic Courtès wrote:
>
>> A program in a package I created is trying to access /var, but has no
>> permissions. (Well, /gnu/store/.../var)
>
>First, you probably need to pass --localstatedir=/var to this package’s
>configure state, since at run time it won’t be able to write to
>/gnu/store/…/var anyway.
>
>Second, it will try and fail to create /var. The way to address that is
>by simply commenting out or patching out the offending commands. See
>for instance ‘avahi-localstatedir.patch’ or ‘mcron-install.patch’.
That's what happened indeed. When I removed the writes to /var the build
passed. But the programs in the package couldn't write to the system /var
directory, since they expect /var/lib/<package>/ to exist and be
writable.
Besides, writing to /var on a foreign distro may interfere with the same
package installed natively there (if it is installed).
>> is there anything in Guix that can do things at install time, like postinst
>> scripts in Debian?
>
>No. There are “profile hooks” in (guix profiles) that are used to a
>similar effect, for instance to assemble the ‘dir’ file that contains
>pointers to Info documentation.
This looks to me much better than the system-wide /var. It is not only
user-specific, but generation-specific. Really nice mechanism.
I tried to write a new hook, to scan the installed packages and if they
have a /var/lib/<package>/ inside, to create a writable copy in the
user's profile, so the programs can write to it without interfering with
anything on the system.
It didn't work because the hook's output turned out to be immutable...
Whatever chmod or chown I tried inside the hook, the files always ended
up '-r--r--r-- root root'
Why are these customizations immutable?
I'm probably missing something, but nothing seems to depend on them.
If there was a way to create a writable customization, that would be
the perfect place to put /var directories.
--
Regards,
Georgi
[-- Attachment #2: var-lib-package.patch --]
[-- Type: text/x-diff, Size: 1800 bytes --]
--- profiles.scm 2017-01-21 16:30:02.436621423 +0200
+++ bak/profiles.scm 2017-01-21 16:29:06.631019582 +0200
@@ -516,6 +516,34 @@
(anym %store-monad
entry-lookup-package (manifest-entries manifest)))
+(define (var-lib-package manifest)
+ (define build
+ (with-imported-modules '((guix build utils))
+ #~(begin
+ (use-modules (guix build utils)
+ (srfi srfi-1) (srfi srfi-26)
+ (ice-9 ftw))
+ (define profile-var-lib (string-append #$output "/var/lib"))
+ (define (package-var-libs top)
+ (let ((varlibdir (string-append top "/var/lib")))
+ (map (cut string-append varlibdir "/" <>)
+ (or (scandir varlibdir (lambda (file)
+ (not (member file '("." ".."))))) '()))))
+ (define (install-var dir)
+ (copy-recursively dir profile-var-lib)
+ ;; the file mode ends up being overwritten:
+ ;; (chmod dir #o777)
+ ;; guixbuilder* users can't do chown:
+ ;; (chown dir 1000 100)
+ )
+ (mkdir-p profile-var-lib)
+ (exit (every install-var
+ (append-map package-var-libs
+ '#$(manifest-inputs manifest)))))))
+ (gexp->derivation "var-lib" build
+ #:local-build? #t
+ #:substitutable? #f))
+
(define (info-dir-file manifest)
"Return a derivation that builds the 'dir' file for all the entries of
MANIFEST."
@@ -909,6 +937,7 @@
;; This is the list of derivation-returning procedures that are called by
;; default when making a non-empty profile.
(list info-dir-file
+ var-lib-package
fonts-dir-file
ghc-package-cache-file
ca-certificate-bundle
next prev parent reply other threads:[~2017-01-21 14:39 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-01-19 18:30 A postinst equivalent in Guix? Georgi Kirilov
2017-01-20 6:23 ` John Darrington
2017-01-20 14:09 ` Ludovic Courtès
2017-01-21 14:39 ` Georgi Kirilov [this message]
2017-01-21 15:34 ` Ludovic Courtès
2017-01-21 16:36 ` Georgi Kirilov
2017-01-23 9:34 ` Ludovic Courtès
2017-01-25 0:26 ` Christopher Allan Webber
2017-01-25 13:15 ` Ludovic Courtès
2017-01-25 13:42 ` John Darrington
2017-01-25 16:19 ` Christopher Allan Webber
2017-01-25 14:54 ` Georgi Kirilov
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20170121143923.vdmmljvc3ngksuze@gmail.com \
--to=kirilov.georgi.s@gmail.com \
--cc=guix-devel@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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.