Skip to contentSkip to conversation

introduce lib_subpackage

PATCH In review Sinan Kaya 2 participants 8 messages Dec 3, 2020 – Dec 9, 2020 1 message not in the archive

lore
Share & tools
lore

Sinan Kaya

author
#0 lore raw

PATCH v4 1/3 introduce lib_subpackage

This subclass allows us to easily split a recipe into subpackages.

---
 meta/classes/lib_subpackage.bbclass | 40 +++++++++++++++++++++++++++++
 1 file changed, 40 insertions(+)
 create mode 100644 meta/classes/lib_subpackage.bbclass
meta/classes/lib_subpackage.bbclass new file +40 -0
new file mode 100644
index 00000000000..a0c3d2446c7
@@ -0,0 +1,40 @@
+python __anonymous() {
+    packages = []
+
+    variables = [ ("base_sbindir_progs", "base_sbindir"),
+                  ("base_bindir_progs", "base_bindir"),
+                  ("bindir_progs", "bindir"),
+                  ("sbindir_progs", "sbindir"),
+                ]
+
+    for v in variables:
+        if d.getVar(v[0]) is None:
+            continue
+        for prog in d.getVar(v[0]).split():
+            pkg = "%s-%s" % (d.getVar("PN"), prog.replace("_", "-"))
+            packages.append(pkg)
+
+            # set alternatives
+            d.setVar("ALTERNATIVE_%s" % pkg, prog.replace("_", "-"))
+            d.setVarFlag('ALTERNATIVE_LINK_NAME', prog, '%s/%s' % (d.getVar(v[1]), prog))
+
+            d.setVar("RDEPENDS_%s" % pkg, "%s-lib" % d.getVar("PN"))
+            d.appendVar("FILES_%s" % pkg, " ${%s}/%s.%s" % (v[1], prog, d.getVar("BPN")))
+
+    pkg = "%s-man" % (d.getVar("PN"))
+    packages.append(pkg)
+    d.appendVar("FILES_%s" % pkg, " ${mandir}/*")
+
+    pkg = "%s-lib" % (d.getVar("PN"))
+    packages.append(pkg)
+    d.appendVar("FILES_%s" % pkg, " ${libdir}/*")
+
+    d.setVar("LIB_SUBPACKAGES_%s" % d.getVar("PN"), " ".join(packages))
+
+    d.setVar("FILES_%s" % d.getVar("PN"), "")
+    d.setVar("ALTERNATIVE_%s" % d.getVar("PN"), "")
+    d.setVar("ALLOW_EMPTY_%s" % d.getVar("PN"), "1")
+    d.appendVar("PACKAGES", " " + " ".join(packages))
+    d.appendVar("PROVIDES", " " + " ".join(packages))
+    d.appendVar("RRECOMMENDS_%s" % d.getVar("PN"), " " + " ".join(packages))
+}
Signature · 1 line
2.17.1
author
#1 lore raw

PATCH v4 2/3 net-tools: split into binary packages

Support per binary package to not bloat the system with unneeded tools.

---
 .../net-tools/net-tools_1.60-20181103.bb                 | 9 +--------
 1 file changed, 1 insertion(+), 8 deletions(-)
meta/recipes-extended/net-tools/net-tools_1.60-20181103.bb +1 -8
index e97731073e8..f9253123c24 100644
@@ -21,6 +21,7 @@ UPSTREAM_VERSION_UNKNOWN = "1"
 S = "${WORKDIR}/git"
 
 inherit gettext
+inherit lib_subpackage
 
 # The Makefile is lame, no parallel build
 PARALLEL_MAKE = ""
@@ -93,18 +94,10 @@ base_bindir_progs  = "ifconfig netstat route \
     ${@bb.utils.contains('PACKAGECONFIG', 'hostname', 'dnsdomainname domainname hostname nisdomainname ypdomainname', '', d)} \
 "
 
-ALTERNATIVE_${PN} = "${base_sbindir_progs} ${base_bindir_progs}"
 ALTERNATIVE_${PN}-doc += "${@bb.utils.contains('PACKAGECONFIG', 'hostname', 'hostname.1 dnsdomainname.1', '', d)}"
 ALTERNATIVE_LINK_NAME[hostname.1] = "${mandir}/man1/hostname.1"
 ALTERNATIVE_LINK_NAME[dnsdomainname.1] = "${mandir}/man1/dnsdomainname.1"
 ALTERNATIVE_PRIORITY[hostname.1] = "10"
