* [gentoo-user] Automatically copy a file to a different location after package install/update
@ 2016-05-10 8:53 J. Roeleveld
2016-05-10 9:01 ` Neil Bothwick
0 siblings, 1 reply; 8+ messages in thread
From: J. Roeleveld @ 2016-05-10 8:53 UTC (permalink / raw
To: gentoo-user
Hi all,
I have accounts configured in LDAP (OpenLDAP)
And a FTP-server on a different host.
The FTP server succesfully authenticates against OpenLDAP, using a schema
provided by the FTP server ebuild.
Currently, I have to manually remember to copy the schema across when I update
the ftp-server. Is there a way to set up a little script that will
automatically copy the schema file to a different location after a successful
install/update without having to patch the ebuild-files. (manually copying is
less error-prone)
Many thanks,
Joost
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [gentoo-user] Automatically copy a file to a different location after package install/update
2016-05-10 8:53 [gentoo-user] Automatically copy a file to a different location after package install/update J. Roeleveld
@ 2016-05-10 9:01 ` Neil Bothwick
2016-05-10 12:44 ` [SOLVED] " J. Roeleveld
0 siblings, 1 reply; 8+ messages in thread
From: Neil Bothwick @ 2016-05-10 9:01 UTC (permalink / raw
To: gentoo-user
[-- Attachment #1: Type: text/plain, Size: 784 bytes --]
On Tue, 10 May 2016 10:53:03 +0200, J. Roeleveld wrote:
> Currently, I have to manually remember to copy the schema across when I
> update the ftp-server. Is there a way to set up a little script that
> will automatically copy the schema file to a different location after a
> successful install/update without having to patch the ebuild-files.
> (manually copying is less error-prone)
You can define hooks in /etc/portage/bashrc and /etc/portage/env that are
run at various stages of the ebuild. A post_install hook in
/etc/portage/env/cat/ftp-server should do what you want.
https://dev.gentoo.org/~zmedico/portage/doc/portage.html#config-bashrc-ebuild-phase-hooks
--
Neil Bothwick
A great many people mistake opinions for thoughts. -- Herbert V. Prochnow
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 181 bytes --]
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [SOLVED] [gentoo-user] Automatically copy a file to a different location after package install/update
2016-05-10 9:01 ` Neil Bothwick
@ 2016-05-10 12:44 ` J. Roeleveld
2016-05-10 14:13 ` Neil Bothwick
0 siblings, 1 reply; 8+ messages in thread
From: J. Roeleveld @ 2016-05-10 12:44 UTC (permalink / raw
To: gentoo-user
[-- Attachment #1: Type: text/plain, Size: 1344 bytes --]
On Tuesday, May 10, 2016 10:01:10 AM Neil Bothwick wrote:
> On Tue, 10 May 2016 10:53:03 +0200, J. Roeleveld wrote:
> > Currently, I have to manually remember to copy the schema across when I
> > update the ftp-server. Is there a way to set up a little script that
> > will automatically copy the schema file to a different location after a
> > successful install/update without having to patch the ebuild-files.
> > (manually copying is less error-prone)
>
> You can define hooks in /etc/portage/bashrc and /etc/portage/env that are
> run at various stages of the ebuild. A post_install hook in
> /etc/portage/env/cat/ftp-server should do what you want.
>
> https://dev.gentoo.org/~zmedico/portage/doc/portage.html#config-bashrc-ebuil
> d-phase-hooks
Thank you for the reply. It gave me the keywords to search for.
If anyone else ever needs to write something similar, here is how I got it to
work:
=====
# cat /etc/portage/bashrc
#!/bin/bash
if [ "${EBUILD_PHASE}" = "postinst" ]
then
if [ "${CATEGORY}/${PN}" = "net-ftp/pure-ftpd" ]
then
cp /etc/openldap/schema/pureftpd.schema
/opt/packages/SHARED/etc/openldap/schema/pureftpd.schema
echo "NOTE: LDAP Schema File copied."
fi
fi
======
This should be easy to adjust to needs.
Using /etc/portage/env doesn't work.
--
Joost
[-- Attachment #2: This is a digitally signed message part. --]
[-- Type: application/pgp-signature, Size: 473 bytes --]
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [SOLVED] [gentoo-user] Automatically copy a file to a different location after package install/update
2016-05-10 12:44 ` [SOLVED] " J. Roeleveld
@ 2016-05-10 14:13 ` Neil Bothwick
2016-05-10 14:30 ` J. Roeleveld
0 siblings, 1 reply; 8+ messages in thread
From: Neil Bothwick @ 2016-05-10 14:13 UTC (permalink / raw
To: gentoo-user
[-- Attachment #1: Type: text/plain, Size: 1577 bytes --]
On Tue, 10 May 2016 14:44:58 +0200, J. Roeleveld wrote:
> > You can define hooks in /etc/portage/bashrc and /etc/portage/env that
> > are run at various stages of the ebuild. A post_install hook in
> > /etc/portage/env/cat/ftp-server should do what you want.
> >
> > https://dev.gentoo.org/~zmedico/portage/doc/portage.html#config-bashrc-ebuil
> > d-phase-hooks
>
> Thank you for the reply. It gave me the keywords to search for.
>
> If anyone else ever needs to write something similar, here is how I got
> it to work:
>
> =====
> # cat /etc/portage/bashrc
>
> #!/bin/bash
>
> if [ "${EBUILD_PHASE}" = "postinst" ]
> then
> if [ "${CATEGORY}/${PN}" = "net-ftp/pure-ftpd" ]
> then
> cp /etc/openldap/schema/pureftpd.schema
> /opt/packages/SHARED/etc/openldap/schema/pureftpd.schema
> echo "NOTE: LDAP Schema File copied."
> fi
> fi
>
> ======
Couldn't you do it with register_install_hook? I've not done it with that
phase, but I have used hooks like this.
>
> This should be easy to adjust to needs.
>
> Using /etc/portage/env doesn't work.
I think the approach there is to define pkg_postinst()
in /etc/portage/cat/pkg, then that function is run after the install
phase of the ebuild.
Something like
pkg_postinst() {
cp /etc/openldap/schema/pureftpd.schema
/opt/packages/SHARED/etc/openldap/schema/pureftpd.schema
einfo "NOTE: LDAP Schema File copied."
}
in /etc/portage/env/net-ftp/pure-ftpd
--
Neil Bothwick
"Doing it right is no excuse for not meeting the schedule."
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 181 bytes --]
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [SOLVED] [gentoo-user] Automatically copy a file to a different location after package install/update
2016-05-10 14:13 ` Neil Bothwick
@ 2016-05-10 14:30 ` J. Roeleveld
2016-05-10 15:08 ` Neil Bothwick
0 siblings, 1 reply; 8+ messages in thread
From: J. Roeleveld @ 2016-05-10 14:30 UTC (permalink / raw
To: gentoo-user
[-- Attachment #1: Type: text/plain, Size: 2088 bytes --]
On Tuesday, May 10, 2016 03:13:08 PM Neil Bothwick wrote:
> On Tue, 10 May 2016 14:44:58 +0200, J. Roeleveld wrote:
> > > You can define hooks in /etc/portage/bashrc and /etc/portage/env that
> > > are run at various stages of the ebuild. A post_install hook in
> > > /etc/portage/env/cat/ftp-server should do what you want.
> > >
> > > https://dev.gentoo.org/~zmedico/portage/doc/portage.html#config-bashrc-e
> > > buil d-phase-hooks
> >
> > Thank you for the reply. It gave me the keywords to search for.
> >
> > If anyone else ever needs to write something similar, here is how I got
> > it to work:
> >
> > =====
> > # cat /etc/portage/bashrc
> >
> > #!/bin/bash
> >
> > if [ "${EBUILD_PHASE}" = "postinst" ]
> > then
> >
> > if [ "${CATEGORY}/${PN}" = "net-ftp/pure-ftpd" ]
> > then
> >
> > cp /etc/openldap/schema/pureftpd.schema
> >
> > /opt/packages/SHARED/etc/openldap/schema/pureftpd.schema
> >
> > echo "NOTE: LDAP Schema File copied."
> >
> > fi
> >
> > fi
> >
> > ======
>
> Couldn't you do it with register_install_hook? I've not done it with that
> phase, but I have used hooks like this.
>
> > This should be easy to adjust to needs.
> >
> > Using /etc/portage/env doesn't work.
>
> I think the approach there is to define pkg_postinst()
> in /etc/portage/cat/pkg, then that function is run after the install
> phase of the ebuild.
>
> Something like
>
>
> pkg_postinst() {
> cp /etc/openldap/schema/pureftpd.schema
> /opt/packages/SHARED/etc/openldap/schema/pureftpd.schema
> einfo "NOTE: LDAP Schema File copied."
> }
>
> in /etc/portage/env/net-ftp/pure-ftpd
When I did that, it complained about the syntax.
Apparently, from what I read through google-searches, /etc/portage/env/... is
handled by Python. And that doesn't, obviously, understand bash-syntax.
/etc/portage/bashrc is handled by Bash, which makes this possible.
The "pkg_postinst()" is for either ebuilds, or I am doing something wrong...
I am using the latest stable portage.
--
Joost
[-- Attachment #2: This is a digitally signed message part. --]
[-- Type: application/pgp-signature, Size: 473 bytes --]
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [SOLVED] [gentoo-user] Automatically copy a file to a different location after package install/update
2016-05-10 14:30 ` J. Roeleveld
@ 2016-05-10 15:08 ` Neil Bothwick
2016-05-10 15:49 ` [gentoo-user] Re: [SOLVED] " James
0 siblings, 1 reply; 8+ messages in thread
From: Neil Bothwick @ 2016-05-10 15:08 UTC (permalink / raw
To: gentoo-user
[-- Attachment #1: Type: text/plain, Size: 1261 bytes --]
On Tue, 10 May 2016 16:30:49 +0200, J. Roeleveld wrote:
> > pkg_postinst() {
> > cp /etc/openldap/schema/pureftpd.schema
> > /opt/packages/SHARED/etc/openldap/schema/pureftpd.schema
> > einfo "NOTE: LDAP Schema File copied."
> > }
> >
> > in /etc/portage/env/net-ftp/pure-ftpd
>
> When I did that, it complained about the syntax.
> Apparently, from what I read through
> google-searches, /etc/portage/env/... is handled by Python. And that
> doesn't, obviously, understand bash-syntax.
I definitely have bash in there.
> /etc/portage/bashrc is handled by Bash, which makes this possible.
>
> The "pkg_postinst()" is for either ebuilds, or I am doing something
> wrong...
You can define functions as for ebuilds to have them executed in here.
For example, for one package that I wanted to apply a patch
from /etc/portage/patches, but didn't call epatch_user from its ebuild,
I put this in /etc/portage/env/cat/pkg
post_src_unpack() {
cd "${S}"
epatch_user
}
> I am using the latest stable portage.
I'm using testing here, but have used this for years, so it worked with
versions older than the current stable.
--
Neil Bothwick
Things are more like they are now than they ever were before.
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 181 bytes --]
^ permalink raw reply [flat|nested] 8+ messages in thread
* [gentoo-user] Re: [SOLVED] Automatically copy a file to a different location after package install/update
2016-05-10 15:08 ` Neil Bothwick
@ 2016-05-10 15:49 ` James
2016-05-10 16:03 ` Neil Bothwick
0 siblings, 1 reply; 8+ messages in thread
From: James @ 2016-05-10 15:49 UTC (permalink / raw
To: gentoo-user
Neil Bothwick <neil <at> digimed.co.uk> writes:
> You can define functions as for ebuilds to have them executed in here.
> For example, for one package that I wanted to apply a patch
> from /etc/portage/patches, but didn't call epatch_user from its ebuild,
> I put this in /etc/portage/env/cat/pkg
I'm most interested in what you guys are discussing, so thanks...
Maybe the result of this thread belongs either in the devManual
or some example linked to the devManual?
> post_src_unpack() {
> cd "${S}"
> epatch_user
> }
Didn't I read somewhere that 'epatch' is changing in EAPI 6 or 7?
That may affect your solution?
Maybe a better solution is to put this function/feature into
one of the eclasses?
(note, I'm no expert here so ..... a dev or 2 might want to chime
in or verify? )
curiously,
James
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [gentoo-user] Re: [SOLVED] Automatically copy a file to a different location after package install/update
2016-05-10 15:49 ` [gentoo-user] Re: [SOLVED] " James
@ 2016-05-10 16:03 ` Neil Bothwick
0 siblings, 0 replies; 8+ messages in thread
From: Neil Bothwick @ 2016-05-10 16:03 UTC (permalink / raw
To: gentoo-user
[-- Attachment #1: Type: text/plain, Size: 747 bytes --]
On Tue, 10 May 2016 15:49:24 +0000 (UTC), James wrote:
> > post_src_unpack() {
> > cd "${S}"
> > epatch_user
> > }
>
>
> Didn't I read somewhere that 'epatch' is changing in EAPI 6 or 7?
epatch_user is automatic with EAPI6
> That may affect your solution?
No, because the ebuild in question was not EAPI6, so epatch_user only got
run if specified in the ebuild.
--
Neil Bothwick
Das Internet is nicht fuer gefingerclicken und giffengrabben. Ist easy
droppenpacket der routers und overloaden der backbone mit der spammen
und der me-tooen. Ist nicht fuer gewerken bei das dumpkopfen. Das
mausklicken sichtseeren keepen das bandwit-spewin hans in das pockets
muss; relaxen und watchen das cursorblinken.
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 181 bytes --]
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2016-05-10 16:03 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-05-10 8:53 [gentoo-user] Automatically copy a file to a different location after package install/update J. Roeleveld
2016-05-10 9:01 ` Neil Bothwick
2016-05-10 12:44 ` [SOLVED] " J. Roeleveld
2016-05-10 14:13 ` Neil Bothwick
2016-05-10 14:30 ` J. Roeleveld
2016-05-10 15:08 ` Neil Bothwick
2016-05-10 15:49 ` [gentoo-user] Re: [SOLVED] " James
2016-05-10 16:03 ` Neil Bothwick
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox