Skip to contentSkip to conversation

Problems with postinstall

DISCUSSION Neuer User 5 participants 9 messages Jun 5, 2014 – Jun 7, 2014

lore
Share & tools
lore

Neuer User

author
#0 lore raw

Hi

I am desperately trying to get some postinstall scripts working. They should replace some defualt files with custom files I have. They are all in one package. The package looks like this:

do_install() {
    install -d ${D}${sbindir}
    install -m 0700 ${S}/sbin/* ${D}${sbindir}

    install -d ${D}${bindir}
    install -m 0755 ${S}/bin/LEDstatus ${D}${bindir}

    install -d ${D}/etc/udev/rules.d
    install -m 0644 ${S}/udev/* ${D}/etc/udev/rules.d/

    install -d ${D}/etc/ssh
    install -m 0600 ${S}/ssh/ssh_* ${D}/etc/ssh/
    install -m 0644 ${S}/ssh/authorized_keys ${D}/etc/ssh/

    install -d ${D}/etc/gnupg
    install -m 0600 ${S}/gnupg/trustedkeys.gpg ${D}/etc/gnupg/
}

# Overwrite some configuration data with specific files

pkg_postinst_${PN} () {
    install -o root -g root -m 0600 ${S}/ssh/sshd_config ${D}/etc/ssh/
    install -m 0755 ${S}/etc/rc.local ${D}/etc/
    install -m 0644 ${S}/etc/watchdog.conf ${D}/etc/
    install -m 0400 ${S}/etc/shadow ${D}/etc/
    install -m 0440 ${S}/etc/sudoers ${D}/etc/
    install -d ${D}/etc/default
    install -o root -g root -m 0644 ${S}/etc/default-ntpdate

${D}/etc/default/ntpdate
}

RDEPENDS_${PN} += "ntpdate udev ssh sudo"

FILES_${PN} += "/*"

I even tried changing the ownership of the files, but that did not change aything.

Am I doing this completely wrong?

Thanks for any hints

Michael

author
#1 lore raw

Nobody using any postinstalls?

I am still wondering why the postinstall does not work. I don't get any error messages. The files are just not installed.

Am 05.06.2014 12:44, schrieb Neuer User:

Quoted 50 lines

Hi

I am desperately trying to get some postinstall scripts working. They should replace some defualt files with custom files I have. They are all in one package. The package looks like this:

do_install() {
    install -d ${D}${sbindir}
    install -m 0700 ${S}/sbin/* ${D}${sbindir}

    install -d ${D}${bindir}
    install -m 0755 ${S}/bin/LEDstatus ${D}${bindir}

    install -d ${D}/etc/udev/rules.d
    install -m 0644 ${S}/udev/* ${D}/etc/udev/rules.d/

    install -d ${D}/etc/ssh
    install -m 0600 ${S}/ssh/ssh_* ${D}/etc/ssh/
    install -m 0644 ${S}/ssh/authorized_keys ${D}/etc/ssh/

    install -d ${D}/etc/gnupg
    install -m 0600 ${S}/gnupg/trustedkeys.gpg ${D}/etc/gnupg/
}

# Overwrite some configuration data with specific files

pkg_postinst_${PN} () {
    install -o root -g root -m 0600 ${S}/ssh/sshd_config ${D}/etc/ssh/
    install -m 0755 ${S}/etc/rc.local ${D}/etc/
    install -m 0644 ${S}/etc/watchdog.conf ${D}/etc/
    install -m 0400 ${S}/etc/shadow ${D}/etc/
    install -m 0440 ${S}/etc/sudoers ${D}/etc/
    install -d ${D}/etc/default
    install -o root -g root -m 0644 ${S}/etc/default-ntpdate

${D}/etc/default/ntpdate
}

RDEPENDS_${PN} += "ntpdate udev ssh sudo"

FILES_${PN} += "/*"

I even tried changing the ownership of the files, but that did not change aything.

Am I doing this completely wrong?

Thanks for any hints

Michael

#2 lore raw
Quoted 5 lines · Neuer User

Nobody using any postinstalls?

I am still wondering why the postinstall does not work. I don't get any error messages. The files are just not installed.

I usually leave things more than a day before sending a ping email, people can be busy but usually you'll get replies within a couple of days on this list.

Quoted 13 lines
Quoted 10 lines

# Overwrite some configuration data with specific files

pkg_postinst_${PN} () {
    install -o root -g root -m 0600 ${S}/ssh/sshd_config ${D}/etc/ssh/
    install -m 0755 ${S}/etc/rc.local ${D}/etc/
    install -m 0644 ${S}/etc/watchdog.conf ${D}/etc/
    install -m 0400 ${S}/etc/shadow ${D}/etc/
    install -m 0440 ${S}/etc/sudoers ${D}/etc/
    install -d ${D}/etc/default
    install -o root -g root -m 0644 ${S}/etc/default-ntpdate
Quoted 3 lines

${D}/etc/default/ntpdate
}

The postinst is executed by the package manager when the package is installed. If that installation takes place during do_rootfs, ${D} will refer to the rootfs directory for the image being built and ${S} will probably refer to something else to do with the image recipe but I'm not entirely sure on the details. If the installation takes place on the device, or the postinst is delayed until the first boot, ${D} and ${S} will not be set.

Hope this helps,

Signature · 4 lines
Paul Barker

Email: [email protected]
http://www.paulbarker.me.uk
author
#3 lore raw

Am 06.06.2014 12:54, schrieb Paul Barker:

Quoted 4 lines

I usually leave things more than a day before sending a ping email, people can be busy but usually you'll get replies within a couple of days on this list.

Sorry, I guess these 18h were driving me crazy as I don't understand why it is not working. I actually thought, it had already been working earlier...

Quoted 22 lines
Quoted 13 lines
Quoted 10 lines

# Overwrite some configuration data with specific files

pkg_postinst_${PN} () {
    install -o root -g root -m 0600 ${S}/ssh/sshd_config ${D}/etc/ssh/
    install -m 0755 ${S}/etc/rc.local ${D}/etc/
    install -m 0644 ${S}/etc/watchdog.conf ${D}/etc/
    install -m 0400 ${S}/etc/shadow ${D}/etc/
    install -m 0440 ${S}/etc/sudoers ${D}/etc/
    install -d ${D}/etc/default
    install -o root -g root -m 0644 ${S}/etc/default-ntpdate
Quoted 3 lines

${D}/etc/default/ntpdate
}

The postinst is executed by the package manager when the package is installed. If that installation takes place during do_rootfs, ${D} will refer to the rootfs directory for the image being built and ${S} will probably refer to something else to do with the image recipe but I'm not entirely sure on the details. If the installation takes place on the device, or the postinst is delayed until the first boot, ${D} and ${S} will not be set.

Quoted 2 lines

Hope this helps,

So, I guess there are now two possibilities:
a.) The postinstall is not done at all.
b.) The postinstall is done, but before the other packages are installed, which overwrite the files again. Is this possible? If yes, howto specify that this postinstall should really be done last of all?

Thanks a lot

Michael

#4 lore raw
Quoted 32 lines · Neuer User

Am 06.06.2014 12:54, schrieb Paul Barker:

Quoted 4 lines

I usually leave things more than a day before sending a ping email, people can be busy but usually you'll get replies within a couple of days on this list.

Sorry, I guess these 18h were driving me crazy as I don't understand why it is not working. I actually thought, it had already been working earlier...

Quoted 22 lines
Quoted 13 lines
Quoted 10 lines

# Overwrite some configuration data with specific files

pkg_postinst_${PN} () {
    install -o root -g root -m 0600 ${S}/ssh/sshd_config ${D}/etc/ssh/
    install -m 0755 ${S}/etc/rc.local ${D}/etc/
    install -m 0644 ${S}/etc/watchdog.conf ${D}/etc/
    install -m 0400 ${S}/etc/shadow ${D}/etc/
    install -m 0440 ${S}/etc/sudoers ${D}/etc/
    install -d ${D}/etc/default
    install -o root -g root -m 0644 ${S}/etc/default-ntpdate
Quoted 3 lines

${D}/etc/default/ntpdate
}

The postinst is executed by the package manager when the package is installed. If that installation takes place during do_rootfs, ${D} will refer to the rootfs directory for the image being built and ${S} will probably refer to something else to do with the image recipe but I'm not entirely sure on the details. If the installation takes place on the device, or the postinst is delayed until the first boot, ${D} and ${S} will not be set.

Quoted 10 lines
Quoted 2 lines

Hope this helps,

So, I guess there are now two possibilities:
a.) The postinstall is not done at all.
b.) The postinstall is done, but before the other packages are installed, which overwrite the files again. Is this possible? If yes, howto specify that this postinstall should really be done last of all?

I'm not sure if this helps, but you can specify rootfs-post-process commands in your image recipe:

setup_my_image() {

    # do stuff
}

ROOTFS_POSTPROCESS_COMMAND += 'setup_my_image ;'

This will run after the rootfs is created from the package installations

/Jacob

author
#5 lore raw

Am 06.06.2014 13:19, schrieb Jacob Kroon:

Quoted 4 lines

I'm not sure if this helps, but you can specify rootfs-post-process commands in your image recipe:

setup_my_image() {

Quoted 8 lines
    # do stuff
}

ROOTFS_POSTPROCESS_COMMAND += 'setup_my_image ;'

This will run after the rootfs is created from the package installations

/Jacob

Thanks, that sounds like a good idea. Will try that out. :-)

#6 lore raw
In reply to Neuer User
Quoted 8 lines · Neuer User
Quoted 8 lines

The postinst is executed by the package manager when the package is installed. If that installation takes place during do_rootfs, ${D} will refer to the rootfs directory for the image being built and ${S} will probably refer to something else to do with the image recipe but I'm not entirely sure on the details. If the installation takes place on the device, or the postinst is delayed until the first boot, ${D} and ${S} will not be set.

Quoted 8 lines
Quoted 2 lines

Hope this helps,

So, I guess there are now two possibilities:
a.) The postinstall is not done at all.
b.) The postinstall is done, but before the other packages are installed, which overwrite the files again. Is this possible? If yes, howto specify that this postinstall should really be done last of all?

Basically a postinstall is *not* the way of doing this. You can't control when it runs and when it does, you can't get to the files you want to install.

If the files are installed by other packages then use a bbappend to change those files. If nothing installs them already, write a recipe to install them. If there are changes that can only be done at rootfs time, then use a rootfs postproces command.

Ross

author
#7 lore raw

Am 06.06.2014 14:31, schrieb Burton, Ross:

Quoted 22 lines · Neuer User
Quoted 8 lines
Quoted 8 lines

The postinst is executed by the package manager when the package is installed. If that installation takes place during do_rootfs, ${D} will refer to the rootfs directory for the image being built and ${S} will probably refer to something else to do with the image recipe but I'm not entirely sure on the details. If the installation takes place on the device, or the postinst is delayed until the first boot, ${D} and ${S} will not be set.

Quoted 8 lines
Quoted 2 lines

Hope this helps,

So, I guess there are now two possibilities:
a.) The postinstall is not done at all.
b.) The postinstall is done, but before the other packages are installed, which overwrite the files again. Is this possible? If yes, howto specify that this postinstall should really be done last of all?

Basically a postinstall is *not* the way of doing this. You can't control when it runs and when it does, you can't get to the files you want to install.

Quoted 7 lines

If the files are installed by other packages then use a bbappend to change those files. If nothing installs them already, write a recipe to install them. If there are changes that can only be done at rootfs time, then use a rootfs postproces command.

Ross

Thanks Ross

I guess the "rootfs postprocess command" is the way to go.

I have already separated the files into new files (which get installed as a normal install process by that package) and files that overwrite other package files.

I guess, I could for most (but not all) files add a bbappend to the relevant original package, but it would be more complicated than doing it all together at rootfs postprocess.

Thanks for all the help. I will try the rootfs postprocess today :-)

Cheers

Michael

#8 lore raw
In reply to Neuer User

Hi

postinstall is afaik run during installation. And that could very well be on the actual target. So ${S} etc. are not available. The step is just for steps that *need* to run on the actual target utilizing the files that where install in do_install.

Fredag den 6. juni 2014 08:16:39 skrev Neuer User:

Quoted 59 lines

Nobody using any postinstalls?

I am still wondering why the postinstall does not work. I don't get any error messages. The files are just not installed.

Am 05.06.2014 12:44, schrieb Neuer User:

Quoted 53 lines

Hi

I am desperately trying to get some postinstall scripts working. They should replace some defualt files with custom files I have. They are all in one package. The package looks like this:

do_install() {

    install -d ${D}${sbindir}
    install -m 0700 ${S}/sbin/* ${D}${sbindir}
    
    install -d ${D}${bindir}
    install -m 0755 ${S}/bin/LEDstatus ${D}${bindir}
    
    install -d ${D}/etc/udev/rules.d
    install -m 0644 ${S}/udev/* ${D}/etc/udev/rules.d/
    
    install -d ${D}/etc/ssh
    install -m 0600 ${S}/ssh/ssh_* ${D}/etc/ssh/
    install -m 0644 ${S}/ssh/authorized_keys ${D}/etc/ssh/
    
    install -d ${D}/etc/gnupg
    install -m 0600 ${S}/gnupg/trustedkeys.gpg ${D}/etc/gnupg/

}

# Overwrite some configuration data with specific files pkg_postinst_${PN} () {

    install -o root -g root -m 0600 ${S}/ssh/sshd_config ${D}/etc/ssh/
    install -m 0755 ${S}/etc/rc.local ${D}/etc/
    install -m 0644 ${S}/etc/watchdog.conf ${D}/etc/
    install -m 0400 ${S}/etc/shadow ${D}/etc/
    install -m 0440 ${S}/etc/sudoers ${D}/etc/
    install -d ${D}/etc/default
    install -o root -g root -m 0644 ${S}/etc/default-ntpdate

${D}/etc/default/ntpdate
}

RDEPENDS_${PN} += "ntpdate udev ssh sudo"

FILES_${PN} += "/*"

I even tried changing the ownership of the files, but that did not change aything.

Am I doing this completely wrong?

Thanks for any hints

Michael

Signature · 1 line
Søren Holm