-
-python __anonymous() {
-    for prog in d.getVar('base_sbindir_progs').split():
-        d.setVarFlag('ALTERNATIVE_LINK_NAME', prog, '%s/%s' % (d.getVar('base_sbindir'), prog))
-    for prog in d.getVar('base_bindir_progs').split():
-        d.setVarFlag('ALTERNATIVE_LINK_NAME', prog, '%s/%s' % (d.getVar('base_bindir'), prog))
-}
 ALTERNATIVE_PRIORITY = "100"
 
 BBCLASSEXTEND = "native nativesdk"
Signature · 1 line
2.17.1
author
#2 lore raw

PATCH v4 3/3 procps: split into binary subpackages

In reply to Sinan Kaya

This change allows you to pull individual binaries into the target without including the entire suite.

---
 meta/recipes-extended/procps/procps_3.3.16.bb | 15 ++++-----------
 1 file changed, 4 insertions(+), 11 deletions(-)
meta/recipes-extended/procps/procps_3.3.16.bb +4 -11
index 2810ebd285a..efca33127a4 100644
@@ -11,6 +11,7 @@ LIC_FILES_CHKSUM = "file://COPYING;md5=b234ee4d69f5fce4486a80fdaf4a4263 \
 DEPENDS = "ncurses"
 
 inherit autotools gettext pkgconfig update-alternatives
+inherit lib_subpackage
 
 SRC_URI = "git://gitlab.com/procps-ng/procps.git;protocol=https \
            file://sysctl.conf \
@@ -50,27 +51,19 @@ do_install_append () {
 
 CONFFILES_${PN} = "${sysconfdir}/sysctl.conf"
 
-bindir_progs = "free pkill pmap pgrep pwdx skill snice top uptime w"
+bindir_progs = "free pkill pmap pgrep pwdx skill slabtop snice tload top uptime vmstat w"
 base_bindir_progs += "kill pidof ps watch"
 base_sbindir_progs += "sysctl"
 
 ALTERNATIVE_PRIORITY = "200"
 ALTERNATIVE_PRIORITY[pidof] = "150"
 
-ALTERNATIVE_${PN} = "${bindir_progs} ${base_bindir_progs} ${base_sbindir_progs}"
-
 ALTERNATIVE_${PN}-doc = "kill.1 uptime.1"
 ALTERNATIVE_LINK_NAME[kill.1] = "${mandir}/man1/kill.1"
 ALTERNATIVE_LINK_NAME[uptime.1] = "${mandir}/man1/uptime.1"
 
-python __anonymous() {
-    for prog in d.getVar('base_bindir_progs').split():
-        d.setVarFlag('ALTERNATIVE_LINK_NAME', prog, '%s/%s' % (d.getVar('base_bindir'), prog))
-
-    for prog in d.getVar('base_sbindir_progs').split():
-        d.setVarFlag('ALTERNATIVE_LINK_NAME', prog, '%s/%s' % (d.getVar('base_sbindir'), prog))
-}
-
 # 'ps' isn't suitable for use as a security tool so whitelist this CVE.
 # https://bugzilla.redhat.com/show_bug.cgi?id=1575473#c3
 CVE_CHECK_WHITELIST += "CVE-2018-1121"
+
+FILES_${PN}-sysctl_append = " ${sysconfdir}/sysctl.conf ${sysconfdir}/sysctl.d"
Signature · 1 line
2.17.1
#3 lore raw
In reply to Sinan Kaya
Quoted 2 lines · Sinan Kaya

This subclass allows us to easily split a recipe into subpackages.

"lib_subpackage" seems a slightly odd name for something that isn't dealing with libraries. What's the etymology of that?

meta/classes/lib_subpackage.bbclass line 38

Quoted 2 lines
meta/classes/lib_subpackage.bbclass new file +2 -0
+    d.appendVar("PACKAGES", " " + " ".join(packages))
+    d.appendVar("PROVIDES", " " + " ".join(packages))

It seems a bit strange to be putting the same things in PACKAGES and PROVIDES. Is that actually necessary?

p.

author
#4 lore raw

+Richard,

Quoted 6 lines · Phil Blundell via lists.openembedded.org
Quoted 2 lines · Sinan Kaya

This subclass allows us to easily split a recipe into subpackages.

"lib_subpackage" seems a slightly odd name for something that isn't dealing with libraries. What's the etymology of that?

I'm open to giving it a better name. Richard pointed me to a file beginning with lib_foo.class for where this functionality could be hosted before.

Quoted 6 lines

meta/classes/lib_subpackage.bbclass line 38

Quoted 3 lines
meta/classes/lib_subpackage.bbclass new file +2 -0
+    d.appendVar("PACKAGES", " " + " ".join(packages))
+    d.appendVar("PROVIDES", " " + " ".join(packages))

It seems a bit strange to be putting the same things in PACKAGES and PROVIDES. Is that actually necessary?

I want to be able to include procps-ps without the entire procps package. I was not able to do that without the above two lines.

