Re: [OE-core] [PATCH] Revert "kernel: Fix symlinks"

2017-08-22 Thread David Vincent
On vendredi 18 août 2017 14:44:30 CEST Otavio Salvador wrote:
> On Wed, Aug 16, 2017 at 3:15 PM, Otavio Salvador
> 
>  wrote:
> > This reverts commit c7bc46b9bc29dd0953ab8d63b50fa105bb66892e.
> > 
> > The commit has broken the alternatives concept as it is managed by
> > links controlled by the alternatives system. That said the failing
> > case identified (which some bootloaders fail to load the file) seems
> > to be due a misuse of the alternative system.
> > 
> > Cc: Christopher Larson 
> > Cc: Ross Burton 
> > Signed-off-by: Otavio Salvador 
> 
> I ended forgetting to add the commit author on Cc. Adding now :-)

This issue has been discussed here : http://lists.openembedded.org/pipermail/
openembedded-core/2017-April/135923.html

Reverting this patch to solve the alternative problem cannot be a definitive 
solution as it breaks boot on some boards. IMHO, I'd rather break the 
alternative system than boot (full disclosure : I use opkg's update-
alternatives).

As already said, absolute paths cannot be used in bootloaders since it may 
point to an invalid location (rootfs may not be mounted). I do not have 
another solution with plain 'ls', but I think we should find a way to better 
handle all cases than going back and forth on this patch.

FYI, this is my use case : I have a bootloader which resides in EEPROM, but 
needs to boot kernels that can be upgraded. Therefore, I rely on a fixed path 
to the last kernel / devicetree on a specific partition outside rootfs.

--
David
-- 
___
Openembedded-core mailing list
Openembedded-core@lists.openembedded.org
http://lists.openembedded.org/mailman/listinfo/openembedded-core


[OE-core] [PATCH] initscripts: start bootmisc.sh at 36 instead of 55

2017-07-10 Thread David Vincent
bootmisc.sh is responsible for setting the system date to a sane
default. Currently, it is the last script to be run from the rcS
runlevel.

Problem is that the files created before appear to have been created
on 1/1/1970. Most notably, /var/log/dmesg created in dmesg.sh cannot be
properly rotated with logrotate which does not consider it a valid date
and stops processing.

There is no blocker on moving this script right before populating
volatiles because it just requires the local and virtual filesystems to
be mounted to work.

Signed-off-by: David Vincent <freesili...@gmail.com>
---
 meta/recipes-core/initscripts/initscripts_1.0.bb | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/meta/recipes-core/initscripts/initscripts_1.0.bb 
