I'm trying to make a sym link in Yocto to enable a systemd service that is not enabled by default (apache2, by the way). Here my post process command:

my_postprocess_function() {
    ln -s ${IMAGE_ROOTFS}/lib/systemd/system/apache2.service ${IMAGE_ROOTFS}/etc/systemd/system/multi-user.target.wants/apache2.service     

ROOTFS_POSTPROCESS_COMMAND += "my_postprocess_function; "

Of course the problem is the source file does not exists on the target, but if I use the right path (i.e. /lib/systemd/system/apache2.service) it does not exists on the dev machine and then the recipe fails.

What is the right approach to make a sym link in the rootfs (sub)paths?

  • @meuh your comment is actually the answer. If you write it I can accept it. – Mark Nov 3 '19 at 16:45

Normally, you can create symbolic links to targets that don't exist. For example, try in any shell

ln -s /no/such/file xxx

and it will create link xxx. So simply remove the first ${IMAGE_ROOTFS} from your command:

ln -s /lib/systemd/system/apache2.service ${IMAGE_ROOTFS}/etc/systemd/system/multi-user.target.wants/apache2.service
|improve this answer|||||

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.