Quoted 7 lines

p.

#5 lore raw
Quoted 7 lines · Sinan Kaya

+Richard,

Quoted 4 lines · Phil Blundell via lists.openembedded.org
Quoted 2 lines · Sinan Kaya

This subclass allows us to easily split a recipe into subpackages.

Quoted 6 lines
Quoted 2 lines

"lib_subpackage" seems a slightly odd name for something that isn't dealing with libraries. What's the etymology of that?

I'm open to giving it a better name. Richard pointed me to a file beginning with lib_foo.class for where this functionality could be hosted before.

I suppose the interesting question here, then, is "what is this class actually for?" The description above says that it "allows us to easily split a recipe into subpackages" but doesn't say very much about what the consequences of including the class actually are or under what circumstances that's useful.

Reading between the lines the idea seems to be that this class is appropriate for recipes that build a collection of utilities each of which is essentially independent and is useful in its own right without any of the others. Is that right?

Quoted 8 lines
Quoted 5 lines

meta/classes/lib_subpackage.bbclass line 38

Quoted 2 lines
meta/classes/lib_subpackage.bbclass new file +2 -0
+    d.appendVar("PACKAGES", " " + " ".join(packages))
+    d.appendVar("PROVIDES", " " + " ".join(packages))

It seems a bit strange to be putting the same things in PACKAGES and PROVIDES. Is that actually necessary?

I want to be able to include procps-ps without the entire procps package. I was not able to do that without the above two lines.

What do you mean by "include procps-ps"? It sounds like you're saying you want to be able to introduce procps-ps to DEPENDS, is that right?

p.

author
#6 lore raw
Quoted 9 lines · Phil Blundell
Quoted 3 lines

I'm open to giving it a better name. Richard pointed me to a file beginning with lib_foo.class for where this functionality could be hosted before.

I suppose the interesting question here, then, is "what is this class actually for?" The description above says that it "allows us to easily split a recipe into subpackages" but doesn't say very much about what the consequences of including the class actually are or under what circumstances that's useful.

Quoted 4 lines

Reading between the lines the idea seems to be that this class is appropriate for recipes that build a collection of utilities each of which is essentially independent and is useful in its own right without any of the others. Is that right?

Yes, this is correct.

Quoted 10 lines
Quoted 7 lines
Quoted 5 lines

meta/classes/lib_subpackage.bbclass line 38

Quoted 3 lines
meta/classes/lib_subpackage.bbclass new file +2 -0
+    d.appendVar("PACKAGES", " " + " ".join(packages))
+    d.appendVar("PROVIDES", " " + " ".join(packages))

It seems a bit strange to be putting the same things in PACKAGES and PROVIDES. Is that actually necessary?

I want to be able to include procps-ps without the entire procps package. I was not able to do that without the above two lines.

What do you mean by "include procps-ps"? It sounds like you're saying you want to be able to introduce procps-ps to DEPENDS, is that right?

I want to be able to include a specific tool out of N number of tools that a package builds into the image.

Quoted 1 line

p.

author
#8 lore raw
In reply to a message not in the archive
Quoted 22 lines · Sinan Kaya
Quoted 9 lines · Phil Blundell
Quoted 3 lines

I'm open to giving it a better name. Richard pointed me to a file beginning with lib_foo.class for where this functionality could be hosted before.

I suppose the interesting question here, then, is "what is this class actually for?" The description above says that it "allows us to easily split a recipe into subpackages" but doesn't say very much about what the consequences of including the class actually are or under what circumstances that's useful.

Quoted 4 lines

Reading between the lines the idea seems to be that this class is appropriate for recipes that build a collection of utilities each of which is essentially independent and is useful in its own right without any of the others. Is that right?

Yes, this is correct.

Quoted 5 lines
Quoted 5 lines
Quoted 5 lines

meta/classes/lib_subpackage.bbclass line 38

Quoted 3 lines
meta/classes/lib_subpackage.bbclass new file +2 -0
+    d.appendVar("PACKAGES", " " + " ".join(packages))
+    d.appendVar("PROVIDES", " " + " ".join(packages))

It seems a bit strange to be putting the same things in PACKAGES and PROVIDES. Is that actually necessary?

Quoted 11 lines
Quoted 5 lines
Quoted 2 lines

I want to be able to include procps-ps without the entire procps package. I was not able to do that without the above two lines.

What do you mean by "include procps-ps"? It sounds like you're saying you want to be able to introduce procps-ps to DEPENDS, is that right?

I want to be able to include a specific tool out of N number of tools that a package builds into the image.

Quoted 1 line

p.

Is there anything else that i need to do on this changeset to move it forward?

I have no clue if there has been a build failure somewhere or if I have addressed all comments.