b/meta/recipes-core/initscripts/initscripts_1.0.bb
index 2e4f7e4669..a65f1b24a5 100644
--- a/meta/recipes-core/initscripts/initscripts_1.0.bb
+++ b/meta/recipes-core/initscripts/initscripts_1.0.bb
@@ -134,7 +134,7 @@ do_install () {
update-rc.d -r ${D} mountall.sh start 03 S .
update-rc.d -r ${D} hostname.sh start 39 S .
update-rc.d -r ${D} mountnfs.sh start 15 2 3 4 5 .
-   update-rc.d -r ${D} bootmisc.sh start 55 S .
+   update-rc.d -r ${D} bootmisc.sh start 36 S .
update-rc.d -r ${D} sysfs.sh start 02 S .
update-rc.d -r ${D} populate-volatile.sh start 37 S .
update-rc.d -r ${D} read-only-rootfs-hook.sh start 29 S .
-- 
2.13.2

-- 
___
Openembedded-core mailing list
Openembedded-core@lists.openembedded.org
http://lists.openembedded.org/mailman/listinfo/openembedded-core


Re: [OE-core] [PATCH RESEND 0/3] openssh: Package server configuration

2017-06-13 Thread David Vincent
On vendredi 9 juin 2017 15:53:40 CEST André Draszik wrote:
> Hi.
> 
> On Fri, 2017-06-09 at 09:04 +0200, David Vincent wrote:
> > This serie of patches provides a way to package OpenSSH sshd
> > configuration. This
> > way, it should be easier to change the configuration either in distro
> > and/or BSP
> > layers.
> > It also simplifies management for R/O rootfs
> 
> Looking at some previous patches and comments, this split seems to have been
> done with the intention to better support R/O rootfs.
Not only, it has been done with the intention of providing a completely custom 
configuration. But maybe it wasn't the proper way to do it.
> I have a sent a patch that addresses the R/O rootfs issue in a different
> way, which I believe to be a simpler and less intrusive approach. We've been
> using this for a while.
Yes, I saw it has been merged recently. I'm not sure it addresses the problem 
I had in mind but I agree it simplifies the configuration for R/O rootfs.
> 
> http://lists.openembedded.org/pipermail/openembedded-core/2017-June/137848.h
> tml
> 
> Let me know what you think.
> 
> 
> Cheers,
> Andre'
> 
> > David Vincent (3):
> >   openssh: Package server configuration
> >   core-image: Set default sshd configuration
> >   rootfs-postcommands: Modify ssh-related commands
> > 
> >  meta/classes/core-image.bbclass|  3 +-
> >  meta/classes/rootfs-postcommands.bbclass   | 17 +++-
> >  meta/recipes-connectivity/openssh/openssh_7.5p1.bb | 51
> > ++
> >  3 files changed, 50 insertions(+), 21 deletions(-)
> > 
> > -- 
> > 2.13.0


--
David
-- 
___
Openembedded-core mailing list
Openembedded-core@lists.openembedded.org
http://lists.openembedded.org/mailman/listinfo/openembedded-core


Re: [OE-core] [PATCH RESEND 1/3] openssh: Package server configuration

2017-06-13 Thread David Vincent
On vendredi 9 juin 2017 11:41:25 CEST Peter Kjellerstedt wrote:
> > -Original Message-
> > From: openembedded-core-boun...@lists.openembedded.org
> > [mailto:openembedded-core-boun...@lists.openembedded.org] On Behalf Of
> > David Vincent
> > Sent: den 9 juni 2017 09:04
> > To: openembedded-core@lists.openembedded.org
> > Subject: [OE-core] [PATCH RESEND 1/3] openssh: Package server
> > configuration
> > 
> > Split sshd configuration for read-write/read-only rootfs in two
> > distinct
> > packages. Also, add a package dependency between openssh-sshd package
> > and a provider of sshd-config.
> > 
> > Signed-off-by: David Vincent <freesili...@gmail.com>
> > ---
> > 
> >  meta/recipes-connectivity/openssh/openssh_7.5p1.bb | 51
> > 
> > ++
> > 
> >  1 file changed, 42 insertions(+), 9 deletions(-)
> > 
> > diff --git a/meta/recipes-connectivity/openssh/openssh_7.5p1.bb
> > b/meta/recipes-connectivity/openssh/openssh_7.5p1.bb
> > index 5b96745aae..e22e6c672d 100644
> > --- a/meta/recipes-connectivity/openssh/openssh_7.5p1.bb
> > +++ b/meta/recipes-connectivity/openssh/openssh_7.5p1.bb
> > @@ -91,13 +91,17 @@ do_compile_ptest() {
> > 
> >  }
> >  
> >  do_install_append () {
> > 
> > -   if [ "${@bb.utils.filter('DISTRO_FEATURES', 'pam', d)}" ]; then
> > +   # Create default config files
> > +   install -m 0644 ${D}${sysconfdir}/ssh/sshd_config
> > ${D}${sysconfdir}/ssh/sshd_config_default + rm -f
> > ${D}${sysconfdir}/ssh/sshd_config
> > +
> > +   if [ "${@bb.utils.contains('DISTRO_FEATURES', 'pam', 'pam', '', d)}" =
> > "pam" ]; then> 
> > install -D -m 0644 ${WORKDIR}/sshd ${D}${sysconfdir}/pam.d/sshd
> > 
> > -   sed -i -e 's:#UsePAM no:UsePAM yes:' ${D}${sysconfdir}/ssh/
sshd_config
> > +   sed -i -e 's:#UsePAM no:UsePAM yes:'
> > ${D}${sysconfdir}/ssh/sshd_config_default> 
> > fi
> > 
> > -   if [ "${@bb.utils.filter('DISTRO_FEATURES', 'x11', d)}" ]; then
> > -   sed -i -e 's:#X11Forwarding no:X11Forwarding yes:'
> > ${D}${sysconfdir}/ssh/sshd_config + if [
> > "${@bb.utils.contains('DISTRO_FEATURES', 'x11', 'x11', '', d)}" = "x11"
> > ]; then +   sed -i -e 's:#X11Forwarding no:X11Forwarding yes:'
> > ${D}${sysconfdir}/ssh/sshd_config_default> 
> > fi
> 
> Instead of all the changes above you could just do this here instead:
Yes, it is simpler that way. If a v2 is to be sent, I will do that change.
> 
>   mv ${D}${sysconfdir}/ssh/sshd_config
> ${D}${sysconfdir}/ssh/sshd_config_default
> > install -d ${D}${sysconfdir}/init.d
> > 
> > @@ -110,7 +114,7 @@ do_install_append () {
> > 
> > # Create config files for read-only rootfs
> > install -d ${D}${sysconfdir}/ssh
> 
> Creating the directory here again is unnecessary.
That's the old code, maybe it should be dropped.
> 
> > -   install -m 644 ${D}${sysconfdir}/ssh/sshd_config
> > ${D}${sysconfdir}/ssh/sshd_config_readonly +install -m 644
> > ${D}${sysconfdir}/ssh/sshd_config_default
> > ${D}${sysconfdir}/ssh/sshd_config_readonly> 
> > sed -i '/HostKey/d' ${D}${sysconfdir}/ssh/sshd_config_readonly
> > echo "HostKey /var/run/ssh/ssh_host_rsa_key" >>
> > ${D}${sysconfdir}/ssh/sshd_config_readonly echo "HostKey
> > /var/run/ssh/ssh_host_dsa_key" >>
> > ${D}${sysconfdir}/ssh/sshd_config_readonly> 
> > @@ -134,30 +138,59 @@ do_install_ptest () {
> > 
> >  ALLOW_EMPTY_${PN} = "1"
> > 
> > -PACKAGES =+ "${PN}-keygen ${PN}-scp ${PN}-ssh ${PN}-sshd ${PN}-sftp
> > ${PN}-misc ${PN}-sftp-server" +PACKAGES =+ "${PN}-keygen ${PN}-scp
> > ${PN}-ssh ${PN}-sshd-config ${PN}-sshd-config-readonly ${PN}-sshd
> > ${PN}-sftp ${PN}-misc ${PN}-sftp-server"> 
> >  FILES_${PN}-scp = "${bindir}/scp.${BPN}"
> >  FILES_${PN}-ssh = "${bindir}/ssh.${BPN} ${sysconfdir}/ssh/ssh_config"
> > 
> > +FILES_${PN}-sshd-config = "${sysconfdir}/ssh/sshd_config_default"
> > +FILES_${PN}-sshd-config-readonly =
> > "${sysconfdir}/ssh/sshd_config_readonly"> 
> >  FILES_${PN}-sshd = "${sbindir}/sshd ${sysconfdir}/init.d/sshd
> >  ${systemd_unitdir}/system"> 
> > -FILES_${PN}-sshd += "${sysconfdir}/ssh/moduli
> > ${sysconfdir}/ssh/sshd_config ${sysconfdir}/ssh/sshd_config_readonly
> > ${sysconfdir}/default/volatiles/99_ssh

[OE-core] [PATCH RESEND 3/3] rootfs-postcommands: Modify ssh-related commands

2017-06-09 Thread David Vincent
OpenSSH configuration is now a symlink which points to the desired
configuration, so the functions that modified it must be updated to
modify the target and not override it.

Signed-off-by: David Vincent <freesili...@gmail.com>
---
 meta/classes/rootfs-postcommands.bbclass | 17 ++---
 1 file changed, 6 insertions(+), 11 deletions(-)

diff --git a/meta/classes/rootfs-postcommands.bbclass 
b/meta/classes/rootfs-postcommands.bbclass
index 1d66a42953..1c0af87c9f 100644
--- a/meta/classes/rootfs-postcommands.bbclass
+++ b/meta/classes/rootfs-postcommands.bbclass
@@ -89,15 +89,12 @@ read_only_rootfs_hook () {
fi
 
# If we're using openssh and the /etc/ssh directory has no 
pre-generated keys,
-   # we should configure openssh to use the configuration file 
/etc/ssh/sshd_config_readonly
-   # and the keys under /var/run/ssh.
+   # we should configure openssh to use the keys under /var/run/ssh.
if [ -d ${IMAGE_ROOTFS}/etc/ssh ]; then
if [ -e ${IMAGE_ROOTFS}/etc/ssh/ssh_host_rsa_key ]; then
echo "SYSCONFDIR=/etc/ssh" >> 
${IMAGE_ROOTFS}/etc/default/ssh
-   echo "SSHD_OPTS=" >> ${IMAGE_ROOTFS}/etc/default/ssh
else
echo "SYSCONFDIR=/var/run/ssh" >> 
${IMAGE_ROOTFS}/etc/default/ssh
-   echo "SSHD_OPTS='-f /etc/ssh/sshd_config_readonly'" >> 
${IMAGE_ROOTFS}/etc/default/ssh
fi
fi
 
@@ -140,12 +137,10 @@ zap_empty_root_password () {
 # allow dropbear/openssh to accept root logins and logins from accounts with 
an empty password string
 #
 ssh_allow_empty_password () {
-   for config in sshd_config sshd_config_readonly; do
-   if [ -e ${IMAGE_ROOTFS}${sysconfdir}/ssh/$config ]; then
-   sed -i 
's/^[#[:space:]]*PermitRootLogin.*/PermitRootLogin yes/' 
${IMAGE_ROOTFS}${sysconfdir}/ssh/$config
-   sed -i 
's/^[#[:space:]]*PermitEmptyPasswords.*/PermitEmptyPasswords yes/' 
${IMAGE_ROOTFS}${sysconfdir}/ssh/$config
-   fi
-   done
+   if [ -e ${IMAGE_ROOTFS}${sysconfdir}/ssh/sshd_config ]; then
+   sed -i --follow-symlinks 
's/^[#[:space:]]*PermitRootLogin.*/PermitRootLogin yes/' 
${IMAGE_ROOTFS}${sysconfdir}/ssh/sshd_config
+   sed -i --follow-symlinks 
's/^[#[:space:]]*PermitEmptyPasswords.*/PermitEmptyPasswords yes/' 
${IMAGE_ROOTFS}${sysconfdir}/ssh/sshd_config
+   fi
 
if [ -e ${IMAGE_ROOTFS}${sbindir}/dropbear ] ; then
if grep -q DROPBEAR_EXTRA_ARGS 
${IMAGE_ROOTFS}${sysconfdir}/default/dropbear 2>/dev/null ; then
@@ -164,7 +159,7 @@ ssh_allow_empty_password () {
 
 ssh_disable_dns_lookup () {
if [ -e ${IMAGE_ROOTFS}${sysconfdir}/ssh/sshd_config ]; then
-   sed -i -e 's:#UseDNS yes:UseDNS no:' 
${IMAGE_ROOTFS}${sysconfdir}/ssh/sshd_config
+   sed -i --follow-symlinks -e 's:#UseDNS yes:UseDNS no:' 
${IMAGE_ROOTFS}${sysconfdir}/ssh/sshd_config
fi
 }
 
-- 
2.13.0

-- 
___
Openembedded-core mailing list
Openembedded-core@lists.openembedded.org
http://lists.openembedded.org/mailman/listinfo/openembedded-core


[OE-core] [PATCH RESEND 1/3] openssh: Package server configuration

2017-06-09 Thread David Vincent
Split sshd configuration for read-write/read-only rootfs in two distinct
packages. Also, add a package dependency between openssh-sshd package
and a provider of sshd-config.

Signed-off-by: David Vincent <freesili...@gmail.com>
---
 meta/recipes-connectivity/openssh/openssh_7.5p1.bb | 51 ++
 1 file changed, 42 insertions(+), 9 deletions(-)

diff --git a/meta/recipes-connectivity/openssh/openssh_7.5p1.bb 
b/meta/recipes-connectivity/openssh/openssh_7.5p1.bb
index 5b96745aae..e22e6c672d 100644
--- a/meta/recipes-connectivity/openssh/openssh_7.5p1.bb
+++ b/meta/recipes-connectivity/openssh/openssh_7.5p1.bb
@@ -91,13 +91,17 @@ do_compile_ptest() {
 }
 
 do_install_append () {
-   if [ "${@bb.utils.filter('DISTRO_FEATURES', 'pam', d)}" ]; then
+   # Create default config files
+   install -m 0644 ${D}${sysconfdir}/ssh/sshd_config 
${D}${sysconfdir}/ssh/sshd_config_default
+   rm -f ${D}${sysconfdir}/ssh/sshd_config
+
+   if [ "${@bb.utils.contains('DISTRO_FEATURES', 'pam', 'pam', '', d)}" = 
"pam" ]; then
install -D -m 0644 ${WORKDIR}/sshd ${D}${sysconfdir}/pam.d/sshd
-   sed -i -e 's:#UsePAM no:UsePAM yes:' 
${D}${sysconfdir}/ssh/sshd_config
+   sed -i -e 's:#UsePAM no:UsePAM yes:' 
${D}${sysconfdir}/ssh/sshd_config_default
fi
 
-   if [ "${@bb.utils.filter('DISTRO_FEATURES', 'x11', d)}" ]; then
-   sed -i -e 's:#X11Forwarding no:X11Forwarding yes:' 
${D}${sysconfdir}/ssh/sshd_config
+   if [ "${@bb.utils.contains('DISTRO_FEATURES', 'x11', 'x11', '', d)}" = 
"x11" ]; then
+   sed -i -e 's:#X11Forwarding no:X11Forwarding yes:' 
${D}${sysconfdir}/ssh/sshd_config_default
fi
 
install -d ${D}${sysconfdir}/init.d
@@ -110,7 +114,7 @@ do_install_append () {
 
# Create config files for read-only rootfs
install -d ${D}${sysconfdir}/ssh
-   install -m 644 ${D}${sysconfdir}/ssh/sshd_config 
${D}${sysconfdir}/ssh/sshd_config_readonly
+   install -m 644 ${D}${sysconfdir}/ssh/sshd_config_default 
${D}${sysconfdir}/ssh/sshd_config_readonly
sed -i '/HostKey/d' ${D}${sysconfdir}/ssh/sshd_config_readonly
echo "HostKey /var/run/ssh/ssh_host_rsa_key" >> 
${D}${sysconfdir}/ssh/sshd_config_readonly
echo "HostKey /var/run/ssh/ssh_host_dsa_key" >> 
${D}${sysconfdir}/ssh/sshd_config_readonly
@@ -134,30 +138,59 @@ do_install_ptest () {
 
 ALLOW_EMPTY_${PN} = "1"
 
-PACKAGES =+ "${PN}-keygen ${PN}-scp ${PN}-ssh ${PN}-sshd ${PN}-sftp ${PN}-misc 
${PN}-sftp-server"
+PACKAGES =+ "${PN}-keygen ${PN}-scp ${PN}-ssh ${PN}-sshd-config 
${PN}-sshd-config-readonly ${PN}-sshd ${PN}-sftp ${PN}-misc ${PN}-sftp-server"
 FILES_${PN}-scp = "${bindir}/scp.${BPN}"
 FILES_${PN}-ssh = "${bindir}/ssh.${BPN} ${sysconfdir}/ssh/ssh_config"
+FILES_${PN}-sshd-config = "${sysconfdir}/ssh/sshd_config_default"
+FILES_${PN}-sshd-config-readonly = "${sysconfdir}/ssh/sshd_config_readonly"
 FILES_${PN}-sshd = "${sbindir}/sshd ${sysconfdir}/init.d/sshd 
${systemd_unitdir}/system"
-FILES_${PN}-sshd += "${sysconfdir}/ssh/moduli ${sysconfdir}/ssh/sshd_config 
${sysconfdir}/ssh/sshd_config_readonly ${sysconfdir}/default/volatiles/99_sshd 
${sysconfdir}/pam.d/sshd"
+FILES_${PN}-sshd += "${sysconfdir}/ssh/moduli 
${sysconfdir}/default/volatiles/99_sshd ${sysconfdir}/pam.d/sshd"
 FILES_${PN}-sftp = "${bindir}/sftp"
 FILES_${PN}-sftp-server = "${libexecdir}/sftp-server"
 FILES_${PN}-misc = "${bindir}/ssh* ${libexecdir}/ssh*"
 FILES_${PN}-keygen = "${bindir}/ssh-keygen"
 
 RDEPENDS_${PN} += "${PN}-scp ${PN}-ssh ${PN}-sshd ${PN}-keygen"
-RDEPENDS_${PN}-sshd += "${PN}-keygen ${@bb.utils.contains('DISTRO_FEATURES', 
'pam', 'pam-plugin-keyinit pam-plugin-loginuid', '', d)}"
+RDEPENDS_${PN}-sshd += "${PN}-keygen sshd-config 
${@bb.utils.contains('DISTRO_FEATURES', 'pam', 'pam-plugin-keyinit 
pam-plugin-loginuid', '', d)}"
 RDEPENDS_${PN}-ptest += "${PN}-sftp ${PN}-misc ${PN}-sftp-server make"
 
 RPROVIDES_${PN}-ssh = "ssh"
+RPROVIDES_${PN}-sshd-config = "sshd-config"
+RPROVIDES_${PN}-sshd-config-readonly = "sshd-config"
 RPROVIDES_${PN}-sshd = "sshd"
 
 RCONFLICTS_${PN} = "dropbear"
+RCONFLICTS_${PN}-sshd-config = "${PN}-sshd-config-readonly"
+RCONFLICTS_${PN}-sshd-config-readonly = "${PN}-sshd-config"
 RCONFLICTS_${PN}-sshd = "dropbear"
 RCONFLICTS_${PN}-keygen = "ssh-keygen"
 
-CONFFILES_${PN}-sshd = "${sysconfdir}/ssh/sshd_config"
+CONFFILES_${PN}-sshd-config = "${sysconfdir}/ssh/sshd_config_default"
+CONFFILES_${PN}-sshd-config-readonly = "${sysconfdir}/ssh/sshd_config_readonly"
 CONFFILES_${PN}-ssh =

[OE-core] [PATCH RESEND 2/3] core-image: Set default sshd configuration

2017-06-09 Thread David Vincent
When selecting OpenSSH as ssh server provider instead of dropbear, also
install the correct configuration depending on whether the final rootfs
is read-only or not.

Signed-off-by: David Vincent <freesili...@gmail.com>
---
 meta/classes/core-image.bbclass | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/meta/classes/core-image.bbclass b/meta/classes/core-image.bbclass
index a9a2cec68f..77f3c19494 100644
--- a/meta/classes/core-image.bbclass
+++ b/meta/classes/core-image.bbclass
@@ -45,7 +45,7 @@ FEATURE_PACKAGES_tools-sdk = "packagegroup-core-sdk 
packagegroup-core-standalone
 FEATURE_PACKAGES_nfs-server = "packagegroup-core-nfs-server"
 FEATURE_PACKAGES_nfs-client = "packagegroup-core-nfs-client"
 FEATURE_PACKAGES_ssh-server-dropbear = "packagegroup-core-ssh-dropbear"
-FEATURE_PACKAGES_ssh-server-openssh = "packagegroup-core-ssh-openssh"
+FEATURE_PACKAGES_ssh-server-openssh = "packagegroup-core-ssh-openssh 
${SSHD_CONFIG}"
 FEATURE_PACKAGES_hwcodecs = "${MACHINE_HWCODECS}"
 
 
@@ -56,6 +56,7 @@ IMAGE_FEATURES_REPLACES_ssh-server-openssh = 
"ssh-server-dropbear"
 # IMAGE_FEATURES_CONFLICTS_foo = 'bar1 bar2'
 # An error exception would be raised if both image features foo and bar1(or 
bar2) are included
 
+SSHD_CONFIG ??= 
"${@bb.utils.contains('IMAGE_FEATURES','read-only-rootfs','openssh-sshd-config-readonly','openssh-sshd-config',d)}"
 MACHINE_HWCODECS ??= ""
 
 CORE_IMAGE_BASE_INSTALL = '\
-- 
2.13.0

-- 
___
Openembedded-core mailing list
Openembedded-core@lists.openembedded.org
http://lists.openembedded.org/mailman/listinfo/openembedded-core


[OE-core] [PATCH RESEND 0/3] openssh: Package server configuration

2017-06-09 Thread David Vincent
This serie of patches provides a way to package OpenSSH sshd configuration. This
way, it should be easier to change the configuration either in distro and/or BSP
layers.
It also simplifies management for R/O rootfs

David Vincent (3):
  openssh: Package server configuration
  core-image: Set default sshd configuration
  rootfs-postcommands: Modify ssh-related commands

 meta/classes/core-image.bbclass|  3 +-
 meta/classes/rootfs-postcommands.bbclass   | 17 +++-
 meta/recipes-connectivity/openssh/openssh_7.5p1.bb | 51 ++
 3 files changed, 50 insertions(+), 21 deletions(-)

-- 
2.13.0

-- 
___
Openembedded-core mailing list
Openembedded-core@lists.openembedded.org
http://lists.openembedded.org/mailman/listinfo/openembedded-core


[OE-core] [PATCH] initscripts: Populate volatile from existing file

2017-06-02 Thread David Vincent
In some cases, it may be useful to populate a volatile file from an
existing one, e.g. a file in a read-only rootfs that may be edited in a
read-write destination.

To provide this behavior, creation of volatile files has been updated to
copy a file which has been given in the  field. If set to
none, the current behavior is preserved.

Signed-off-by: David Vincent <freesili...@gmail.com>
---
 .../initscripts/initscripts-1.0/populate-volatile.sh | 16 ++--
 1 file changed, 14 insertions(+), 2 deletions(-)

diff --git a/meta/recipes-core/initscripts/initscripts-1.0/populate-volatile.sh 
b/meta/recipes-core/initscripts/initscripts-1.0/populate-volatile.sh
index 22a71ecaae..35316ec2ba 100755
--- a/meta/recipes-core/initscripts/initscripts-1.0/populate-volatile.sh
+++ b/meta/recipes-core/initscripts/initscripts-1.0/populate-volatile.sh
@@ -25,8 +25,18 @@ COREDEF="00_core"
 [ "${VERBOSE}" != "no" ] && echo "Populating volatile Filesystems."
 
 create_file() {
+   EXEC=""
+   [ -z "$2" ] && {
+   EXEC="
+   touch \"$1\";
+   "
+   } || {
+   EXEC="
+   cp \"$2\" \"$1\";
+   "
+   }
EXEC="
-   touch \"$1\";
+   ${EXEC}
chown ${TUSER}.${TGROUP} $1 || echo \"Failed to set owner -${TUSER}- 
for -$1-.\" >/dev/tty0 2>&1;
chmod ${TMODE} $1 || echo \"Failed to set mode -${TMODE}- for -$1-.\" 
>/dev/tty0 2>&1 "
 
@@ -187,7 +197,9 @@ apply_cfgfile() {
 
case "${TTYPE}" in
"f")  [ "${VERBOSE}" != "no" ] && echo "Creating file 
-${TNAME}-."
-   create_file "${TNAME}"
+   TSOURCE="$TLTARGET"
+   [ "${TSOURCE}" = "none" ] && TSOURCE=""
+   create_file "${TNAME}" "${TSOURCE}" &
;;
"d")  [ "${VERBOSE}" != "no" ] && echo "Creating 
directory -${TNAME}-."
mk_dir "${TNAME}"
-- 
2.13.0

-- 
___
Openembedded-core mailing list
Openembedded-core@lists.openembedded.org
http://lists.openembedded.org/mailman/listinfo/openembedded-core


[OE-core] [PATCH] image.bbclass: Set ROOTFS_RO_UNNEEDED correctly

2017-04-26 Thread David Vincent
Use a weak assignment for ROOTFS_RO_UNNEEDED to let users define their
own list overriding defaults.

Signed-off-by: David Vincent <freesili...@gmail.com>
---
 meta/classes/image.bbclass | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/meta/classes/image.bbclass b/meta/classes/image.bbclass
index 405fd73c04..58cd608d14 100644
--- a/meta/classes/image.bbclass
+++ b/meta/classes/image.bbclass
@@ -33,7 +33,7 @@ ROOTFS_BOOTSTRAP_INSTALL = "run-postinsts"
 
 # These packages will be removed from a read-only rootfs after all other
 # packages have been installed
-ROOTFS_RO_UNNEEDED = "update-rc.d base-passwd shadow 
${VIRTUAL-RUNTIME_update-alternatives} ${ROOTFS_BOOTSTRAP_INSTALL}"
+ROOTFS_RO_UNNEEDED ??= "update-rc.d base-passwd shadow 
${VIRTUAL-RUNTIME_update-alternatives} ${ROOTFS_BOOTSTRAP_INSTALL}"
 
 # packages to install from features
 FEATURE_INSTALL = "${@' 
'.join(oe.packagegroup.required_packages(oe.data.typed_value('IMAGE_FEATURES', 
d), d))}"
-- 
2.12.2

-- 
___
Openembedded-core mailing list
Openembedded-core@lists.openembedded.org
http://lists.openembedded.org/mailman/listinfo/openembedded-core


Re: [OE-core] [Openembedded-architecture] [RFC] Handling configuration files

2017-04-24 Thread David Vincent
On vendredi 21 avril 2017 15:41:58 CEST Mark Hatle wrote:
> On 4/21/17 5:49 AM, David Vincent wrote:
> > Following this thread on OE-Core
> > (http://lists.openembedded.org/pipermail/openembedded-core/2017-April/1358
> > 12.html), the subject of handling configuration files for a machine just
> > got back. It seems there already was a discussion around it but I
> > couldn't find it. I know that 2.3 has now hit 'feature-freeze' status but
> > I try to gather some ideas for maybe an implementation in 2.4.
> > 
> > Simply put, the problem is this:
> > I want to
> > 
> >   - Override a configuration file in a package
> >   - Make the configuration machine-specific
> >   - Upgrade the configuration during package upgrade without human
> >   interaction> 
> > For now, one way to do this is to append the recipe and to replace the
> > PACKAGE_ARCH with MACHINE_ARCH. The downside of this approach is that
> > a package is created for each machine on package repositories where
> > only the configuration is modified.
> > 
> > Another way is to modify the file in ROOTFS_POSTPROCESS_COMMAND. The
> > downside is that depending on the packager, it would either not
> > survive the package upgrade or not be upgradable.
> 
> Update is potentially an issue..  but not surviving a package upgrade means
> we've got a recipe/package manager bug to deal with.
> 
> If the configuration items are properly specified, then a package upgrade
> should NOT destroy custom configurations... if it does, I consider this a
> bug.
I agree, package managers are smart when it comes to configuration and should 
not boldly override a custom configuration.

The other issue is that there are some cases where the configuration must be 
destroyed at package installation (remember that I want the package upgrade to 
be without human interaction) and that is, AFAIK, impossible with a 
postcommand (could work with a postinstall task though but it requires more 
work on the recipe side especially during package upgrades).
> > The last way would be to use update-alternatives, but IMHO it does
> > feel weird. Another downside would be the need to modify all recipes
> > to mark the configurations as alternatives.
> > 
> > My idea was the following. Maybe we could rely on the CONFFILES
> > variable to create a -conf package (like -dbg/-dev/-staticdev). If
> > possible, this package only should be marked as MACHINE_ARCH. This
> > could happen behind the scenes in package.bbclass. The only problem I
> > see for now is how to identify that the configuration file has been
> > overridden in a machine-specific recipe (SRC_URI or other variable ?).
> > Do you think it is feasible or am I missing something ? I could
> > proceed to implement that kind of behavior but I would like to know
> > beforehand if there are other things I should take into account.
> 
> Unfortunately RPM does not permit generating a single package with multiple
> architectures.
> 
> Also if even a piece of the constructed system is MACHINE specific, then
> usually all of it has to be rebuilt from source -- which would overwrite
> previous versions in the feeds.
Too bad, but this was cherry-on-top. We lived with this restriction until now 
so we could live a little longer with it, right ? Anyway, storage is cheap and 
compile time is a no-blocker ?
> 
> I agree the update-alternatives feels 'strange', because it effectively
> preserves the original and provides the 'custom' at the same time.. but
> functionally it will work fine.
> 
> The other option is to go through the system and construct new 'conf'
> packages (to be used as dependencies for the runtime) for packages that
> typically get configured
> 
> I'd almost suggest that a hybrid approach to this might be appropriate.
> 
> Use the update-alternatives method for items that are not commonly modified
> in deployment...
Problem is 'How to define commonly modified ?' . Given the number of recipes 
and 
use-case scenarios, that's pretty impossible to say ?
> then use a "new" conf recipe for each item that is
> typically modified.  (I'm worried this will add additional overhead to
> recipe upgrades and such, so I'm not convinced a conf recipe is actually a
> sustainable idea here.)
I wasn't thinking of creating a conf recipe, just a conf package. That is much 
less work overhead. And to identify recipes that adds configuration elements, I 
thought of creating a CONFOVERRIDE variable that could be used like 
NOAUTOPACKAGEDEBUG (the name is just a suggestion) to mark recipes that 
overrides configuration files. This way, BSP layers could simply provide their 
own configuration a

Re: [OE-core] [PATCH] Revert "kernel: Fix symlinks"

2017-04-24 Thread David Vincent
On samedi 22 avril 2017 00:04:34 CEST Andrea Adami wrote:
> 
> We lived for years with the relative symlink.
> 
> Then  78ee4d8  broke the bootloaders in 2014
> Finally it was reverted end 2016 and now it is under review again...ouch
> 
> What broke what?
> 
> My point is, while I had the sources and could modify and reflash the
> bootloader, the same is not valid for many people.
> 
> Anyway, I have found out that there was a workaround to allow boot from NFS:
> 
> +ROOTFS_POSTPROCESS_COMMAND += "make_zimage_symlink_relative;"

This works at image level, it is not package upgrade safe. IMHO, the symlinks 
must be relative (like every other distro) and therefore should not be 
maintained with update-alternatives (postinstall task should use plain 'ln')

> 
> Cheers
> Andrea

David
-- 
___
Openembedded-core mailing list
Openembedded-core@lists.openembedded.org
http://lists.openembedded.org/mailman/listinfo/openembedded-core


Re: [OE-core] [PATCH] Revert "kernel: Fix symlinks"

2017-04-21 Thread David Vincent
On 2017-04-21 13:30 GMT+02:00 Andreas Oberritter :
> On Fri, 21 Apr 2017 13:02:51 +0200
> Andrea Adami  wrote:
>
>> On Fri, Apr 21, 2017 at 12:39 PM, Andreas Oberritter
>>  wrote:
>> > This reverts commit c7bc46b9bc29dd0953ab8d63b50fa105bb66892e.
>> >
>> > It broke dpkg's update-alternatives, which requires absolute paths.
>>
>> This is really uncommon.
>
> Actually it's not. Try it on any Debian or Ubuntu system.
>
>> I had already expressed my negative opinion about absolute paths for kernel 
>> [1].
>> Personally, I had to patch the bootloader (kexecboot).

Same here, that's why I submitted it in the first place. Didn't
thought that would break dpkg...

>>
>> So please try some workaround instead of changing it back.
>
> Well, there's no workaround. Other than opkg's update-alternatives, dpkg's 
> maintains
> an alternatives database in /etc/alternatives, so the symlink is going to 
> point to
> an absolute path outside of /boot anyway.

The problem is that, for bootloaders, it is not always possible to
mount the rootfs. So, it must only rely on information in the boot
partition that can be mounted anywhere.

>
> To fix your problem, kernel.bbclass should be changed to not use 
> update-alternatives
> at all. But it's definitely wrong to break the original u-a by using invalid 
> command-
> line arguments.
>

And reverting this patch breaks boot for those who rely on a relative
symlink ; that is also wrong. Maybe you're right and
update-alternatives should be abandoned altogether for managing kernel
symlinks.

> Regards,
> Andreas
>
>
>> Cheers
>> Andrea

David

>>
>> [1] 
>> http://lists.openembedded.org/pipermail/openembedded-core/2014-July/093988.html
>>
>> >
>> > | update-alternatives: error: alternative path is not absolute as it 
>> > should be
>> >
>> > Signed-off-by: Andreas Oberritter 
>> > ---
>> >  meta/classes/kernel.bbclass | 6 +++---
>> >  meta/recipes-kernel/linux/linux-dtb.inc | 4 ++--
>> >  2 files changed, 5 insertions(+), 5 deletions(-)
>> >
>> > diff --git a/meta/classes/kernel.bbclass b/meta/classes/kernel.bbclass
>> > index 12a748d..8cf357f 100644
>> > --- a/meta/classes/kernel.bbclass
>> > +++ b/meta/classes/kernel.bbclass
>> > @@ -49,11 +49,10 @@ python __anonymous () {
>> >
>> >  for type in types.split():
>> >  typelower = type.lower()
>> > -imagedest = d.getVar('KERNEL_IMAGEDEST')
>> >
>> >  d.appendVar('PACKAGES', ' ' + 'kernel-image-' + typelower)
>> >
>> > -d.setVar('FILES_kernel-image-' + typelower, '/' + imagedest + '/' 
>> > + type + '-${KERNEL_VERSION_NAME}')
>> > +d.setVar('FILES_kernel-image-' + typelower, '/boot/' + type + 
>> > '-${KERNEL_VERSION_NAME}')
>> >
>> >  d.appendVar('RDEPENDS_kernel-image', ' ' + 'kernel-image-' + 
>> > typelower)
>> >
>> > @@ -61,8 +60,9 @@ python __anonymous () {
>> >
>> >  d.setVar('ALLOW_EMPTY_kernel-image-' + typelower, '1')
>> >
>> > +imagedest = d.getVar('KERNEL_IMAGEDEST')
>> >  priority = d.getVar('KERNEL_PRIORITY')
>> > -postinst = '#!/bin/sh\n' + 'update-alternatives --install /' + 
>> > imagedest + '/' + type + ' ' + type + ' ' + type + 
>> > '-${KERNEL_VERSION_NAME} ' + priority + ' || true' + '\n'
>> > +postinst = '#!/bin/sh\n' + 'update-alternatives --install /' + 
>> > imagedest + '/' + type + ' ' + type + ' ' + '/' + imagedest + '/' + type + 
>> > '-${KERNEL_VERSION_NAME} ' + priority + ' || true' + '\n'
>> >  d.setVar('pkg_postinst_kernel-image-' + typelower, postinst)
>> >
>> >  postrm = '#!/bin/sh\n' + 'update-alternatives --remove' + ' ' + 
>> > type + ' ' + type + '-${KERNEL_VERSION_NAME} || true' + '\n'
>> > diff --git a/meta/recipes-kernel/linux/linux-dtb.inc 
>> > b/meta/recipes-kernel/linux/linux-dtb.inc
>> > index 22e374f..41aad7c 100644
>> > --- a/meta/recipes-kernel/linux/linux-dtb.inc
>> > +++ b/meta/recipes-kernel/linux/linux-dtb.inc
>> > @@ -63,7 +63,7 @@ pkg_postinst_kernel-devicetree () {
>> > DTB_EXT=${DTB##*.}
>> > DTB_BASE_NAME=`basename ${DTB} ."${DTB_EXT}"`
>> > DTB_SYMLINK_NAME=`echo ${symlink_name} | sed 
>> > "s/${MACHINE}/${DTB_BASE_NAME}/g"`
>> > -   update-alternatives --install 
>> > /${KERNEL_IMAGEDEST}/${DTB_BASE_NAME}.${DTB_EXT} 
>> > ${DTB_BASE_NAME}.${DTB_EXT} devicetree-${DTB_SYMLINK_NAME}.${DTB_EXT} 
>> > ${KERNEL_PRIORITY} || true
>> > +   update-alternatives --install 
>> > /${KERNEL_IMAGEDEST}/${DTB_BASE_NAME}.${DTB_EXT} 
>> > ${DTB_BASE_NAME}.${DTB_EXT} 
>> > /boot/devicetree-${DTB_SYMLINK_NAME}.${DTB_EXT} ${KERNEL_PRIORITY} || true
>> > done
>> > done
>> >  }
>> > @@ -76,7 +76,7 @@ pkg_postrm_kernel-devicetree () {
>> > DTB_EXT=${DTB##*.}
>> > DTB_BASE_NAME=`basename ${DTB} ."${DTB_EXT}"`
>> 

[OE-core] [RFC] Handling configuration files

2017-04-21 Thread David Vincent
Following this thread on OE-Core
(http://lists.openembedded.org/pipermail/openembedded-core/2017-April/135812.html),
the subject of handling configuration files for a machine just got
back. It seems there already was a discussion around it but I couldn't
find it. I know that 2.3 has now hit 'feature-freeze' status but I try
to gather some ideas for maybe an implementation in 2.4.

Simply put, the problem is this:
I want to
  - Override a configuration file in a package
  - Make the configuration machine-specific
  - Upgrade the configuration during package upgrade without human interaction

For now, one way to do this is to append the recipe and to replace the
PACKAGE_ARCH with MACHINE_ARCH. The downside of this approach is that
a package is created for each machine on package repositories where
only the configuration is modified.

Another way is to modify the file in ROOTFS_POSTPROCESS_COMMAND. The
downside is that depending on the packager, it would either not
survive the package upgrade or not be upgradable.

The last way would be to use update-alternatives, but IMHO it does
feel weird. Another downside would be the need to modify all recipes
to mark the configurations as alternatives.

My idea was the following. Maybe we could rely on the CONFFILES
variable to create a -conf package (like -dbg/-dev/-staticdev). If
possible, this package only should be marked as MACHINE_ARCH. This
could happen behind the scenes in package.bbclass. The only problem I
see for now is how to identify that the configuration file has been
overridden in a machine-specific recipe (SRC_URI or other variable ?).
Do you think it is feasible or am I missing something ? I could
proceed to implement that kind of behavior but I would like to know
beforehand if there are other things I should take into account.

Thanks,
David
-- 
___
Openembedded-core mailing list
Openembedded-core@lists.openembedded.org
http://lists.openembedded.org/mailman/listinfo/openembedded-core


Re: [OE-core] [PATCH] openssl: Fix symlink creation

2017-04-21 Thread David Vincent
On 2017-04-20 15:04 GMT+02:00 Martin Jansa <martin.ja...@gmail.com>:
> On Thu, Apr 20, 2017 at 03:37:24PM +0300, Alexander Kanavin wrote:
>> On 04/19/2017 04:03 PM, David Vincent wrote:
>> > The problem is that I must be able to manage the configuration of a machine
>> > without physical intervention and only via package upgrades. A new
>> > configuration can be applied simply by incrementing the PR of a 
>> > configuration
>> > package.
>> >
>> > But maybe this is a use case only needed by me and I should manage it in my
>> > own specific layer ?
>> >
>> > Now that I think of it, I have the same kind of problem for all machine
>> > specific configurations. For now, I just replace the PACKAGE_ARCH in my BSP
>> > layer with a machine specific one to indicate that a package contains a
>> > configuration valid only for a specific machine. Maybe, in a future 
>> > release, it
>> > should be desirable to create -conf packages based on the CONFFILES 
>> > variable ?
>> > I don't know if it's a good idea, but maybe I could bring that up on the
>> > architecture mailing list ?
>>
>> By all means please do so. Yocto lacks a solution for configuration
>> management, and this was discussed some time ago, although I cannot
>> anymore find where it happened. Mark, do you remember?

Yes I'll bring that up on the architecture mailing list to gather some advices.

>
> I still haven't seen any argument why not use u-a like for any other
> alternative files.

I don't really have an argument, it's just that it feels wrong to me to manage
configuration files via update-alternatives. Just like it did for
initscripts. I agree that
it works, until some corner cases reveal problems.
(see https://bugzilla.yoctoproject.org/show_bug.cgi?id=10433)

>
> All you have to do is create openssl bbappend (this part might be
> integrated into oe-core):
>
> inherit update-alternatives
> ALTERNATIVE_${PN} = "openssl-cnf"
> ALTERNATIVE_LINK_NAME[openssl-cnf] = "${sysconfdir}/ssl/openssl.cnf"
> ALTERNATIVE_PRIORITY[openssl-cnf] ?= "1"
>
> And then in your recipe which provides alternative config add similar
> fragment:
>
> inherit update-alternatives
> ALTERNATIVE_${PN} = "openssl-cnf"
> ALTERNATIVE_LINK_NAME[openssl-cnf] = "${sysconfdir}/ssl/openssl.cnf"
> ALTERNATIVE_PRIORITY[openssl-cnf] ?= "10"
>
> And that's it. We're using this for last 4 years since:
> https://github.com/openwebos/meta-webos/commit/b13980be3f28bf60582ec3f691e392db03942e21
> and it worked fine until this oe-core change was merged (and I had to
> undo it in the same bbappend).

OTOH, I could also append the install task for my target. There are
many solutions to
this problem, but I think that like it was said before, the main one
is handling properly the
configuration and provide a way to override it in BSP or distro layers.

>
> Regards,
> --
> Martin 'JaMa' Jansa jabber: martin.ja...@gmail.com

David
-- 
___
Openembedded-core mailing list
Openembedded-core@lists.openembedded.org
http://lists.openembedded.org/mailman/listinfo/openembedded-core


Re: [OE-core] [PATCH] openssl: Fix symlink creation

2017-04-19 Thread David Vincent
On mercredi 19 avril 2017 13:57:40 CEST Alexander Kanavin wrote:
> On 04/19/2017 02:53 PM, David Vincent wrote:
> >> This kind of thing is better done via ROOTFS_POSTPROCESS_COMMAND, I
> >> think. Look for examples in rootfs-postcommands.bbclass.
> > 
> > The problem of ROOTFS_POSTPROCESS_COMMAND is that it is a one shot
> > function
> > that is run at image creation. In my case, I must be able to upgrade the
> > package over time via package management tools. Sorry for not bringing
> > that up before.
> 
> What is it in the openssl config file that must be managed via package
> updates?
The problem is that I must be able to manage the configuration of a machine 
without physical intervention and only via package upgrades. A new 
configuration can be applied simply by incrementing the PR of a configuration 
package.

But maybe this is a use case only needed by me and I should manage it in my 
own specific layer ?

Now that I think of it, I have the same kind of problem for all machine 
specific configurations. For now, I just replace the PACKAGE_ARCH in my BSP 
layer with a machine specific one to indicate that a package contains a 
configuration valid only for a specific machine. Maybe, in a future release, it 
should be desirable to create -conf packages based on the CONFFILES variable ? 
I don't know if it's a good idea, but maybe I could bring that up on the 
architecture mailing list ?
> 
> Alex

David
-- 
___
Openembedded-core mailing list
Openembedded-core@lists.openembedded.org
http://lists.openembedded.org/mailman/listinfo/openembedded-core


Re: [OE-core] [PATCH] openssl: Fix symlink creation

2017-04-19 Thread David Vincent
On mercredi 19 avril 2017 12:21:18 CEST Alexander Kanavin wrote:
> On 04/19/2017 11:27 AM, David Vincent wrote:
> > The package is then chosen during image creation based on some
> > MACHINE_FEATURES, i.e. if the machine provides a crypto accelerator to use
> > instead of relying on software implementations. I hope that these new
> > details will help you understand what I was trying to achieve.
> 
> This kind of thing is better done via ROOTFS_POSTPROCESS_COMMAND, I
> think. Look for examples in rootfs-postcommands.bbclass.

The problem of ROOTFS_POSTPROCESS_COMMAND is that it is a one shot function 
that is run at image creation. In my case, I must be able to upgrade the 
package over time via package management tools. Sorry for not bringing that up 
before.

> 
> Alex

David


-- 
___
Openembedded-core mailing list
Openembedded-core@lists.openembedded.org
http://lists.openembedded.org/mailman/listinfo/openembedded-core


Re: [OE-core] [PATCH] openssl: Fix symlink creation

2017-04-19 Thread David Vincent
On jeudi 13 avril 2017 10:05:29 CEST Jussi Kukkonen wrote:
> Hi David,
> 
> Just a heads-up: I will propose a revert of this patch this week unless
> better ideas come up in the mean time.
Sorry, I've been away last week so didn't have time to respond to your 
previous mails. I've seen the revert proposal but I think I could provide some 
heads-up to find a better solution to deal with my problem after the revert.
> 
> I get that you have an actual problem you're solving but I don't think
> postinstall is a correct solution. I'm sorry I don't have an alternative
> solution ready for you: if you share your other configuration recipe and
> explain how you use the two, maybe we can figure something out.
This is my other recipe that installs the alternative configuration:

FILESEXTRAPATHS_prepend := "${THISDIR}/${PN}:"

SRC_URI += "file://openssl-hwengine.cnf"

do_install_append () {
install -m 0644 ${WORKDIR}/openssl-hwengine.cnf ${D}${sysconfdir}/ssl/
}

PACKAGES =+ "${PN}-conf-hwengine"

FILES_${PN}-conf-hwengine = "${sysconfdir}/ssl/openssl-hwengine.cnf"
CONFFILES_${PN}-conf-hwengine = "${sysconfdir}/ssl/openssl-hwengine.cnf"
RPROVIDES_${PN}-conf-hwengine += "${PN}-conf"
RCONFLICTS_${PN}-conf-hwengine += "${PN}-conf"
RREPLACES_${PN}-conf-hwengine += "${PN}-conf"
RDEPENDS_${PN}-conf-hwengine = "libp11-engine"
RDEPENDS_${PN}-conf-hwengine_class-native = ""
RDEPENDS_${PN}-conf-hwengine_class-nativesdk = ""

pkg_postinst_${PN}-conf-hwengine () {
#!/bin/sh
if [ -e $D${libdir}/ssl/openssl.cnf ]; then
rm -f $D${libdir}/ssl/openssl.cnf
fi

# If openssl-conf is installed before openssl, we must ensure that the symlink
# destination exists
mkdir -p $D${libdir}/ssl/
ln -s ${sysconfdir}/ssl/openssl-hwengine.cnf $D${libdir}/ssl/openssl.cnf
}


The package is then chosen during image creation based on some 
MACHINE_FEATURES, i.e. if the machine provides a crypto accelerator to use 
instead of relying on software implementations. I hope that these new details 
will help you understand what I was trying to achieve.

> 
> Jussi
> 

David
-- 
___
Openembedded-core mailing list
Openembedded-core@lists.openembedded.org
http://lists.openembedded.org/mailman/listinfo/openembedded-core


Re: [OE-core] [PATCH] openssl: Fix symlink creation

2017-04-07 Thread David Vincent
On jeudi 6 avril 2017 15:03:36 CEST Martin Jansa wrote:
> I still don't understand why not use standard update-alternatives and
> install another package with your favorite openssl.conf which has higher
> ALTERNATIVE_PRIORITY.

Why not, but maybe this https://bugzilla.yoctoproject.org/show_bug.cgi?
id=10777 can be a stopper since libcrypto RRECOMMENDS openssl-conf

> This way u-a will switch to new config even when you just install the
> package which require it on the target later and will switch back to
> default openssl.conf when the alternative package with config file is
> uninstalled.
> 
> On Thu, Apr 6, 2017 at 12:55 PM, Jussi Kukkonen 
>> So previously openssl-conf package included etc/ssl/openssl.cnf and the
>> symlink ${libdir}/ssl/openssl.conf.

The symlink is not inside openssl-conf package but rather inside openssl.

>> Nothing RDEPENDS on this package (but
>> libcrypto RRECOMMENDS it).
>> 
>> After your patch the actual configuration file is still installed. In a
>> postinst
>> 
>>   * ${libdir}/ssl/openssl.conf is removed if it exists (why? If it's for
>> upgrading, then this should happen in a prerm or postrm)
>>   * the symlink ${libdir}/ssl/openssl.conf is created
>> 
>> My confusion is this: how does the above solve the problem you describe?
>> If you've managed to use RCONFLICTS to prevent the configuration package
>> from getting included in the image, why are changes to the package needed?
>> 

To avoid creation of the symlink inside openssl package. But I agree for the 
postrm/prerm tasks instead of postinst.

>> 
>> Some alternative solutions to your problem I think might work:
>> * openssl_%.bbappend with a do_install_append() that simply copies your
>> conf file over the one from upstream recipe. No extra packages needed
>> * BAD_RECOMMENDATIONS or PACKAGE_EXCLUDE to prevent openssl-conf from
>> getting included in your image, then adding your own package with your
>> configuration (does not work for dpkg I think)
>> 

I could consider this if the patch gets reverted, but I still prefer using 
extra packages. It's easier this way to know which configuration has been 
applied (but update-alternatives could work too).

TBH, I say that because I've submitted a similar series of patches for openssh 
based on the same principle. I think my main problem is the handling of 
configuration files at build time. This holds especially true for read-only 
rootfs where these files must be available at build time. Is there guidelines 
for that ?

>> Jussi
>> 
>> --
>> ___
>> Openembedded-core mailing list
>> Openembedded-core@lists.openembedded.org
>> http://lists.openembedded.org/mailman/listinfo/openembedded-core

David
-- 
___
Openembedded-core mailing list
Openembedded-core@lists.openembedded.org
http://lists.openembedded.org/mailman/listinfo/openembedded-core


Re: [OE-core] [PATCH] openssl: Fix symlink creation

2017-04-06 Thread David Vincent
On mercredi 5 avril 2017 09:30:52 CEST Jussi Kukkonen wrote:
> This apparently breaks key generation with openssl-native because the file
> doesn't exist.

Looking at the recipe right now, I understand why key generation is broken for 
native build (I should have been more careful). I see two ways of fixing it :
- either recreate the symlink in do_install_append_class_native
- or simply modifiyng the OPENSSL_CONF variable in the same task.

> 
> I can fix it by adding one more complication to the recipe (will send a
> patch) but I don't think the current solution is all that great: I've been
> looking at this patch for a while now and still don't really understand why
> it is needed and how these different packages interact. I'm sure it makes
> sense when you look at the other recipe but ... isn't it a bad sign that
> that context seems to be needed?

OK, I will provide some context because maybe my approach was wrong. In some 
of my builds, I require some images to have a very specific configuration to 
make OpenSSL use engines. My idea was to provide a package for this task since 
the default file can not be overridden (and in fact shouldn't be for the native 
build). This way, using RCONFLICTS I can provide a new configuration package 
for these specific builds while maintaining the default behavior for all 
others.

> 
> Jussi
> 

David
-- 
___
Openembedded-core mailing list
Openembedded-core@lists.openembedded.org
http://lists.openembedded.org/mailman/listinfo/openembedded-core


[OE-core] [PATCH] package.bbclass: add CONFFILES to pkgdata

2017-04-05 Thread David Vincent
Emit CONFFILES variable in pkgdata, or else the get_conffiles function
will return 'None' for some packages instead of the expected value. This
is especially true for optional module packages.

Signed-off-by: David Vincent <freesili...@gmail.com>
---
 meta/classes/package.bbclass | 1 +
 1 file changed, 1 insertion(+)

diff --git a/meta/classes/package.bbclass b/meta/classes/package.bbclass
index 1bc4f6a4dc..cc466bd1b2 100644
--- a/meta/classes/package.bbclass
+++ b/meta/classes/package.bbclass
@@ -1380,6 +1380,7 @@ python emit_pkgdata() {
 write_if_exists(sf, pkg, 'PKG')
 write_if_exists(sf, pkg, 'ALLOW_EMPTY')
 write_if_exists(sf, pkg, 'FILES')
+write_if_exists(sf, pkg, 'CONFFILES')
 write_if_exists(sf, pkg, 'pkg_postinst')
 write_if_exists(sf, pkg, 'pkg_postrm')
 write_if_exists(sf, pkg, 'pkg_preinst')
-- 
2.12.2

-- 
___
Openembedded-core mailing list
Openembedded-core@lists.openembedded.org
http://lists.openembedded.org/mailman/listinfo/openembedded-core


[OE-core] [PATCH] ifupdown: Fix initscript

2017-03-27 Thread David Vincent
ifupdown does not provide an initscript so this recipe should not
inherit update-rc.d class. Instead, we rely on init-ifupdown recipe to
startup networking.

Signed-off-by: David Vincent <freesili...@gmail.com>
---
 meta/recipes-core/ifupdown/ifupdown_0.8.16.bb | 5 +
 1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/meta/recipes-core/ifupdown/ifupdown_0.8.16.bb 
b/meta/recipes-core/ifupdown/ifupdown_0.8.16.bb
index eb8426cb97..5654528ae8 100644
--- a/meta/recipes-core/ifupdown/ifupdown_0.8.16.bb
+++ b/meta/recipes-core/ifupdown/ifupdown_0.8.16.bb
@@ -16,7 +16,7 @@ SRCREV = "11b9f99f7ecc7052497e6786156cfed531f11823"
 S = "${WORKDIR}/git"
 
 
-inherit update-rc.d update-alternatives
+inherit update-alternatives
 
 do_compile () {
chmod a+rx *.pl *.sh
@@ -44,6 +44,3 @@ ALTERNATIVE_${PN} = "ifup ifdown"
 
 ALTERNATIVE_LINK_NAME[ifup] = "${base_sbindir}/ifup"
 ALTERNATIVE_LINK_NAME[ifdown] = "${base_sbindir}/ifdown"
-
-INITSCRIPT_NAME = "ifup"
-INITSCRIPT_PARAMS = "start 39 S . stop 39 0 6 1 ."
-- 
2.12.0

-- 
___
Openembedded-core mailing list
Openembedded-core@lists.openembedded.org
http://lists.openembedded.org/mailman/listinfo/openembedded-core


Re: [OE-core] [oe-commits] [openembedded-core] 13/29: openssl: Fix symlink creation

2017-03-14 Thread David Vincent
On samedi 11 mars 2017 21:50:23 CET Martin Jansa wrote:
> Why not use update-alternatives for this file?

IMO, update-alternatives should not handle configuration files. I think that 
using it can “silently” apply a new configuration with higher priority and 
things will break in some odd ways. Using conflicting packages ensures that the 
applied configuration has been enforced at install time and the administrator 
knows what is doing. Again, it is just my personal taste...

> 
> That's what I'm using in openssl bbappend because we also use different
> provider for this file and it worked well .. until this change.
> 

Sorry this change broke some builds, if I am the only one to use this 
configuration, feel free to revert this patch.

OTOH, I have also provided the same kind of patch for OpenSSH configuration 
(not yet applied), so tell me what would be the best way to handle 
configuration files in Yocto, I may have missed it in the documentation.

David
-- 
___
Openembedded-core mailing list
Openembedded-core@lists.openembedded.org
http://lists.openembedded.org/mailman/listinfo/openembedded-core


Re: [OE-core] Fwd: [PATCH] busybox: conditional inclusion of login utilities

2017-03-06 Thread David Vincent
On lundi 6 mars 2017 13:48:22 CET Burton, Ross wrote:
> On 6 March 2017 at 08:31, David Vincent <freesili...@gmail.com> wrote:
> > +   ${@["", "file://login-utilities.cfg"][(d.getVar('VIRTUAL-
> > RUNTIME_login_manager') == 'busybox')]} \
> 
> VIRTUAL_RUNTIME can be set per-image, so you can't do this.
> 
> Ross

I just copied the lines already present in the recipe (and I also forgot to 
modify the git version on a side note) :

${@[””, "file://init.cfg"][(d.getVar('VIRTUAL-RUNTIME_init_manager', True) == 
'busybox')]} \
 ${@["", "file://mdev.cfg"][(d.getVar('VIRTUAL-RUNTIME_dev_manager', True) == 
'busybox-mdev')]} \

So, what should be the proper way to conditionally include these fragments ?

I don't know for init and dev managers, but for login-utilities, my use case 
is that I don't want busybox to provide adduser/addgroup/... if I already have 
these provided by another package (e.g. Shadow).

David
-- 
___
Openembedded-core mailing list
Openembedded-core@lists.openembedded.org
http://lists.openembedded.org/mailman/listinfo/openembedded-core


[OE-core] Fwd: [PATCH] initscripts: Populate volatile from existing file

2017-03-06 Thread David Vincent
Ping

--  Forwarded Message  --

Subject: [PATCH] initscripts: Populate volatile from existing file
Date: mercredi 25 janvier 2017, 12:35:52 CET
From: David Vincent <freesili...@gmail.com>
To: openembedded-core@lists.openembedded.org
CC: David Vincent <freesili...@gmail.com>

In some cases, it may be useful to populate a volatile file from an
existing one, e.g. a file in a read-only rootfs that may be edited in a
read-write destination.

To provide this behavior, creation of volatile files has been updated to
copy a file which has been given in the  field. If set to
none, the current behavior is preserved.

Signed-off-by: David Vincent <freesili...@gmail.com>
---
 .../initscripts/initscripts-1.0/populate-volatile.sh | 16 +
+--
 1 file changed, 14 insertions(+), 2 deletions(-)

diff --git a/meta/recipes-core/initscripts/initscripts-1.0/populate-
volatile.sh b/meta/recipes-core/initscripts/initscripts-1.0/populate-
volatile.sh
index 22a71ecaae..35316ec2ba 100755
--- a/meta/recipes-core/initscripts/initscripts-1.0/populate-volatile.sh
+++ b/meta/recipes-core/initscripts/initscripts-1.0/populate-volatile.sh
@@ -25,8 +25,18 @@ COREDEF="00_core"
 [ "${VERBOSE}" != "no" ] && echo "Populating volatile Filesystems."
 
 create_file() {
+   EXEC=""
+   [ -z "$2" ] && {
+   EXEC="
+   touch \"$1\";
+   "
+   } || {
+   EXEC="
+   cp \"$2\" \"$1\";
+   "
+   }
EXEC="
-   touch \"$1\";
+   ${EXEC}
chown ${TUSER}.${TGROUP} $1 || echo \"Failed to set owner -${TUSER}- 
for -
$1-.\" >/dev/tty0 2>&1;
chmod ${TMODE} $1 || echo \"Failed to set mode -${TMODE}- for -$1-.\" >/
dev/tty0 2>&1 "
 
@@ -187,7 +197,9 @@ apply_cfgfile() {
 
case "${TTYPE}" in
"f")  [ "${VERBOSE}" != "no" ] && echo "Creating file 
-${TNAME}-."
-   create_file "${TNAME}"
+   TSOURCE="$TLTARGET"
+   [ "${TSOURCE}" = "none" ] && TSOURCE=""
+   create_file "${TNAME}" "${TSOURCE}" &
;;
"d")  [ "${VERBOSE}" != "no" ] && echo "Creating 
directory -$
{TNAME}-."
mk_dir "${TNAME}"
-- 
2.11.0


-
-- 
___
Openembedded-core mailing list
Openembedded-core@lists.openembedded.org
http://lists.openembedded.org/mailman/listinfo/openembedded-core


[OE-core] Fwd: [PATCH] openssl: Fix symlink creation

2017-03-06 Thread David Vincent
Ping

--  Forwarded Message  --

Subject: [PATCH] openssl: Fix symlink creation
Date: lundi 23 janvier 2017, 14:59:16 CET
From: David Vincent <freesili...@gmail.com>
To: openembedded-core@lists.openembedded.org
CC: David Vincent <freesili...@gmail.com>

Symlinking the openssl configuration file at install time results in
errors when overriding it using an external package which also provides
openssl-conf. This should be done as a postinstall task for such
packages.

Signed-off-by: David Vincent <freesili...@gmail.com>
---
 meta/recipes-connectivity/openssl/openssl.inc | 13 -
 1 file changed, 12 insertions(+), 1 deletion(-)

diff --git a/meta/recipes-connectivity/openssl/openssl.inc b/meta/recipes-
connectivity/openssl/openssl.inc
index 5cca019e1d..696b564cdd 100644
--- a/meta/recipes-connectivity/openssl/openssl.inc
+++ b/meta/recipes-connectivity/openssl/openssl.inc
@@ -201,7 +201,6 @@ do_install () {
   ${D}${sysconfdir}/ssl/
ln -sf ${sysconfdir}/ssl/certs ${D}${libdir}/ssl/certs
ln -sf ${sysconfdir}/ssl/private ${D}${libdir}/ssl/private
-   ln -sf ${sysconfdir}/ssl/openssl.cnf ${D}${libdir}/ssl/openssl.cnf
 }
 
 do_install_ptest () {
@@ -245,4 +244,16 @@ do_install_append_class-native() {
OPENSSL_ENGINES=${libdir}/ssl/engines
 }
 
+pkg_postinst_openssl-conf () {
+#!/bin/sh
+if [ -e $D${libdir}/ssl/openssl.cnf ]; then
+   rm -f $D${libdir}/ssl/openssl.cnf
+fi
+
+# If openssl-conf is installed before openssl, we must ensure that the 
symlink
+# destination exists
+mkdir -p $D${libdir}/ssl/
+ln -s ${sysconfdir}/ssl/openssl.cnf $D${libdir}/ssl/openssl.cnf
+}
+
 BBCLASSEXTEND = "native nativesdk"
-- 
2.11.0


-
-- 
___
Openembedded-core mailing list
Openembedded-core@lists.openembedded.org
http://lists.openembedded.org/mailman/listinfo/openembedded-core


[OE-core] [PATCH v4 2/3] core-image: Set default sshd configuration

2017-03-06 Thread David Vincent
When selecting OpenSSH as ssh server provider instead of dropbear, also
install the correct configuration depending on whether the final rootfs
is read-only or not.

Signed-off-by: David Vincent <freesili...@gmail.com>
---
 meta/classes/core-image.bbclass | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/meta/classes/core-image.bbclass b/meta/classes/core-image.bbclass
index 8431440db4..d1f643d920 100644
--- a/meta/classes/core-image.bbclass
+++ b/meta/classes/core-image.bbclass
@@ -41,7 +41,7 @@ FEATURE_PACKAGES_tools-sdk = "packagegroup-core-sdk 
packagegroup-core-standalone
 FEATURE_PACKAGES_nfs-server = "packagegroup-core-nfs-server"
 FEATURE_PACKAGES_nfs-client = "packagegroup-core-nfs-client"
 FEATURE_PACKAGES_ssh-server-dropbear = "packagegroup-core-ssh-dropbear"
-FEATURE_PACKAGES_ssh-server-openssh = "packagegroup-core-ssh-openssh"
+FEATURE_PACKAGES_ssh-server-openssh = "packagegroup-core-ssh-openssh 
${SSHD_CONFIG}"
 FEATURE_PACKAGES_hwcodecs = "${MACHINE_HWCODECS}"
 
 
@@ -52,6 +52,7 @@ IMAGE_FEATURES_REPLACES_ssh-server-openssh = 
"ssh-server-dropbear"
 # IMAGE_FEATURES_CONFLICTS_foo = 'bar1 bar2'
 # An error exception would be raised if both image features foo and bar1(or 
bar2) are included
 
+SSHD_CONFIG ??= 
"${@bb.utils.contains('IMAGE_FEATURES','read-only-rootfs','openssh-sshd-config-readonly','openssh-sshd-config',d)}"
 MACHINE_HWCODECS ??= ""
 
 CORE_IMAGE_BASE_INSTALL = '\
-- 
2.12.0

-- 
___
Openembedded-core mailing list
Openembedded-core@lists.openembedded.org
http://lists.openembedded.org/mailman/listinfo/openembedded-core


[OE-core] [PATCH v4 1/3] openssh: Package server configuration

2017-03-06 Thread David Vincent
Split sshd configuration for read-write/read-only rootfs in two distinct
packages. Also, add a package dependency between openssh-sshd package
and a provider of sshd-config.

Signed-off-by: David Vincent <freesili...@gmail.com>
---
 meta/recipes-connectivity/openssh/openssh_7.4p1.bb | 51 ++
 1 file changed, 42 insertions(+), 9 deletions(-)

diff --git a/meta/recipes-connectivity/openssh/openssh_7.4p1.bb 
b/meta/recipes-connectivity/openssh/openssh_7.4p1.bb
index c8093d4e2b..0afc4bd948 100644
--- a/meta/recipes-connectivity/openssh/openssh_7.4p1.bb
+++ b/meta/recipes-connectivity/openssh/openssh_7.4p1.bb
@@ -91,13 +91,17 @@ do_compile_ptest() {
 }
 
 do_install_append () {
-   if [ "${@bb.utils.filter('DISTRO_FEATURES', 'pam', d)}" ]; then
+   # Create default config files
+   install -m 0644 ${D}${sysconfdir}/ssh/sshd_config 
${D}${sysconfdir}/ssh/sshd_config_default
+   rm -f ${D}${sysconfdir}/ssh/sshd_config
+
+   if [ "${@bb.utils.contains('DISTRO_FEATURES', 'pam', 'pam', '', d)}" = 
"pam" ]; then
install -D -m 0644 ${WORKDIR}/sshd ${D}${sysconfdir}/pam.d/sshd
-   sed -i -e 's:#UsePAM no:UsePAM yes:' 
${D}${sysconfdir}/ssh/sshd_config
+   sed -i -e 's:#UsePAM no:UsePAM yes:' 
${D}${sysconfdir}/ssh/sshd_config_default
fi
 
-   if [ "${@bb.utils.filter('DISTRO_FEATURES', 'x11', d)}" ]; then
-   sed -i -e 's:#X11Forwarding no:X11Forwarding yes:' 
${D}${sysconfdir}/ssh/sshd_config
+   if [ "${@bb.utils.contains('DISTRO_FEATURES', 'x11', 'x11', '', d)}" = 
"x11" ]; then
+   sed -i -e 's:#X11Forwarding no:X11Forwarding yes:' 
${D}${sysconfdir}/ssh/sshd_config_default
fi
 
install -d ${D}${sysconfdir}/init.d
@@ -110,7 +114,7 @@ do_install_append () {
 
# Create config files for read-only rootfs
install -d ${D}${sysconfdir}/ssh
-   install -m 644 ${D}${sysconfdir}/ssh/sshd_config 
${D}${sysconfdir}/ssh/sshd_config_readonly
+   install -m 644 ${D}${sysconfdir}/ssh/sshd_config_default 
${D}${sysconfdir}/ssh/sshd_config_readonly
sed -i '/HostKey/d' ${D}${sysconfdir}/ssh/sshd_config_readonly
echo "HostKey /var/run/ssh/ssh_host_rsa_key" >> 
${D}${sysconfdir}/ssh/sshd_config_readonly
echo "HostKey /var/run/ssh/ssh_host_dsa_key" >> 
${D}${sysconfdir}/ssh/sshd_config_readonly
@@ -134,30 +138,59 @@ do_install_ptest () {
 
 ALLOW_EMPTY_${PN} = "1"
 
-PACKAGES =+ "${PN}-keygen ${PN}-scp ${PN}-ssh ${PN}-sshd ${PN}-sftp ${PN}-misc 
${PN}-sftp-server"
+PACKAGES =+ "${PN}-keygen ${PN}-scp ${PN}-ssh ${PN}-sshd-config 
${PN}-sshd-config-readonly ${PN}-sshd ${PN}-sftp ${PN}-misc ${PN}-sftp-server"
 FILES_${PN}-scp = "${bindir}/scp.${BPN}"
 FILES_${PN}-ssh = "${bindir}/ssh.${BPN} ${sysconfdir}/ssh/ssh_config"
+FILES_${PN}-sshd-config = "${sysconfdir}/ssh/sshd_config_default"
+FILES_${PN}-sshd-config-readonly = "${sysconfdir}/ssh/sshd_config_readonly"
 FILES_${PN}-sshd = "${sbindir}/sshd ${sysconfdir}/init.d/sshd 
${systemd_unitdir}/system"
-FILES_${PN}-sshd += "${sysconfdir}/ssh/moduli ${sysconfdir}/ssh/sshd_config 
${sysconfdir}/ssh/sshd_config_readonly ${sysconfdir}/default/volatiles/99_sshd 
${sysconfdir}/pam.d/sshd"
+FILES_${PN}-sshd += "${sysconfdir}/ssh/moduli 
${sysconfdir}/default/volatiles/99_sshd ${sysconfdir}/pam.d/sshd"
 FILES_${PN}-sftp = "${bindir}/sftp"
 FILES_${PN}-sftp-server = "${libexecdir}/sftp-server"
 FILES_${PN}-misc = "${bindir}/ssh* ${libexecdir}/ssh*"
 FILES_${PN}-keygen = "${bindir}/ssh-keygen"
 
 RDEPENDS_${PN} += "${PN}-scp ${PN}-ssh ${PN}-sshd ${PN}-keygen"
-RDEPENDS_${PN}-sshd += "${PN}-keygen ${@bb.utils.contains('DISTRO_FEATURES', 
'pam', 'pam-plugin-keyinit pam-plugin-loginuid', '', d)}"
+RDEPENDS_${PN}-sshd += "${PN}-keygen sshd-config 
${@bb.utils.contains('DISTRO_FEATURES', 'pam', 'pam-plugin-keyinit 
pam-plugin-loginuid', '', d)}"
 RDEPENDS_${PN}-ptest += "${PN}-sftp ${PN}-misc ${PN}-sftp-server make"
 
 RPROVIDES_${PN}-ssh = "ssh"
+RPROVIDES_${PN}-sshd-config = "sshd-config"
+RPROVIDES_${PN}-sshd-config-readonly = "sshd-config"
 RPROVIDES_${PN}-sshd = "sshd"
 
 RCONFLICTS_${PN} = "dropbear"
+RCONFLICTS_${PN}-sshd-config = "${PN}-sshd-config-readonly"
+RCONFLICTS_${PN}-sshd-config-readonly = "${PN}-sshd-config"
 RCONFLICTS_${PN}-sshd = "dropbear"
 RCONFLICTS_${PN}-keygen = "ssh-keygen"
 
-CONFFILES_${PN}-sshd = "${sysconfdir}/ssh/sshd_config"
+CONFFILES_${PN}-sshd-config = "${sysconfdir}/ssh/sshd_config_default"
+CONFFILES_${PN}-sshd-config-readonly = "${sysconfdir}/ssh/sshd_config_readonly"
 CONFFILES_${PN}-ssh =

[OE-core] [PATCH v4 0/3] openssh: Package server configuration

2017-03-06 Thread David Vincent
This serie of patches provides a way to package OpenSSH sshd
configuration. This way, it should be easier to change the configuration
either in distro and/or BSP layers.

It also simplifies management of configuration for r/o rootfs.

David Vincent (3):
  openssh: Package server configuration
  core-image: Set default sshd configuration
  rootfs-postcommands: Modify ssh-related commands

 meta/classes/core-image.bbclass|  3 +-
 meta/classes/rootfs-postcommands.bbclass   | 17 +++-
 meta/recipes-connectivity/openssh/openssh_7.4p1.bb | 51 ++
 3 files changed, 50 insertions(+), 21 deletions(-)

-- 
2.12.0

-- 
___
Openembedded-core mailing list
Openembedded-core@lists.openembedded.org
http://lists.openembedded.org/mailman/listinfo/openembedded-core


[OE-core] Fwd: [PATCH] busybox: conditional inclusion of login utilities

2017-03-06 Thread David Vincent
Ping

--  Forwarded Message  --

Subject: [PATCH] busybox: conditional inclusion of login utilities
Date: jeudi 26 janvier 2017, 17:45:18 CET
From: David Vincent <freesili...@gmail.com>
To: openembedded-core@lists.openembedded.org
CC: David Vincent <freesili...@gmail.com>

If busybox is not selected as login manager, do not include the fragment
containing the corresponding utilities.

Signed-off-by: David Vincent <freesili...@gmail.com>
---
 meta/recipes-core/busybox/busybox_1.24.1.bb | 2 +-
 meta/recipes-core/busybox/busybox_git.bb| 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/meta/recipes-core/busybox/busybox_1.24.1.bb b/meta/recipes-core/
busybox/busybox_1.24.1.bb
index afb69d13e6..7d994dc10d 100644
--- a/meta/recipes-core/busybox/busybox_1.24.1.bb
+++ b/meta/recipes-core/busybox/busybox_1.24.1.bb
@@ -25,7 +25,7 @@ SRC_URI = "http://www.busybox.net/downloads/busybox-$
{PV}.tar.bz2;name=tarball \
file://run-ptest \
file://inetd.conf \
file://inetd \
-   file://login-utilities.cfg \
+   ${@["", "file://login-utilities.cfg"][(d.getVar('VIRTUAL-
RUNTIME_login_manager') == 'busybox')]} \
file://recognize_connmand.patch \
file://busybox-cross-menuconfig.patch \
file://0001-Use-CC-when-linking-instead-of-LD-and-use-CFLAGS-
and.patch \
diff --git a/meta/recipes-core/busybox/busybox_git.bb b/meta/recipes-core/
busybox/busybox_git.bb
index c2ee3e6c4b..4213ef4b1e 100644
--- a/meta/recipes-core/busybox/busybox_git.bb
+++ b/meta/recipes-core/busybox/busybox_git.bb
@@ -31,7 +31,7 @@ SRC_URI = "git://busybox.net/busybox.git \
file://run-ptest \
file://inetd.conf \
file://inetd \
-   file://login-utilities.cfg \
+   ${@["", "file://login-utilities.cfg"][(d.getVar('VIRTUAL-
RUNTIME_login_manager') == 'busybox')]} \
file://recognize_connmand.patch \
file://busybox-cross-menuconfig.patch \
file://0001-Use-CC-when-linking-instead-of-LD-and-use-CFLAGS-
and.patch \
-- 
2.11.0


-
-- 
___
Openembedded-core mailing list
Openembedded-core@lists.openembedded.org
http://lists.openembedded.org/mailman/listinfo/openembedded-core


[OE-core] [PATCH v3 3/3] rootfs-postcommands: Modify ssh-related commands

2017-02-02 Thread David Vincent
OpenSSH configuration is now a symlink which points to the desired
configuration, so the functions that modified it must be updated to
modify the target and not override it.

Signed-off-by: David Vincent <freesili...@gmail.com>
---
 meta/classes/rootfs-postcommands.bbclass | 17 ++---
 1 file changed, 6 insertions(+), 11 deletions(-)

diff --git a/meta/classes/rootfs-postcommands.bbclass 
b/meta/classes/rootfs-postcommands.bbclass
index c42829dd65..60cfac82c4 100644
--- a/meta/classes/rootfs-postcommands.bbclass
+++ b/meta/classes/rootfs-postcommands.bbclass
@@ -87,15 +87,12 @@ read_only_rootfs_hook () {
sed -i -e 
'/^[#[:space:]]*\/dev\/root/{s/defaults/ro/;s/\([[:space:]]*[[:digit:]]\)\([[:space:]]*\)[[:digit:]]$/\1\20/}'
 ${IMAGE_ROOTFS}/etc/fstab
 
# If we're using openssh and the /etc/ssh directory has no 
pre-generated keys,
-   # we should configure openssh to use the configuration file 
/etc/ssh/sshd_config_readonly
-   # and the keys under /var/run/ssh.
+   # we should configure openssh to use the keys under /var/run/ssh.
if [ -d ${IMAGE_ROOTFS}/etc/ssh ]; then
if [ -e ${IMAGE_ROOTFS}/etc/ssh/ssh_host_rsa_key ]; then
echo "SYSCONFDIR=/etc/ssh" >> 
${IMAGE_ROOTFS}/etc/default/ssh
-   echo "SSHD_OPTS=" >> ${IMAGE_ROOTFS}/etc/default/ssh
else
echo "SYSCONFDIR=/var/run/ssh" >> 
${IMAGE_ROOTFS}/etc/default/ssh
-   echo "SSHD_OPTS='-f /etc/ssh/sshd_config_readonly'" >> 
${IMAGE_ROOTFS}/etc/default/ssh
fi
fi
 
@@ -138,12 +135,10 @@ zap_empty_root_password () {
 # allow dropbear/openssh to accept root logins and logins from accounts with 
an empty password string
 #
 ssh_allow_empty_password () {
-   for config in sshd_config sshd_config_readonly; do
-   if [ -e ${IMAGE_ROOTFS}${sysconfdir}/ssh/$config ]; then
-   sed -i 
's/^[#[:space:]]*PermitRootLogin.*/PermitRootLogin yes/' 
${IMAGE_ROOTFS}${sysconfdir}/ssh/$config
-   sed -i 
's/^[#[:space:]]*PermitEmptyPasswords.*/PermitEmptyPasswords yes/' 
${IMAGE_ROOTFS}${sysconfdir}/ssh/$config
-   fi
-   done
+   if [ -e ${IMAGE_ROOTFS}${sysconfdir}/ssh/sshd_config ]; then
+   sed -i --follow-symlinks 
's/^[#[:space:]]*PermitRootLogin.*/PermitRootLogin yes/' 
${IMAGE_ROOTFS}${sysconfdir}/ssh/sshd_config
+   sed -i --follow-symlinks 
's/^[#[:space:]]*PermitEmptyPasswords.*/PermitEmptyPasswords yes/' 
${IMAGE_ROOTFS}${sysconfdir}/ssh/sshd_config
+   fi
 
if [ -e ${IMAGE_ROOTFS}${sbindir}/dropbear ] ; then
if grep -q DROPBEAR_EXTRA_ARGS 
${IMAGE_ROOTFS}${sysconfdir}/default/dropbear 2>/dev/null ; then
@@ -162,7 +157,7 @@ ssh_allow_empty_password () {
 
 ssh_disable_dns_lookup () {
if [ -e ${IMAGE_ROOTFS}${sysconfdir}/ssh/sshd_config ]; then
-   sed -i -e 's:#UseDNS yes:UseDNS no:' 
${IMAGE_ROOTFS}${sysconfdir}/ssh/sshd_config
+   sed -i --follow-symlinks -e 's:#UseDNS yes:UseDNS no:' 
${IMAGE_ROOTFS}${sysconfdir}/ssh/sshd_config
fi
 }
 
-- 
2.11.0

-- 
___
Openembedded-core mailing list
Openembedded-core@lists.openembedded.org
http://lists.openembedded.org/mailman/listinfo/openembedded-core


[OE-core] [PATCH v3 1/3] openssh: Package server configuration

2017-02-02 Thread David Vincent
Split sshd configuration for read-write/read-only rootfs in two distinct
packages. Also, add a package dependency between openssh-sshd package
and a provider of sshd-config.

Signed-off-by: David Vincent <freesili...@gmail.com>
---
 meta/recipes-connectivity/openssh/openssh_7.4p1.bb | 47 ++
 1 file changed, 40 insertions(+), 7 deletions(-)

diff --git a/meta/recipes-connectivity/openssh/openssh_7.4p1.bb 
b/meta/recipes-connectivity/openssh/openssh_7.4p1.bb
index 3b3d667a68..0afc4bd948 100644
--- a/meta/recipes-connectivity/openssh/openssh_7.4p1.bb
+++ b/meta/recipes-connectivity/openssh/openssh_7.4p1.bb
@@ -91,13 +91,17 @@ do_compile_ptest() {
 }
 
 do_install_append () {
+   # Create default config files
+   install -m 0644 ${D}${sysconfdir}/ssh/sshd_config 
${D}${sysconfdir}/ssh/sshd_config_default
+   rm -f ${D}${sysconfdir}/ssh/sshd_config
+
if [ "${@bb.utils.contains('DISTRO_FEATURES', 'pam', 'pam', '', d)}" = 
"pam" ]; then
install -D -m 0644 ${WORKDIR}/sshd ${D}${sysconfdir}/pam.d/sshd
-   sed -i -e 's:#UsePAM no:UsePAM yes:' 
${D}${sysconfdir}/ssh/sshd_config
+   sed -i -e 's:#UsePAM no:UsePAM yes:' 
${D}${sysconfdir}/ssh/sshd_config_default
fi
 
if [ "${@bb.utils.contains('DISTRO_FEATURES', 'x11', 'x11', '', d)}" = 
"x11" ]; then
-   sed -i -e 's:#X11Forwarding no:X11Forwarding yes:' 
${D}${sysconfdir}/ssh/sshd_config
+   sed -i -e 's:#X11Forwarding no:X11Forwarding yes:' 
${D}${sysconfdir}/ssh/sshd_config_default
fi
 
install -d ${D}${sysconfdir}/init.d
@@ -110,7 +114,7 @@ do_install_append () {
 
# Create config files for read-only rootfs
install -d ${D}${sysconfdir}/ssh
-   install -m 644 ${D}${sysconfdir}/ssh/sshd_config 
${D}${sysconfdir}/ssh/sshd_config_readonly
+   install -m 644 ${D}${sysconfdir}/ssh/sshd_config_default 
${D}${sysconfdir}/ssh/sshd_config_readonly
sed -i '/HostKey/d' ${D}${sysconfdir}/ssh/sshd_config_readonly
echo "HostKey /var/run/ssh/ssh_host_rsa_key" >> 
${D}${sysconfdir}/ssh/sshd_config_readonly
echo "HostKey /var/run/ssh/ssh_host_dsa_key" >> 
${D}${sysconfdir}/ssh/sshd_config_readonly
@@ -134,30 +138,59 @@ do_install_ptest () {
 
 ALLOW_EMPTY_${PN} = "1"
 
-PACKAGES =+ "${PN}-keygen ${PN}-scp ${PN}-ssh ${PN}-sshd ${PN}-sftp ${PN}-misc 
${PN}-sftp-server"
+PACKAGES =+ "${PN}-keygen ${PN}-scp ${PN}-ssh ${PN}-sshd-config 
${PN}-sshd-config-readonly ${PN}-sshd ${PN}-sftp ${PN}-misc ${PN}-sftp-server"
 FILES_${PN}-scp = "${bindir}/scp.${BPN}"
 FILES_${PN}-ssh = "${bindir}/ssh.${BPN} ${sysconfdir}/ssh/ssh_config"
+FILES_${PN}-sshd-config = "${sysconfdir}/ssh/sshd_config_default"
+FILES_${PN}-sshd-config-readonly = "${sysconfdir}/ssh/sshd_config_readonly"
 FILES_${PN}-sshd = "${sbindir}/sshd ${sysconfdir}/init.d/sshd 
${systemd_unitdir}/system"
-FILES_${PN}-sshd += "${sysconfdir}/ssh/moduli ${sysconfdir}/ssh/sshd_config 
${sysconfdir}/ssh/sshd_config_readonly ${sysconfdir}/default/volatiles/99_sshd 
${sysconfdir}/pam.d/sshd"
+FILES_${PN}-sshd += "${sysconfdir}/ssh/moduli 
${sysconfdir}/default/volatiles/99_sshd ${sysconfdir}/pam.d/sshd"
 FILES_${PN}-sftp = "${bindir}/sftp"
 FILES_${PN}-sftp-server = "${libexecdir}/sftp-server"
 FILES_${PN}-misc = "${bindir}/ssh* ${libexecdir}/ssh*"
 FILES_${PN}-keygen = "${bindir}/ssh-keygen"
 
 RDEPENDS_${PN} += "${PN}-scp ${PN}-ssh ${PN}-sshd ${PN}-keygen"
-RDEPENDS_${PN}-sshd += "${PN}-keygen ${@bb.utils.contains('DISTRO_FEATURES', 
'pam', 'pam-plugin-keyinit pam-plugin-loginuid', '', d)}"
+RDEPENDS_${PN}-sshd += "${PN}-keygen sshd-config 
${@bb.utils.contains('DISTRO_FEATURES', 'pam', 'pam-plugin-keyinit 
pam-plugin-loginuid', '', d)}"
 RDEPENDS_${PN}-ptest += "${PN}-sftp ${PN}-misc ${PN}-sftp-server make"
 
 RPROVIDES_${PN}-ssh = "ssh"
+RPROVIDES_${PN}-sshd-config = "sshd-config"
+RPROVIDES_${PN}-sshd-config-readonly = "sshd-config"
 RPROVIDES_${PN}-sshd = "sshd"
 
 RCONFLICTS_${PN} = "dropbear"
+RCONFLICTS_${PN}-sshd-config = "${PN}-sshd-config-readonly"
+RCONFLICTS_${PN}-sshd-config-readonly = "${PN}-sshd-config"
 RCONFLICTS_${PN}-sshd = "dropbear"
 RCONFLICTS_${PN}-keygen = "ssh-keygen"
 
-CONFFILES_${PN}-sshd = "${sysconfdir}/ssh/sshd_config"
+CONFFILES_${PN}-sshd-config = "${sysconfdir}/ssh/sshd_config_default"
+CONFFILES_${PN}-sshd-config-readonly = "${sysconfdir}/ssh/sshd_config_readonly"
 CONFFILES_${PN}-ssh = "${sysconfdir}/ssh/ssh_config"
 
+pkg_postinst_${PN}-sshd-config () {
+#!/bin/sh
+if [ -e $D${sysconfdir}/ssh/sshd_config ]; then
+rm $D${sysconfdir}/

[OE-core] [PATCH v3 2/3] core-image: Set default sshd configuration

2017-02-02 Thread David Vincent
When selecting OpenSSH as ssh server provider instead of dropbear, also
install the correct configuration depending on whether the final rootfs
is read-only or not.

Signed-off-by: David Vincent <freesili...@gmail.com>
---
 meta/classes/core-image.bbclass | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/meta/classes/core-image.bbclass b/meta/classes/core-image.bbclass
index 8431440db4..d1f643d920 100644
--- a/meta/classes/core-image.bbclass
+++ b/meta/classes/core-image.bbclass
@@ -41,7 +41,7 @@ FEATURE_PACKAGES_tools-sdk = "packagegroup-core-sdk 
packagegroup-core-standalone
 FEATURE_PACKAGES_nfs-server = "packagegroup-core-nfs-server"
 FEATURE_PACKAGES_nfs-client = "packagegroup-core-nfs-client"
 FEATURE_PACKAGES_ssh-server-dropbear = "packagegroup-core-ssh-dropbear"
-FEATURE_PACKAGES_ssh-server-openssh = "packagegroup-core-ssh-openssh"
+FEATURE_PACKAGES_ssh-server-openssh = "packagegroup-core-ssh-openssh 
${SSHD_CONFIG}"
 FEATURE_PACKAGES_hwcodecs = "${MACHINE_HWCODECS}"
 
 
@@ -52,6 +52,7 @@ IMAGE_FEATURES_REPLACES_ssh-server-openssh = 
"ssh-server-dropbear"
 # IMAGE_FEATURES_CONFLICTS_foo = 'bar1 bar2'
 # An error exception would be raised if both image features foo and bar1(or 
bar2) are included
 
+SSHD_CONFIG ??= 
"${@bb.utils.contains('IMAGE_FEATURES','read-only-rootfs','openssh-sshd-config-readonly','openssh-sshd-config',d)}"
 MACHINE_HWCODECS ??= ""
 
 CORE_IMAGE_BASE_INSTALL = '\
-- 
2.11.0

-- 
___
Openembedded-core mailing list
Openembedded-core@lists.openembedded.org
http://lists.openembedded.org/mailman/listinfo/openembedded-core


[OE-core] [PATCH v3 0/3] openssh: Make sshd-config a package

2017-02-02 Thread David Vincent
This series of patch introduces a new way of modifying OpenSSH sshd
configuration. Instead of modifying the files and launching the server with
custom options, a package which RPROVIDES sshd-config must be installed.

The package to use is selected using a new variable called SSHD_CONFIG which is
used exclusively when selecting ssh-server-openssh in IMAGE_FEATURES.

Changes since v1:
  Remove documentation

Changes since v2:
  Restore SYSCONFDIR in /etc/default/ssh, otherwise keys are not correctly
  generated

David Vincent (3):
  openssh: Package server configuration
  core-image: Set default sshd configuration
  rootfs-postcommands: Modify ssh-related commands

 meta/classes/core-image.bbclass|  3 +-
 meta/classes/rootfs-postcommands.bbclass   | 17 +++-
 meta/recipes-connectivity/openssh/openssh_7.4p1.bb | 47 ++
 3 files changed, 48 insertions(+), 19 deletions(-)

-- 
2.11.0

-- 
___
Openembedded-core mailing list
Openembedded-core@lists.openembedded.org
http://lists.openembedded.org/mailman/listinfo/openembedded-core


Re: [OE-core] [PATCH] busybox: conditional inclusion of login utilities

2017-01-27 Thread David Vincent
On jeudi 26 janvier 2017 09:55:17 CET Christopher Larson wrote:
> Question, why not use ${PN} here?

It was done the same way in the recipe for other fragments so I made it look 
like the existing declarations.

David
-- 
___
Openembedded-core mailing list
Openembedded-core@lists.openembedded.org
http://lists.openembedded.org/mailman/listinfo/openembedded-core


[OE-core] [PATCH] busybox: conditional inclusion of login utilities

2017-01-26 Thread David Vincent
If busybox is not selected as login manager, do not include the fragment
containing the corresponding utilities.

Signed-off-by: David Vincent <freesili...@gmail.com>
---
 meta/recipes-core/busybox/busybox_1.24.1.bb | 2 +-
 meta/recipes-core/busybox/busybox_git.bb| 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/meta/recipes-core/busybox/busybox_1.24.1.bb 
b/meta/recipes-core/busybox/busybox_1.24.1.bb
index afb69d13e6..7d994dc10d 100644
--- a/meta/recipes-core/busybox/busybox_1.24.1.bb
+++ b/meta/recipes-core/busybox/busybox_1.24.1.bb
@@ -25,7 +25,7 @@ SRC_URI = 
"http://www.busybox.net/downloads/busybox-${PV}.tar.bz2;name=tarball \
file://run-ptest \
file://inetd.conf \
file://inetd \
-   file://login-utilities.cfg \
+   ${@["", 
"file://login-utilities.cfg"][(d.getVar('VIRTUAL-RUNTIME_login_manager') == 
'busybox')]} \
file://recognize_connmand.patch \
file://busybox-cross-menuconfig.patch \

file://0001-Use-CC-when-linking-instead-of-LD-and-use-CFLAGS-and.patch \
diff --git a/meta/recipes-core/busybox/busybox_git.bb 
b/meta/recipes-core/busybox/busybox_git.bb
index c2ee3e6c4b..4213ef4b1e 100644
--- a/meta/recipes-core/busybox/busybox_git.bb
+++ b/meta/recipes-core/busybox/busybox_git.bb
@@ -31,7 +31,7 @@ SRC_URI = "git://busybox.net/busybox.git \
file://run-ptest \
file://inetd.conf \
file://inetd \
-   file://login-utilities.cfg \
+   ${@["", 
"file://login-utilities.cfg"][(d.getVar('VIRTUAL-RUNTIME_login_manager') == 
'busybox')]} \
file://recognize_connmand.patch \
file://busybox-cross-menuconfig.patch \

file://0001-Use-CC-when-linking-instead-of-LD-and-use-CFLAGS-and.patch \
-- 
2.11.0

-- 
___
Openembedded-core mailing list
Openembedded-core@lists.openembedded.org
http://lists.openembedded.org/mailman/listinfo/openembedded-core


[OE-core] [PATCH] initscripts: Populate volatile from existing file

2017-01-25 Thread David Vincent
In some cases, it may be useful to populate a volatile file from an
existing one, e.g. a file in a read-only rootfs that may be edited in a
read-write destination.

To provide this behavior, creation of volatile files has been updated to
copy a file which has been given in the  field. If set to
none, the current behavior is preserved.

Signed-off-by: David Vincent <freesili...@gmail.com>
---
 .../initscripts/initscripts-1.0/populate-volatile.sh | 16 ++--
 1 file changed, 14 insertions(+), 2 deletions(-)

diff --git a/meta/recipes-core/initscripts/initscripts-1.0/populate-volatile.sh 
b/meta/recipes-core/initscripts/initscripts-1.0/populate-volatile.sh
index 22a71ecaae..35316ec2ba 100755
--- a/meta/recipes-core/initscripts/initscripts-1.0/populate-volatile.sh
+++ b/meta/recipes-core/initscripts/initscripts-1.0/populate-volatile.sh
@@ -25,8 +25,18 @@ COREDEF="00_core"
 [ "${VERBOSE}" != "no" ] && echo "Populating volatile Filesystems."
 
 create_file() {
+   EXEC=""
+   [ -z "$2" ] && {
+   EXEC="
+   touch \"$1\";
+   "
+   } || {
+   EXEC="
+   cp \"$2\" \"$1\";
+   "
+   }
EXEC="
-   touch \"$1\";
+   ${EXEC}
chown ${TUSER}.${TGROUP} $1 || echo \"Failed to set owner -${TUSER}- 
for -$1-.\" >/dev/tty0 2>&1;
chmod ${TMODE} $1 || echo \"Failed to set mode -${TMODE}- for -$1-.\" 
>/dev/tty0 2>&1 "
 
@@ -187,7 +197,9 @@ apply_cfgfile() {
 
case "${TTYPE}" in
"f")  [ "${VERBOSE}" != "no" ] && echo "Creating file 
-${TNAME}-."
-   create_file "${TNAME}"
+   TSOURCE="$TLTARGET"
+   [ "${TSOURCE}" = "none" ] && TSOURCE=""
+   create_file "${TNAME}" "${TSOURCE}" &
;;
"d")  [ "${VERBOSE}" != "no" ] && echo "Creating 
directory -${TNAME}-."
mk_dir "${TNAME}"
-- 
2.11.0

-- 
___
Openembedded-core mailing list
Openembedded-core@lists.openembedded.org
http://lists.openembedded.org/mailman/listinfo/openembedded-core


Re: [OE-core] [PATCH v2 0/3] openssh: Make sshd-config a package

2017-01-24 Thread David Vincent
On mardi 24 janvier 2017 11:07:18 CET Khem Raj wrote:
> How does this work with dropbear. Since we can use dropbear as a ssh
> server alternative.
Dropbear support has not been modified. SSHD_CONFIG has only been added to 
FEATURE_PACKAGES_ssh-server-openssh variable and only applies to OpenSSH (I 
think dropbear has no config file so I don't see the point of applying this).

On a side note, I see that this serie of patches is still marked as 'failure' 
on patchwork, is that a problem or should I resubmit it as new (I may have 
made some mistakes resubmitting it without marking it v2)

David
-- 
___
Openembedded-core mailing list
Openembedded-core@lists.openembedded.org
http://lists.openembedded.org/mailman/listinfo/openembedded-core


[OE-core] [PATCH 1/3] openssh: Package server configuration

2017-01-24 Thread David Vincent
Split sshd configuration for read-write/read-only rootfs in two distinct
packages. Also, add a package dependency between openssh-sshd package
and a provider of sshd-config.

Signed-off-by: David Vincent <freesili...@gmail.com>
---
 meta/recipes-connectivity/openssh/openssh_7.3p1.bb | 47 ++
 1 file changed, 40 insertions(+), 7 deletions(-)

diff --git a/meta/recipes-connectivity/openssh/openssh_7.3p1.bb 
b/meta/recipes-connectivity/openssh/openssh_7.3p1.bb
index 94eb0ed208..c02bb7d450 100644
--- a/meta/recipes-connectivity/openssh/openssh_7.3p1.bb
+++ b/meta/recipes-connectivity/openssh/openssh_7.3p1.bb
@@ -92,13 +92,17 @@ do_compile_ptest() {
 }
 
 do_install_append () {
+   # Create default config files
+   install -m 0644 ${D}${sysconfdir}/ssh/sshd_config 
${D}${sysconfdir}/ssh/sshd_config_default
+   rm -f ${D}${sysconfdir}/ssh/sshd_config
+
if [ "${@bb.utils.contains('DISTRO_FEATURES', 'pam', 'pam', '', d)}" = 
"pam" ]; then
install -D -m 0644 ${WORKDIR}/sshd ${D}${sysconfdir}/pam.d/sshd
-   sed -i -e 's:#UsePAM no:UsePAM yes:' 
${D}${sysconfdir}/ssh/sshd_config
+   sed -i -e 's:#UsePAM no:UsePAM yes:' 
${D}${sysconfdir}/ssh/sshd_config_default
fi
 
if [ "${@bb.utils.contains('DISTRO_FEATURES', 'x11', 'x11', '', d)}" = 
"x11" ]; then
-   sed -i -e 's:#X11Forwarding no:X11Forwarding yes:' 
${D}${sysconfdir}/ssh/sshd_config
+   sed -i -e 's:#X11Forwarding no:X11Forwarding yes:' 
${D}${sysconfdir}/ssh/sshd_config_default
fi
 
install -d ${D}${sysconfdir}/init.d
@@ -111,7 +115,7 @@ do_install_append () {
 
# Create config files for read-only rootfs
install -d ${D}${sysconfdir}/ssh
-   install -m 644 ${D}${sysconfdir}/ssh/sshd_config 
${D}${sysconfdir}/ssh/sshd_config_readonly
+   install -m 644 ${D}${sysconfdir}/ssh/sshd_config_default 
${D}${sysconfdir}/ssh/sshd_config_readonly
sed -i '/HostKey/d' ${D}${sysconfdir}/ssh/sshd_config_readonly
echo "HostKey /var/run/ssh/ssh_host_rsa_key" >> 
${D}${sysconfdir}/ssh/sshd_config_readonly
echo "HostKey /var/run/ssh/ssh_host_dsa_key" >> 
${D}${sysconfdir}/ssh/sshd_config_readonly
@@ -135,30 +139,59 @@ do_install_ptest () {
 
 ALLOW_EMPTY_${PN} = "1"
 
-PACKAGES =+ "${PN}-keygen ${PN}-scp ${PN}-ssh ${PN}-sshd ${PN}-sftp ${PN}-misc 
${PN}-sftp-server"
+PACKAGES =+ "${PN}-keygen ${PN}-scp ${PN}-ssh ${PN}-sshd-config 
${PN}-sshd-config-readonly ${PN}-sshd ${PN}-sftp ${PN}-misc ${PN}-sftp-server"
 FILES_${PN}-scp = "${bindir}/scp.${BPN}"
 FILES_${PN}-ssh = "${bindir}/ssh.${BPN} ${sysconfdir}/ssh/ssh_config"
+FILES_${PN}-sshd-config = "${sysconfdir}/ssh/sshd_config_default"
+FILES_${PN}-sshd-config-readonly = "${sysconfdir}/ssh/sshd_config_readonly"
 FILES_${PN}-sshd = "${sbindir}/sshd ${sysconfdir}/init.d/sshd 
${systemd_unitdir}/system"
-FILES_${PN}-sshd += "${sysconfdir}/ssh/moduli ${sysconfdir}/ssh/sshd_config 
${sysconfdir}/ssh/sshd_config_readonly ${sysconfdir}/default/volatiles/99_sshd 
${sysconfdir}/pam.d/sshd"
+FILES_${PN}-sshd += "${sysconfdir}/ssh/moduli 
${sysconfdir}/default/volatiles/99_sshd ${sysconfdir}/pam.d/sshd"
 FILES_${PN}-sftp = "${bindir}/sftp"
 FILES_${PN}-sftp-server = "${libexecdir}/sftp-server"
 FILES_${PN}-misc = "${bindir}/ssh* ${libexecdir}/ssh*"
 FILES_${PN}-keygen = "${bindir}/ssh-keygen"
 
 RDEPENDS_${PN} += "${PN}-scp ${PN}-ssh ${PN}-sshd ${PN}-keygen"
-RDEPENDS_${PN}-sshd += "${PN}-keygen ${@bb.utils.contains('DISTRO_FEATURES', 
'pam', 'pam-plugin-keyinit pam-plugin-loginuid', '', d)}"
+RDEPENDS_${PN}-sshd += "${PN}-keygen sshd-config 
${@bb.utils.contains('DISTRO_FEATURES', 'pam', 'pam-plugin-keyinit 
pam-plugin-loginuid', '', d)}"
 RDEPENDS_${PN}-ptest += "${PN}-sftp ${PN}-misc ${PN}-sftp-server make"
 
 RPROVIDES_${PN}-ssh = "ssh"
+RPROVIDES_${PN}-sshd-config = "sshd-config"
+RPROVIDES_${PN}-sshd-config-readonly = "sshd-config"
 RPROVIDES_${PN}-sshd = "sshd"
 
 RCONFLICTS_${PN} = "dropbear"
+RCONFLICTS_${PN}-sshd-config = "${PN}-sshd-config-readonly"
+RCONFLICTS_${PN}-sshd-config-readonly = "${PN}-sshd-config"
 RCONFLICTS_${PN}-sshd = "dropbear"
 RCONFLICTS_${PN}-keygen = "ssh-keygen"
 
-CONFFILES_${PN}-sshd = "${sysconfdir}/ssh/sshd_config"
+CONFFILES_${PN}-sshd-config = "${sysconfdir}/ssh/sshd_config_default"
+CONFFILES_${PN}-sshd-config-readonly = "${sysconfdir}/ssh/sshd_config_readonly"
 CONFFILES_${PN}-ssh = "${sysconfdir}/ssh/ssh_config"
 
+pkg_postinst_${PN}-sshd-config () {
+#!/bin/sh
+if [ -e $D${sysconfdir}/ssh/sshd_config ]; then
+rm $D${sysconfdir}/

[OE-core] [PATCH 3/3] rootfs-postcommands: Modify ssh-related commands

2017-01-24 Thread David Vincent
OpenSSH configuration is now a symlink which points to the desired
configuration, so the functions that modified it must be updated to
modify the target and not override it.

Signed-off-by: David Vincent <freesili...@gmail.com>
---
 meta/classes/rootfs-postcommands.bbclass | 28 +++-
 1 file changed, 7 insertions(+), 21 deletions(-)

diff --git a/meta/classes/rootfs-postcommands.bbclass 
b/meta/classes/rootfs-postcommands.bbclass
index c8f18c6702..2d862b0b2e 100644
--- a/meta/classes/rootfs-postcommands.bbclass
+++ b/meta/classes/rootfs-postcommands.bbclass
@@ -86,20 +86,8 @@ read_only_rootfs_hook () {
# Tweak the mount option and fs_passno for rootfs in fstab
sed -i -e 
'/^[#[:space:]]*\/dev\/root/{s/defaults/ro/;s/\([[:space:]]*[[:digit:]]\)\([[:space:]]*\)[[:digit:]]$/\1\20/}'
 ${IMAGE_ROOTFS}/etc/fstab
 
-   # If we're using openssh and the /etc/ssh directory has no 
pre-generated keys,
-   # we should configure openssh to use the configuration file 
/etc/ssh/sshd_config_readonly
-   # and the keys under /var/run/ssh.
-   if [ -d ${IMAGE_ROOTFS}/etc/ssh ]; then
-   if [ -e ${IMAGE_ROOTFS}/etc/ssh/ssh_host_rsa_key ]; then
-   echo "SYSCONFDIR=/etc/ssh" >> 
${IMAGE_ROOTFS}/etc/default/ssh
-   echo "SSHD_OPTS=" >> ${IMAGE_ROOTFS}/etc/default/ssh
-   else
-   echo "SYSCONFDIR=/var/run/ssh" >> 
${IMAGE_ROOTFS}/etc/default/ssh
-   echo "SSHD_OPTS='-f /etc/ssh/sshd_config_readonly'" >> 
${IMAGE_ROOTFS}/etc/default/ssh
-   fi
-   fi
-
-   # Also tweak the key location for dropbear in the same way.
+   # If we're using dropbear and the /etc/dropbear directory has no 
pre-generated keys,
+   # we should configure dropbear to use the keys under /var/lib/dropbear.
if [ -d ${IMAGE_ROOTFS}/etc/dropbear ]; then
if [ -e ${IMAGE_ROOTFS}/etc/dropbear/dropbear_rsa_host_key ]; 
then
echo "DROPBEAR_RSAKEY_DIR=/etc/dropbear" >> 
${IMAGE_ROOTFS}/etc/default/dropbear
@@ -138,12 +126,10 @@ zap_empty_root_password () {
 # allow dropbear/openssh to accept root logins and logins from accounts with 
an empty password string
 #
 ssh_allow_empty_password () {
-   for config in sshd_config sshd_config_readonly; do
-   if [ -e ${IMAGE_ROOTFS}${sysconfdir}/ssh/$config ]; then
-   sed -i 
's/^[#[:space:]]*PermitRootLogin.*/PermitRootLogin yes/' 
${IMAGE_ROOTFS}${sysconfdir}/ssh/$config
-   sed -i 
's/^[#[:space:]]*PermitEmptyPasswords.*/PermitEmptyPasswords yes/' 
${IMAGE_ROOTFS}${sysconfdir}/ssh/$config
-   fi
-   done
+   if [ -e ${IMAGE_ROOTFS}${sysconfdir}/ssh/sshd_config ]; then
+   sed -i --follow-symlinks 
's/^[#[:space:]]*PermitRootLogin.*/PermitRootLogin yes/' 
${IMAGE_ROOTFS}${sysconfdir}/ssh/sshd_config
+   sed -i --follow-symlinks 
's/^[#[:space:]]*PermitEmptyPasswords.*/PermitEmptyPasswords yes/' 
${IMAGE_ROOTFS}${sysconfdir}/ssh/sshd_config
+   fi
 
if [ -e ${IMAGE_ROOTFS}${sbindir}/dropbear ] ; then
if grep -q DROPBEAR_EXTRA_ARGS 
${IMAGE_ROOTFS}${sysconfdir}/default/dropbear 2>/dev/null ; then
@@ -162,7 +148,7 @@ ssh_allow_empty_password () {
 
 ssh_disable_dns_lookup () {
if [ -e ${IMAGE_ROOTFS}${sysconfdir}/ssh/sshd_config ]; then
-   sed -i -e 's:#UseDNS yes:UseDNS no:' 
${IMAGE_ROOTFS}${sysconfdir}/ssh/sshd_config
+   sed -i --follow-symlinks -e 's:#UseDNS yes:UseDNS no:' 
${IMAGE_ROOTFS}${sysconfdir}/ssh/sshd_config
fi
 }
 
-- 
2.11.0

-- 
___
Openembedded-core mailing list
Openembedded-core@lists.openembedded.org
http://lists.openembedded.org/mailman/listinfo/openembedded-core


[OE-core] [PATCH 2/3] core-image: Set default sshd configuration

2017-01-24 Thread David Vincent
When selecting OpenSSH as ssh server provider instead of dropbear, also
install the correct configuration depending on whether the final rootfs
is read-only or not.

Signed-off-by: David Vincent <freesili...@gmail.com>
---
 meta/classes/core-image.bbclass | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/meta/classes/core-image.bbclass b/meta/classes/core-image.bbclass
index 8431440db4..d1f643d920 100644
--- a/meta/classes/core-image.bbclass
+++ b/meta/classes/core-image.bbclass
@@ -41,7 +41,7 @@ FEATURE_PACKAGES_tools-sdk = "packagegroup-core-sdk 
packagegroup-core-standalone
 FEATURE_PACKAGES_nfs-server = "packagegroup-core-nfs-server"
 FEATURE_PACKAGES_nfs-client = "packagegroup-core-nfs-client"
 FEATURE_PACKAGES_ssh-server-dropbear = "packagegroup-core-ssh-dropbear"
-FEATURE_PACKAGES_ssh-server-openssh = "packagegroup-core-ssh-openssh"
+FEATURE_PACKAGES_ssh-server-openssh = "packagegroup-core-ssh-openssh 
${SSHD_CONFIG}"
 FEATURE_PACKAGES_hwcodecs = "${MACHINE_HWCODECS}"
 
 
@@ -52,6 +52,7 @@ IMAGE_FEATURES_REPLACES_ssh-server-openssh = 
"ssh-server-dropbear"
 # IMAGE_FEATURES_CONFLICTS_foo = 'bar1 bar2'
 # An error exception would be raised if both image features foo and bar1(or 
bar2) are included
 
+SSHD_CONFIG ??= 
"${@bb.utils.contains('IMAGE_FEATURES','read-only-rootfs','openssh-sshd-config-readonly','openssh-sshd-config',d)}"
 MACHINE_HWCODECS ??= ""
 
 CORE_IMAGE_BASE_INSTALL = '\
-- 
2.11.0

-- 
___
Openembedded-core mailing list
Openembedded-core@lists.openembedded.org
http://lists.openembedded.org/mailman/listinfo/openembedded-core


[OE-core] [PATCH v2 0/3] openssh: Make sshd-config a package

2017-01-24 Thread David Vincent
This series of patch introduces a new way of modifying OpenSSH sshd
configuration. Instead of modifying the files and launching the server with
custom options, a package which RPROVIDES sshd-config must be installed.

The package to use is selected using a new variable called SSHD_CONFIG which is
used exclusively when selecting ssh-server-openssh in IMAGE_FEATURES.

Changes since v1:
  Remove documentation

David Vincent (3):
  openssh: Package server configuration
  core-image: Set default sshd configuration
  rootfs-postcommands: Modify ssh-related commands

 meta/classes/core-image.bbclass|  3 +-
 meta/classes/rootfs-postcommands.bbclass   | 28 -
 meta/recipes-connectivity/openssh/openssh_7.3p1.bb | 47 ++
 3 files changed, 49 insertions(+), 29 deletions(-)

-- 
2.11.0

-- 
___
Openembedded-core mailing list
Openembedded-core@lists.openembedded.org
http://lists.openembedded.org/mailman/listinfo/openembedded-core


[OE-core] [PATCH 3/3] rootfs-postcommands: Modify ssh-related commands

2017-01-24 Thread David Vincent
OpenSSH configuration is now a symlink which points to the desired
configuration, so the functions that modified it must be updated to
modify the target and not override it.

Signed-off-by: David Vincent <freesili...@gmail.com>
---
 meta/classes/rootfs-postcommands.bbclass | 28 +++-
 1 file changed, 7 insertions(+), 21 deletions(-)

diff --git a/meta/classes/rootfs-postcommands.bbclass 
b/meta/classes/rootfs-postcommands.bbclass
index c8f18c6702..2d862b0b2e 100644
--- a/meta/classes/rootfs-postcommands.bbclass
+++ b/meta/classes/rootfs-postcommands.bbclass
@@ -86,20 +86,8 @@ read_only_rootfs_hook () {
# Tweak the mount option and fs_passno for rootfs in fstab
sed -i -e 
'/^[#[:space:]]*\/dev\/root/{s/defaults/ro/;s/\([[:space:]]*[[:digit:]]\)\([[:space:]]*\)[[:digit:]]$/\1\20/}'
 ${IMAGE_ROOTFS}/etc/fstab
 
-   # If we're using openssh and the /etc/ssh directory has no 
pre-generated keys,
-   # we should configure openssh to use the configuration file 
/etc/ssh/sshd_config_readonly
-   # and the keys under /var/run/ssh.
-   if [ -d ${IMAGE_ROOTFS}/etc/ssh ]; then
-   if [ -e ${IMAGE_ROOTFS}/etc/ssh/ssh_host_rsa_key ]; then
-   echo "SYSCONFDIR=/etc/ssh" >> 
${IMAGE_ROOTFS}/etc/default/ssh
-   echo "SSHD_OPTS=" >> ${IMAGE_ROOTFS}/etc/default/ssh
-   else
-   echo "SYSCONFDIR=/var/run/ssh" >> 
${IMAGE_ROOTFS}/etc/default/ssh
-   echo "SSHD_OPTS='-f /etc/ssh/sshd_config_readonly'" >> 
${IMAGE_ROOTFS}/etc/default/ssh
-   fi
-   fi
-
-   # Also tweak the key location for dropbear in the same way.
+   # If we're using dropbear and the /etc/dropbear directory has no 
pre-generated keys,
+   # we should configure dropbear to use the keys under /var/lib/dropbear.
if [ -d ${IMAGE_ROOTFS}/etc/dropbear ]; then
if [ -e ${IMAGE_ROOTFS}/etc/dropbear/dropbear_rsa_host_key ]; 
then
echo "DROPBEAR_RSAKEY_DIR=/etc/dropbear" >> 
${IMAGE_ROOTFS}/etc/default/dropbear
@@ -138,12 +126,10 @@ zap_empty_root_password () {
 # allow dropbear/openssh to accept root logins and logins from accounts with 
an empty password string
 #
 ssh_allow_empty_password () {
-   for config in sshd_config sshd_config_readonly; do
-   if [ -e ${IMAGE_ROOTFS}${sysconfdir}/ssh/$config ]; then
-   sed -i 
's/^[#[:space:]]*PermitRootLogin.*/PermitRootLogin yes/' 
${IMAGE_ROOTFS}${sysconfdir}/ssh/$config
-   sed -i 
's/^[#[:space:]]*PermitEmptyPasswords.*/PermitEmptyPasswords yes/' 
${IMAGE_ROOTFS}${sysconfdir}/ssh/$config
-   fi
-   done
+   if [ -e ${IMAGE_ROOTFS}${sysconfdir}/ssh/sshd_config ]; then
+   sed -i --follow-symlinks 
's/^[#[:space:]]*PermitRootLogin.*/PermitRootLogin yes/' 
${IMAGE_ROOTFS}${sysconfdir}/ssh/sshd_config
+   sed -i --follow-symlinks 
's/^[#[:space:]]*PermitEmptyPasswords.*/PermitEmptyPasswords yes/' 
${IMAGE_ROOTFS}${sysconfdir}/ssh/sshd_config
+   fi
 
if [ -e ${IMAGE_ROOTFS}${sbindir}/dropbear ] ; then
if grep -q DROPBEAR_EXTRA_ARGS 
${IMAGE_ROOTFS}${sysconfdir}/default/dropbear 2>/dev/null ; then
@@ -162,7 +148,7 @@ ssh_allow_empty_password () {
 
 ssh_disable_dns_lookup () {
if [ -e ${IMAGE_ROOTFS}${sysconfdir}/ssh/sshd_config ]; then
-   sed -i -e 's:#UseDNS yes:UseDNS no:' 
${IMAGE_ROOTFS}${sysconfdir}/ssh/sshd_config
+   sed -i --follow-symlinks -e 's:#UseDNS yes:UseDNS no:' 
${IMAGE_ROOTFS}${sysconfdir}/ssh/sshd_config
fi
 }
 
-- 
2.11.0

-- 
___
Openembedded-core mailing list
Openembedded-core@lists.openembedded.org
http://lists.openembedded.org/mailman/listinfo/openembedded-core


[OE-core] [PATCH 1/3] openssh: Package server configuration

2017-01-24 Thread David Vincent
Split sshd configuration for read-write/read-only rootfs in two distinct
packages. Also, add a package dependency between openssh-sshd package
and a provider of sshd-config.

Signed-off-by: David Vincent <freesili...@gmail.com>
---
 meta/recipes-connectivity/openssh/openssh_7.3p1.bb | 47 ++
 1 file changed, 40 insertions(+), 7 deletions(-)

diff --git a/meta/recipes-connectivity/openssh/openssh_7.3p1.bb 
b/meta/recipes-connectivity/openssh/openssh_7.3p1.bb
index 94eb0ed208..c02bb7d450 100644
--- a/meta/recipes-connectivity/openssh/openssh_7.3p1.bb
+++ b/meta/recipes-connectivity/openssh/openssh_7.3p1.bb
@@ -92,13 +92,17 @@ do_compile_ptest() {
 }
 
 do_install_append () {
+   # Create default config files
+   install -m 0644 ${D}${sysconfdir}/ssh/sshd_config 
${D}${sysconfdir}/ssh/sshd_config_default
+   rm -f ${D}${sysconfdir}/ssh/sshd_config
+
if [ "${@bb.utils.contains('DISTRO_FEATURES', 'pam', 'pam', '', d)}" = 
"pam" ]; then
install -D -m 0644 ${WORKDIR}/sshd ${D}${sysconfdir}/pam.d/sshd
-   sed -i -e 's:#UsePAM no:UsePAM yes:' 
${D}${sysconfdir}/ssh/sshd_config
+   sed -i -e 's:#UsePAM no:UsePAM yes:' 
${D}${sysconfdir}/ssh/sshd_config_default
fi
 
if [ "${@bb.utils.contains('DISTRO_FEATURES', 'x11', 'x11', '', d)}" = 
"x11" ]; then
-   sed -i -e 's:#X11Forwarding no:X11Forwarding yes:' 
${D}${sysconfdir}/ssh/sshd_config
+   sed -i -e 's:#X11Forwarding no:X11Forwarding yes:' 
${D}${sysconfdir}/ssh/sshd_config_default
fi
 
install -d ${D}${sysconfdir}/init.d
@@ -111,7 +115,7 @@ do_install_append () {
 
# Create config files for read-only rootfs
install -d ${D}${sysconfdir}/ssh
-   install -m 644 ${D}${sysconfdir}/ssh/sshd_config 
${D}${sysconfdir}/ssh/sshd_config_readonly
+   install -m 644 ${D}${sysconfdir}/ssh/sshd_config_default 
${D}${sysconfdir}/ssh/sshd_config_readonly
sed -i '/HostKey/d' ${D}${sysconfdir}/ssh/sshd_config_readonly
echo "HostKey /var/run/ssh/ssh_host_rsa_key" >> 
${D}${sysconfdir}/ssh/sshd_config_readonly
echo "HostKey /var/run/ssh/ssh_host_dsa_key" >> 
${D}${sysconfdir}/ssh/sshd_config_readonly
@@ -135,30 +139,59 @@ do_install_ptest () {
 
 ALLOW_EMPTY_${PN} = "1"
 
-PACKAGES =+ "${PN}-keygen ${PN}-scp ${PN}-ssh ${PN}-sshd ${PN}-sftp ${PN}-misc 
${PN}-sftp-server"
+PACKAGES =+ "${PN}-keygen ${PN}-scp ${PN}-ssh ${PN}-sshd-config 
${PN}-sshd-config-readonly ${PN}-sshd ${PN}-sftp ${PN}-misc ${PN}-sftp-server"
 FILES_${PN}-scp = "${bindir}/scp.${BPN}"
 FILES_${PN}-ssh = "${bindir}/ssh.${BPN} ${sysconfdir}/ssh/ssh_config"
+FILES_${PN}-sshd-config = "${sysconfdir}/ssh/sshd_config_default"
+FILES_${PN}-sshd-config-readonly = "${sysconfdir}/ssh/sshd_config_readonly"
 FILES_${PN}-sshd = "${sbindir}/sshd ${sysconfdir}/init.d/sshd 
${systemd_unitdir}/system"
-FILES_${PN}-sshd += "${sysconfdir}/ssh/moduli ${sysconfdir}/ssh/sshd_config 
${sysconfdir}/ssh/sshd_config_readonly ${sysconfdir}/default/volatiles/99_sshd 
${sysconfdir}/pam.d/sshd"
+FILES_${PN}-sshd += "${sysconfdir}/ssh/moduli 
${sysconfdir}/default/volatiles/99_sshd ${sysconfdir}/pam.d/sshd"
 FILES_${PN}-sftp = "${bindir}/sftp"
 FILES_${PN}-sftp-server = "${libexecdir}/sftp-server"
 FILES_${PN}-misc = "${bindir}/ssh* ${libexecdir}/ssh*"
 FILES_${PN}-keygen = "${bindir}/ssh-keygen"
 
 RDEPENDS_${PN} += "${PN}-scp ${PN}-ssh ${PN}-sshd ${PN}-keygen"
-RDEPENDS_${PN}-sshd += "${PN}-keygen ${@bb.utils.contains('DISTRO_FEATURES', 
'pam', 'pam-plugin-keyinit pam-plugin-loginuid', '', d)}"
+RDEPENDS_${PN}-sshd += "${PN}-keygen sshd-config 
${@bb.utils.contains('DISTRO_FEATURES', 'pam', 'pam-plugin-keyinit 
pam-plugin-loginuid', '', d)}"
 RDEPENDS_${PN}-ptest += "${PN}-sftp ${PN}-misc ${PN}-sftp-server make"
 
 RPROVIDES_${PN}-ssh = "ssh"
+RPROVIDES_${PN}-sshd-config = "sshd-config"
+RPROVIDES_${PN}-sshd-config-readonly = "sshd-config"
 RPROVIDES_${PN}-sshd = "sshd"
 
 RCONFLICTS_${PN} = "dropbear"
+RCONFLICTS_${PN}-sshd-config = "${PN}-sshd-config-readonly"
+RCONFLICTS_${PN}-sshd-config-readonly = "${PN}-sshd-config"
 RCONFLICTS_${PN}-sshd = "dropbear"
 RCONFLICTS_${PN}-keygen = "ssh-keygen"
 
-CONFFILES_${PN}-sshd = "${sysconfdir}/ssh/sshd_config"
+CONFFILES_${PN}-sshd-config = "${sysconfdir}/ssh/sshd_config_default"
+CONFFILES_${PN}-sshd-config-readonly = "${sysconfdir}/ssh/sshd_config_readonly"
 CONFFILES_${PN}-ssh = "${sysconfdir}/ssh/ssh_config"
 
+pkg_postinst_${PN}-sshd-config () {
+#!/bin/sh
+if [ -e $D${sysconfdir}/ssh/sshd_config ]; then
+rm $D${sysconfdir}/

[OE-core] [PATCH 2/3] core-image: Set default sshd configuration

2017-01-24 Thread David Vincent
When selecting OpenSSH as ssh server provider instead of dropbear, also
install the correct configuration depending on whether the final rootfs
is read-only or not.

Signed-off-by: David Vincent <freesili...@gmail.com>
---
 meta/classes/core-image.bbclass | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/meta/classes/core-image.bbclass b/meta/classes/core-image.bbclass
index 8431440db4..d1f643d920 100644
--- a/meta/classes/core-image.bbclass
+++ b/meta/classes/core-image.bbclass
@@ -41,7 +41,7 @@ FEATURE_PACKAGES_tools-sdk = "packagegroup-core-sdk 
packagegroup-core-standalone
 FEATURE_PACKAGES_nfs-server = "packagegroup-core-nfs-server"
 FEATURE_PACKAGES_nfs-client = "packagegroup-core-nfs-client"
 FEATURE_PACKAGES_ssh-server-dropbear = "packagegroup-core-ssh-dropbear"
-FEATURE_PACKAGES_ssh-server-openssh = "packagegroup-core-ssh-openssh"
+FEATURE_PACKAGES_ssh-server-openssh = "packagegroup-core-ssh-openssh 
${SSHD_CONFIG}"
 FEATURE_PACKAGES_hwcodecs = "${MACHINE_HWCODECS}"
 
 
@@ -52,6 +52,7 @@ IMAGE_FEATURES_REPLACES_ssh-server-openssh = 
"ssh-server-dropbear"
 # IMAGE_FEATURES_CONFLICTS_foo = 'bar1 bar2'
 # An error exception would be raised if both image features foo and bar1(or 
bar2) are included
 
+SSHD_CONFIG ??= 
"${@bb.utils.contains('IMAGE_FEATURES','read-only-rootfs','openssh-sshd-config-readonly','openssh-sshd-config',d)}"
 MACHINE_HWCODECS ??= ""
 
 CORE_IMAGE_BASE_INSTALL = '\
-- 
2.11.0

-- 
___
Openembedded-core mailing list
Openembedded-core@lists.openembedded.org
http://lists.openembedded.org/mailman/listinfo/openembedded-core


[OE-core] [PATCH 0/3] openssh: Make sshd-config a package

2017-01-24 Thread David Vincent
This series of patch introduces a new way of modifying OpenSSH sshd
configuration. Instead of modifying the files and launching the server with
custom options, a package which RPROVIDES sshd-config must be installed.

The package to use is selected using a new variable called SSHD_CONFIG which is
used exclusively when selecting ssh-server-openssh in IMAGE_FEATURES.

Changes since v2:
  Remove documentation

David Vincent (3):
  openssh: Package server configuration
  core-image: Set default sshd configuration
  rootfs-postcommands: Modify ssh-related commands

 meta/classes/core-image.bbclass|  3 +-
 meta/classes/rootfs-postcommands.bbclass   | 28 -
 meta/recipes-connectivity/openssh/openssh_7.3p1.bb | 47 ++
 3 files changed, 49 insertions(+), 29 deletions(-)

-- 
2.11.0

-- 
___
Openembedded-core mailing list
Openembedded-core@lists.openembedded.org
http://lists.openembedded.org/mailman/listinfo/openembedded-core


Re: [OE-core] ✗ patchtest: failure for openssh: Make sshd-config a package

2017-01-23 Thread David Vincent
On lundi 23 janvier 2017 10:08:04 CET Leonardo Sandoval wrote:
> David, This is what I get from the command line
> 
> oe-core$ git pw mbox 4904 | git apply --check
> error: documentation/ref-manual/ref-variables.xml: No such file or directory
> 
> Meaning that you have a patch on your series that is targeted for the
> documentation folder, which is not part of the oe-core project. The
> latter need to be sent to:
> 
> documentation:
>  Git repository: http://git.yoctoproject.org/cgit/cgit.cgi/yocto-docs/
>  Mailing list: yo...@yoctoproject.org
> 

OK, my bad, I patched directly against my poky clone. I didn't know that 
documentation was handled elsewhere. So, I will resubmit it removing the 
latest patch.

But since these patches are related, is there a specific procedure to follow ? 
I didn't found anything in the contribution guidelines on the wiki...

Sorry for the inconvenience,
David
-- 
___
Openembedded-core mailing list
Openembedded-core@lists.openembedded.org
http://lists.openembedded.org/mailman/listinfo/openembedded-core


Re: [OE-core] ✗ patchtest: failure for openssh: Make sshd-config a package

2017-01-23 Thread David Vincent
On lundi 23 janvier 2017 15:23:36 CET Patchwork wrote:
> == Series Details ==
> 
> Series: openssh: Make sshd-config a package
> Revision: 1
> URL   : https://patchwork.openembedded.org/series/4904/
> State : failure
> 
> == Summary ==
> 
> 
> Thank you for submitting this patch series to OpenEmbedded Core. This is
> an automated response. Several tests have been executed on the proposed
> series by patchtest resulting in the following failures:
> 
> 
> 
> * Issue Series does not apply on top of target branch
> [test_series_merge_on_head] Suggested fixRebase your series on top of
> targeted branch
>   Targeted branch  master (currently at 842ad404b3)
> 
> 
> 
> If you believe any of these test results are incorrect, please reply to the
> mailing list (openembedded-core@lists.openembedded.org) raising your
> concerns. Otherwise we would appreciate you correcting the issues and
> submitting a new version of the patchset if applicable. Please ensure you
> add/increment the version number when sending the new version (i.e. [PATCH]
> -> [PATCH v2] -> [PATCH v3] -> ...).
> 
> ---
> Test framework: http://git.yoctoproject.org/cgit/cgit.cgi/patchtest
> Test suite: http://git.yoctoproject.org/cgit/cgit.cgi/patchtest-oe

This result seems to be an error since I rebased my patches on top of current 
HEAD before submitting it. I just checked again to see if some other patches 
were left behind but my branch is currently up-to-date.

David

-- 
___
Openembedded-core mailing list
Openembedded-core@lists.openembedded.org
http://lists.openembedded.org/mailman/listinfo/openembedded-core


[OE-core] [PATCH 2/4] core-image: Set default sshd configuration

2017-01-23 Thread David Vincent
When selecting OpenSSH as ssh server provider instead of dropbear, also
install the correct configuration depending on whether the final rootfs
is read-only or not.

Signed-off-by: David Vincent <freesili...@gmail.com>
---
 meta/classes/core-image.bbclass | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/meta/classes/core-image.bbclass b/meta/classes/core-image.bbclass
index 8431440db4..d1f643d920 100644
--- a/meta/classes/core-image.bbclass
+++ b/meta/classes/core-image.bbclass
@@ -41,7 +41,7 @@ FEATURE_PACKAGES_tools-sdk = "packagegroup-core-sdk 
packagegroup-core-standalone
 FEATURE_PACKAGES_nfs-server = "packagegroup-core-nfs-server"
 FEATURE_PACKAGES_nfs-client = "packagegroup-core-nfs-client"
 FEATURE_PACKAGES_ssh-server-dropbear = "packagegroup-core-ssh-dropbear"
-FEATURE_PACKAGES_ssh-server-openssh = "packagegroup-core-ssh-openssh"
+FEATURE_PACKAGES_ssh-server-openssh = "packagegroup-core-ssh-openssh 
${SSHD_CONFIG}"
 FEATURE_PACKAGES_hwcodecs = "${MACHINE_HWCODECS}"
 
 
@@ -52,6 +52,7 @@ IMAGE_FEATURES_REPLACES_ssh-server-openssh = 
"ssh-server-dropbear"
 # IMAGE_FEATURES_CONFLICTS_foo = 'bar1 bar2'
 # An error exception would be raised if both image features foo and bar1(or 
bar2) are included
 
+SSHD_CONFIG ??= 
"${@bb.utils.contains('IMAGE_FEATURES','read-only-rootfs','openssh-sshd-config-readonly','openssh-sshd-config',d)}"
 MACHINE_HWCODECS ??= ""
 
 CORE_IMAGE_BASE_INSTALL = '\
-- 
2.11.0

-- 
___
Openembedded-core mailing list
Openembedded-core@lists.openembedded.org
http://lists.openembedded.org/mailman/listinfo/openembedded-core


[OE-core] [PATCH 4/4] ref-manual: Add SSHD_CONFIG

2017-01-23 Thread David Vincent
Add description for the SSHD_CONFIG variable which is used to select the
package to use as provider for sshd-config.

Signed-off-by: David Vincent <freesili...@gmail.com>
---
 documentation/ref-manual/ref-variables.xml | 21 +
 1 file changed, 21 insertions(+)

diff --git a/documentation/ref-manual/ref-variables.xml 
b/documentation/ref-manual/ref-variables.xml
index 6e15e65f54..803f0da980 100644
--- a/documentation/ref-manual/ref-variables.xml
+++ b/documentation/ref-manual/ref-variables.xml
@@ -12511,6 +12511,27 @@ recipes-graphics/xorg-font/font-alias_1.0.3.bb:PR = 
"${INC_PR}.3"
 
 
 
+SSHD_CONFIG
+
+SSHD_CONFIG[doc] = "The package used to provide OpenSSH sshd 
configuration.
+
+
+
+When selecting "ssh-server-openssh" in
+IMAGE_FEATURES,
+specifies which package should be used as provider for
+sshd-config.
+
+
+
+This defaults to openssh-sshd-config.
+If "read-only-rootfs" is also specified in
+IMAGE_FEATURES,
+it defaults to 
openssh-sshd-config-readonly
+
+
+
+
 SSTATE_DIR
 
 SSTATE_DIR[doc] = "The directory for the shared state cache."
-- 
2.11.0

-- 
___
Openembedded-core mailing list
Openembedded-core@lists.openembedded.org
http://lists.openembedded.org/mailman/listinfo/openembedded-core


[OE-core] [PATCH 3/4] rootfs-postcommands: Modify ssh-related commands

2017-01-23 Thread David Vincent
OpenSSH configuration is now a symlink which points to the desired
configuration, so the functions that modified it must be updated to
modify the target and not override it.

Signed-off-by: David Vincent <freesili...@gmail.com>
---
 meta/classes/rootfs-postcommands.bbclass | 28 +++-
 1 file changed, 7 insertions(+), 21 deletions(-)

diff --git a/meta/classes/rootfs-postcommands.bbclass 
b/meta/classes/rootfs-postcommands.bbclass
index c8f18c6702..2d862b0b2e 100644
--- a/meta/classes/rootfs-postcommands.bbclass
+++ b/meta/classes/rootfs-postcommands.bbclass
@@ -86,20 +86,8 @@ read_only_rootfs_hook () {
# Tweak the mount option and fs_passno for rootfs in fstab
sed -i -e 
'/^[#[:space:]]*\/dev\/root/{s/defaults/ro/;s/\([[:space:]]*[[:digit:]]\)\([[:space:]]*\)[[:digit:]]$/\1\20/}'
 ${IMAGE_ROOTFS}/etc/fstab
 
-   # If we're using openssh and the /etc/ssh directory has no 
pre-generated keys,
-   # we should configure openssh to use the configuration file 
/etc/ssh/sshd_config_readonly
-   # and the keys under /var/run/ssh.
-   if [ -d ${IMAGE_ROOTFS}/etc/ssh ]; then
-   if [ -e ${IMAGE_ROOTFS}/etc/ssh/ssh_host_rsa_key ]; then
-   echo "SYSCONFDIR=/etc/ssh" >> 
${IMAGE_ROOTFS}/etc/default/ssh
-   echo "SSHD_OPTS=" >> ${IMAGE_ROOTFS}/etc/default/ssh
-   else
-   echo "SYSCONFDIR=/var/run/ssh" >> 
${IMAGE_ROOTFS}/etc/default/ssh
-   echo "SSHD_OPTS='-f /etc/ssh/sshd_config_readonly'" >> 
${IMAGE_ROOTFS}/etc/default/ssh
-   fi
-   fi
-
-   # Also tweak the key location for dropbear in the same way.
+   # If we're using dropbear and the /etc/dropbear directory has no 
pre-generated keys,
+   # we should configure dropbear to use the keys under /var/lib/dropbear.
if [ -d ${IMAGE_ROOTFS}/etc/dropbear ]; then
if [ -e ${IMAGE_ROOTFS}/etc/dropbear/dropbear_rsa_host_key ]; 
then
echo "DROPBEAR_RSAKEY_DIR=/etc/dropbear" >> 
${IMAGE_ROOTFS}/etc/default/dropbear
@@ -138,12 +126,10 @@ zap_empty_root_password () {
 # allow dropbear/openssh to accept root logins and logins from accounts with 
an empty password string
 #
 ssh_allow_empty_password () {
-   for config in sshd_config sshd_config_readonly; do
-   if [ -e ${IMAGE_ROOTFS}${sysconfdir}/ssh/$config ]; then
-   sed -i 
's/^[#[:space:]]*PermitRootLogin.*/PermitRootLogin yes/' 
${IMAGE_ROOTFS}${sysconfdir}/ssh/$config
-   sed -i 
's/^[#[:space:]]*PermitEmptyPasswords.*/PermitEmptyPasswords yes/' 
${IMAGE_ROOTFS}${sysconfdir}/ssh/$config
-   fi
-   done
+   if [ -e ${IMAGE_ROOTFS}${sysconfdir}/ssh/sshd_config ]; then
+   sed -i --follow-symlinks 
's/^[#[:space:]]*PermitRootLogin.*/PermitRootLogin yes/' 
${IMAGE_ROOTFS}${sysconfdir}/ssh/sshd_config
+   sed -i --follow-symlinks 
's/^[#[:space:]]*PermitEmptyPasswords.*/PermitEmptyPasswords yes/' 
${IMAGE_ROOTFS}${sysconfdir}/ssh/sshd_config
+   fi
 
if [ -e ${IMAGE_ROOTFS}${sbindir}/dropbear ] ; then
if grep -q DROPBEAR_EXTRA_ARGS 
${IMAGE_ROOTFS}${sysconfdir}/default/dropbear 2>/dev/null ; then
@@ -162,7 +148,7 @@ ssh_allow_empty_password () {
 
 ssh_disable_dns_lookup () {
if [ -e ${IMAGE_ROOTFS}${sysconfdir}/ssh/sshd_config ]; then
-   sed -i -e 's:#UseDNS yes:UseDNS no:' 
${IMAGE_ROOTFS}${sysconfdir}/ssh/sshd_config
+   sed -i --follow-symlinks -e 's:#UseDNS yes:UseDNS no:' 
${IMAGE_ROOTFS}${sysconfdir}/ssh/sshd_config
fi
 }
 
-- 
2.11.0

-- 
___
Openembedded-core mailing list
Openembedded-core@lists.openembedded.org
http://lists.openembedded.org/mailman/listinfo/openembedded-core


[OE-core] [PATCH 0/4] openssh: Make sshd-config a package

2017-01-23 Thread David Vincent
This series of patch introduces a new way of modifying OpenSSH sshd
configuration. Instead of modifying the files and launching the server with
custom options, a package which RPROVIDES sshd-config must be installed.

The package to use is selected using a new variable called SSHD_CONFIG which is
used exclusively when selecting ssh-server-openssh in IMAGE_FEATURES.

David Vincent (4):
  openssh: Package server configuration
  core-image: Set default sshd configuration
  rootfs-postcommands: Modify ssh-related commands
  ref-manual: Add SSHD_CONFIG

 documentation/ref-manual/ref-variables.xml | 21 ++
 meta/classes/core-image.bbclass|  3 +-
 meta/classes/rootfs-postcommands.bbclass   | 28 -
 meta/recipes-connectivity/openssh/openssh_7.3p1.bb | 47 ++
 4 files changed, 70 insertions(+), 29 deletions(-)

-- 
2.11.0

-- 
___
Openembedded-core mailing list
Openembedded-core@lists.openembedded.org
http://lists.openembedded.org/mailman/listinfo/openembedded-core


[OE-core] [PATCH 1/4] openssh: Package server configuration

2017-01-23 Thread David Vincent
Split sshd configuration for read-write/read-only rootfs in two distinct
packages. Also, add a package dependency between openssh-sshd package
and a provider of sshd-config.

Signed-off-by: David Vincent <freesili...@gmail.com>
---
 meta/recipes-connectivity/openssh/openssh_7.3p1.bb | 47 ++
 1 file changed, 40 insertions(+), 7 deletions(-)

diff --git a/meta/recipes-connectivity/openssh/openssh_7.3p1.bb 
b/meta/recipes-connectivity/openssh/openssh_7.3p1.bb
index 94eb0ed208..c02bb7d450 100644
--- a/meta/recipes-connectivity/openssh/openssh_7.3p1.bb
+++ b/meta/recipes-connectivity/openssh/openssh_7.3p1.bb
@@ -92,13 +92,17 @@ do_compile_ptest() {
 }
 
 do_install_append () {
+   # Create default config files
+   install -m 0644 ${D}${sysconfdir}/ssh/sshd_config 
${D}${sysconfdir}/ssh/sshd_config_default
+   rm -f ${D}${sysconfdir}/ssh/sshd_config
+
if [ "${@bb.utils.contains('DISTRO_FEATURES', 'pam', 'pam', '', d)}" = 
"pam" ]; then
install -D -m 0644 ${WORKDIR}/sshd ${D}${sysconfdir}/pam.d/sshd
-   sed -i -e 's:#UsePAM no:UsePAM yes:' 
${D}${sysconfdir}/ssh/sshd_config
+   sed -i -e 's:#UsePAM no:UsePAM yes:' 
${D}${sysconfdir}/ssh/sshd_config_default
fi
 
if [ "${@bb.utils.contains('DISTRO_FEATURES', 'x11', 'x11', '', d)}" = 
"x11" ]; then
-   sed -i -e 's:#X11Forwarding no:X11Forwarding yes:' 
${D}${sysconfdir}/ssh/sshd_config
+   sed -i -e 's:#X11Forwarding no:X11Forwarding yes:' 
${D}${sysconfdir}/ssh/sshd_config_default
fi
 
install -d ${D}${sysconfdir}/init.d
@@ -111,7 +115,7 @@ do_install_append () {
 
# Create config files for read-only rootfs
install -d ${D}${sysconfdir}/ssh
-   install -m 644 ${D}${sysconfdir}/ssh/sshd_config 
${D}${sysconfdir}/ssh/sshd_config_readonly
+   install -m 644 ${D}${sysconfdir}/ssh/sshd_config_default 
${D}${sysconfdir}/ssh/sshd_config_readonly
sed -i '/HostKey/d' ${D}${sysconfdir}/ssh/sshd_config_readonly
echo "HostKey /var/run/ssh/ssh_host_rsa_key" >> 
${D}${sysconfdir}/ssh/sshd_config_readonly
echo "HostKey /var/run/ssh/ssh_host_dsa_key" >> 
${D}${sysconfdir}/ssh/sshd_config_readonly
@@ -135,30 +139,59 @@ do_install_ptest () {
 
 ALLOW_EMPTY_${PN} = "1"
 
-PACKAGES =+ "${PN}-keygen ${PN}-scp ${PN}-ssh ${PN}-sshd ${PN}-sftp ${PN}-misc 
${PN}-sftp-server"
+PACKAGES =+ "${PN}-keygen ${PN}-scp ${PN}-ssh ${PN}-sshd-config 
${PN}-sshd-config-readonly ${PN}-sshd ${PN}-sftp ${PN}-misc ${PN}-sftp-server"
 FILES_${PN}-scp = "${bindir}/scp.${BPN}"
 FILES_${PN}-ssh = "${bindir}/ssh.${BPN} ${sysconfdir}/ssh/ssh_config"
+FILES_${PN}-sshd-config = "${sysconfdir}/ssh/sshd_config_default"
+FILES_${PN}-sshd-config-readonly = "${sysconfdir}/ssh/sshd_config_readonly"
 FILES_${PN}-sshd = "${sbindir}/sshd ${sysconfdir}/init.d/sshd 
${systemd_unitdir}/system"
-FILES_${PN}-sshd += "${sysconfdir}/ssh/moduli ${sysconfdir}/ssh/sshd_config 
${sysconfdir}/ssh/sshd_config_readonly ${sysconfdir}/default/volatiles/99_sshd 
${sysconfdir}/pam.d/sshd"
+FILES_${PN}-sshd += "${sysconfdir}/ssh/moduli 
${sysconfdir}/default/volatiles/99_sshd ${sysconfdir}/pam.d/sshd"
 FILES_${PN}-sftp = "${bindir}/sftp"
 FILES_${PN}-sftp-server = "${libexecdir}/sftp-server"
 FILES_${PN}-misc = "${bindir}/ssh* ${libexecdir}/ssh*"
 FILES_${PN}-keygen = "${bindir}/ssh-keygen"
 
 RDEPENDS_${PN} += "${PN}-scp ${PN}-ssh ${PN}-sshd ${PN}-keygen"
-RDEPENDS_${PN}-sshd += "${PN}-keygen ${@bb.utils.contains('DISTRO_FEATURES', 
'pam', 'pam-plugin-keyinit pam-plugin-loginuid', '', d)}"
+RDEPENDS_${PN}-sshd += "${PN}-keygen sshd-config 
${@bb.utils.contains('DISTRO_FEATURES', 'pam', 'pam-plugin-keyinit 
pam-plugin-loginuid', '', d)}"
 RDEPENDS_${PN}-ptest += "${PN}-sftp ${PN}-misc ${PN}-sftp-server make"
 
 RPROVIDES_${PN}-ssh = "ssh"
+RPROVIDES_${PN}-sshd-config = "sshd-config"
+RPROVIDES_${PN}-sshd-config-readonly = "sshd-config"
 RPROVIDES_${PN}-sshd = "sshd"
 
 RCONFLICTS_${PN} = "dropbear"
+RCONFLICTS_${PN}-sshd-config = "${PN}-sshd-config-readonly"
+RCONFLICTS_${PN}-sshd-config-readonly = "${PN}-sshd-config"
 RCONFLICTS_${PN}-sshd = "dropbear"
 RCONFLICTS_${PN}-keygen = "ssh-keygen"
 
-CONFFILES_${PN}-sshd = "${sysconfdir}/ssh/sshd_config"
+CONFFILES_${PN}-sshd-config = "${sysconfdir}/ssh/sshd_config_default"
+CONFFILES_${PN}-sshd-config-readonly = "${sysconfdir}/ssh/sshd_config_readonly"
 CONFFILES_${PN}-ssh = "${sysconfdir}/ssh/ssh_config"
 
+pkg_postinst_${PN}-sshd-config () {
+#!/bin/sh
+if [ -e $D${sysconfdir}/ssh/sshd_config ]; then
+rm $D${sysconfdir}/

[OE-core] [PATCH] openssl: Fix symlink creation

2017-01-23 Thread David Vincent
Symlinking the openssl configuration file at install time results in
errors when overriding it using an external package which also provides
openssl-conf. This should be done as a postinstall task for such
packages.

Signed-off-by: David Vincent <freesili...@gmail.com>
---
 meta/recipes-connectivity/openssl/openssl.inc | 13 -
 1 file changed, 12 insertions(+), 1 deletion(-)

diff --git a/meta/recipes-connectivity/openssl/openssl.inc 
b/meta/recipes-connectivity/openssl/openssl.inc
index 5cca019e1d..696b564cdd 100644
--- a/meta/recipes-connectivity/openssl/openssl.inc
+++ b/meta/recipes-connectivity/openssl/openssl.inc
@@ -201,7 +201,6 @@ do_install () {
   ${D}${sysconfdir}/ssl/
ln -sf ${sysconfdir}/ssl/certs ${D}${libdir}/ssl/certs
ln -sf ${sysconfdir}/ssl/private ${D}${libdir}/ssl/private
-   ln -sf ${sysconfdir}/ssl/openssl.cnf ${D}${libdir}/ssl/openssl.cnf
 }
 
 do_install_ptest () {
@@ -245,4 +244,16 @@ do_install_append_class-native() {
OPENSSL_ENGINES=${libdir}/ssl/engines
 }
 
+pkg_postinst_openssl-conf () {
+#!/bin/sh
+if [ -e $D${libdir}/ssl/openssl.cnf ]; then
+   rm -f $D${libdir}/ssl/openssl.cnf
+fi
+
+# If openssl-conf is installed before openssl, we must ensure that the symlink
+# destination exists
+mkdir -p $D${libdir}/ssl/
+ln -s ${sysconfdir}/ssl/openssl.cnf $D${libdir}/ssl/openssl.cnf
+}
+
 BBCLASSEXTEND = "native nativesdk"
-- 
2.11.0

-- 
___
Openembedded-core mailing list
Openembedded-core@lists.openembedded.org
http://lists.openembedded.org/mailman/listinfo/openembedded-core


[OE-core] [PATCH] useradd-staticids: Fix groupadd

2017-01-23 Thread David Vincent
When a group name is duplicated between USERADD_PARAM and
GROUPADD_PARAM, this class tries to add it twice which results in
failure of the groupadd command.

Signed-off-by: David Vincent <freesili...@gmail.com>
---
 meta/classes/useradd-staticids.bbclass | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/meta/classes/useradd-staticids.bbclass 
b/meta/classes/useradd-staticids.bbclass
index f7f6057ac3..a309b8873d 100644
--- a/meta/classes/useradd-staticids.bbclass
+++ b/meta/classes/useradd-staticids.bbclass
@@ -165,7 +165,9 @@ def update_useradd_static_config(d):
 if newgroup and is_pkg:
 groupadd = d.getVar("GROUPADD_PARAM_%s" % pkg)
 if groupadd:
-d.setVar("GROUPADD_PARAM_%s" % pkg, "%s; %s" % 
(groupadd, newgroup))
+# Only add the group if not already specified
+if not uaargs.groupname in groupadd:
+d.setVar("GROUPADD_PARAM_%s" % pkg, "%s; %s" % 
(groupadd, newgroup))
 else:
 d.setVar("GROUPADD_PARAM_%s" % pkg, newgroup)
 
-- 
2.11.0

-- 
___
Openembedded-core mailing list
Openembedded-core@lists.openembedded.org
http://lists.openembedded.org/mailman/listinfo/openembedded-core


Re: [OE-core] [PATCH v7] rootfs: Modify RPM installation

2017-01-17 Thread David Vincent
On lundi 16 janvier 2017 17:39:45 CET Burton, Ross wrote:
> On 12 January 2017 at 09:08, David Vincent <freesili...@gmail.com> wrote:
> > When using a custom RPM data directory instead of the default dir
> > '/var/lib/rpm', the final image did not contain any of the database
> > files in the expected location. This commit takes into account the
> > 'rpmlibdir' variable set into 'rootfs_rpm.bbclass'.
> 
> Something changed and this is now breaking rootfs generation for me:

It becomes weirder and weirder...

> 
> File: 'exec_python_func() autogenerated', lineno: 2, function: 
>  0001:
>  *** 0002:license_create_manifest(d)
>  0003:
> File:
> '/home/pokybuild/yocto-autobuilder/yocto-worker/nightly-x86-64/build/meta/cl
> asses/license.bbclass', lineno: 48, function: license_create_manifest
>  0044:pkg_dic = {}
>  0045:for pkg in sorted(image_list_installed_packages(d)):
>  0046:pkg_info = os.path.join(d.getVar('PKGDATA_DIR'),
>  0047:'runtime-reverse', pkg)
>  *** 0048:pkg_name = os.path.basename(os.readlink(pkg_info))
>  0049:
>  0050:pkg_dic[pkg_name] =
> oe.packagedata.read_pkgdatafile(pkg_info)
>  0051:if not "LICENSE" in pkg_dic[pkg_name].keys():
>  0052:pkg_lic_name = "LICENSE_" + pkg_name
> Exception: FileNotFoundError: [Errno 2] No such file or directory:
> '/home/pokybuild/yocto-autobuilder/yocto-worker/nightly-x86-64/build/build/t
> mp/sysroots/qemux86-64/pkgdata/runtime-reverse/error:'
> 
> Note how pkg is set to "error:".

I found that the RpmPkgsList is also using 'rpmlibdir'. Could it be possible 
that it must be defined for class-native and class-target ? Therefore, maybe 
setting a default value in each case could solve the problem ?
I'm using this patch on a daily basis and I don't have problems but, in my 
case, I set a default value for rpmlibdir at the distro level which I override 
for class-target in some of my BSP layers.

I can fall back to v6 and set a default value using a weak assignment for 
rpmlibdir.

> 
> Clearly the error handling in image_list_installed_packages() needs work,
> but I can make this problem appear/disappear by adding/removing this patch.
> 
> Ross

David
-- 
___
Openembedded-core mailing list
Openembedded-core@lists.openembedded.org
http://lists.openembedded.org/mailman/listinfo/openembedded-core


[OE-core] [PATCH] extrausers: Use static ids when available

2017-01-16 Thread David Vincent
When creating users at the image level using extrausers class, the
current behavior is to ignore the status of USERADDEXTENSION. This could
lead to undefined behavior when static ids are expected but the system
falls back to dynamic ones.

Signed-off-by: David Vincent <freesili...@gmail.com>
---
 meta/classes/extrausers.bbclass|  4 
 meta/classes/useradd-staticids.bbclass | 37 --
 2 files changed, 35 insertions(+), 6 deletions(-)

diff --git a/meta/classes/extrausers.bbclass b/meta/classes/extrausers.bbclass
index 402fc7d808..7709407b69 100644
--- a/meta/classes/extrausers.bbclass
+++ b/meta/classes/extrausers.bbclass
@@ -63,3 +63,7 @@ set_user_group () {
remaining=`echo $remaining | cut -d ';' -f2-`
done
 }
+
+USERADDEXTENSION ?= ""
+
+inherit ${USERADDEXTENSION}
diff --git a/meta/classes/useradd-staticids.bbclass 
b/meta/classes/useradd-staticids.bbclass
index 94bcbaa3d7..f7f6057ac3 100644
--- a/meta/classes/useradd-staticids.bbclass
+++ b/meta/classes/useradd-staticids.bbclass
@@ -58,7 +58,7 @@ def update_useradd_static_config(d):
 bb.warn("%s - %s: %sname %s does not have a static ID defined." % 
(d.getVar('PN'), pkg, type, id))
 
 # We parse and rewrite the useradd components
-def rewrite_useradd(params):
+def rewrite_useradd(params, is_pkg):
 # The following comes from --help on useradd from shadow
 parser = myArgumentParser(prog='useradd')
 parser.add_argument("-b", "--base-dir", metavar="BASE_DIR", help="base 
directory for the home directory of the new account")
@@ -162,7 +162,7 @@ def update_useradd_static_config(d):
 
 uaargs.gid = uaargs.groupid
 uaargs.user_group = None
-if newgroup:
+if newgroup and is_pkg:
 groupadd = d.getVar("GROUPADD_PARAM_%s" % pkg)
 if groupadd:
 d.setVar("GROUPADD_PARAM_%s" % pkg, "%s; %s" % 
(groupadd, newgroup))
@@ -206,7 +206,7 @@ def update_useradd_static_config(d):
 return ";".join(newparams).strip()
 
 # We parse and rewrite the groupadd components
-def rewrite_groupadd(params):
+def rewrite_groupadd(params, is_pkg):
 # The following comes from --help on groupadd from shadow
 parser = myArgumentParser(prog='groupadd')
 parser.add_argument("-f", "--force", help="exit successfully if the 
group already exists, and cancel -g if the GID is already used", 
action="store_true")
@@ -298,7 +298,7 @@ def update_useradd_static_config(d):
 bb.parse.mark_dependency(d, bb.utils.which(bbpath, conf_file))
 
 # Load and process the users and groups, rewriting the adduser/addgroup 
params
-useradd_packages = d.getVar('USERADD_PACKAGES')
+useradd_packages = d.getVar('USERADD_PACKAGES') or ""
 
 for pkg in useradd_packages.split():
 # Groupmems doesn't have anything we might want to change, so simply 
validating
@@ -306,15 +306,40 @@ def update_useradd_static_config(d):
 useradd_param = d.getVar('USERADD_PARAM_%s' % pkg)
 if useradd_param:
 #bb.warn("Before: 'USERADD_PARAM_%s' - '%s'" % (pkg, 
useradd_param))
-d.setVar('USERADD_PARAM_%s' % pkg, rewrite_useradd(useradd_param))
+d.setVar('USERADD_PARAM_%s' % pkg, rewrite_useradd(useradd_param, 
True))
 #bb.warn("After:  'USERADD_PARAM_%s' - '%s'" % (pkg, 
d.getVar('USERADD_PARAM_%s' % pkg)))
 
 groupadd_param = d.getVar('GROUPADD_PARAM_%s' % pkg)
 if groupadd_param:
 #bb.warn("Before: 'GROUPADD_PARAM_%s' - '%s'" % (pkg, 
groupadd_param))
-d.setVar('GROUPADD_PARAM_%s' % pkg, 
rewrite_groupadd(groupadd_param))
+d.setVar('GROUPADD_PARAM_%s' % pkg, 
rewrite_groupadd(groupadd_param, True))
 #bb.warn("After:  'GROUPADD_PARAM_%s' - '%s'" % (pkg, 
d.getVar('GROUPADD_PARAM_%s' % pkg)))
 
+# Load and process extra users and groups, rewriting only adduser/addgroup 
params
+pkg = d.getVar('PN')
+extrausers = d.getVar('EXTRA_USERS_PARAMS') or ""
+
+#bb.warn("Before:  'EXTRA_USERS_PARAMS' - '%s'" % 
(d.getVar('EXTRA_USERS_PARAMS')))
+new_extrausers = []
+for cmd in re.split('''[ \t]*;[ \t]*(?=(?:[^'"]|'[^']*'|"[^"]*")*$)''', 
extrausers):
+cmd = cmd.strip()
+if not cmd:
+continue
+
+if re.match('''useradd (.*)''', cmd):
+useradd_param = re.match('''useradd (.*)''', cmd).group(1)
+useradd_param = rewrite_useradd(useradd_param, False)
+cmd = 'useradd %s' % useradd_param
+elif re.match('''groupadd (.*)''', cmd):
+groupadd_param = re.match('''

[OE-core] [PATCH v7] rootfs: Modify RPM installation

2017-01-12 Thread David Vincent
When using a custom RPM data directory instead of the default dir
'/var/lib/rpm', the final image did not contain any of the database
files in the expected location. This commit takes into account the
'rpmlibdir' variable set into 'rootfs_rpm.bbclass'.

Changes since v4:
- Remove boolean in d.getVar() calls.

Changes since v5:
- Also modify rpm recipe to build the database in the correct
  location and avoid errors during rootfs creation.

Changes since v6:
- Activate database path only for target builds to avoid host build
  errors (Thanks to Ross Burton)

Signed-off-by: David Vincent <freesili...@gmail.com>
---
 meta/lib/oe/package_manager.py  | 23 +--
 meta/lib/oe/rootfs.py   |  3 ++-
 meta/recipes-devtools/rpm/rpm_5.4.16.bb |  2 ++
 3 files changed, 17 insertions(+), 11 deletions(-)

diff --git a/meta/lib/oe/package_manager.py b/meta/lib/oe/package_manager.py
index a8644cc1c0..cfca178095 100644
--- a/meta/lib/oe/package_manager.py
+++ b/meta/lib/oe/package_manager.py
@@ -354,7 +354,8 @@ class RpmPkgsList(PkgsList):
 super(RpmPkgsList, self).__init__(d, rootfs_dir)
 
 self.rpm_cmd = bb.utils.which(os.getenv('PATH'), "rpm")
-self.image_rpmlib = os.path.join(self.rootfs_dir, 'var/lib/rpm')
+self.rpm_libdir = self.d.getVar('rpmlibdir')
+self.image_rpmlib = os.path.join(self.rootfs_dir, self.rpm_libdir[1:])
 
 self.ml_prefix_list, self.ml_os_list = \
 RpmIndexer(d, rootfs_dir).get_ml_prefix_and_os_list(arch_var, 
os_var)
@@ -414,7 +415,7 @@ class RpmPkgsList(PkgsList):
 
 def list_pkgs(self):
 cmd = [self.rpm_cmd, '--root', self.rootfs_dir]
-cmd.extend(['-D', '_dbpath /var/lib/rpm'])
+cmd.extend(['-D', '_dbpath', self.rpm_libdir])
 cmd.extend(['-qa', '--qf', '[%{NAME} %{ARCH} %{VERSION} 
%{PACKAGEORIGIN}\n]'])
 
 try:
@@ -681,7 +682,8 @@ class RpmPM(PackageManager):
 self.solution_manifest = self.d.expand('${T}/saved/%s_solution' %
self.task_name)
 self.saved_rpmlib = self.d.expand('${T}/saved/%s' % self.task_name)
-self.image_rpmlib = os.path.join(self.target_rootfs, 'var/lib/rpm')
+self.rpm_libdir = self.d.getVar('rpmlibdir')
+self.image_rpmlib = os.path.join(self.target_rootfs, 
self.rpm_libdir[1:])
 
 if not os.path.exists(self.d.expand('${T}/saved')):
 bb.utils.mkdirhier(self.d.expand('${T}/saved'))
@@ -952,7 +954,7 @@ class RpmPM(PackageManager):
 open(db_config_dir, 'w+').write(DB_CONFIG_CONTENT)
 
 # Create database so that smart doesn't complain (lazy init)
-cmd = [self.rpm_cmd, '--root', self.target_rootfs, '--dbpath', 
'/var/lib/rpm', '-qa']
+cmd = [self.rpm_cmd, '--root', self.target_rootfs, '--dbpath', 
self.rpm_libdir, '-qa']
 try:
 subprocess.check_output(cmd, stderr=subprocess.STDOUT)
 except subprocess.CalledProcessError as e:
@@ -961,20 +963,19 @@ class RpmPM(PackageManager):
 # Import GPG key to RPM database of the target system
 if self.d.getVar('RPM_SIGN_PACKAGES') == '1':
 pubkey_path = self.d.getVar('RPM_GPG_PUBKEY')
-cmd = [self.rpm_cmd, '--root', self.target_rootfs, '--dbpath', 
'/var/lib/rpm', '--import', pubkey_path]
+cmd = [self.rpm_cmd, '--root', self.target_rootfs, '--dbpath', 
self.rpm_libdir, '--import', pubkey_path]
 try:
 subprocess.check_output(cmd, stderr=subprocess.STDOUT)
 except subprocess.CalledProcessError as e:
 bb.fatal("Import GPG key failed. Command '%s' "
 "returned %d:\n%s" % (' '.join(cmd), e.returncode, 
e.output.decode("utf-8")))
 
-
 # Configure smart
 bb.note("configuring Smart settings")
 bb.utils.remove(os.path.join(self.target_rootfs, 'var/lib/smart'),
 True)
 self._invoke_smart(['config', '--set', 'rpm-root=%s' % 
self.target_rootfs])
-self._invoke_smart(['config', '--set', 'rpm-dbpath=/var/lib/rpm'])
+self._invoke_smart(['config', '--set', 'rpm-dbpath=%s' % 
self.rpm_libdir])
 self._invoke_smart(['config', '--set', 'rpm-extra-macros._var=%s' %
self.d.getVar('localstatedir')])
 cmd = ["config", "--set", "rpm-extra-macros._tmppath=/%s/tmp" % 
self.install_dir_name]
@@ -1234,7 +1235,7 @@ class RpmPM(PackageManager):
 
 if not with_dependencies:
 cmd = [self.rpm_cmd] + ["-e", "--nodeps", "--root=%s" %
-self.target_rootfs, "--dbpath=/var/lib/rpm",
+self.target_rootfs, "--dbpath=%s" % self.rpm_libdir,
 "--define='_cross_scriptlet_wrapper %s'" %
  

Re: [OE-core] [PATCH v6] rootfs: Modify RPM installation

2017-01-06 Thread David Vincent
On jeudi 22 décembre 2016 15:45:34 CET David Vincent wrote:
> On jeudi 22 décembre 2016 14:09:32 CET Burton, Ross wrote:
> > Small problem: we always build rpm-native as we need it for some tools,
> > but
> > rpmlibdir is only defined in package_rpm.bbclass which doesn't have to be
> > inherited.
> 
> I didn't know that rpm-native was built in any case, rpm being selected as
> package manager or not.
> 
> > This leads to just --with-path-database= being passed to configure. 
> > What's
> > the behaviour of RPM when this happens? What does it default to?  If it's
> > going to be safe (ie a sane default is used), please update the commit
> > message to explain this.
> 
> Indeed, this can lead to undefined behavior. I can propose some solutions
> but which one would you find better :
>   - Setting a weak assignment for rpmlibdir inside rpm recipe
>   - Setting a default assignment for rpmlibdir_class-native inside rpm 
recipe
> - Another option I didn't think of

Any news on that ?

> 
> > Ross
> 

David
-- 
___
Openembedded-core mailing list
Openembedded-core@lists.openembedded.org
http://lists.openembedded.org/mailman/listinfo/openembedded-core


[OE-core] [PATCH] nss: Fix postinstall script

2017-01-04 Thread David Vincent
When installing NSS on a read-only rootfs, the current postinstall
scriptlet exits after having run the signing part. This causes an error
when appending the task because the rest of the script is simply ignored
and therefore never run.

Signed-off-by: David Vincent <freesili...@gmail.com>
---
 meta/recipes-support/nss/nss_3.27.1.bb | 12 ++--
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/meta/recipes-support/nss/nss_3.27.1.bb 
b/meta/recipes-support/nss/nss_3.27.1.bb
index 091793899f..a69672b3d8 100644
--- a/meta/recipes-support/nss/nss_3.27.1.bb
+++ b/meta/recipes-support/nss/nss_3.27.1.bb
@@ -208,18 +208,18 @@ do_install_append_class-target() {
 
 pkg_postinst_${PN} () {
 if [ -n "$D" ]; then
-for I in $D/${libdir}/lib*.chk; do
+for I in $D${libdir}/lib*.chk; do
 DN=`dirname $I`
 BN=`basename $I .chk`
 FN=$DN/$BN.so
 shlibsign -i $FN
-   if [ $? -ne 0 ]; then
-  exit 1
-   fi
+if [ $? -ne 0 ]; then
+exit 1
+fi
 done
-exit 0
+else
+signlibs.sh
 fi
-signlibs.sh
 }
 
 PACKAGES =+ "${PN}-smime"
-- 
2.11.0

-- 
___
Openembedded-core mailing list
Openembedded-core@lists.openembedded.org
http://lists.openembedded.org/mailman/listinfo/openembedded-core


Re: [OE-core] [PATCH v6] rootfs: Modify RPM installation

2016-12-22 Thread David Vincent
On jeudi 22 décembre 2016 14:09:32 CET Burton, Ross wrote:
> Small problem: we always build rpm-native as we need it for some tools, but
> rpmlibdir is only defined in package_rpm.bbclass which doesn't have to be
> inherited.

I didn't know that rpm-native was built in any case, rpm being selected as 
package manager or not.
 
> This leads to just --with-path-database= being passed to configure.  What's
> the behaviour of RPM when this happens? What does it default to?  If it's
> going to be safe (ie a sane default is used), please update the commit
> message to explain this.

Indeed, this can lead to undefined behavior. I can propose some solutions but 
which one would you find better :
- Setting a weak assignment for rpmlibdir inside rpm recipe
- Setting a default assignment for rpmlibdir_class-native inside rpm 
recipe
- Another option I didn't think of

> Ross
> 

David
-- 
___
Openembedded-core mailing list
Openembedded-core@lists.openembedded.org
http://lists.openembedded.org/mailman/listinfo/openembedded-core


[OE-core] [PATCH v6] rootfs: Modify RPM installation

2016-12-22 Thread David Vincent
When using a custom RPM data directory instead of the default dir
'/var/lib/rpm', the final image did not contain any of the database
files in the expected location. This commit takes into account the
'rpmlibdir' variable set into 'rootfs_rpm.bbclass'.

Changes since v4:
- Remove boolean in d.getVar() calls.

Changes since v5:
- Also modify rpm recipe to build the database in the correct
  location and avoid errors during rootfs creation.

Signed-off-by: David Vincent <freesili...@gmail.com>
---
 meta/lib/oe/package_manager.py  | 23 +--
 meta/lib/oe/rootfs.py   |  3 ++-
 meta/recipes-devtools/rpm/rpm_5.4.16.bb |  2 ++
 3 files changed, 17 insertions(+), 11 deletions(-)

diff --git a/meta/lib/oe/package_manager.py b/meta/lib/oe/package_manager.py
index e557473999..3f2878c394 100644
--- a/meta/lib/oe/package_manager.py
+++ b/meta/lib/oe/package_manager.py
@@ -356,7 +356,8 @@ class RpmPkgsList(PkgsList):
 super(RpmPkgsList, self).__init__(d, rootfs_dir)
 
 self.rpm_cmd = bb.utils.which(os.getenv('PATH'), "rpm")
-self.image_rpmlib = os.path.join(self.rootfs_dir, 'var/lib/rpm')
+self.rpm_libdir = self.d.getVar('rpmlibdir')
+self.image_rpmlib = os.path.join(self.rootfs_dir, self.rpm_libdir[1:])
 
 self.ml_prefix_list, self.ml_os_list = \
 RpmIndexer(d, rootfs_dir).get_ml_prefix_and_os_list(arch_var, 
os_var)
@@ -416,7 +417,7 @@ class RpmPkgsList(PkgsList):
 
 def list_pkgs(self):
 cmd = [self.rpm_cmd, '--root', self.rootfs_dir]
-cmd.extend(['-D', '_dbpath /var/lib/rpm'])
+cmd.extend(['-D', '_dbpath', self.rpm_libdir])
 cmd.extend(['-qa', '--qf', '[%{NAME} %{ARCH} %{VERSION} 
%{PACKAGEORIGIN}\n]'])
 
 try:
@@ -683,7 +684,8 @@ class RpmPM(PackageManager):
 self.solution_manifest = self.d.expand('${T}/saved/%s_solution' %
self.task_name)
 self.saved_rpmlib = self.d.expand('${T}/saved/%s' % self.task_name)
-self.image_rpmlib = os.path.join(self.target_rootfs, 'var/lib/rpm')
+self.rpm_libdir = self.d.getVar('rpmlibdir')
+self.image_rpmlib = os.path.join(self.target_rootfs, 
self.rpm_libdir[1:])
 
 if not os.path.exists(self.d.expand('${T}/saved')):
 bb.utils.mkdirhier(self.d.expand('${T}/saved'))
@@ -954,7 +956,7 @@ class RpmPM(PackageManager):
 open(db_config_dir, 'w+').write(DB_CONFIG_CONTENT)
 
 # Create database so that smart doesn't complain (lazy init)
-cmd = [self.rpm_cmd, '--root', self.target_rootfs, '--dbpath', 
'/var/lib/rpm', '-qa']
+cmd = [self.rpm_cmd, '--root', self.target_rootfs, '--dbpath', 
self.rpm_libdir, '-qa']
 try:
 subprocess.check_output(cmd, stderr=subprocess.STDOUT)
 except subprocess.CalledProcessError as e:
@@ -963,20 +965,19 @@ class RpmPM(PackageManager):
 # Import GPG key to RPM database of the target system
 if self.d.getVar('RPM_SIGN_PACKAGES') == '1':
 pubkey_path = self.d.getVar('RPM_GPG_PUBKEY')
-cmd = [self.rpm_cmd, '--root', self.target_rootfs, '--dbpath', 
'/var/lib/rpm', '--import', pubkey_path]
+cmd = [self.rpm_cmd, '--root', self.target_rootfs, '--dbpath', 
self.rpm_libdir, '--import', pubkey_path]
 try:
 subprocess.check_output(cmd, stderr=subprocess.STDOUT)
 except subprocess.CalledProcessError as e:
 bb.fatal("Import GPG key failed. Command '%s' "
 "returned %d:\n%s" % (' '.join(cmd), e.returncode, 
e.output.decode("utf-8")))
 
-
 # Configure smart
 bb.note("configuring Smart settings")
 bb.utils.remove(os.path.join(self.target_rootfs, 'var/lib/smart'),
 True)
 self._invoke_smart(['config', '--set', 'rpm-root=%s' % 
self.target_rootfs])
-self._invoke_smart(['config', '--set', 'rpm-dbpath=/var/lib/rpm'])
+self._invoke_smart(['config', '--set', 'rpm-dbpath=%s' % 
self.rpm_libdir])
 self._invoke_smart(['config', '--set', 'rpm-extra-macros._var=%s' %
self.d.getVar('localstatedir')])
 cmd = ["config", "--set", "rpm-extra-macros._tmppath=/%s/tmp" % 
self.install_dir_name]
@@ -1236,7 +1237,7 @@ class RpmPM(PackageManager):
 
 if not with_dependencies:
 cmd = [self.rpm_cmd] + ["-e", "--nodeps", "--root=%s" %
-self.target_rootfs, "--dbpath=/var/lib/rpm",
+self.target_rootfs, "--dbpath=%s" % self.rpm_libdir,
 "--define='_cross_scriptlet_wrapper %s'" %
 self.scriptlet_wrapper,
 "--define='_tmppath /%s/tmp'" % self.install_dir_name] +

Re: [OE-core] [PATCH v5] rootfs: Modify RPM installation

2016-12-22 Thread David Vincent
On mardi 20 décembre 2016 17:44:54 CET Burton, Ross wrote:
> This breaks list_pkgs() for the RPM backend. Instead of returning a list of
> packages, rpm just says "%dbpath is not defined" (or words to that effect,
> as the log disappeared in 100 pages of errors).
> 
> Ross
> 

OK, I found the bug. I also modified the rpm recipe in another layer using a 
bbappend, but now I must include these changes in this patch. I'll resend this 
ASAP with the change.

Sorry for the inconvenience,
David
-- 
___
Openembedded-core mailing list
Openembedded-core@lists.openembedded.org
http://lists.openembedded.org/mailman/listinfo/openembedded-core


[OE-core] [PATCH] kernel: Fix symlinks

2016-12-20 Thread David Vincent
When installing a kernel package, the symlinks created by
update-alternatives should point to a path relative to KERNEL_IMAGEDEST
and not an absolute path to '/boot'.

Failing to do so causes problems when resolving the symlink inside some
bootloaders which mount the boot partition elsewhere.

Signed-off-by: David Vincent <freesili...@gmail.com>
---
 meta/classes/kernel.bbclass | 6 +++---
 meta/recipes-kernel/linux/linux-dtb.inc | 4 ++--
 2 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/meta/classes/kernel.bbclass b/meta/classes/kernel.bbclass
index fa598cff7f..3630042dbd 100644
--- a/meta/classes/kernel.bbclass
+++ b/meta/classes/kernel.bbclass
@@ -45,10 +45,11 @@ python __anonymous () {
 
 for type in types.split():
 typelower = type.lower()
+imagedest = d.getVar('KERNEL_IMAGEDEST')
 
 d.appendVar('PACKAGES', ' ' + 'kernel-image-' + typelower)
 
-d.setVar('FILES_kernel-image-' + typelower, '/boot/' + type + 
'-${KERNEL_VERSION_NAME}')
+d.setVar('FILES_kernel-image-' + typelower, '/' + imagedest + '/' + 
type + '-${KERNEL_VERSION_NAME}')
 
 d.appendVar('RDEPENDS_kernel-image', ' ' + 'kernel-image-' + typelower)
 
@@ -56,9 +57,8 @@ python __anonymous () {
 
 d.setVar('ALLOW_EMPTY_kernel-image-' + typelower, '1')
 
-imagedest = d.getVar('KERNEL_IMAGEDEST')
 priority = d.getVar('KERNEL_PRIORITY')
-postinst = '#!/bin/sh\n' + 'update-alternatives --install /' + 
imagedest + '/' + type + ' ' + type + ' ' + '/' + imagedest + '/' + type + 
'-${KERNEL_VERSION_NAME} ' + priority + ' || true' + '\n'
+postinst = '#!/bin/sh\n' + 'update-alternatives --install /' + 
imagedest + '/' + type + ' ' + type + ' ' + type + '-${KERNEL_VERSION_NAME} ' + 
priority + ' || true' + '\n'
 d.setVar('pkg_postinst_kernel-image-' + typelower, postinst)
 
 postrm = '#!/bin/sh\n' + 'update-alternatives --remove' + ' ' + type + 
' ' + type + '-${KERNEL_VERSION_NAME} || true' + '\n'
diff --git a/meta/recipes-kernel/linux/linux-dtb.inc 
b/meta/recipes-kernel/linux/linux-dtb.inc
index 8528d646dd..668f6342b5 100644
--- a/meta/recipes-kernel/linux/linux-dtb.inc
+++ b/meta/recipes-kernel/linux/linux-dtb.inc
@@ -70,7 +70,7 @@ pkg_postinst_kernel-devicetree () {
DTB_EXT=${DTB##*.}
DTB_BASE_NAME=`basename ${DTB} | awk -F "." '{print 
$1}'`
DTB_SYMLINK_NAME=`echo ${symlink_name} | sed 
"s/${MACHINE}/${DTB_BASE_NAME}/g"`
-   update-alternatives --install 
/${KERNEL_IMAGEDEST}/${DTB_BASE_NAME}.${DTB_EXT} ${DTB_BASE_NAME}.${DTB_EXT} 
/boot/devicetree-${DTB_SYMLINK_NAME}.${DTB_EXT} ${KERNEL_PRIORITY} || true
+   update-alternatives --install 
/${KERNEL_IMAGEDEST}/${DTB_BASE_NAME}.${DTB_EXT} ${DTB_BASE_NAME}.${DTB_EXT} 
devicetree-${DTB_SYMLINK_NAME}.${DTB_EXT} ${KERNEL_PRIORITY} || true
done
done
 }
@@ -83,7 +83,7 @@ pkg_postrm_kernel-devicetree () {
DTB_EXT=${DTB##*.}
DTB_BASE_NAME=`basename ${DTB} | awk -F "." '{print 
$1}'`
DTB_SYMLINK_NAME=`echo ${symlink_name} | sed 
"s/${MACHINE}/${DTB_BASE_NAME}/g"`
-   update-alternatives --remove 
${DTB_BASE_NAME}.${DTB_EXT} /boot/devicetree-${DTB_SYMLINK_NAME}.${DTB_EXT} 
${KERNEL_PRIORITY} || true
+   update-alternatives --remove 
${DTB_BASE_NAME}.${DTB_EXT} devicetree-${DTB_SYMLINK_NAME}.${DTB_EXT} 
${KERNEL_PRIORITY} || true
done
done
 }
-- 
2.11.0

-- 
___
Openembedded-core mailing list
Openembedded-core@lists.openembedded.org
http://lists.openembedded.org/mailman/listinfo/openembedded-core


[OE-core] [PATCH v5] rootfs: Modify RPM installation

2016-12-20 Thread David Vincent
When using a custom RPM data directory instead of the default dir
'/var/lib/rpm', the final image did not contain any of the database
files in the expected location. This commit takes into account the
'rpmlibdir' variable set into 'rootfs_rpm.bbclass'.

Changes since v4:
- Remove boolean in d.getVar() calls.

Signed-off-by: David Vincent <freesili...@gmail.com>
---
 meta/lib/oe/package_manager.py | 23 +--
 meta/lib/oe/rootfs.py  |  3 ++-
 2 files changed, 15 insertions(+), 11 deletions(-)

diff --git a/meta/lib/oe/package_manager.py b/meta/lib/oe/package_manager.py
index e557473999..4299220eec 100644
--- a/meta/lib/oe/package_manager.py
+++ b/meta/lib/oe/package_manager.py
@@ -356,7 +356,8 @@ class RpmPkgsList(PkgsList):
 super(RpmPkgsList, self).__init__(d, rootfs_dir)
 
 self.rpm_cmd = bb.utils.which(os.getenv('PATH'), "rpm")
-self.image_rpmlib = os.path.join(self.rootfs_dir, 'var/lib/rpm')
+self.rpm_libdir = self.d.getVar('rpmlibdir')
+self.image_rpmlib = os.path.join(self.rootfs_dir, self.rpm_libdir[1:])
 
 self.ml_prefix_list, self.ml_os_list = \
 RpmIndexer(d, rootfs_dir).get_ml_prefix_and_os_list(arch_var, 
os_var)
@@ -416,7 +417,7 @@ class RpmPkgsList(PkgsList):
 
 def list_pkgs(self):
 cmd = [self.rpm_cmd, '--root', self.rootfs_dir]
-cmd.extend(['-D', '_dbpath /var/lib/rpm'])
+cmd.extend(['-D', '_dbpath', self.rpm_libdir])
 cmd.extend(['-qa', '--qf', '[%{NAME} %{ARCH} %{VERSION} 
%{PACKAGEORIGIN}\n]'])
 
 try:
@@ -683,7 +684,8 @@ class RpmPM(PackageManager):
 self.solution_manifest = self.d.expand('${T}/saved/%s_solution' %
self.task_name)
 self.saved_rpmlib = self.d.expand('${T}/saved/%s' % self.task_name)
-self.image_rpmlib = os.path.join(self.target_rootfs, 'var/lib/rpm')
+self.rpm_libdir = self.d.getVar('rpmlibdir')
+self.image_rpmlib = os.path.join(self.target_rootfs, 
self.rpm_libdir[1:])
 
 if not os.path.exists(self.d.expand('${T}/saved')):
 bb.utils.mkdirhier(self.d.expand('${T}/saved'))
@@ -954,7 +956,7 @@ class RpmPM(PackageManager):
 open(db_config_dir, 'w+').write(DB_CONFIG_CONTENT)
 
 # Create database so that smart doesn't complain (lazy init)
-cmd = [self.rpm_cmd, '--root', self.target_rootfs, '--dbpath', 
'/var/lib/rpm', '-qa']
+cmd = [self.rpm_cmd, '--root', self.target_rootfs, '--dbpath', 
self.rpm_libdir, '-qa']
 try:
 subprocess.check_output(cmd, stderr=subprocess.STDOUT)
 except subprocess.CalledProcessError as e:
@@ -963,20 +965,19 @@ class RpmPM(PackageManager):
 # Import GPG key to RPM database of the target system
 if self.d.getVar('RPM_SIGN_PACKAGES') == '1':
 pubkey_path = self.d.getVar('RPM_GPG_PUBKEY')
-cmd = [self.rpm_cmd, '--root', self.target_rootfs, '--dbpath', 
'/var/lib/rpm', '--import', pubkey_path]
+cmd = [self.rpm_cmd, '--root', self.target_rootfs, '--dbpath', 
self.rpm_libdir, '--import', pubkey_path]
 try:
 subprocess.check_output(cmd, stderr=subprocess.STDOUT)
 except subprocess.CalledProcessError as e:
 bb.fatal("Import GPG key failed. Command '%s' "
 "returned %d:\n%s" % (' '.join(cmd), e.returncode, 
e.output.decode("utf-8")))
 
-
 # Configure smart
 bb.note("configuring Smart settings")
 bb.utils.remove(os.path.join(self.target_rootfs, 'var/lib/smart'),
 True)
 self._invoke_smart(['config', '--set', 'rpm-root=%s' % 
self.target_rootfs])
-self._invoke_smart(['config', '--set', 'rpm-dbpath=/var/lib/rpm'])
+self._invoke_smart(['config', '--set', 'rpm-dbpath=%s' % 
self.rpm_libdir])
 self._invoke_smart(['config', '--set', 'rpm-extra-macros._var=%s' %
self.d.getVar('localstatedir')])
 cmd = ["config", "--set", "rpm-extra-macros._tmppath=/%s/tmp" % 
self.install_dir_name]
@@ -1236,7 +1237,7 @@ class RpmPM(PackageManager):
 
 if not with_dependencies:
 cmd = [self.rpm_cmd] + ["-e", "--nodeps", "--root=%s" %
-self.target_rootfs, "--dbpath=/var/lib/rpm",
+self.target_rootfs, "--dbpath=%s" % self.rpm_libdir,
 "--define='_cross_scriptlet_wrapper %s'" %
 self.scriptlet_wrapper,
 "--define='_tmppath /%s/tmp'" % self.install_dir_name] + 
pkgs
@@ -1384,7 +1385,8 @@ class RpmPM(PackageManager):
 saved_dir = self.target_rootfs + 
self.d.expand('${sysconfdir}/rpm-postinsts/') + new_pkg
 
 cmd = self.rpm_cmd + ' -q --scripts --root ' + se

[OE-core] [PATCH v6] classes: Fix alternatives and rc.d ordering

2016-12-20 Thread David Vincent
When using an alternative as an initscript, the ordering between
update-rc.d and update-alternatives tasks during prerm and postinst
tasks must always be the following in order to work:
  * prerm:
- stop daemon
- remove alternative

  * postinst:
- add alternative
- start daemon

This patchset adds comments to the scripts generated by both classes and
organize the generated sections based on those comments.

[YOCTO #10433]

Changes since v5:
- Remove boolean in d.getVar() calls

Signed-off-by: David Vincent <freesili...@gmail.com>
---
 meta/classes/update-alternatives.bbclass | 29 ++---
 meta/classes/update-rc.d.bbclass | 20 ++--
 2 files changed, 40 insertions(+), 9 deletions(-)

diff --git a/meta/classes/update-alternatives.bbclass 
b/meta/classes/update-alternatives.bbclass
index 0460bf0241..a90ef19e45 100644
--- a/meta/classes/update-alternatives.bbclass
+++ b/meta/classes/update-alternatives.bbclass
@@ -195,8 +195,8 @@ python populate_packages_updatealternatives () {
 pkgdest = d.getVar('PKGD')
 for pkg in (d.getVar('PACKAGES') or "").split():
 # Create post install/removal scripts
-alt_setup_links = ""
-alt_remove_links = ""
+alt_setup_links = "# Begin section update-alternatives\n"
+alt_remove_links = "# Begin section update-alternatives\n"
 for alt_name in (d.getVar('ALTERNATIVE_%s' % pkg) or "").split():
 alt_link = d.getVarFlag('ALTERNATIVE_LINK_NAME', alt_name)
 alt_target   = d.getVarFlag('ALTERNATIVE_TARGET_%s' % pkg, 
alt_name) or d.getVarFlag('ALTERNATIVE_TARGET', alt_name)
@@ -219,10 +219,13 @@ python populate_packages_updatealternatives () {
 # Default to generate shell script.. eventually we may want to 
change this...
 alt_target = os.path.normpath(alt_target)
 
-alt_setup_links  += '\tupdate-alternatives --install %s %s %s 
%s\n' % (alt_link, alt_name, alt_target, alt_priority)
-alt_remove_links += '\tupdate-alternatives --remove  %s %s\n' % 
(alt_name, alt_target)
+alt_setup_links  += 'update-alternatives --install %s %s %s %s\n' 
% (alt_link, alt_name, alt_target, alt_priority)
+alt_remove_links += 'update-alternatives --remove  %s %s\n' % 
(alt_name, alt_target)
 
-if alt_setup_links:
+alt_setup_links += "# End section update-alternatives\n"
+alt_remove_links += "# End section update-alternatives\n"
+
+if len(alt_setup_links.splitlines()) > 2:
 # RDEPENDS setup
 provider = d.getVar('VIRTUAL-RUNTIME_update-alternatives')
 if provider:
@@ -232,12 +235,24 @@ python populate_packages_updatealternatives () {
 bb.note('adding update-alternatives calls to postinst/prerm for 
%s' % pkg)
 bb.note('%s' % alt_setup_links)
 postinst = d.getVar('pkg_postinst_%s' % pkg) or '#!/bin/sh\n'
-postinst += alt_setup_links
+postinst = postinst.splitlines(True)
+try:
+index = postinst.index('# Begin section update-rc.d\n')
+postinst.insert(index, alt_setup_links)
+except ValueError:
+postinst.append(alt_setup_links)
+postinst = ''.join(postinst)
 d.setVar('pkg_postinst_%s' % pkg, postinst)
 
 bb.note('%s' % alt_remove_links)
 prerm = d.getVar('pkg_prerm_%s' % pkg) or '#!/bin/sh\n'
-prerm += alt_remove_links
+prerm = prerm.splitlines(True)
+try:
+index = prerm.index('# End section update-rc.d\n')
+prerm.insert(index + 1, alt_remove_links)
+except ValueError:
+prerm.append(alt_remove_links)
+prerm = ''.join(prerm)
 d.setVar('pkg_prerm_%s' % pkg, prerm)
 }
 
diff --git a/meta/classes/update-rc.d.bbclass b/meta/classes/update-rc.d.bbclass
index 2746c360fe..9d3a7bc0c7 100644
--- a/meta/classes/update-rc.d.bbclass
+++ b/meta/classes/update-rc.d.bbclass
@@ -35,6 +35,7 @@ fi
 }
 
 updatercd_postinst() {
+# Begin section update-rc.d
 if ${@use_updatercd(d)} && type update-rc.d >/dev/null 2>/dev/null; then
if [ -n "$D" ]; then
OPT="-r $D"
@@ -43,12 +44,15 @@ if ${@use_updatercd(d)} && type update-rc.d >/dev/null 
2>/dev/null; then
fi
update-rc.d $OPT ${INITSCRIPT_NAME} ${INITSCRIPT_PARAMS}
 fi
+# End section update-rc.d
 }
 
 updatercd_prerm() {
+# Begin section update-rc.d
 if ${@use_updatercd(d)} && [ -z "$D" -a -x "${INIT_D_DIR}/${INITSCRIPT_NAME}" 
]; then
${INIT_D_DIR}/${INITSCRIPT_NAME} stop || :
 fi
+# End section update-rc.d
 }
 
 updatercd_postrm() {
@@ -111,13 +115,25 @@ python populate_packages_updat

[OE-core] [PATCH v5] classes: Fix alternatives and rc.d ordering

2016-12-12 Thread David Vincent
When using an alternative as an initscript, the ordering between
update-rc.d and update-alternatives tasks during prerm and postinst
tasks must always be the following in order to work:
  * prerm:
- stop daemon
- remove alternative

  * postinst:
- add alternative
- start daemon

This patchset adds comments to the scripts generated by both classes and
organize the generated sections based on those comments.

[YOCTO #10433]

Signed-off-by: David Vincent <freesili...@gmail.com>
---
 meta/classes/update-alternatives.bbclass | 29 ++---
 meta/classes/update-rc.d.bbclass | 20 ++--
 2 files changed, 40 insertions(+), 9 deletions(-)

diff --git a/meta/classes/update-alternatives.bbclass 
b/meta/classes/update-alternatives.bbclass
index 1fdd681315..65929e 100644
--- a/meta/classes/update-alternatives.bbclass
+++ b/meta/classes/update-alternatives.bbclass
@@ -195,8 +195,8 @@ python populate_packages_updatealternatives () {
 pkgdest = d.getVar('PKGD', True)
 for pkg in (d.getVar('PACKAGES', True) or "").split():
 # Create post install/removal scripts
-alt_setup_links = ""
-alt_remove_links = ""
+alt_setup_links = "# Begin section update-alternatives\n"
+alt_remove_links = "# Begin section update-alternatives\n"
 for alt_name in (d.getVar('ALTERNATIVE_%s' % pkg, True) or "").split():
 alt_link = d.getVarFlag('ALTERNATIVE_LINK_NAME', alt_name, 
True)
 alt_target   = d.getVarFlag('ALTERNATIVE_TARGET_%s' % pkg, 
alt_name, True) or d.getVarFlag('ALTERNATIVE_TARGET', alt_name, True)
@@ -219,10 +219,13 @@ python populate_packages_updatealternatives () {
 # Default to generate shell script.. eventually we may want to 
change this...
 alt_target = os.path.normpath(alt_target)
 
-alt_setup_links  += '\tupdate-alternatives --install %s %s %s 
%s\n' % (alt_link, alt_name, alt_target, alt_priority)
-alt_remove_links += '\tupdate-alternatives --remove  %s %s\n' % 
(alt_name, alt_target)
+alt_setup_links  += 'update-alternatives --install %s %s %s %s\n' 
% (alt_link, alt_name, alt_target, alt_priority)
+alt_remove_links += 'update-alternatives --remove  %s %s\n' % 
(alt_name, alt_target)
 
-if alt_setup_links:
+alt_setup_links += "# End section update-alternatives\n"
+alt_remove_links += "# End section update-alternatives\n"
+
+if len(alt_setup_links.splitlines()) > 2:
 # RDEPENDS setup
 provider = d.getVar('VIRTUAL-RUNTIME_update-alternatives', True)
 if provider:
@@ -232,12 +235,24 @@ python populate_packages_updatealternatives () {
 bb.note('adding update-alternatives calls to postinst/prerm for 
%s' % pkg)
 bb.note('%s' % alt_setup_links)
 postinst = d.getVar('pkg_postinst_%s' % pkg, True) or '#!/bin/sh\n'
-postinst += alt_setup_links
+postinst = postinst.splitlines(True)
+try:
+index = postinst.index('# Begin section update-rc.d\n')
+postinst.insert(index, alt_setup_links)
+except ValueError:
+postinst.append(alt_setup_links)
+postinst = ''.join(postinst)
 d.setVar('pkg_postinst_%s' % pkg, postinst)
 
 bb.note('%s' % alt_remove_links)
 prerm = d.getVar('pkg_prerm_%s' % pkg, True) or '#!/bin/sh\n'
-prerm += alt_remove_links
+prerm = prerm.splitlines(True)
+try:
+index = prerm.index('# End section update-rc.d\n')
+prerm.insert(index + 1, alt_remove_links)
+except ValueError:
+prerm.append(alt_remove_links)
+prerm = ''.join(prerm)
 d.setVar('pkg_prerm_%s' % pkg, prerm)
 }
 
diff --git a/meta/classes/update-rc.d.bbclass b/meta/classes/update-rc.d.bbclass
index 2c3ef9edd1..530de87270 100644
--- a/meta/classes/update-rc.d.bbclass
+++ b/meta/classes/update-rc.d.bbclass
@@ -35,6 +35,7 @@ fi
 }
 
 updatercd_postinst() {
+# Begin section update-rc.d
 if ${@use_updatercd(d)} && type update-rc.d >/dev/null 2>/dev/null; then
if [ -n "$D" ]; then
OPT="-r $D"
@@ -43,12 +44,15 @@ if ${@use_updatercd(d)} && type update-rc.d >/dev/null 
2>/dev/null; then
fi
update-rc.d $OPT ${INITSCRIPT_NAME} ${INITSCRIPT_PARAMS}
 fi
+# End section update-rc.d
 }
 
 updatercd_prerm() {
+# Begin section update-rc.d
 if ${@use_updatercd(d)} && [ -z "$D" -a -x "${INIT_D_DIR}/${INITSCRIPT_NAME}" 
]; then
${INIT_D_DIR}/${INITSCRIPT_NAME} stop || :
 fi
+# End section update-rc.d
 }
 
 updatercd_postrm() {
@@ -111,13 +115,25 @@ python populate_packages_updatercd (

[OE-core] [PATCH v4] rootfs: Modify RPM installation

2016-12-12 Thread David Vincent
When using a custom RPM data directory instead of the default dir
'/var/lib/rpm', the final image did not contain any of the database
files in the expected location. This commit takes into account the
'rpmlibdir' variable set into 'rootfs_rpm.bbclass'.

Signed-off-by: David Vincent <freesili...@gmail.com>
---
 meta/lib/oe/package_manager.py | 23 +--
 meta/lib/oe/rootfs.py  |  3 ++-
 2 files changed, 15 insertions(+), 11 deletions(-)

diff --git a/meta/lib/oe/package_manager.py b/meta/lib/oe/package_manager.py
index e5e3c3b679..e063ee 100644
--- a/meta/lib/oe/package_manager.py
+++ b/meta/lib/oe/package_manager.py
@@ -352,7 +352,8 @@ class RpmPkgsList(PkgsList):
 super(RpmPkgsList, self).__init__(d, rootfs_dir)
 
 self.rpm_cmd = bb.utils.which(os.getenv('PATH'), "rpm")
-self.image_rpmlib = os.path.join(self.rootfs_dir, 'var/lib/rpm')
+self.rpm_libdir = self.d.getVar('rpmlibdir', True)
+self.image_rpmlib = os.path.join(self.rootfs_dir, self.rpm_libdir[1:])
 
 self.ml_prefix_list, self.ml_os_list = \
 RpmIndexer(d, rootfs_dir).get_ml_prefix_and_os_list(arch_var, 
os_var)
@@ -412,7 +413,7 @@ class RpmPkgsList(PkgsList):
 
 def list_pkgs(self):
 cmd = [self.rpm_cmd, '--root', self.rootfs_dir]
-cmd.extend(['-D', '_dbpath /var/lib/rpm'])
+cmd.extend(['-D', '_dbpath', self.rpm_libdir])
 cmd.extend(['-qa', '--qf', '[%{NAME} %{ARCH} %{VERSION} 
%{PACKAGEORIGIN}\n]'])
 
 try:
@@ -679,7 +680,8 @@ class RpmPM(PackageManager):
 self.solution_manifest = self.d.expand('${T}/saved/%s_solution' %
self.task_name)
 self.saved_rpmlib = self.d.expand('${T}/saved/%s' % self.task_name)
-self.image_rpmlib = os.path.join(self.target_rootfs, 'var/lib/rpm')
+self.rpm_libdir = self.d.getVar('rpmlibdir', True)
+self.image_rpmlib = os.path.join(self.target_rootfs, 
self.rpm_libdir[1:])
 
 if not os.path.exists(self.d.expand('${T}/saved')):
 bb.utils.mkdirhier(self.d.expand('${T}/saved'))
@@ -950,7 +952,7 @@ class RpmPM(PackageManager):
 open(db_config_dir, 'w+').write(DB_CONFIG_CONTENT)
 
 # Create database so that smart doesn't complain (lazy init)
-cmd = [self.rpm_cmd, '--root', self.target_rootfs, '--dbpath', 
'/var/lib/rpm', '-qa']
+cmd = [self.rpm_cmd, '--root', self.target_rootfs, '--dbpath', 
self.rpm_libdir, '-qa']
 try:
 subprocess.check_output(cmd, stderr=subprocess.STDOUT)
 except subprocess.CalledProcessError as e:
@@ -959,20 +961,19 @@ class RpmPM(PackageManager):
 # Import GPG key to RPM database of the target system
 if self.d.getVar('RPM_SIGN_PACKAGES', True) == '1':
 pubkey_path = self.d.getVar('RPM_GPG_PUBKEY', True)
-cmd = [self.rpm_cmd, '--root', self.target_rootfs, '--dbpath', 
'/var/lib/rpm', '--import', pubkey_path]
+cmd = [self.rpm_cmd, '--root', self.target_rootfs, '--dbpath', 
self.rpm_libdir, '--import', pubkey_path]
 try:
 subprocess.check_output(cmd, stderr=subprocess.STDOUT)
 except subprocess.CalledProcessError as e:
 bb.fatal("Import GPG key failed. Command '%s' "
 "returned %d:\n%s" % (' '.join(cmd), e.returncode, 
e.output.decode("utf-8")))
 
-
 # Configure smart
 bb.note("configuring Smart settings")
 bb.utils.remove(os.path.join(self.target_rootfs, 'var/lib/smart'),
 True)
 self._invoke_smart(['config', '--set', 'rpm-root=%s' % 
self.target_rootfs])
-self._invoke_smart(['config', '--set', 'rpm-dbpath=/var/lib/rpm'])
+self._invoke_smart(['config', '--set', 'rpm-dbpath=%s' % 
self.rpm_libdir])
 self._invoke_smart(['config', '--set', 'rpm-extra-macros._var=%s' %
self.d.getVar('localstatedir', True)])
 cmd = ["config", "--set", "rpm-extra-macros._tmppath=/%s/tmp" % 
self.install_dir_name]
@@ -1232,7 +1233,7 @@ class RpmPM(PackageManager):
 
 if not with_dependencies:
 cmd = [self.rpm_cmd] + ["-e", "--nodeps", "--root=%s" %
-self.target_rootfs, "--dbpath=/var/lib/rpm",
+self.target_rootfs, "--dbpath=%s" % self.rpm_libdir,
 "--define='_cross_scriptlet_wrapper %s'" %
 self.scriptlet_wrapper,
 "--define='_tmppath /%s/tmp'" % self.install_dir_name] + 
pkgs
@@ -1380,7 +1381,8 @@ class RpmPM(PackageManager):
 saved_dir = self.target_rootfs + 
self.d.expand('${sysconfdir}/rpm-postinsts/') + new_pkg
 
 cmd = self.rpm_cmd + ' -q --scripts --root ' + self.target_rootfs

[OE-core] [PATCH v4] classes: Fix alternatives and rc.d ordering

2016-11-28 Thread David Vincent

Changes since v3:
* Count the number of lines produced by update-alternatives to detect if
  lines were inserted. Failing to do so introduced bugs in native
  packages (e.g. binutils-cross-canadian-arm)
-- 
___
Openembedded-core mailing list
Openembedded-core@lists.openembedded.org
http://lists.openembedded.org/mailman/listinfo/openembedded-core


[OE-core] [PATCH] classes: Fix alternatives and rc.d ordering

2016-11-28 Thread David Vincent
When using an alternative as an initscript, the ordering between
update-rc.d and update-alternatives tasks during prerm and postinst
tasks must always be the following in order to work:
  * prerm:
- stop daemon
- remove alternative

  * postinst:
- add alternative
- start daemon

This patchset adds comments to the scripts generated by both classes and
organize the generated sections based on those comments.

[YOCTO #10433]

Signed-off-by: David Vincent <freesili...@gmail.com>
---
 meta/classes/update-alternatives.bbclass | 29 ++---
 meta/classes/update-rc.d.bbclass | 20 ++--
 2 files changed, 40 insertions(+), 9 deletions(-)

diff --git a/meta/classes/update-alternatives.bbclass 
b/meta/classes/update-alternatives.bbclass
index 1fdd681..65929e5 100644
--- a/meta/classes/update-alternatives.bbclass
+++ b/meta/classes/update-alternatives.bbclass
@@ -195,8 +195,8 @@ python populate_packages_updatealternatives () {
 pkgdest = d.getVar('PKGD', True)
 for pkg in (d.getVar('PACKAGES', True) or "").split():
 # Create post install/removal scripts
-alt_setup_links = ""
-alt_remove_links = ""
+alt_setup_links = "# Begin section update-alternatives\n"
+alt_remove_links = "# Begin section update-alternatives\n"
 for alt_name in (d.getVar('ALTERNATIVE_%s' % pkg, True) or "").split():
 alt_link = d.getVarFlag('ALTERNATIVE_LINK_NAME', alt_name, 
True)
 alt_target   = d.getVarFlag('ALTERNATIVE_TARGET_%s' % pkg, 
alt_name, True) or d.getVarFlag('ALTERNATIVE_TARGET', alt_name, True)
@@ -219,10 +219,13 @@ python populate_packages_updatealternatives () {
 # Default to generate shell script.. eventually we may want to 
change this...
 alt_target = os.path.normpath(alt_target)
 
-alt_setup_links  += '\tupdate-alternatives --install %s %s %s 
%s\n' % (alt_link, alt_name, alt_target, alt_priority)
-alt_remove_links += '\tupdate-alternatives --remove  %s %s\n' % 
(alt_name, alt_target)
+alt_setup_links  += 'update-alternatives --install %s %s %s %s\n' 
% (alt_link, alt_name, alt_target, alt_priority)
+alt_remove_links += 'update-alternatives --remove  %s %s\n' % 
(alt_name, alt_target)
 
-if alt_setup_links:
+alt_setup_links += "# End section update-alternatives\n"
+alt_remove_links += "# End section update-alternatives\n"
+
+if len(alt_setup_links.splitlines()) > 2:
 # RDEPENDS setup
 provider = d.getVar('VIRTUAL-RUNTIME_update-alternatives', True)
 if provider:
@@ -232,12 +235,24 @@ python populate_packages_updatealternatives () {
 bb.note('adding update-alternatives calls to postinst/prerm for 
%s' % pkg)
 bb.note('%s' % alt_setup_links)
 postinst = d.getVar('pkg_postinst_%s' % pkg, True) or '#!/bin/sh\n'
-postinst += alt_setup_links
+postinst = postinst.splitlines(True)
+try:
+index = postinst.index('# Begin section update-rc.d\n')
+postinst.insert(index, alt_setup_links)
+except ValueError:
+postinst.append(alt_setup_links)
+postinst = ''.join(postinst)
 d.setVar('pkg_postinst_%s' % pkg, postinst)
 
 bb.note('%s' % alt_remove_links)
 prerm = d.getVar('pkg_prerm_%s' % pkg, True) or '#!/bin/sh\n'
-prerm += alt_remove_links
+prerm = prerm.splitlines(True)
+try:
+index = prerm.index('# End section update-rc.d\n')
+prerm.insert(index + 1, alt_remove_links)
+except ValueError:
+prerm.append(alt_remove_links)
+prerm = ''.join(prerm)
 d.setVar('pkg_prerm_%s' % pkg, prerm)
 }
 
diff --git a/meta/classes/update-rc.d.bbclass b/meta/classes/update-rc.d.bbclass
index 321924b..18df2dc 100644
--- a/meta/classes/update-rc.d.bbclass
+++ b/meta/classes/update-rc.d.bbclass
@@ -26,6 +26,7 @@ fi
 }
 
 updatercd_postinst() {
+# Begin section update-rc.d
 if type update-rc.d >/dev/null 2>/dev/null; then
if [ -n "$D" ]; then
OPT="-r $D"
@@ -34,12 +35,15 @@ if type update-rc.d >/dev/null 2>/dev/null; then
fi
update-rc.d $OPT ${INITSCRIPT_NAME} ${INITSCRIPT_PARAMS}
 fi
+# End section update-rc.d
 }
 
 updatercd_prerm() {
+# Begin section update-rc.d
 if [ -z "$D" -a -x "${INIT_D_DIR}/${INITSCRIPT_NAME}" ]; then
${INIT_D_DIR}/${INITSCRIPT_NAME} stop || :
 fi
+# End section update-rc.d
 }
 
 updatercd_postrm() {
@@ -102,13 +106,25 @@ python populate_packages_updatercd () {
 postinst = d.getVar('pkg_postinst_%s' % pkg, True)
 if not postinst:
 postinst

Re: [OE-core] [PATCH v3] rootfs: Modify RPM installation

2016-11-28 Thread David Vincent
On vendredi 25 novembre 2016 13:09:30 CET Mark Hatle wrote:
> On 11/25/16 12:17 PM, Burton, Ross wrote:
> > On 24 November 2016 at 10:49, David Vincent <freesili...@gmail.com
> > 
> > <mailto:freesili...@gmail.com>> wrote:
> > -self._setup_dbg_rootfs(['/etc/rpm', '/var/lib/rpm',
> > '/var/lib/smart']) +self._setup_dbg_rootfs(['/etc/rpm',
> > rpm_libdir, '/var/lib/smart'])> 
> > Can we extend the un-hardcoding so this uses ${localstatedir}/lib/smart,
> > and rpmlibdir also uses ${localstatedir}?
> 
> The value for the rpm directory is hard coded into the configuration file.
> Anything we do outside of that MUST match.  Inspect the rpm macros file for
> the matching value.  (This is why /var/lib/rpm was hard coded in the past.)

And that was the root cause of the problem when rpmlibdir is modified from its 
default value. Maybe the rpmlibdir variable should be documented in the ref-
manual for those who wants to tinker with it.

> 
> As for smart, I don't remember the rules offhand, so someone will need to
> figure out if it's variable (compile time) or hard coded.
> 
> --Mark
> 
> > Also current master lets you not bother passing True to d.getVar() as that
> > is the default now.

So should I send a v4 ?

> > 
> > Ross


-- 
___
Openembedded-core mailing list
Openembedded-core@lists.openembedded.org
http://lists.openembedded.org/mailman/listinfo/openembedded-core


[OE-core] [PATCH v3] rootfs: Modify RPM installation

2016-11-24 Thread David Vincent
When using a custom RPM data directory instead of the default dir
'/var/lib/rpm', the final image did not contain any of the database
files in the expected location. This commit takes into account the
'rpmlibdir' variable set into 'rootfs_rpm.bbclass'.

Signed-off-by: David Vincent <freesili...@gmail.com>
---
 meta/lib/oe/package_manager.py | 26 +++---
 meta/lib/oe/rootfs.py  |  3 ++-
 2 files changed, 17 insertions(+), 12 deletions(-)

diff --git a/meta/lib/oe/package_manager.py b/meta/lib/oe/package_manager.py
index 7ba2e4d..6344543 100644
--- a/meta/lib/oe/package_manager.py
+++ b/meta/lib/oe/package_manager.py
@@ -352,7 +352,8 @@ class RpmPkgsList(PkgsList):
 super(RpmPkgsList, self).__init__(d, rootfs_dir)
 
 self.rpm_cmd = bb.utils.which(os.getenv('PATH'), "rpm")
-self.image_rpmlib = os.path.join(self.rootfs_dir, 'var/lib/rpm')
+self.rpm_libdir = self.d.getVar('rpmlibdir', True)
+self.image_rpmlib = os.path.join(self.rootfs_dir, self.rpm_libdir[1:])
 
 self.ml_prefix_list, self.ml_os_list = \
 RpmIndexer(d, rootfs_dir).get_ml_prefix_and_os_list(arch_var, 
os_var)
@@ -413,7 +414,7 @@ class RpmPkgsList(PkgsList):
 
 def list_pkgs(self):
 cmd = self.rpm_cmd + ' --root ' + self.rootfs_dir
-cmd += ' -D "_dbpath /var/lib/rpm" -qa'
+cmd += ' -D "_dbpath %s" -qa' % self.rpm_libdir
 cmd += " --qf '[%{NAME} %{ARCH} %{VERSION} %{PACKAGEORIGIN}\n]'"
 
 try:
@@ -681,7 +682,8 @@ class RpmPM(PackageManager):
 self.solution_manifest = self.d.expand('${T}/saved/%s_solution' %
self.task_name)
 self.saved_rpmlib = self.d.expand('${T}/saved/%s' % self.task_name)
-self.image_rpmlib = os.path.join(self.target_rootfs, 'var/lib/rpm')
+self.rpm_libdir = self.d.getVar('rpmlibdir', True)
+self.image_rpmlib = os.path.join(self.target_rootfs, 
self.rpm_libdir[1:])
 
 if not os.path.exists(self.d.expand('${T}/saved')):
 bb.utils.mkdirhier(self.d.expand('${T}/saved'))
@@ -950,8 +952,8 @@ class RpmPM(PackageManager):
 
 # Create database so that smart doesn't complain (lazy init)
 opt = "-qa"
-cmd = "%s --root %s --dbpath /var/lib/rpm %s > /dev/null" % (
-  self.rpm_cmd, self.target_rootfs, opt)
+cmd = "%s --root %s --dbpath %s %s > /dev/null" % (
+  self.rpm_cmd, self.target_rootfs, self.rpm_libdir, opt)
 try:
 subprocess.check_output(cmd, stderr=subprocess.STDOUT, shell=True)
 except subprocess.CalledProcessError as e:
@@ -960,8 +962,8 @@ class RpmPM(PackageManager):
 # Import GPG key to RPM database of the target system
 if self.d.getVar('RPM_SIGN_PACKAGES', True) == '1':
 pubkey_path = self.d.getVar('RPM_GPG_PUBKEY', True)
-cmd = "%s --root %s --dbpath /var/lib/rpm --import %s > /dev/null" 
% (
-  self.rpm_cmd, self.target_rootfs, pubkey_path)
+cmd = "%s --root %s --dbpath %s --import %s > /dev/null" % (
+  self.rpm_cmd, self.target_rootfs, self.rpm_libdir, 
pubkey_path)
 subprocess.check_output(cmd, stderr=subprocess.STDOUT, shell=True)
 
 # Configure smart
@@ -969,7 +971,7 @@ class RpmPM(PackageManager):
 bb.utils.remove(os.path.join(self.target_rootfs, 'var/lib/smart'),
 True)
 self._invoke_smart('config --set rpm-root=%s' % self.target_rootfs)
-self._invoke_smart('config --set rpm-dbpath=/var/lib/rpm')
+self._invoke_smart('config --set rpm-dbpath=%s' % self.rpm_libdir)
 self._invoke_smart('config --set rpm-extra-macros._var=%s' %
self.d.getVar('localstatedir', True))
 cmd = "config --set rpm-extra-macros._tmppath=/%s/tmp" % 
(self.install_dir_name)
@@ -1231,7 +1233,7 @@ class RpmPM(PackageManager):
 if not with_dependencies:
 cmd = "%s -e --nodeps " % self.rpm_cmd
 cmd += "--root=%s " % self.target_rootfs
-cmd += "--dbpath=/var/lib/rpm "
+cmd += "--dbpath=%s " % self.rpm_libdir
 cmd += "--define='_cross_scriptlet_wrapper %s' " % \
self.scriptlet_wrapper
 cmd += "--define='_tmppath /%s/tmp' %s" % (self.install_dir_name, 
' '.join(pkgs))
@@ -1385,7 +1387,8 @@ class RpmPM(PackageManager):
 saved_dir = self.target_rootfs + 
self.d.expand('${sysconfdir}/rpm-postinsts/') + new_pkg
 
 cmd = self.rpm_cmd + ' -q --scripts --root ' + self.target_rootfs
-cmd += ' --dbpath=/var/lib/rpm ' + new_pkg
+cmd += ' --dbpath=%s ' %  self.rpm_libdir
+cmd += new_pkg
 cmd += ' | sed -n -e "/^postinst

[OE-core] [PATCH] slang: Disable parallel make install

2016-11-24 Thread David Vincent
Installation task fails if run in parallel. This case happens if we
define PARALLEL_MAKEINST to a different value of PARALLEL_MAKE.

Signed-off-by: David Vincent <freesili...@gmail.com>
---
 meta/recipes-extended/slang/slang_2.3.0.bb | 1 +
 1 file changed, 1 insertion(+)

diff --git a/meta/recipes-extended/slang/slang_2.3.0.bb 
b/meta/recipes-extended/slang/slang_2.3.0.bb
index 52b2a63..d5967d2 100644
--- a/meta/recipes-extended/slang/slang_2.3.0.bb
+++ b/meta/recipes-extended/slang/slang_2.3.0.bb
@@ -53,5 +53,6 @@ do_install() {
 FILES_${PN} += "${libdir}/${BPN}/v2/modules/ ${datadir}/slsh/"
 
 PARALLEL_MAKE = ""
+PARALLEL_MAKEINST = ""
 
 BBCLASSEXTEND = "native"
-- 
2.10.2

-- 
___
Openembedded-core mailing list
Openembedded-core@lists.openembedded.org
http://lists.openembedded.org/mailman/listinfo/openembedded-core


[OE-core] [PATCH v3] rootfs: Modify RPM installation

2016-11-24 Thread David Vincent
When using a custom RPM data directory instead of the default dir
'/var/lib/rpm', the final image did not contain any of the database
files in the expected location. This commit takes into account the
'rpmlibdir' variable set into 'rootfs_rpm.bbclass'.

Signed-off-by: David Vincent <freesili...@gmail.com>
---
 meta/lib/oe/package_manager.py | 26 +++---
 meta/lib/oe/rootfs.py  |  3 ++-
 2 files changed, 17 insertions(+), 12 deletions(-)

diff --git a/meta/lib/oe/package_manager.py b/meta/lib/oe/package_manager.py
index 7ba2e4d..6344543 100644
--- a/meta/lib/oe/package_manager.py
+++ b/meta/lib/oe/package_manager.py
@@ -352,7 +352,8 @@ class RpmPkgsList(PkgsList):
 super(RpmPkgsList, self).__init__(d, rootfs_dir)
 
 self.rpm_cmd = bb.utils.which(os.getenv('PATH'), "rpm")
-self.image_rpmlib = os.path.join(self.rootfs_dir, 'var/lib/rpm')
+self.rpm_libdir = self.d.getVar('rpmlibdir', True)
+self.image_rpmlib = os.path.join(self.rootfs_dir, self.rpm_libdir[1:])
 
 self.ml_prefix_list, self.ml_os_list = \
 RpmIndexer(d, rootfs_dir).get_ml_prefix_and_os_list(arch_var, 
os_var)
@@ -413,7 +414,7 @@ class RpmPkgsList(PkgsList):
 
 def list_pkgs(self):
 cmd = self.rpm_cmd + ' --root ' + self.rootfs_dir
-cmd += ' -D "_dbpath /var/lib/rpm" -qa'
+cmd += ' -D "_dbpath %s" -qa' % self.rpm_libdir
 cmd += " --qf '[%{NAME} %{ARCH} %{VERSION} %{PACKAGEORIGIN}\n]'"
 
 try:
@@ -681,7 +682,8 @@ class RpmPM(PackageManager):
 self.solution_manifest = self.d.expand('${T}/saved/%s_solution' %
self.task_name)
 self.saved_rpmlib = self.d.expand('${T}/saved/%s' % self.task_name)
-self.image_rpmlib = os.path.join(self.target_rootfs, 'var/lib/rpm')
+self.rpm_libdir = self.d.getVar('rpmlibdir', True)
+self.image_rpmlib = os.path.join(self.target_rootfs, 
self.rpm_libdir[1:])
 
 if not os.path.exists(self.d.expand('${T}/saved')):
 bb.utils.mkdirhier(self.d.expand('${T}/saved'))
@@ -950,8 +952,8 @@ class RpmPM(PackageManager):
 
 # Create database so that smart doesn't complain (lazy init)
 opt = "-qa"
-cmd = "%s --root %s --dbpath /var/lib/rpm %s > /dev/null" % (
-  self.rpm_cmd, self.target_rootfs, opt)
+cmd = "%s --root %s --dbpath %s %s > /dev/null" % (
+  self.rpm_cmd, self.target_rootfs, self.rpm_libdir, opt)
 try:
 subprocess.check_output(cmd, stderr=subprocess.STDOUT, shell=True)
 except subprocess.CalledProcessError as e:
@@ -960,8 +962,8 @@ class RpmPM(PackageManager):
 # Import GPG key to RPM database of the target system
 if self.d.getVar('RPM_SIGN_PACKAGES', True) == '1':
 pubkey_path = self.d.getVar('RPM_GPG_PUBKEY', True)
-cmd = "%s --root %s --dbpath /var/lib/rpm --import %s > /dev/null" 
% (
-  self.rpm_cmd, self.target_rootfs, pubkey_path)
+cmd = "%s --root %s --dbpath %s --import %s > /dev/null" % (
+  self.rpm_cmd, self.target_rootfs, self.rpm_libdir, 
pubkey_path)
 subprocess.check_output(cmd, stderr=subprocess.STDOUT, shell=True)
 
 # Configure smart
@@ -969,7 +971,7 @@ class RpmPM(PackageManager):
 bb.utils.remove(os.path.join(self.target_rootfs, 'var/lib/smart'),
 True)
 self._invoke_smart('config --set rpm-root=%s' % self.target_rootfs)
-self._invoke_smart('config --set rpm-dbpath=/var/lib/rpm')
+self._invoke_smart('config --set rpm-dbpath=%s' % self.rpm_libdir)
 self._invoke_smart('config --set rpm-extra-macros._var=%s' %
self.d.getVar('localstatedir', True))
 cmd = "config --set rpm-extra-macros._tmppath=/%s/tmp" % 
(self.install_dir_name)
@@ -1231,7 +1233,7 @@ class RpmPM(PackageManager):
 if not with_dependencies:
 cmd = "%s -e --nodeps " % self.rpm_cmd
 cmd += "--root=%s " % self.target_rootfs
-cmd += "--dbpath=/var/lib/rpm "
+cmd += "--dbpath=%s " % self.rpm_libdir
 cmd += "--define='_cross_scriptlet_wrapper %s' " % \
self.scriptlet_wrapper
 cmd += "--define='_tmppath /%s/tmp' %s" % (self.install_dir_name, 
' '.join(pkgs))
@@ -1385,7 +1387,8 @@ class RpmPM(PackageManager):
 saved_dir = self.target_rootfs + 
self.d.expand('${sysconfdir}/rpm-postinsts/') + new_pkg
 
 cmd = self.rpm_cmd + ' -q --scripts --root ' + self.target_rootfs
-cmd += ' --dbpath=/var/lib/rpm ' + new_pkg
+cmd += ' --dbpath=%s ' %  self.rpm_libdir
+cmd += new_pkg
 cmd += ' | sed -n -e "/^postinst

[OE-core] [PATCH v3] classes: Fix alternatives and rc.d ordering

2016-11-24 Thread David Vincent
When using an alternative as an initscript, the ordering between
update-rc.d and update-alternatives tasks during prerm and postinst
tasks must always be the following in order to work:
  * prerm:
- stop daemon
- remove alternative

  * postinst:
- add alternative
- start daemon

This patchset adds comments to the scripts generated by both classes and
organize the generated sections based on those comments.

[YOCTO #10433]

Signed-off-by: David Vincent <freesili...@gmail.com>
---
 meta/classes/update-alternatives.bbclass | 27 +--
 meta/classes/update-rc.d.bbclass | 20 ++--
 2 files changed, 39 insertions(+), 8 deletions(-)

diff --git a/meta/classes/update-alternatives.bbclass 
b/meta/classes/update-alternatives.bbclass
index 1fdd681..bbd5a47 100644
--- a/meta/classes/update-alternatives.bbclass
+++ b/meta/classes/update-alternatives.bbclass
@@ -195,8 +195,8 @@ python populate_packages_updatealternatives () {
 pkgdest = d.getVar('PKGD', True)
 for pkg in (d.getVar('PACKAGES', True) or "").split():
 # Create post install/removal scripts
-alt_setup_links = ""
-alt_remove_links = ""
+alt_setup_links = "# Begin section update-alternatives\n"
+alt_remove_links = "# Begin section update-alternatives\n"
 for alt_name in (d.getVar('ALTERNATIVE_%s' % pkg, True) or "").split():
 alt_link = d.getVarFlag('ALTERNATIVE_LINK_NAME', alt_name, 
True)
 alt_target   = d.getVarFlag('ALTERNATIVE_TARGET_%s' % pkg, 
alt_name, True) or d.getVarFlag('ALTERNATIVE_TARGET', alt_name, True)
@@ -219,8 +219,11 @@ python populate_packages_updatealternatives () {
 # Default to generate shell script.. eventually we may want to 
change this...
 alt_target = os.path.normpath(alt_target)
 
-alt_setup_links  += '\tupdate-alternatives --install %s %s %s 
%s\n' % (alt_link, alt_name, alt_target, alt_priority)
-alt_remove_links += '\tupdate-alternatives --remove  %s %s\n' % 
(alt_name, alt_target)
+alt_setup_links  += 'update-alternatives --install %s %s %s %s\n' 
% (alt_link, alt_name, alt_target, alt_priority)
+alt_remove_links += 'update-alternatives --remove  %s %s\n' % 
(alt_name, alt_target)
+
+alt_setup_links += "# End section update-alternatives\n"
+alt_remove_links += "# End section update-alternatives\n"
 
 if alt_setup_links:
 # RDEPENDS setup
@@ -232,12 +235,24 @@ python populate_packages_updatealternatives () {
 bb.note('adding update-alternatives calls to postinst/prerm for 
%s' % pkg)
 bb.note('%s' % alt_setup_links)
 postinst = d.getVar('pkg_postinst_%s' % pkg, True) or '#!/bin/sh\n'
-postinst += alt_setup_links
+postinst = postinst.splitlines(True)
+try:
+index = postinst.index('# Begin section update-rc.d\n')
+postinst.insert(index, alt_setup_links)
+except ValueError:
+postinst.append(alt_setup_links)
+postinst = ''.join(postinst)
 d.setVar('pkg_postinst_%s' % pkg, postinst)
 
 bb.note('%s' % alt_remove_links)
 prerm = d.getVar('pkg_prerm_%s' % pkg, True) or '#!/bin/sh\n'
-prerm += alt_remove_links
+prerm = prerm.splitlines(True)
+try:
+index = prerm.index('# End section update-rc.d\n')
+prerm.insert(index + 1, alt_remove_links)
+except ValueError:
+prerm.append(alt_remove_links)
+prerm = ''.join(prerm)
 d.setVar('pkg_prerm_%s' % pkg, prerm)
 }
 
diff --git a/meta/classes/update-rc.d.bbclass b/meta/classes/update-rc.d.bbclass
index 321924b..18df2dc 100644
--- a/meta/classes/update-rc.d.bbclass
+++ b/meta/classes/update-rc.d.bbclass
@@ -26,6 +26,7 @@ fi
 }
 
 updatercd_postinst() {
+# Begin section update-rc.d
 if type update-rc.d >/dev/null 2>/dev/null; then
if [ -n "$D" ]; then
OPT="-r $D"
@@ -34,12 +35,15 @@ if type update-rc.d >/dev/null 2>/dev/null; then
fi
update-rc.d $OPT ${INITSCRIPT_NAME} ${INITSCRIPT_PARAMS}
 fi
+# End section update-rc.d
 }
 
 updatercd_prerm() {
+# Begin section update-rc.d
 if [ -z "$D" -a -x "${INIT_D_DIR}/${INITSCRIPT_NAME}" ]; then
${INIT_D_DIR}/${INITSCRIPT_NAME} stop || :
 fi
+# End section update-rc.d
 }
 
 updatercd_postrm() {
@@ -102,13 +106,25 @@ python populate_packages_updatercd () {
 postinst = d.getVar('pkg_postinst_%s' % pkg, True)
 if not postinst:
 postinst = '#!/bin/sh\n'
-postinst += localdata.getVar('updatercd_postinst', True)
+postinst = postinst.splitlines(True)
+try:
+index = 

[OE-core] [PATCH v2] classes: Fix alternatives and rc.d ordering

2016-11-24 Thread David Vincent
When using an alternative as an initscript, the ordering between
update-rc.d and update-alternatives tasks during prerm and postinst
tasks must always be the following in order to work:
  * prerm:
- stop daemon
- remove alternative

  * postinst:
- add alternative
- start daemon

This patchset adds comments to the scripts generated by both classes and
organize the generated sections based on those comments.

[YOCTO #10433]

Signed-off-by: David Vincent <freesili...@gmail.com>
---
 meta/classes/update-alternatives.bbclass | 27 +--
 meta/classes/update-rc.d.bbclass | 20 ++--
 2 files changed, 39 insertions(+), 8 deletions(-)

diff --git a/meta/classes/update-alternatives.bbclass
b/meta/classes/update-alternatives.bbclass
index 1fdd681..bbd5a47 100644
--- a/meta/classes/update-alternatives.bbclass
+++ b/meta/classes/update-alternatives.bbclass
@@ -195,8 +195,8 @@ python populate_packages_updatealternatives () {
 pkgdest = d.getVar('PKGD', True)
 for pkg in (d.getVar('PACKAGES', True) or "").split():
 # Create post install/removal scripts
-alt_setup_links = ""
-alt_remove_links = ""
+alt_setup_links = "# Begin section update-alternatives\n"
+alt_remove_links = "# Begin section update-alternatives\n"
 for alt_name in (d.getVar('ALTERNATIVE_%s' % pkg, True) or "").split():
 alt_link = d.getVarFlag('ALTERNATIVE_LINK_NAME',
alt_name, True)
 alt_target   = d.getVarFlag('ALTERNATIVE_TARGET_%s' %
pkg, alt_name, True) or d.getVarFlag('ALTERNATIVE_TARGET', alt_name,
True)
@@ -219,8 +219,11 @@ python populate_packages_updatealternatives () {
 # Default to generate shell script.. eventually we may
want to change this...
 alt_target = os.path.normpath(alt_target)

-alt_setup_links  += '\tupdate-alternatives --install %s
%s %s %s\n' % (alt_link, alt_name, alt_target, alt_priority)
-alt_remove_links += '\tupdate-alternatives --remove  %s
%s\n' % (alt_name, alt_target)
+alt_setup_links  += 'update-alternatives --install %s %s
%s %s\n' % (alt_link, alt_name, alt_target, alt_priority)
+alt_remove_links += 'update-alternatives --remove  %s
%s\n' % (alt_name, alt_target)
+
+alt_setup_links += "# End section update-alternatives\n"
+alt_remove_links += "# End section update-alternatives\n"

 if alt_setup_links:
 # RDEPENDS setup
@@ -232,12 +235,24 @@ python populate_packages_updatealternatives () {
 bb.note('adding update-alternatives calls to
postinst/prerm for %s' % pkg)
 bb.note('%s' % alt_setup_links)
 postinst = d.getVar('pkg_postinst_%s' % pkg, True) or '#!/bin/sh\n'
-postinst += alt_setup_links
+postinst = postinst.splitlines(True)
+try:
+index = postinst.index('# Begin section update-rc.d\n')
+postinst.insert(index, alt_setup_links)
+except ValueError:
+postinst.append(alt_setup_links)
+postinst = ''.join(postinst)
 d.setVar('pkg_postinst_%s' % pkg, postinst)

 bb.note('%s' % alt_remove_links)
 prerm = d.getVar('pkg_prerm_%s' % pkg, True) or '#!/bin/sh\n'
-prerm += alt_remove_links
+prerm = prerm.splitlines(True)
+try:
+index = prerm.index('# End section update-rc.d\n')
+prerm.insert(index + 1, alt_remove_links)
+except ValueError:
+prerm.append(alt_remove_links)
+prerm = ''.join(prerm)
 d.setVar('pkg_prerm_%s' % pkg, prerm)
 }

diff --git a/meta/classes/update-rc.d.bbclass b/meta/classes/update-rc.d.bbclass
index 321924b..18df2dc 100644
--- a/meta/classes/update-rc.d.bbclass
+++ b/meta/classes/update-rc.d.bbclass
@@ -26,6 +26,7 @@ fi
 }

 updatercd_postinst() {
+# Begin section update-rc.d
 if type update-rc.d >/dev/null 2>/dev/null; then
  if [ -n "$D" ]; then
  OPT="-r $D"
@@ -34,12 +35,15 @@ if type update-rc.d >/dev/null 2>/dev/null; then
  fi
  update-rc.d $OPT ${INITSCRIPT_NAME} ${INITSCRIPT_PARAMS}
 fi
+# End section update-rc.d
 }

 updatercd_prerm() {
+# Begin section update-rc.d
 if [ -z "$D" -a -x "${INIT_D_DIR}/${INITSCRIPT_NAME}" ]; then
  ${INIT_D_DIR}/${INITSCRIPT_NAME} stop || :
 fi
+# End section update-rc.d
 }

 updatercd_postrm() {
@@ -102,13 +106,25 @@ python populate_packages_updatercd () {
 postinst = d.getVar('pkg_postinst_%s' % pkg, True)
 if not postinst:
 postinst = '#!/bin/sh\n'
-postinst += localdata.getVar('updatercd_postinst', True)
+postinst = postinst.splitlines(True)
+try:
+index = postinst.index('# End section update-alternatives\n')
+   

[OE-core] [PATCH] classes: Fix alternatives and rc.d ordering

2016-11-23 Thread David Vincent
When using an alternative as an initscript, the ordering between
update-rc.d and update-alternatives tasks during prerm and postinst
tasks must always be the following in order to work:
  * prerm:
- stop daemon
- remove alternative

  * postinst:
- add alternative
- start daemon

This patchset adds comments to the scripts generated by both classes and
organize the generated sections based on those comments.

[YOCTO #10433]

Signed-off-by: David Vincent <freesili...@gmail.com>
---
 meta/classes/update-alternatives.bbclass | 27 +--
 meta/classes/update-rc.d.bbclass | 20 ++--
 2 files changed, 39 insertions(+), 8 deletions(-)

diff --git a/meta/classes/update-alternatives.bbclass
b/meta/classes/update-alternatives.bbclass
index 1fdd681..e84a6cd 100644
--- a/meta/classes/update-alternatives.bbclass
+++ b/meta/classes/update-alternatives.bbclass
@@ -195,8 +195,8 @@ python populate_packages_updatealternatives () {
 pkgdest = d.getVar('PKGD', True)
 for pkg in (d.getVar('PACKAGES', True) or "").split():
 # Create post install/removal scripts
-alt_setup_links = ""
-alt_remove_links = ""
+alt_setup_links = "# Begin section update-alternatives\n"
+alt_remove_links = "# Begin section update-alternatives\n"
 for alt_name in (d.getVar('ALTERNATIVE_%s' % pkg, True) or "").split():
 alt_link = d.getVarFlag('ALTERNATIVE_LINK_NAME',
alt_name, True)
 alt_target   = d.getVarFlag('ALTERNATIVE_TARGET_%s' %
pkg, alt_name, True) or d.getVarFlag('ALTERNATIVE_TARGET', alt_name,
True)
@@ -219,8 +219,11 @@ python populate_packages_updatealternatives () {
 # Default to generate shell script.. eventually we may
want to change this...
 alt_target = os.path.normpath(alt_target)

-alt_setup_links  += '\tupdate-alternatives --install %s
%s %s %s\n' % (alt_link, alt_name, alt_target, alt_priority)
-alt_remove_links += '\tupdate-alternatives --remove  %s
%s\n' % (alt_name, alt_target)
+alt_setup_links  += 'update-alternatives --install %s %s
%s %s\n' % (alt_link, alt_name, alt_target, alt_priority)
+alt_remove_links += 'update-alternatives --remove  %s
%s\n' % (alt_name, alt_target)
+
+alt_setup_links += "# End section update-alternatives\n"
+alt_remove_links += "# End section update-alternatives\n"

 if alt_setup_links:
 # RDEPENDS setup
@@ -232,12 +235,24 @@ python populate_packages_updatealternatives () {
 bb.note('adding update-alternatives calls to
postinst/prerm for %s' % pkg)
 bb.note('%s' % alt_setup_links)
 postinst = d.getVar('pkg_postinst_%s' % pkg, True) or '#!/bin/sh\n'
-postinst += alt_setup_links
+postinst = postinst.splitlines(True)
+try:
+index = postinst.index('# Begin section update-rc.d\n')
+postinst.insert(index, alt_setup_links)
+except ValueError:
+postinst.append(alt_setup_links)
+postinst = ''.join(postinst)
 d.setVar('pkg_postinst_%s' % pkg, postinst)

 bb.note('%s' % alt_remove_links)
 prerm = d.getVar('pkg_prerm_%s' % pkg, True) or '#!/bin/sh\n'
-prerm += alt_remove_links
+prerm = prerm.splitlines(True)
+try:
+index = prerm.index('# End section update-rc.d\n')
+prerm.insert(index + 1, alt_remove_links)
+except ValueError:
+prerm.append(alt_remove_links)
+prerm = ''.join(prerm)
 d.setVar('pkg_prerm_%s' % pkg, prerm)
 }

diff --git a/meta/classes/update-rc.d.bbclass b/meta/classes/update-rc.d.bbclass
index 321924b..18df2dc 100644
--- a/meta/classes/update-rc.d.bbclass
+++ b/meta/classes/update-rc.d.bbclass
@@ -26,6 +26,7 @@ fi
 }

 updatercd_postinst() {
+# Begin section update-rc.d
 if type update-rc.d >/dev/null 2>/dev/null; then
  if [ -n "$D" ]; then
  OPT="-r $D"
@@ -34,12 +35,15 @@ if type update-rc.d >/dev/null 2>/dev/null; then
  fi
  update-rc.d $OPT ${INITSCRIPT_NAME} ${INITSCRIPT_PARAMS}
 fi
+# End section update-rc.d
 }

 updatercd_prerm() {
+# Begin section update-rc.d
 if [ -z "$D" -a -x "${INIT_D_DIR}/${INITSCRIPT_NAME}" ]; then
  ${INIT_D_DIR}/${INITSCRIPT_NAME} stop || :
 fi
+# End section update-rc.d
 }

 updatercd_postrm() {
@@ -102,13 +106,25 @@ python populate_packages_updatercd () {
 postinst = d.getVar('pkg_postinst_%s' % pkg, True)
 if not postinst:
 postinst = '#!/bin/sh\n'
-postinst += localdata.getVar('updatercd_postinst', True)
+postinst = postinst.splitlines(True)
+try:
+index = postinst.index('# End section update-alternatives\n')
+   

[OE-core] [PATCH][jethro] rootfs: Modify RPM installation

2016-07-08 Thread David Vincent
When using a custom RPM data directory instead of the default dir
'/var/lib/rpm', the final image did not contain any of the database
files in the expected location. This commit takes into account the
'rpmlibdir' variable set into 'rootfs_rpm.bbclass'.

Signed-off-by: David Vincent <freesili...@gmail.com>
---
 meta/lib/oe/package_manager.py | 26 +++---
 meta/lib/oe/rootfs.py  |  3 ++-
 2 files changed, 17 insertions(+), 12 deletions(-)

diff --git a/meta/lib/oe/package_manager.py b/meta/lib/oe/package_manager.py
index b9fa6d8..83c9858 100644
--- a/meta/lib/oe/package_manager.py
+++ b/meta/lib/oe/package_manager.py
@@ -302,7 +302,8 @@ class RpmPkgsList(PkgsList):
 super(RpmPkgsList, self).__init__(d, rootfs_dir)

 self.rpm_cmd = bb.utils.which(os.getenv('PATH'), "rpm")
-self.image_rpmlib = os.path.join(self.rootfs_dir, 'var/lib/rpm')
+self.rpm_libdir = self.d.getVar('rpmlibdir', True)
+self.image_rpmlib = os.path.join(self.rootfs_dir, self.rpm_libdir[1:])

 self.ml_prefix_list, self.ml_os_list = \
 RpmIndexer(d,
rootfs_dir).get_ml_prefix_and_os_list(arch_var, os_var)
@@ -369,7 +370,7 @@ class RpmPkgsList(PkgsList):
 return self._list_pkg_deps()

 cmd = self.rpm_cmd + ' --root ' + self.rootfs_dir
-cmd += ' -D "_dbpath /var/lib/rpm" -qa'
+cmd += ' -D "_dbpath %s" -qa' % self.rpm_libdir
 if self.rpm_version == 4:
 cmd += " --qf '[%{NAME} %{ARCH} %{VERSION}\n]'"
 else:
@@ -670,7 +671,8 @@ class RpmPM(PackageManager):
 self.solution_manifest = self.d.expand('${T}/saved/%s_solution' %
self.task_name)
 self.saved_rpmlib = self.d.expand('${T}/saved/%s' % self.task_name)
-self.image_rpmlib = os.path.join(self.target_rootfs, 'var/lib/rpm')
+self.rpm_libdir = self.d.getVar('rpmlibdir', True)
+self.image_rpmlib = os.path.join(self.target_rootfs,
self.rpm_libdir[1:])

 if not os.path.exists(self.d.expand('${T}/saved')):
 bb.utils.mkdirhier(self.d.expand('${T}/saved'))
@@ -924,8 +926,8 @@ class RpmPM(PackageManager):
 opt = "-qa"
 if self.rpm_version == 4:
 opt = "--initdb"
-cmd = "%s --root %s --dbpath /var/lib/rpm %s > /dev/null" % (
-  self.rpm_cmd, self.target_rootfs, opt)
+cmd = "%s --root %s --dbpath %s %s > /dev/null" % (
+  self.rpm_cmd, self.target_rootfs, self.rpm_libdir, opt)
 try:
 subprocess.check_output(cmd, stderr=subprocess.STDOUT, shell=True)
 except subprocess.CalledProcessError as e:
@@ -934,8 +936,8 @@ class RpmPM(PackageManager):
 # Import GPG key to RPM database of the target system
 if self.d.getVar('RPM_SIGN_PACKAGES', True) == '1':
 pubkey_path = self.d.getVar('RPM_GPG_PUBKEY', True)
-cmd = "%s --root %s --dbpath /var/lib/rpm --import %s >
/dev/null" % (
-  self.rpm_cmd, self.target_rootfs, pubkey_path)
+cmd = "%s --root %s --dbpath %s --import %s > /dev/null" % (
+  self.rpm_cmd, self.target_rootfs, self.rpm_libdir,
pubkey_path)
 subprocess.check_output(cmd, stderr=subprocess.STDOUT, shell=True)

 # Configure smart
@@ -943,7 +945,7 @@ class RpmPM(PackageManager):
 bb.utils.remove(os.path.join(self.target_rootfs, 'var/lib/smart'),
 True)
 self._invoke_smart('config --set rpm-root=%s' % self.target_rootfs)
-self._invoke_smart('config --set rpm-dbpath=/var/lib/rpm')
+self._invoke_smart('config --set rpm-dbpath=%s' % self.rpm_libdir)
 self._invoke_smart('config --set rpm-extra-macros._var=%s' %
self.d.getVar('localstatedir', True))
 cmd = "config --set rpm-extra-macros._tmppath=/%s/tmp" %
(self.install_dir_name)
@@ -1179,7 +1181,7 @@ class RpmPM(PackageManager):
 if not with_dependencies:
 cmd = "%s -e --nodeps " % self.rpm_cmd
 cmd += "--root=%s " % self.target_rootfs
-cmd += "--dbpath=/var/lib/rpm "
+cmd += "--dbpath=%s " % self.rpm_libdir
 cmd += "--define='_cross_scriptlet_wrapper %s' " % \
self.scriptlet_wrapper
 cmd += "--define='_tmppath /%s/tmp' %s" %
(self.install_dir_name, ' '.join(pkgs))
@@ -1333,7 +1335,8 @@ class RpmPM(PackageManager):
 saved_dir = self.target_rootfs +
self.d.expand('${sysconfdir}/rpm-postinsts/') + new_pkg

 cmd = self.rpm_cmd + ' -q --scripts --root ' + self.target_rootfs
-cmd += ' --dbpath=/var/lib/rpm ' + new_pkg
+cmd += ' --dbpath=%s ' %  self.rpm_libdir
+cmd += new_pkg
 cmd

[OE-core] [OE-Core][PATCH] rootfs: Modify RPM installation

2016-07-08 Thread David Vincent
When using a custom RPM data directory instead of the default dir
'/var/lib/rpm', the final image did not contain any of the database
files in the expected location. This commit takes into account the
'rpmlibdir' variable set into 'rootfs_rpm.bbclass'.

Signed-off-by: David Vincent <freesili...@gmail.com>
---
 meta/lib/oe/package_manager.py | 26 +++---
 meta/lib/oe/rootfs.py  |  3 ++-
 2 files changed, 17 insertions(+), 12 deletions(-)

diff --git a/meta/lib/oe/package_manager.py b/meta/lib/oe/package_manager.py
index 2004a42..8dd7567 100644
--- a/meta/lib/oe/package_manager.py
+++ b/meta/lib/oe/package_manager.py
@@ -351,7 +351,8 @@ class RpmPkgsList(PkgsList):
 super(RpmPkgsList, self).__init__(d, rootfs_dir)

 self.rpm_cmd = bb.utils.which(os.getenv('PATH'), "rpm")
-self.image_rpmlib = os.path.join(self.rootfs_dir, 'var/lib/rpm')
+self.rpm_libdir = self.d.getVar('rpmlibdir', True)
+self.image_rpmlib = os.path.join(self.rootfs_dir, self.rpm_libdir[1:])

 self.ml_prefix_list, self.ml_os_list = \
 RpmIndexer(d,
rootfs_dir).get_ml_prefix_and_os_list(arch_var, os_var)
@@ -412,7 +413,7 @@ class RpmPkgsList(PkgsList):

 def list_pkgs(self):
 cmd = self.rpm_cmd + ' --root ' + self.rootfs_dir
-cmd += ' -D "_dbpath /var/lib/rpm" -qa'
+cmd += ' -D "_dbpath %s" -qa' % self.rpm_libdir
 cmd += " --qf '[%{NAME} %{ARCH} %{VERSION} %{PACKAGEORIGIN}\n]'"

 try:
@@ -680,7 +681,8 @@ class RpmPM(PackageManager):
 self.solution_manifest = self.d.expand('${T}/saved/%s_solution' %
self.task_name)
 self.saved_rpmlib = self.d.expand('${T}/saved/%s' % self.task_name)
-self.image_rpmlib = os.path.join(self.target_rootfs, 'var/lib/rpm')
+self.rpm_libdir = self.d.getVar('rpmlibdir', True)
+self.image_rpmlib = os.path.join(self.target_rootfs,
self.rpm_libdir[1:])

 if not os.path.exists(self.d.expand('${T}/saved')):
 bb.utils.mkdirhier(self.d.expand('${T}/saved'))
@@ -944,8 +946,8 @@ class RpmPM(PackageManager):

 # Create database so that smart doesn't complain (lazy init)
 opt = "-qa"
-cmd = "%s --root %s --dbpath /var/lib/rpm %s > /dev/null" % (
-  self.rpm_cmd, self.target_rootfs, opt)
+cmd = "%s --root %s --dbpath %s %s > /dev/null" % (
+  self.rpm_cmd, self.target_rootfs, self.rpm_libdir, opt)
 try:
 subprocess.check_output(cmd, stderr=subprocess.STDOUT, shell=True)
 except subprocess.CalledProcessError as e:
@@ -954,8 +956,8 @@ class RpmPM(PackageManager):
 # Import GPG key to RPM database of the target system
 if self.d.getVar('RPM_SIGN_PACKAGES', True) == '1':
 pubkey_path = self.d.getVar('RPM_GPG_PUBKEY', True)
-cmd = "%s --root %s --dbpath /var/lib/rpm --import %s >
/dev/null" % (
-  self.rpm_cmd, self.target_rootfs, pubkey_path)
+cmd = "%s --root %s --dbpath %s --import %s > /dev/null" % (
+  self.rpm_cmd, self.target_rootfs, self.rpm_libdir,
pubkey_path)
 subprocess.check_output(cmd, stderr=subprocess.STDOUT, shell=True)

 # Configure smart
@@ -963,7 +965,7 @@ class RpmPM(PackageManager):
 bb.utils.remove(os.path.join(self.target_rootfs, 'var/lib/smart'),
 True)
 self._invoke_smart('config --set rpm-root=%s' % self.target_rootfs)
-self._invoke_smart('config --set rpm-dbpath=/var/lib/rpm')
+self._invoke_smart('config --set rpm-dbpath=%s' % self.rpm_libdir)
 self._invoke_smart('config --set rpm-extra-macros._var=%s' %
self.d.getVar('localstatedir', True))
 cmd = "config --set rpm-extra-macros._tmppath=/%s/tmp" %
(self.install_dir_name)
@@ -1212,7 +1214,7 @@ class RpmPM(PackageManager):
 if not with_dependencies:
 cmd = "%s -e --nodeps " % self.rpm_cmd
 cmd += "--root=%s " % self.target_rootfs
-cmd += "--dbpath=/var/lib/rpm "
+cmd += "--dbpath=%s " % self.rpm_libdir
 cmd += "--define='_cross_scriptlet_wrapper %s' " % \
self.scriptlet_wrapper
 cmd += "--define='_tmppath /%s/tmp' %s" %
(self.install_dir_name, ' '.join(pkgs))
@@ -1366,7 +1368,8 @@ class RpmPM(PackageManager):
 saved_dir = self.target_rootfs +
self.d.expand('${sysconfdir}/rpm-postinsts/') + new_pkg

 cmd = self.rpm_cmd + ' -q --scripts --root ' + self.target_rootfs
-cmd += ' --dbpath=/var/lib/rpm ' + new_pkg
+cmd += ' --dbpath=%s ' %  self.rpm_libdir
+cmd += new_pkg
 cmd += ' | sed -n -e "/^postinstall scriptlet

Re: [OE-core] [PATCH] barebox: Add recipe

2014-07-30 Thread David Vincent
Hi all,

Sorry to come back on this subject, but what is the current status of
this request?

Do you need more background? Are you waiting for more opinions or a
vote on this subject? Should I submit a v2 of this patch with what we
have discussed to make it more polished for OE-Core (or another
layer)?

Again, sorry for the noise!

Greetings,
David

2014-07-28 16:42 GMT+02:00 Eric Bénard e...@eukrea.com:
 Hi David,

 Le Mon, 28 Jul 2014 14:15:12 +0200,
 David Vincent freesili...@gmail.com a écrit :
  Why don't you use $BAREBOX_BINARY instead of hardcoding
  barebox-flash-image which won't work on old versions of barebox where
  barebox's binary is named barebox.bin ?

 I didn't know that, but I am not sure I can use $BAREBOX_BINARY since
 this variable is used in $DEPLOY_DIR. I tried to mimic u-boot recipe
 behavior as much as possible.

 you can use the variable as it's defined upper. u-boot recipe does it
 this way :
 http://cgit.openembedded.org/openembedded-core/tree/meta/recipes-bsp/u-boot/u-boot.inc#n19
 http://cgit.openembedded.org/openembedded-core/tree/meta/recipes-bsp/u-boot/u-boot.inc#n63

 FWIW you can find here the initial barebox recipe we have in
 meta-fsl-arm :
 https://github.com/Freescale/meta-fsl-arm/tree/master/recipes-bsp/barebox

 Best regards,
 Eric
-- 
___
Openembedded-core mailing list
Openembedded-core@lists.openembedded.org
http://lists.openembedded.org/mailman/listinfo/openembedded-core


Re: [OE-core] [RFC 1/1] add support for the barebox bootloader

2014-07-30 Thread David Vincent
Hi Stefan,

This recipe is more complete than what I've previously submitted and,
I think, is a better base for barebox initial support in OE-Core. Just
like it has already been said, maybe barebox target tools should have
their own recipe. However, I'd be happy to help further developments
on this recipe.

Greetings,
David

2014-07-30 13:49 GMT+02:00 Stefan Müller-Klieser s.mueller-klie...@phytec.de:
 Barebox is a bootloader that inherits the best of U-Boot and the Linux
 kernel. The barebox uses kconfig and kbuild mechanisms similar to the
 Linux kernel. This is reflected in the recipe. As soon as this
 functionality gets more abstraction in classes, the barebox recipe can
 be simplified. The recipe supports: kconfig handling, kconfig fragments,
 packages for dev tools and support for the initial program loader
 creation.

 Signed-off-by: Stefan Müller-Klieser s.mueller-klie...@phytec.de
 ---
  meta/recipes-bsp/barebox/barebox-ipl.inc  |  37 +
  meta/recipes-bsp/barebox/barebox-ipl_2014.07.0.bb |   4 +
  meta/recipes-bsp/barebox/barebox.inc  | 161 
 ++
  meta/recipes-bsp/barebox/barebox_2014.07.0.bb |   4 +
  4 files changed, 206 insertions(+)
  create mode 100644 meta/recipes-bsp/barebox/barebox-ipl.inc
  create mode 100644 meta/recipes-bsp/barebox/barebox-ipl_2014.07.0.bb
  create mode 100644 meta/recipes-bsp/barebox/barebox.inc
  create mode 100644 meta/recipes-bsp/barebox/barebox_2014.07.0.bb

 diff --git a/meta/recipes-bsp/barebox/barebox-ipl.inc 
 b/meta/recipes-bsp/barebox/barebox-ipl.inc
 new file mode 100644
 index 000..f388522
 --- /dev/null
 +++ b/meta/recipes-bsp/barebox/barebox-ipl.inc
 @@ -0,0 +1,37 @@
 +# Copyright (C) 2014 Stefan Mueller-Klieser s.mueller-klie...@phytec.de \
 +# PHYTEC Messtechnik GmbH
 +# Recipe released under the GPL-3.0 license
 +
 +require barebox.inc
 +
 +DESCRIPTION = Barebox IPL Inintial Program Loader: some machines need \
 +   a pre-bootloader. This one gets build by the barebox.
 +PROVIDES = barebox-ipl
 +S = ${WORKDIR}/barebox-${PV}
 +
 +# Pre Bootloader
 +BAREBOX_IPL_BIN ?= barebox.bin
 +BAREBOX_IPL_BIN_DEPLOY ?= IPL-${MACHINE}-${PV}-${PR}.bin
 +BAREBOX_IPL_BIN_SYMLINK ?= IPL
 +BAREBOX_IPL_DEFAULT_DEFCONFIG ?= am335x_mlo_defconfig
 +
 +do_default_defconfig () {
 +   bbnote generating .config for target 
 ${BAREBOX_IPL_DEFAULT_DEFCONFIG}
 +   unset CFLAGS LDFLAGS
 +   oe_runmake ${BAREBOX_IPL_DEFAULT_DEFCONFIG}
 +}
 +
 +do_install () {
 +   bbnote Installing barebox-ipl image on target rootfs
 +   install -d ${D}${base_bootdir}
 +   install ${S}/${BAREBOX_IPL_BIN} 
 ${D}${base_bootdir}/${BAREBOX_IPL_BIN_DEPLOY}
 +   ln -sf ${BAREBOX_IPL_BIN_DEPLOY} 
 ${D}${base_bootdir}/${BAREBOX_IPL_BIN_SYMLINK}
 +}
 +FILES_${PN} = 
 +FILES_${PN} = ${base_bootdir}
 +
 +do_deploy () {
 +   bbnote Deploying barebox ipl
 +   install ${S}/${BAREBOX_IPL_BIN} ${DEPLOYDIR}/${BAREBOX_IPL_BIN_DEPLOY}
 +   ln -sf ${BAREBOX_IPL_BIN_DEPLOY} 
 ${DEPLOYDIR}/${BAREBOX_IPL_BIN_SYMLINK}
 +}
 diff --git a/meta/recipes-bsp/barebox/barebox-ipl_2014.07.0.bb 
 b/meta/recipes-bsp/barebox/barebox-ipl_2014.07.0.bb
 new file mode 100644
 index 000..372828a
 --- /dev/null
 +++ b/meta/recipes-bsp/barebox/barebox-ipl_2014.07.0.bb
 @@ -0,0 +1,4 @@
 +require barebox-ipl.inc
 +
 +SRC_URI[md5sum] = f3a93950777916d4b1c2cd366aec8d91
 +SRC_URI[sha256sum] = 
 6dca5c78de8565a15aaa404edbf1bc4663415f0dc69e094f3b621636876285f2
 diff --git a/meta/recipes-bsp/barebox/barebox.inc 
 b/meta/recipes-bsp/barebox/barebox.inc
 new file mode 100644
 index 000..b7885df
 --- /dev/null
 +++ b/meta/recipes-bsp/barebox/barebox.inc
 @@ -0,0 +1,161 @@
 +# Copyright (C) 2014 Stefan Mueller-Klieser s.mueller-klie...@phytec.de
 +# PHYTEC Messtechnik GmbH
 +# Recipe released under the GPL-3.0 license
 +#
 +# TODO: see if there is some development towards moving all kconfig
 +#   funcionality into the kconfig-frontends package and adjust
 +#   the recipe accordingly.
 +#
 +
 +SUMMARY = The Barebox Bootloader
 +DESCRIPTION = Barebox (formerly known as u-boot-v2) is a bootloader that \
 +   inherits the best of U-Boot and the Linux kernel: The size 
 and \
 +  look-and-feel of u-boot, with driver model and lots of design \
 +  concepts from the kernel. \
 +  The bb recipe adds config fragment support and kconfig \
 +  command handling using the yocto kern-tools-native.
 +HOMEPAGE = http://www.barebox.org;
 +SECTION = bootloaders
 +PROVIDES = virtual/bootloader barebox
 +LICENSE = GPL-2.0
 +LIC_FILES_CHKSUM = file://COPYING;md5=057bf9e50e1ca857d0eb97bfe4ba8e5d
 +SRC_URI = http://barebox.org/download/barebox-${PV}.tar.bz2;
 +
 +inherit kernel-arch cml1 deploy
 +DEPENDS += kern-tools-native
 +PACKAGE_ARCH = ${MACHINE_ARCH}
 +# verbose build 0/1
 +VERBOSE_BUILD ?= 0
 +EXTRA_OEMAKE = 'V=${VERBOSE_BUILD} CROSS_COMPILE=${TARGET_PREFIX} 
 CC=${TARGET_PREFIX}gcc 

[OE-core] [PATCH] barebox: Add recipe

2014-07-28 Thread David Vincent
barebox (formerly known as u-boot-v2) is a bootloader that inherits the
best of U-Boot and the Linux kernel. This commit adds the possibility to
use it as a virtual/bootloader instead of U-Boot.

Signed-off-by: David Vincent freesili...@gmail.com
---
 meta/recipes-bsp/barebox/barebox.inc  |   73 +
 meta/recipes-bsp/barebox/barebox_2014.07.0.bb |   15 +
 2 files changed, 88 insertions(+)
 create mode 100644 meta/recipes-bsp/barebox/barebox.inc
 create mode 100644 meta/recipes-bsp/barebox/barebox_2014.07.0.bb

diff --git a/meta/recipes-bsp/barebox/barebox.inc 
b/meta/recipes-bsp/barebox/barebox.inc
new file mode 100644
index 000..68aeb68
--- /dev/null
+++ b/meta/recipes-bsp/barebox/barebox.inc
@@ -0,0 +1,73 @@
+SUMMARY = The Barebox Bootloader
+DESCRIPTION = Barebox (formerly known as u-boot-v2) is a bootloader that 
inherits the best of U-Boot and the Linux kernel: The size and look-and-feel of 
u-boot, with driver model and lots of design concepts from the kernel.
+HOMEPAGE = http://www.barebox.org;
+SECTION = bootloaders
+PROVIDES = virtual/bootloader
+
+inherit cml1 deploy kernel-arch
+
+EXTRA_OEMAKE = 'CROSS_COMPILE=${TARGET_PREFIX} CC=${TARGET_PREFIX}gcc 
${TOOLCHAIN_OPTIONS}'
+
+BAREBOX_BINARY ?= barebox.bin
+BAREBOX_IMAGE ?= barebox-${MACHINE}-${PV}-${PR}.bin
+BAREBOX_SYMLINK ?= barebox-${MACHINE}.bin
+
+do_configure () {
+   # Copy defconfig to .config if .config does not exist. This allows
+   # recipes to manage the .config themselves in do_configure_prepend().
+   if [ -f ${WORKDIR}/defconfig ]  [ ! -f ${B}/.config ]; then
+   cp ${WORKDIR}/defconfig ${B}/.config
+   fi
+
+   # Use board default defconfig if .config does not exist. This allows
+   # recipes to manage the .config themselves in do_configure_prepend().
+   if [ ! -f ${B}/.config ]; then
+   oe_runmake_call ${BAREBOX_TARGET}
+   fi
+
+   cml1_do_configure
+}
+
+do_compile () {
+   if [ ${@bb.utils.contains('DISTRO_FEATURES', 'ld-is-gold', 
'ld-is-gold', '', d)} = ld-is-gold ] ; then
+   sed -i 's/$(CROSS_COMPILE)ld$/$(CROSS_COMPILE)ld.bfd/g' 
${S}/Makefile
+   fi
+
+   unset CFLAGS CPPFLAGS LDFLAGS
+   oe_runmake
+}
+
+do_install () {
+   install -d ${D}/boot
+   install ${S}/barebox-flash-image ${D}/boot/${BAREBOX_IMAGE}
+   ln -sf ${BAREBOX_IMAGE} ${D}/boot/${BAREBOX_BINARY}
+
+   # Install target tools if available
+   install -d ${D}${sbindir}
+
+   if [ -e ${WORKDIR}/scripts/bareboxenv-target ]; then
+   install -m 0755 ${WORKDIR}/scripts/bareboxenv-target 
${D}${sbindir}/bareboxenv
+   fi
+
+   if [ -e ${WORKDIR}/scripts/bareboxcrc32-target ]; then
+   install -m 0755 ${WORKDIR}/scripts/bareboxcrc32-target 
${D}${sbindir}/bareboxcrc32
+   fi
+
+   if [ -e ${WORKDIR}/scripts/kernel-install-target ]; then
+   install -m 0755 ${WORKDIR}/scripts/kernel-install-target 
${D}${sbindir}/kernel-install
+   fi
+}
+
+FILES_${PN} = /boot ${sbindir}
+
+do_deploy () {
+   install -d ${DEPLOYDIR}
+   install ${S}/barebox-flash-image ${DEPLOYDIR}/${BAREBOX_IMAGE}
+
+   cd ${DEPLOYDIR}
+   rm -f ${BAREBOX_BINARY} ${BAREBOX_SYMLINK}
+   ln -sf ${BAREBOX_IMAGE} ${BAREBOX_SYMLINK}
+   ln -sf ${BAREBOX_IMAGE} ${BAREBOX_BINARY}
+}
+
+addtask deploy before do_build after do_compile
diff --git a/meta/recipes-bsp/barebox/barebox_2014.07.0.bb 
b/meta/recipes-bsp/barebox/barebox_2014.07.0.bb
new file mode 100644
index 000..6adbff4
--- /dev/null
+++ b/meta/recipes-bsp/barebox/barebox_2014.07.0.bb
@@ -0,0 +1,15 @@
+require barebox.inc
+
+# To build barebox for your machine, provide the following lines in your 
machine
+# config, replacing the assignments as appropriate for your machine.
+# BAREBOX_MACHINE = sandbox
+# BAREBOX_TARGET = sandbox_defconfig
+
+LICENSE = GPLv2
+LIC_FILES_CHKSUM = file://COPYING;md5=057bf9e50e1ca857d0eb97bfe4ba8e5d
+
+SRC_URI = http://www.barebox.org/download/${PN}-${PV}.tar.bz2;
+SRC_URI[md5sum] = f3a93950777916d4b1c2cd366aec8d91
+SRC_URI[sha256sum] = 
6dca5c78de8565a15aaa404edbf1bc4663415f0dc69e094f3b621636876285f2
+
+PACKAGE_ARCH = ${MACHINE_ARCH}
-- 
1.7.10.4

-- 
___
Openembedded-core mailing list
Openembedded-core@lists.openembedded.org
http://lists.openembedded.org/mailman/listinfo/openembedded-core


[OE-core] Fwd: [PATCH] barebox: Add recipe

2014-07-28 Thread David Vincent
Sorry, the patch alone was maybe a little harsh, I should have
submitted it as a RFC.
For me, this recipe was needed because I don't use u-boot as the
bootloader for my custom board but barebox. More generically, I know
that the meta-fsl-arm has also a recipe for barebox and since my board
was not based on a Freescale MPU but an Atmel one, I thought that the
work could be shared by the two layers in oe-core or, at least, in
meta-oe instead of being also redeveloped in meta-atmel or another BSP
layer.

Since barebox also supports many architectures like ARM, MIPS,
Blackfin,... and many vendors like Atmel, Freescale, TI,... I think it
provides a good alternative for the 'virtual/bootloader' task. People
who want to use it should not put more effort than what they need to
do for u-boot currently.

I've cc'ed the barebox mailing list for more technical details if needed.

Greetings,

David

2014-07-28 12:23 GMT+02:00 Richard Purdie richard.pur...@linuxfoundation.org:
 On Mon, 2014-07-28 at 11:55 +0200, David Vincent wrote:
 barebox (formerly known as u-boot-v2) is a bootloader that inherits the
 best of U-Boot and the Linux kernel. This commit adds the possibility to
 use it as a virtual/bootloader instead of U-Boot.

 Signed-off-by: David Vincent freesili...@gmail.com
 ---
  meta/recipes-bsp/barebox/barebox.inc  |   73 
 +
  meta/recipes-bsp/barebox/barebox_2014.07.0.bb |   15 +
  2 files changed, 88 insertions(+)
  create mode 100644 meta/recipes-bsp/barebox/barebox.inc
  create mode 100644 meta/recipes-bsp/barebox/barebox_2014.07.0.bb

 I have to admit I don't know a lot about this. To make it into OE-Core
 we need some kind of story about why its necessary and commonly used.
 Are there a number of BSPs using this? Can you give some background to
 why this is needed?

 Cheers,

 Richard

-- 
___
Openembedded-core mailing list
Openembedded-core@lists.openembedded.org
http://lists.openembedded.org/mailman/listinfo/openembedded-core


Re: [OE-core] [PATCH] barebox: Add recipe

2014-07-28 Thread David Vincent
Hi Eric,

2014-07-28 13:58 GMT+02:00 Eric Bénard e...@eukrea.com:
 Hi David,

 Le Mon, 28 Jul 2014 11:55:04 +0200,
 David Vincent freesili...@gmail.com a écrit :


 barebox (formerly known as u-boot-v2) is a bootloader that inherits the
 best of U-Boot and the Linux kernel. This commit adds the possibility to
 use it as a virtual/bootloader instead of U-Boot.

 Signed-off-by: David Vincent freesili...@gmail.com
 ---
  meta/recipes-bsp/barebox/barebox.inc  |   73 
 +
  meta/recipes-bsp/barebox/barebox_2014.07.0.bb |   15 +
  2 files changed, 88 insertions(+)
  create mode 100644 meta/recipes-bsp/barebox/barebox.inc
  create mode 100644 meta/recipes-bsp/barebox/barebox_2014.07.0.bb

 diff --git a/meta/recipes-bsp/barebox/barebox.inc 
 b/meta/recipes-bsp/barebox/barebox.inc
 new file mode 100644
 index 000..68aeb68
 --- /dev/null
 +++ b/meta/recipes-bsp/barebox/barebox.inc
 @@ -0,0 +1,73 @@
 +SUMMARY = The Barebox Bootloader
 +DESCRIPTION = Barebox (formerly known as u-boot-v2) is a bootloader that 
 inherits the best of U-Boot and the Linux kernel: The size and look-and-feel 
 of u-boot, with driver model and lots of design concepts from the kernel.
 +HOMEPAGE = http://www.barebox.org;
 +SECTION = bootloaders
 +PROVIDES = virtual/bootloader
 +
 +inherit cml1 deploy kernel-arch
 +
 +EXTRA_OEMAKE = 'CROSS_COMPILE=${TARGET_PREFIX} CC=${TARGET_PREFIX}gcc 
 ${TOOLCHAIN_OPTIONS}'
 +
 +BAREBOX_BINARY ?= barebox.bin
 +BAREBOX_IMAGE ?= barebox-${MACHINE}-${PV}-${PR}.bin
 +BAREBOX_SYMLINK ?= barebox-${MACHINE}.bin
 +
 +do_configure () {
 + # Copy defconfig to .config if .config does not exist. This allows
 + # recipes to manage the .config themselves in do_configure_prepend().
 + if [ -f ${WORKDIR}/defconfig ]  [ ! -f ${B}/.config ]; then
 + cp ${WORKDIR}/defconfig ${B}/.config
 + fi
 +
 + # Use board default defconfig if .config does not exist. This allows
 + # recipes to manage the .config themselves in do_configure_prepend().
 + if [ ! -f ${B}/.config ]; then
 + oe_runmake_call ${BAREBOX_TARGET}
 + fi
 +
 + cml1_do_configure
 +}
 +
 +do_compile () {
 + if [ ${@bb.utils.contains('DISTRO_FEATURES', 'ld-is-gold', 
 'ld-is-gold', '', d)} = ld-is-gold ] ; then
 + sed -i 's/$(CROSS_COMPILE)ld$/$(CROSS_COMPILE)ld.bfd/g' 
 ${S}/Makefile
 + fi
 +
 I had to add that a few year ago : is that still needed ?

Don't know, I've taken that directly from u-boot recipe (didn't want
to reinvent the wheel)


 + unset CFLAGS CPPFLAGS LDFLAGS
 + oe_runmake
 +}
 +
 +do_install () {
 + install -d ${D}/boot
 + install ${S}/barebox-flash-image ${D}/boot/${BAREBOX_IMAGE}
 + ln -sf ${BAREBOX_IMAGE} ${D}/boot/${BAREBOX_BINARY}
 +
 + # Install target tools if available
 + install -d ${D}${sbindir}
 +
 + if [ -e ${WORKDIR}/scripts/bareboxenv-target ]; then
 + install -m 0755 ${WORKDIR}/scripts/bareboxenv-target 
 ${D}${sbindir}/bareboxenv
 + fi
 +
 + if [ -e ${WORKDIR}/scripts/bareboxcrc32-target ]; then
 + install -m 0755 ${WORKDIR}/scripts/bareboxcrc32-target 
 ${D}${sbindir}/bareboxcrc32
 + fi
 +
 + if [ -e ${WORKDIR}/scripts/kernel-install-target ]; then
 + install -m 0755 ${WORKDIR}/scripts/kernel-install-target 
 ${D}${sbindir}/kernel-install
 + fi
 +}
 +
 +FILES_${PN} = /boot ${sbindir}

 Why not splitting the tools in their own package so that we can have
 the tools on the target without having the binary in /boot ?

Create a barebox-tools recipe should also solve some problems I have
building the said tools (but it is more a question related to barebox
team than OE). I can do it if this request gets accepted. Could be a
v2 for this patch.


 +
 +do_deploy () {
 + install -d ${DEPLOYDIR}
 + install ${S}/barebox-flash-image ${DEPLOYDIR}/${BAREBOX_IMAGE}
 +
 Why don't you use $BAREBOX_BINARY instead of hardcoding
 barebox-flash-image which won't work on old versions of barebox where
 barebox's binary is named barebox.bin ?

I didn't know that, but I am not sure I can use $BAREBOX_BINARY since
this variable is used in $DEPLOY_DIR. I tried to mimic u-boot recipe
behavior as much as possible.


 Best regards,
 Eric

Greetings,

David
-- 
___
Openembedded-core mailing list
Openembedded-core@lists.openembedded.org
http://lists.openembedded.org/mailman/listinfo/openembedded-core


[OE-core] [PATCH] SDK default deploy directory

2014-04-04 Thread David Vincent
If the user changes the DEPLOY_DIR variable to set up a custom deploy
directory for images, packages, SDKs as explained in the documentation,
the variable SDK_DEPLOY does not take it into account and fallback to
TMPDIR as default. Therefore, SDKs were not found in the correct
location.

Signed-off-by: David Vincent freesili...@gmail.com
---
 meta/classes/populate_sdk_base.bbclass |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/meta/classes/populate_sdk_base.bbclass 
b/meta/classes/populate_sdk_base.bbclass
index 81da206..10d04ed 100644
--- a/meta/classes/populate_sdk_base.bbclass
+++ b/meta/classes/populate_sdk_base.bbclass
@@ -24,7 +24,7 @@ inherit populate_sdk_${IMAGE_PKGTYPE}
 
 SDK_DIR = ${WORKDIR}/sdk
 SDK_OUTPUT = ${SDK_DIR}/image
-SDK_DEPLOY = ${TMPDIR}/deploy/sdk
+SDK_DEPLOY = ${DEPLOY_DIR}/sdk
 
 B_task-populate-sdk = ${SDK_DIR}
 
-- 
1.7.10.4

-- 
___
Openembedded-core mailing list
Openembedded-core@lists.openembedded.org
http://lists.openembedded.org/mailman/listinfo/openembedded-core