From: Paul Eggleton <paul.eggleton@linux.intel.com>
To: Davide Soldan <davide.soldan@kynetics.it>
Cc: yocto@yoctoproject.org
Subject: Re: preserving file owners in do_package
Date: Tue, 15 Oct 2013 22:54:34 +0100 [thread overview]
Message-ID: <5619929.RHDHdia3Vk@helios> (raw)
In-Reply-To: <1425778.v7NdBFTXrz@helios>
On Tuesday 15 October 2013 17:18:35 Paul Eggleton wrote:
> On Tuesday 15 October 2013 18:12:42 Davide Soldan wrote:
> > In data martedì 15 ottobre 2013 11:38:21, Paul Eggleton ha scritto:
> > > On Tuesday 15 October 2013 12:02:20 Davide Soldan wrote:
> > > > in my recipe I want to change owner and permission of a file, so I
> > > > wrote:
> > > >
> > > > do_install() {
> > > >
> > > > ls -la ${D}/opt/user
> > > > chown -R user ${D}/opt/user
> > > > chgrp -R user ${D}/opt/user
> > > > ls -la ${D}/opt/user
> > > > chmod 754 ${D}/opt/user/user.sh
> > > > ls -la ${D}/opt/user
> > > >
> > > > }
> > > >
> > > > the output of ls commands is:
> > > >
> > > > drwxr-xr-x 8 root root 4096 Oct 15 11:13 .
> > > > drwxr-xr-x 3 root root 4096 Oct 15 11:13 ..
> > > > -rw-r--r-- 1 *root root* 55753 Aug 2 08:48 user.sh
> > > >
> > > > drwxr-xr-x 8 user user 4096 Oct 15 11:13 .
> > > > drwxr-xr-x 3 root root 4096 Oct 15 11:13 ..
> > > > -rw-r--r-- 1 *user user* 55753 Aug 2 08:48 user.sh
> > > >
> > > > drwxr-xr-x 8 user user 4096 Oct 15 11:13 .
> > > > drwxr-xr-x 3 root root 4096 Oct 15 11:13 ..
> > > > *-rwxr-xr--* 1 user user 55753 Aug 2 08:48 user.sh
> > > >
> > > > So the change of owner and permission works fine in do_install phase.
> > > > Opening the final rootfs tarball, however, the file user.sh has still
> > > > 754
> > > > permission but root as owner...so do_package doesn't preserve owner
> > > > change
> > > > done in do_install? Or maybe I'm doing something wrong in changing
> > > > file
> > > > owner? Any ideas? Thanks to all!
> > >
> > > Does your recipe create the specified user via useradd.bbclass?
> >
> > I solved with a postinstall script (that run at boot):
> >
> > pkg_postinst_${PN}() {
> >
> > #!/bin/sh -e
> > if [ x"$D" = "x" ]; then
> >
> > chown -R user /opt/user
> > chgrp -R user /opt/user
> >
> > else
> >
> > exit 1
> >
> > fi
> >
> > }
>
> This shouldn't be necessary though. I honestly can't tell you why it doesn't
> work as specified. I think it might be worth filing a bug for this.
Actually, thinking about it I don't think this is expected to work. Typically,
recipes that need a specific user to exist use useradd.bbclass themselves
rather than depending upon another recipe that does it. However, if you do
need to do it in a separate recipe (e.g. because multiple recipes use the same
user account), just adding the other recipe to DEPENDS does not guarantee that
it will be around at runtime - the actual package generated by the other
recipe (usually the same name) would need to be added to RDEPENDS_${PN}.
Additionally, if you do this, you should be able to have your postinstall
script run at all times; it should not need to be guarded to run only on the
target (although https://bugzilla.yoctoproject.org/show_bug.cgi?id=5318 may
interfere with this if you are using ipk or deb.)
Cheers,
Paul
--
Paul Eggleton
Intel Open Source Technology Centre
next prev parent reply other threads:[~2013-10-15 21:54 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-10-15 10:02 preserving file owners in do_package Davide Soldan
2013-10-15 10:38 ` Paul Eggleton
2013-10-15 10:50 ` Davide Soldan
2013-10-15 16:12 ` Davide Soldan
2013-10-15 16:18 ` Paul Eggleton
2013-10-15 21:54 ` Paul Eggleton [this message]
2013-10-18 13:31 ` Davide Soldan
2013-10-18 13:38 ` Paul Eggleton
2013-10-18 13:57 ` Davide Soldan
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=5619929.RHDHdia3Vk@helios \
--to=paul.eggleton@linux.intel.com \
--cc=davide.soldan@kynetics.it \
--cc=yocto@yoctoproject.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.
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.