Bug 13188

Summary: systemd 239 bash file test bug
Product: [Build System, Metadata & Runtime] OE-Core Reporter: wei.qingjun
Component: coreAssignee: wei.qingjun
Status: RESOLVED WORKSFORME QA Contact:
Severity: critical    
Priority: Medium CC: jku, meta.mr.watcher, meta.watcher, randy.macleod
Version: 2.6.1   
Target Milestone: 2.8 M4   
Hardware: All   
OS: arm   
Whiteboard:
OS type for building Yocto: --- Type of Regression: ---
Verified: Documentation change: No (bug/feature does not impact docs)

Description wei.qingjun 2019-02-20 01:45:30 UTC
line 231:
[ ! -e ${D}/init ] && ln -s ${rootlibexecdir}/systemd/systemd ${D}/init
Will trigger symbolic link already exists error. On Ubuntu 18.04 bash.

Should it be
[ ! -L ${D}/init ] && ln -s ${rootlibexecdir}/systemd/systemd ${D}/init
Comment 1 wei.qingjun 2019-02-20 03:01:07 UTC
I tried to modify the code but I still get error:

Log below:

| Running custom install script 'XXXXXXXXXXX/tmp/hosttools/sh -c touch $DESTDIR/usr'
| ln: failed to create symbolic link 'XXXXXXXXXX/tmp/work/cortexa17hf-neon-vfpv4-rk-linux-gnueabi/systemd/1_239-r0/image/sbin/init': File exists

No idea why the init file exists.
Comment 2 wei.qingjun 2019-02-20 03:33:28 UTC
I can confirm it is a bug.
Althought I have not traced to the cause.
I had to add a line to remove the sbin/init file.

mv ${D}/${base_sbindir}/init

Then I had to mount the ext4 rootfs and manully create the link.
The current symbolic link is linked to a wrong location.
Comment 3 Randy MacLeod 2019-02-21 15:47:30 UTC
Can you explain in detail how to reproduce the error?
Lots of people are building systemd but perhaps this is a silent failure that we've been ignoring or it could be that you have a custom install script and have made an error. We need more info to proceed.
Comment 4 wei.qingjun 2019-02-21 16:12:10 UTC
I have a local recipe that installs a systemd service to start my system at startup.
The bb file is something like below.
Hope it helps.

Thanks
Qingjun

SUMMARY = "XXX"
LICENSE = "CLOSED"
PV = "1.0"

SRC_URI = "... \
"

S = "${WORKDIR}"

inherit systemd
inherit bin_package
INSANE_SKIP_${PN} = "ldflags"
INHIBIT_PACKAGE_STRIP = "1"
INHIBIT_SYSROOT_STRIP = "1"
INHIBIT_PACKAGE_DEBUG_SPLIT = "1"

do_compile() {
}

do_install () {
	install -Dm 0644 ${S}/XXX.service ${D}/${systemd_unitdir}/system/XXX.service
}


SYSTEMD_SERVICE_${PN} = "XXX.service"
INSANE_SKIP_${PN} += "installed-vs-shipped"
Comment 5 Stephen K Jolley 2019-02-23 00:05:43 UTC
Chen,

It appears an answer to the question has been given.  I have cleared NEEDINFO.  

Thanks,

Stephen
Comment 6 Jussi Kukkonen 2019-04-03 08:32:26 UTC
(In reply to comment #0)
> line 231:
> [ ! -e ${D}/init ] && ln -s ${rootlibexecdir}/systemd/systemd ${D}/init

This is not line 231 in yocto 2.6.1 systemd_239.bb.

Do you have local modifications or are you actually running some other yocto version?
Comment 7 Chen Qi 2019-04-03 09:04:20 UTC
wei,

Sorry for late reply. I guess the cause is that your ubuntu18.04 does not have /lib/systemd/systemd, causing ${D}/init being a dead link.
I think you are right, using '-L' could solve this problem. As an alternative, you can use 'ln -sf' instead 'ln -s'.
You can send out patch if you like, as you have already found the solution.
You can send patch to openembedded-core@lists.openembedded.org, for both thud and master branches.
If not convenient, I'll do it for you.

Best Regards,
Chen Qi
Comment 8 Chen Qi 2019-05-28 01:09:21 UTC
wei,

Do you still have this bug reproduced on your host?
Comment 9 Chen Qi 2019-07-22 02:13:45 UTC
I cannot reproduce this problem, nor can I find out the host environment of the reporter.
Comment 10 wei.qingjun 2019-07-22 02:42:29 UTC
Qingjun(In reply to comment #9)
> I cannot reproduce this problem, nor can I find out the host environment of
> the reporter.

Sorry didn't have a chance to try new release of Yocto.
Will try to test against latest release in this week.

Regards
Comment 11 wei.qingjun 2019-07-22 18:15:04 UTC
(In reply to comment #9)
> I cannot reproduce this problem, nor can I find out the host environment of
> the reporter.

Hello Chen,
I just tried systemd 2.41 on latest warrior-next branch.
The problem still exists

Below is the log. BTW I am running on a Ubuntu 18.04 X64.

ln: failed to create symbolic link '/home/weiqj/rk-yocto-bsp/libre-hub/tmp/work/cortexa17hf-neon-vfpv4-rk-linux-gnueabi/systemd/1_241+AUTOINC+c1f8ff8d0d-r0/image/sbin/init': $
WARNING: exit code 1 from a shell command.
ERROR: Function failed: do_install (log file is located at /home/weiqj/rk-yocto-bsp/libre-hub/tmp/work/cortexa17hf-neon-vfpv4-rk-linux-gnueabi/systemd/1_241+AUTOINC+c1f8ff8d0$

Still, I had to manually modify the script to make it work.
Comment 12 Chen Qi 2019-07-23 01:16:50 UTC
Hi Wei,

I'm wondering why other people don't have such problem. I also use ubuntu hosts.
Do you have some additional layer which might have systemd bbappend files?

What does your run.do_install file under ${WORKDIR}/temp look like?
What creates the ${D}/init link before this line? [ ! -e ${D}/init ] && xxx

Could you please show your run.do_install file?

Also, you mentioned ${D}/init, but your error log is about ${D}/sbin/init.

Anyway, I think showing your run.do_install will help.
Comment 13 Randy MacLeod 2019-08-22 15:01:22 UTC
Wei?
Comment 14 Randy MacLeod 2019-08-29 14:47:01 UTC
No reponse so I'm closing the defect. We'd be happy to have the defect re-opened if the needed info is provided.