From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga03.intel.com (mga03.intel.com [143.182.124.21]) by yocto-www.yoctoproject.org (Postfix) with ESMTP id 841A4E01709 for ; Tue, 15 Oct 2013 14:54:36 -0700 (PDT) Received: from azsmga001.ch.intel.com ([10.2.17.19]) by azsmga101.ch.intel.com with ESMTP; 15 Oct 2013 14:54:36 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="4.93,502,1378882800"; d="scan'208";a="375215874" Received: from unknown (HELO helios.localnet) ([10.252.120.232]) by azsmga001.ch.intel.com with ESMTP; 15 Oct 2013 14:54:35 -0700 From: Paul Eggleton To: Davide Soldan Date: Tue, 15 Oct 2013 22:54:34 +0100 Message-ID: <5619929.RHDHdia3Vk@helios> Organization: Intel Corporation User-Agent: KMail/4.10.5 (Linux/3.8.0-31-generic; KDE/4.10.5; i686; ; ) In-Reply-To: <1425778.v7NdBFTXrz@helios> References: <2654026.GvoHhChOvl@fedora-fisso> <2594354.j31pHjW9di@fedora-fisso> <1425778.v7NdBFTXrz@helios> MIME-Version: 1.0 Cc: yocto@yoctoproject.org Subject: Re: preserving file owners in do_package X-BeenThere: yocto@yoctoproject.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: Discussion of all things Yocto Project List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 15 Oct 2013 21:54:38 -0000 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="iso-8859-1" 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=EC 15 ottobre 2013 11:38:21, Paul Eggleton ha scritt= o: > > > On Tuesday 15 October 2013 12:02:20 Davide Soldan wrote: > > > > in my recipe I want to change owner and permission of a file, s= o I > > > > wrote: > > > >=20 > > > > do_install() { > > > >=20 > > > > 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 > > > >=20 > > > > } > > > >=20 > > > > the output of ls commands is: > > > >=20 > > > > 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 > > > >=20 > > > > 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 > > > >=20 > > > > 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 > > > >=20 > > > > 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 o= wner > > > > change > > > > done in do_install? Or maybe I'm doing something wrong in chang= ing > > > > file > > > > owner? Any ideas? Thanks to all! > > >=20 > > > Does your recipe create the specified user via useradd.bbclass? > >=20 > > I solved with a postinstall script (that run at boot): > >=20 > > pkg_postinst_${PN}() { > >=20 > > #!/bin/sh -e > > if [ x"$D" =3D "x" ]; then > > =20 > > chown -R user /opt/user > > chgrp -R user /opt/user > > =20 > > else > > =20 > > exit 1 > > =20 > > fi > >=20 > > } >=20 > 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. Typ= ically,=20 recipes that need a specific user to exist use useradd.bbclass themselv= es=20 rather than depending upon another recipe that does it. However, if you= do=20 need to do it in a separate recipe (e.g. because multiple recipes use t= he same=20 user account), just adding the other recipe to DEPENDS does not guarant= ee that=20 it will be around at runtime - the actual package generated by the othe= r=20 recipe (usually the same name) would need to be added to RDEPENDS_${PN}= .=20 Additionally, if you do this, you should be able to have your postinsta= ll=20 script run at all times; it should not need to be guarded to run only o= n the=20 target (although https://bugzilla.yoctoproject.org/show_bug.cgi?id=3D53= 18 may=20 interfere with this if you are using ipk or deb.) Cheers, Paul --=20 Paul Eggleton Intel Open Source Technology Centre