Ready to merge patches from O.S. Systems tree
cover Ready to merge patches from O.S. Systems tree
This patchset provides two patches. The first does the changes suggested some time ago by Richard to avoid too much forking in new udev cache support; the later imports gitpkgv from Meta-OE as some layers will start using it (Meta-TI is one) and this avoids the dependency on Meta-OE for its support.
The following changes since commit d7b13cd42ab8d5f44f97e119b73ec2e363677d26:
useradd.bbclass: Fix missing quote (2012-01-27 23:57:33 +0000)
are available in the git repository at:
git://github.com/OSSystems/oe-core master
https://github.com/OSSystems/oe-core/tree/HEAD
Otavio Salvador (2):
udev: improve udev-cache robustness
classes/gitpkgv.bbclass: import from Meta-OE
meta/classes/gitpkgv.bbclass | 95 ++++++++++++++++++++++++ meta/recipes-core/udev/udev.inc | 8 ++- meta/recipes-core/udev/udev/init | 15 +++- meta/recipes-core/udev/udev/udev-cache | 14 +++- meta/recipes-core/udev/udev/udev-cache.default | 4 + 5 files changed, 129 insertions(+), 7 deletions(-) create mode 100644 meta/classes/gitpkgv.bbclass create mode 100644 meta/recipes-core/udev/udev/udev-cache.default
Signature · 1 line
1.7.2.5
PATCH 1/2 udev: improve udev-cache robustness
* allow udev-cache to be disabled at runtime (using /etc/default/udev-cache);
* make cache invalidated if kernel, bootparams or device list changes;
--- meta/recipes-core/udev/udev.inc | 8 +++++++- meta/recipes-core/udev/udev/init | 15 ++++++++++++--- meta/recipes-core/udev/udev/udev-cache | 14 +++++++++++--- meta/recipes-core/udev/udev/udev-cache.default | 4 ++++ 4 files changed, 34 insertions(+), 7 deletions(-) create mode 100644 meta/recipes-core/udev/udev/udev-cache.default
meta/recipes-core/udev/udev.inc +7 -1
@@ -25,6 +25,7 @@ SRC_URI = "${KERNELORG_MIRROR}/linux/utils/kernel/hotplug/udev-${PV}.tar.gz \ file://network.sh \ file://local.rules \ file://udev-cache \ + file://udev-cache.default \ file://init" inherit autotools pkgconfig update-rc.d
@@ -58,7 +59,7 @@ FILES_libgudev = "${base_libdir}/libgudev*.so.* ${libdir}/libgudev*.so.*" FILES_libgudev-dbg = "${base_libdir}/.debug/libgudev*.so.* ${libdir}/.debug/libgudev*.so.*" FILES_libgudev-dev = "${includedir}/gudev* ${libdir}/libgudev*.so ${libdir}/libgudev*.la \ ${libdir}/libgudev*.a ${libdir}/pkgconfig/gudev*.pc" -FILES_udev-cache = "${sysconfdir}/init.d/udev-cache" +FILES_udev-cache = "${sysconfdir}/init.d/udev-cache ${sysconfdir}/default/udev-cache" FILES_udev-acl = "${base_libdir}/udev/udev-acl ${base_libdir}/udev/rules.d/70-acl.rules"
@@ -72,6 +73,11 @@ do_install_append () { install -m 0755 ${WORKDIR}/init ${D}${sysconfdir}/init.d/udev install -m 0755 ${WORKDIR}/udev-cache ${D}${sysconfdir}/init.d/udev-cache + install -d ${D}${sysconfdir}/default + install -m 0755 ${WORKDIR}/udev-cache.default ${D}${sysconfdir}/default/udev-cache + + touch ${D}${sysconfdir}/udev/cache.data + install -d ${D}${sysconfdir}/udev/rules.d/ install -m 0644 ${WORKDIR}/local.rules ${D}${sysconfdir}/udev/rules.d/local.rules
meta/recipes-core/udev/udev/init +12 -3
@@ -14,6 +14,7 @@ export TZ=/etc/localtime [ -d /sys/class ] || exit 1 [ -r /proc/mounts ] || exit 1 [ -x /sbin/udevd ] || exit 1 +[ -f /etc/default/udev-cache ] && . /etc/default/udev-cache [ -f /etc/udev/udev.conf ] && . /etc/udev/udev.conf kill_udevd() {
@@ -35,9 +36,17 @@ LANG=C awk '$2 == "/dev" && ($3 == "tmpfs" || $3 == "devtmpfs") { exit 1 }' /pro [ -e /dev/shm ] || mkdir -m 1777 /dev/shm -if [ -e /etc/dev.tar ]; then - (cd /; tar xf /etc/dev.tar 2>&1 | grep -v 'time stamp' || true) - not_first_boot=1 +if [ "$DEVCACHE" != "" ]; then + # Ensure we are consistent to use the cache + echo -n > /dev/shm/cache.data + [ -x /bin/uname ] && /bin/uname -mrspv >> /dev/shm/cache.data + [ -r /proc/cmdline ] && cat /proc/cmdline >> /dev/shm/cache.data + [ -r /proc/devices ] && cat /proc/devices >> /dev/shm/cache.data + [ -r /proc/atags ] && cat /proc/atags >> /dev/shm/cache.data + if [ -e $DEVCACHE ] && cmp -s /dev/shm/cache.data /etc/udev/cache.data; then + (cd /; tar xf $DEVCACHE > /dev/null 2>&1) + not_first_boot=1 + fi fi # make_extra_nodes
meta/recipes-core/udev/udev/udev-cache +11 -3
@@ -9,12 +9,20 @@ # Short-Description: cache /dev to speedup the udev next boot ### END INIT INFO -[ -d /sys/class ] || exit 1 +export TZ=/etc/localtime + [ -r /proc/mounts ] || exit 1 [ -x /sbin/udevd ] || exit 1 +[ -d /sys/class ] || exit 1 + +[ -f /etc/default/udev-cache ] && . /etc/default/udev-cache -if [ ! -e /etc/dev.tar ]; then - (cd /; tar cf /etc/dev.tar dev) +if [ "$DEVCACHE" != "" ]; then + echo "Populating dev cache" + (cd /; tar cf "$DEVCACHE" dev) + mv /dev/shm/cache.data /etc/udev/cache.data +else + rm -f /dev/shm/cache.data fi exit 0
meta/recipes-core/udev/udev/udev-cache.default new file +4 -0
@@ -0,0 +1,4 @@ +# Default for /etc/init.d/udev + +# Comment this out to disable device cache +DEVCACHE="/etc/dev.tar"
Signature · 1 line
1.7.2.5
Re: [PATCH 1/2] udev: improve udev-cache robustness
Quoted 69 lines · Otavio Salvador
* allow udev-cache to be disabled at runtime (using
/etc/default/udev-cache);* make cache invalidated if kernel, bootparams or device list changes;
Signed-off-by Otavio Salvador <[email protected]>--- meta/recipes-core/udev/udev.inc | 8 +++++++- meta/recipes-core/udev/udev/init | 15 ++++++++++++--- meta/recipes-core/udev/udev/udev-cache | 14 +++++++++++--- meta/recipes-core/udev/udev/udev-cache.default | 4 ++++ 4 files changed, 34 insertions(+), 7 deletions(-) create mode 100644 meta/recipes-core/udev/udev/udev-cache.defaultmeta/recipes-core/udev/udev.inc +7
-1@@ -25,6 +25,7 @@ SRC_URI = "${KERNELORG_MIRROR}/linux/utils/kernel/hotplug/udev-${PV}.tar.gz \ file://network.sh \ file://local.rules \ file://udev-cache \ + file://udev-cache.default \ file://init" inherit autotools pkgconfig update-rc.d@@ -58,7 +59,7 @@ FILES_libgudev = "${base_libdir}/libgudev*.so.* ${libdir}/libgudev*.so.*" FILES_libgudev-dbg = "${base_libdir}/.debug/libgudev*.so.* ${libdir}/.debug/libgudev*.so.*" FILES_libgudev-dev = "${includedir}/gudev* ${libdir}/libgudev*.so ${libdir}/libgudev*.la \ ${libdir}/libgudev*.a ${libdir}/pkgconfig/gudev*.pc" -FILES_udev-cache = "${sysconfdir}/init.d/udev-cache" +FILES_udev-cache = "${sysconfdir}/init.d/udev-cache ${sysconfdir}/default/udev-cache" FILES_udev-acl = "${base_libdir}/udev/udev-acl ${base_libdir}/udev/rules.d/70-acl.rules"@@ -72,6 +73,11 @@ do_install_append () { install -m 0755 ${WORKDIR}/init ${D}${sysconfdir}/init.d/udev install -m 0755 ${WORKDIR}/udev-cache ${D}${sysconfdir}/init.d/udev-cache + install -d ${D}${sysconfdir}/default + install -m 0755 ${WORKDIR}/udev-cache.default ${D}${sysconfdir}/default/udev-cache + + touch ${D}${sysconfdir}/udev/cache.data + install -d ${D}${sysconfdir}/udev/rules.d/ install -m 0644 ${WORKDIR}/local.rules ${D}${sysconfdir}/udev/rules.d/local.rulesmeta/recipes-core/udev/udev/init +3
-3@@ -14,6 +14,7 @@ export TZ=/etc/localtime [ -d /sys/class ] || exit 1 [ -r /proc/mounts ] || exit 1 [ -x /sbin/udevd ] || exit 1 +[ -f /etc/default/udev-cache ] && . /etc/default/udev-cache [ -f /etc/udev/udev.conf ] && . /etc/udev/udev.conf kill_udevd() {@@ -35,9 +36,17 @@ LANG=C awk '$2 == "/dev" && ($3 == "tmpfs" || $3 == "devtmpfs") { exit 1 }' /pro [ -e /dev/shm ] || mkdir -m 1777 /dev/shm -if [ -e /etc/dev.tar ]; then - (cd /; tar xf /etc/dev.tar 2>&1 | grep -v 'time stamp' || true) - not_first_boot=1 +if [ "$DEVCACHE" != "" ]; then + # Ensure we are consistent to use the cache
meta/recipes-core/udev/udev/init LANG=C awk '$2 == "/dev" && ($3 == "tmpfs" || $3 == "devtmpfs") { exit 1 }' /pro · line 50
Quoted 10 lines
meta/recipes-core/udev/udev/init +9
-0+ echo -n > /dev/shm/cache.data + [ -x /bin/uname ] && /bin/uname -mrspv >> /dev/shm/cache.data + [ -r /proc/cmdline ] && cat /proc/cmdline >> /dev/shm/cache.data + [ -r /proc/devices ] && cat /proc/devices >> /dev/shm/cache.data + [ -r /proc/atags ] && cat /proc/atags >> /dev/shm/cache.data + if [ -e $DEVCACHE ] && cmp -s /dev/shm/cache.data /etc/udev/cache.data; then + (cd /; tar xf $DEVCACHE > /dev/null 2>&1) + not_first_boot=1 + fi fi
This still forks much more than I'd like or than is necessary. In the interests of getting this resolved, you could do something like my example below which doesn't fork. It does mangle newlines in the data but in this case I don't think that matters.
Could we get away with /proc/version instead of uname -mrpsv ?
Cheers,
Richard
#!/bin/sh
readfile () {
filename=$1
READDATA=""
if [ -r $filename ]; then
while read line; do
READDATA="$READDATA$line"
done < $filename
fi
}
readfile /proc/cmdline
CMDLINE="$READDATA"
readfile /proc/devices
DEVICES="$READDATA"
readfile /proc/atags
ATAGS="$READDATA"
if [ "$DEVCACHE" != "" ]; then
if [ -e $DEVCACHE ]; then
readfile /etc/udev/cache.data
if [ "$READDATA" = "$CMDLINE $DEVICES $ATAGS" ]; then
(cd /; tar xf $DEVCACHE > /dev/null 2>&1) not_first_boot=1
fi
fi
fi
Re: [PATCH 1/2] udev: improve udev-cache robustness
Quoted 5 lines · Richard Purdie
This still forks much more than I'd like or than is necessary. In the interests of getting this resolved, you could do something like my example below which doesn't fork. It does mangle newlines in the data but in this case I don't think that matters.
I am making a new patch version using your proposal as base.
Quoted 1 line
Could we get away with
/proc/versioninstead of uname -mrpsv ?
Sure. Good catch.
New version of patch will come soon.
Signature · 3 lines
Otavio Salvador O.S. Systems E-mail: [email protected] http://www.ossystems.com.br Mobile: +55 53 9981-7854 http://projetos.ossystems.com.br
PATCH 2/2 classes/gitpkgv.bbclass: import from Meta-OE
In reply to Otavio SalvadorIt provides a GITPKGV and GITPKGVTAG variables to be used in PKGV, as described bellow:
- GITPKGV which is a sortable version with the format NN+GITHASH, to be used in PKGV, where
NN equals the total number of revs up to SRCREV GITHASH is SRCREV's (full) hash
- GITPKGVTAG which is the output of 'git describe' allowing for automatic versioning
gitpkgv.bbclass assumes the git repository has been cloned, and contains SRCREV. So ${GITPKGV} and ${GITPKGVTAG} should never be used in PV, only in PKGV. It can handle SRCREV = ${AUTOREV}, as well as SRCREV = "<some fixed git hash>".
The code has been imported from Meta-OE at revision a76fff17ea8420686ef81b35f80efac1bef21649.
--- meta/classes/gitpkgv.bbclass | 95 ++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 95 insertions(+), 0 deletions(-) create mode 100644 meta/classes/gitpkgv.bbclass
meta/classes/gitpkgv.bbclass new file +95 -0
@@ -0,0 +1,95 @@ +# gitpkgv.bbclass provides a GITPKGV and GITPKGVTAG variables to be +# used in PKGV, as described bellow: +# +# - GITPKGV which is a sortable version with the format NN+GITHASH, to +# be used in PKGV, where +# +# NN equals the total number of revs up to SRCREV +# GITHASH is SRCREV's (full) hash +# +# - GITPKGVTAG which is the output of 'git describe' allowing for +# automatic versioning +# +# gitpkgv.bbclass assumes the git repository has been cloned, and +# contains SRCREV. So ${GITPKGV} and ${GITPKGVTAG} should never be +# used in PV, only in PKGV. It can handle SRCREV = ${AUTOREV}, as +# well as SRCREV = "<some fixed git hash>". +# +# WARNING: if upstream repository is always using consistent and +# sortable tag name scheme you can get sortable version including tag +# name with ${GITPKGVTAG}, but be aware that ie tag sequence "v1.0, +# v1.2, xtest, v2.0" will force you to increment PE to get upgradeable +# path to v2.0 revisions +# +# use example: +# +# inherit gitpkgv +# +# PV = "1.0+gitr${SRCPV}" # expands to something like 1.0+gitr3+4c1c21d7dbbf93b0df336994524313dfe0d4963b +# PKGV = "1.0+gitr${GITPKGV}" # expands also to something like 1.0+gitr31337+4c1c21d7d +# +# or +# +# inherit gitpkgv +# +# PV = "1.0+gitr${SRCPV}" # expands to something like 1.0+gitr3+4c1c21d7dbbf93b0df336994524313dfe0d4963b +# PKGV = "${GITPKGVTAG}" # expands to something like 1.0-31337+g4c1c21d +# if there is tag v1.0 before this revision or +# ver1.0-31337+g4c1c21d if there is tag ver1.0 + +GITPKGV = "${@get_git_pkgv(d, False)}" +GITPKGVTAG = "${@get_git_pkgv(d, True)}" + +def gitpkgv_drop_tag_prefix(version): + import re + if re.match("v\d", version): + return version[1:] + else: + return version + +def get_git_pkgv(d, use_tags): + import os + import bb + + src_uri = bb.data.getVar('SRC_URI', d, 1).split() + fetcher = bb.fetch2.Fetch(src_uri, d) + ud = fetcher.ud + + # + # If SRCREV_FORMAT is set respect it for tags + # + format = bb.data.getVar('SRCREV_FORMAT', d, True) + if not format: + format = 'default' + + found = False + for url in ud.values(): + if url.type == 'git': + for name, rev in url.revisions.items(): + if not os.path.exists(url.localpath): + return None + + found = True + + cwd = os.getcwd() + os.chdir(url.localpath) + + commits = bb.fetch2.runfetchcmd("git rev-list %s -- 2> /dev/null | wc -l" % rev, d, quiet=True).strip() + + if use_tags: + try: + output = bb.fetch2.runfetchcmd("git describe %s 2>/dev/null" % rev, d, quiet=True).strip() + ver = gitpkgv_drop_tag_prefix(output) + except Exception: + ver = "0.0-%s-g%s" % (commits, rev[:7]) + else: + ver = "%s+%s" % (commits, rev[:7]) + + os.chdir(cwd) + + format = format.replace(name, ver) + + if found: + return format + + return '0+0'
Signature · 1 line
1.7.2.5
Re: [PATCH 2/2] classes/gitpkgv.bbclass: import from Meta-OE
Quoted 17 lines · Otavio Salvador
It provides a GITPKGV and GITPKGVTAG variables to be used in PKGV, as described bellow:
- GITPKGV which is a sortable version with the format NN+GITHASH, to be used in PKGV, where
NN equals the total number of revs up to SRCREV GITHASH is SRCREV's (full) hash
- GITPKGVTAG which is the output of 'git describe' allowing for automatic versioning
gitpkgv.bbclass assumes the git repository has been cloned, and contains SRCREV. So ${GITPKGV} and ${GITPKGVTAG} should never be used in PV, only in PKGV. It can handle SRCREV = ${AUTOREV}, as well as SRCREV = "<some fixed git hash>".
Quoted 8 lines
The code has been imported from Meta-OE at revision
a76fff17ea8420686ef81b35f80efac1bef21649.Signed-off-by Otavio Salvador <[email protected]>--- meta/classes/gitpkgv.bbclass | 95 ++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 95 insertions(+), 0 deletions(-) create mode 100644 meta/classes/gitpkgv.bbclass
As discussed on IRC, I think some of the code here should really be integrated into the bitbake git fetcher to ensure we have a clean/consistent API for fetcher functionality. The interface I'm thinking about would be similar to SRCPV:
SRCPV = "${@bb.fetch2.get_srcrev(d)}"
with a new fetcher call being added such as get_simplified_srcrev(d). Switching between the simplified revision and the description could be governed by a variable setting similar to some of the existing variables that control fetcher behaviour.
There has been substantial work done to improve the fetcher APIs and clean up the various corner cases and this would seem a logical continuation of that, in keeping with the objectives of OE-Core.
Cheers,
Richard
Quoted 101 lines
meta/classes/gitpkgv.bbclass new file +95
-0@@ -0,0 +1,95 @@ +# gitpkgv.bbclass provides a GITPKGV and GITPKGVTAG variables to be +# used in PKGV, as described bellow: +# +# - GITPKGV which is a sortable version with the format NN+GITHASH, to +# be used in PKGV, where +# +# NN equals the total number of revs up to SRCREV +# GITHASH is SRCREV's (full) hash +# +# - GITPKGVTAG which is the output of 'git describe' allowing for +# automatic versioning +# +# gitpkgv.bbclass assumes the git repository has been cloned, and +# contains SRCREV. So ${GITPKGV} and ${GITPKGVTAG} should never be +# used in PV, only in PKGV. It can handle SRCREV = ${AUTOREV}, as +# well as SRCREV = "<some fixed git hash>". +# +# WARNING: if upstream repository is always using consistent and +# sortable tag name scheme you can get sortable version including tag +# name with ${GITPKGVTAG}, but be aware that ie tag sequence "v1.0, +# v1.2, xtest, v2.0" will force you to increment PE to get upgradeable +# path to v2.0 revisions +# +# use example: +# +# inherit gitpkgv +# +# PV = "1.0+gitr${SRCPV}" # expands to something like 1.0+gitr3+4c1c21d7dbbf93b0df336994524313dfe0d4963b +# PKGV = "1.0+gitr${GITPKGV}" # expands also to something like 1.0+gitr31337+4c1c21d7d +# +# or +# +# inherit gitpkgv +# +# PV = "1.0+gitr${SRCPV}" # expands to something like 1.0+gitr3+4c1c21d7dbbf93b0df336994524313dfe0d4963b +# PKGV = "${GITPKGVTAG}" # expands to something like 1.0-31337+g4c1c21d +# if there is tag v1.0 before this revision or +# ver1.0-31337+g4c1c21d if there is tag ver1.0 + +GITPKGV = "${@get_git_pkgv(d, False)}" +GITPKGVTAG = "${@get_git_pkgv(d, True)}" + +def gitpkgv_drop_tag_prefix(version): + import re + if re.match("v\d", version): + return version[1:] + else: + return version + +def get_git_pkgv(d, use_tags): + import os + import bb + + src_uri = bb.data.getVar('SRC_URI', d, 1).split() + fetcher = bb.fetch2.Fetch(src_uri, d) + ud = fetcher.ud + + # + # If SRCREV_FORMAT is set respect it for tags + # + format = bb.data.getVar('SRCREV_FORMAT', d, True) + if not format: + format = 'default' + + found = False + for url in ud.values(): + if url.type == 'git': + for name, rev in url.revisions.items(): + if not os.path.exists(url.localpath): + return None + + found = True + + cwd = os.getcwd() + os.chdir(url.localpath) + + commits = bb.fetch2.runfetchcmd("git rev-list %s -- 2> /dev/null | wc -l" % rev, d, quiet=True).strip() + + if use_tags: + try: + output = bb.fetch2.runfetchcmd("git describe %s 2>/dev/null" % rev, d, quiet=True).strip() + ver = gitpkgv_drop_tag_prefix(output) + except Exception: + ver = "0.0-%s-g%s" % (commits, rev[:7]) + else: + ver = "%s+%s" % (commits, rev[:7]) + + os.chdir(cwd) + + format = format.replace(name, ver) + + if found: + return format + + return '0+0'
Re: [PATCH 2/2] classes/gitpkgv.bbclass: import from Meta-OE
Quoted 5 lines · Richard Purdie
As discussed on IRC, I think some of the code here should really be integrated into the bitbake git fetcher to ensure we have a clean/consistent API for fetcher functionality. The interface I'm thinking about would be similar to SRCPV:
Quoted 7 lines
SRCPV = "${@bb.fetch2.get_srcrev(d)}"
with a new fetcher call being added such as
get_simplified_srcrev(d). Switching between the simplified revision and the description could be governed by a variable setting similar to some of the existing variables that control fetcher behaviour.
I fully agree that having some of the code here ought to be in bitbake git fetcher but I'd like to work on this after this code has been merge onto OE-Core mostly because this will blocker on newer bitbake version requirement and some layers are using it but now depending on meta-oe just because of this class.
Quoted 3 lines
There has been substantial work done to improve the fetcher APIs and clean up the various corner cases and this would seem a logical continuation of that, in keeping with the objectives of OE-Core.
Can this be merged and afterwareds I refactor it moving part of this code onto bitbake? I am not used to bitbake code and I don't have enough time to learn it in following week or so.
Signature · 3 lines
Otavio Salvador O.S. Systems E-mail: [email protected] http://www.ossystems.com.br Mobile: +55 53 9981-7854 http://projetos.ossystems.com.br