Gentoo Archives: gentoo-user

From: Neil Bothwick <neil@××××××××××.uk>
To: gentoo-user@l.g.o
Subject: Re: [SOLVED] [gentoo-user] Automatically copy a file to a different location after package install/update
Date: Tue, 10 May 2016 14:13:25
Message-Id: 20160510151308.38311166@digimed.co.uk
In Reply to: Re: [SOLVED] [gentoo-user] Automatically copy a file to a different location after package install/update by "J. Roeleveld"
1 On Tue, 10 May 2016 14:44:58 +0200, J. Roeleveld wrote:
2
3 > > You can define hooks in /etc/portage/bashrc and /etc/portage/env that
4 > > are run at various stages of the ebuild. A post_install hook in
5 > > /etc/portage/env/cat/ftp-server should do what you want.
6 > >
7 > > https://dev.gentoo.org/~zmedico/portage/doc/portage.html#config-bashrc-ebuil
8 > > d-phase-hooks
9 >
10 > Thank you for the reply. It gave me the keywords to search for.
11 >
12 > If anyone else ever needs to write something similar, here is how I got
13 > it to work:
14 >
15 > =====
16 > # cat /etc/portage/bashrc
17 >
18 > #!/bin/bash
19 >
20 > if [ "${EBUILD_PHASE}" = "postinst" ]
21 > then
22 > if [ "${CATEGORY}/${PN}" = "net-ftp/pure-ftpd" ]
23 > then
24 > cp /etc/openldap/schema/pureftpd.schema
25 > /opt/packages/SHARED/etc/openldap/schema/pureftpd.schema
26 > echo "NOTE: LDAP Schema File copied."
27 > fi
28 > fi
29 >
30 > ======
31
32 Couldn't you do it with register_install_hook? I've not done it with that
33 phase, but I have used hooks like this.
34
35 >
36 > This should be easy to adjust to needs.
37 >
38 > Using /etc/portage/env doesn't work.
39
40 I think the approach there is to define pkg_postinst()
41 in /etc/portage/cat/pkg, then that function is run after the install
42 phase of the ebuild.
43
44 Something like
45
46
47 pkg_postinst() {
48 cp /etc/openldap/schema/pureftpd.schema
49 /opt/packages/SHARED/etc/openldap/schema/pureftpd.schema
50 einfo "NOTE: LDAP Schema File copied."
51 }
52
53 in /etc/portage/env/net-ftp/pure-ftpd
54
55
56 --
57 Neil Bothwick
58
59 "Doing it right is no excuse for not meeting the schedule."

Replies