[2/3] dhcp: move dhcp leases files handling to postinst/postrm

Submitted by Otavio Salvador on Feb. 1, 2012, 8:27 p.m.

Details

Message ID 429ddbe3779c6957e6ecad5ae37200865e19fa0f.1328127940.git.otavio@ossystems.com.br
State New
Headers show

Commit Message

Otavio Salvador Feb. 1, 2012, 8:27 p.m.
Both server and client needs access to leases files so its creation
and removal are now handled by postinst/postrm scripts.

Signed-off-by: Otavio Salvador <otavio@ossystems.com.br>
---
 meta/recipes-connectivity/dhcp/dhcp.inc      |   19 ++++++++++++++++++-
 meta/recipes-connectivity/dhcp/dhcp_4.2.0.bb |    2 +-
 2 files changed, 19 insertions(+), 2 deletions(-)

Patch hide | download patch | download mbox

diff --git a/meta/recipes-connectivity/dhcp/dhcp.inc b/meta/recipes-connectivity/dhcp/dhcp.inc
index be256ce..9f0c5ea 100644
--- a/meta/recipes-connectivity/dhcp/dhcp.inc
+++ b/meta/recipes-connectivity/dhcp/dhcp.inc
@@ -66,12 +66,29 @@  FILES_dhcp-server-config = "${sysconfdir}/default/dhcp-server ${sysconfdir}/dhcp
 
 FILES_dhcp-relay = "${sbindir}/dhcrelay ${sysconfdir}/init.d/dhcp-relay ${sysconfdir}/default/dhcp-relay"
 
-FILES_dhcp-client = "${base_sbindir}/dhclient ${base_sbindir}/dhclient-script ${sysconfdir}/dhcp/dhclient.conf ${localstatedir}/lib/dhcp/"
+FILES_dhcp-client = "${base_sbindir}/dhclient ${base_sbindir}/dhclient-script ${sysconfdir}/dhcp/dhclient.conf"
 RDEPENDS_dhcp-client = "bash"
 
 FILES_dhcp-omshell = "${bindir}/omshell"
 
 pkg_postinst_dhcp-server() {
+    install -d $D/${localstatedir}/lib/dhcp
     touch $D/${localstatedir}/lib/dhcp/dhcpd.leases
     touch $D/${localstatedir}/lib/dhcp/dhcpd6.leases
 }
+
+pkg_postinst_dhcp-client() {
+    install -d $D/${localstatedir}/lib/dhcp
+}
+
+pkg_postrm_dhcp-server() {
+    rm -f $D/${localstatedir}/lib/dhcp/dhcpd.leases
+    rm -f $D/${localstatedir}/lib/dhcp/dhcpd6.leases
+    rmdir $D/${localstatedir}/lib/dhcp
+}
+
+pkg_postrm_dhcp-client() {
+    rm -f $D/${localstatedir}/lib/dhcp/dhclient.leases
+    rm -f $D/${localstatedir}/lib/dhcp/dhclient6.leases
+    rmdir $D/${localstatedir}/lib/dhcp
+}
diff --git a/meta/recipes-connectivity/dhcp/dhcp_4.2.0.bb b/meta/recipes-connectivity/dhcp/dhcp_4.2.0.bb
index a3a560b..478fd06 100644
--- a/meta/recipes-connectivity/dhcp/dhcp_4.2.0.bb
+++ b/meta/recipes-connectivity/dhcp/dhcp_4.2.0.bb
@@ -1,6 +1,6 @@ 
 require dhcp.inc
 
-PR = "r5"
+PR = "r6"
 
 SRC_URI += "file://fixincludes.patch \
             file://dhcp-3.0.3-dhclient-dbus.patch;striplevel=0 \

Comments

Phil Blundell Feb. 1, 2012, 8:57 p.m.
On Wed, 2012-02-01 at 20:27 +0000, Otavio Salvador wrote:
>  pkg_postinst_dhcp-server() {
> +    install -d $D/${localstatedir}/lib/dhcp

Is "install" guaranteed to be available on the target?  I would have
thought "mkdir -p" would be better.

p.
Otavio Salvador Feb. 1, 2012, 9:01 p.m.
On Wed, Feb 1, 2012 at 18:57, Phil Blundell <philb@gnu.org> wrote:

> On Wed, 2012-02-01 at 20:27 +0000, Otavio Salvador wrote:
> >  pkg_postinst_dhcp-server() {
> > +    install -d $D/${localstatedir}/lib/dhcp
>
> Is "install" guaranteed to be available on the target?  I would have
> thought "mkdir -p" would be better.
>

It worked on all images I tested. I have no strong opinions about it.
Phil Blundell Feb. 2, 2012, 10:43 a.m.
On Wed, 2012-02-01 at 19:01 -0200, Otavio Salvador wrote:
> On Wed, Feb 1, 2012 at 18:57, Phil Blundell <philb@gnu.org> wrote:
>         On Wed, 2012-02-01 at 20:27 +0000, Otavio Salvador wrote:
>         >  pkg_postinst_dhcp-server() {
>         > +    install -d $D/${localstatedir}/lib/dhcp
>         
>         
>         Is "install" guaranteed to be available on the target?  I
>         would have
>         thought "mkdir -p" would be better.
> 
> 
> It worked on all images I tested. I have no strong opinions about it. 

I just checked a rootfs that I happened to have lying around and there
was indeed no "install" binary in there.  Admittedly I always build with
O_P_M=none so it isn't going to cause me any real problem, but
presumably there might be other folks who have O_P_M on and still lack
"install".  So I think it would be best to change this.

p.
Richard Purdie Feb. 2, 2012, 2:53 p.m.
On Thu, 2012-02-02 at 10:43 +0000, Phil Blundell wrote:
> On Wed, 2012-02-01 at 19:01 -0200, Otavio Salvador wrote:
> > On Wed, Feb 1, 2012 at 18:57, Phil Blundell <philb@gnu.org> wrote:
> >         On Wed, 2012-02-01 at 20:27 +0000, Otavio Salvador wrote:
> >         >  pkg_postinst_dhcp-server() {
> >         > +    install -d $D/${localstatedir}/lib/dhcp
> >         
> >         
> >         Is "install" guaranteed to be available on the target?  I
> >         would have
> >         thought "mkdir -p" would be better.
> > 
> > 
> > It worked on all images I tested. I have no strong opinions about it. 
> 
> I just checked a rootfs that I happened to have lying around and there
> was indeed no "install" binary in there.  Admittedly I always build with
> O_P_M=none so it isn't going to cause me any real problem, but
> presumably there might be other folks who have O_P_M on and still lack
> "install".  So I think it would be best to change this.

Agreed, mkdir is much more likely to be available than install on most
target machines.

Cheers,

Richard
Otavio Salvador Feb. 2, 2012, 6:34 p.m.
On Thu, Feb 2, 2012 at 12:53, Richard Purdie <
richard.purdie@linuxfoundation.org> wrote:

> Agreed, mkdir is much more likely to be available than install on most
> target machines.
>

I did it and pushed to my tree.

When changing it, I bumped PR again as I had it merged in our local tree to
fix this problem for yestarday build and so I'd like to keep those in sync.

Want me to send it again or you pick it from there?