Page 1 of 1

Midnight Commander on NAS542

Posted: Sun 2. Aug 2026, 20:12
by admin
If I try to start mc after installation from MetaRepository I get the following error message:

Code: Select all

/i-data/5fe660ed/.PKG/MidnightCommander/bin/mc: error while loading shared libraries: /i-data/5fe660ed/.PKG/MidnightCommander/lib/libiconv.so.2: file too short
The file /i-data/5fe660ed/.PKG/MidnightCommander/lib/libiconv.so.2 is available but its size is 0 bytes. How can I fix the installation of the MC package?

Re: Midnight Commander on NAS542

Posted: Sat 8. Aug 2026, 18:00
by shv
A working library libiconv.so.2 for NAS542 is available here: http://zyxel.ddnss.eu/Users/Mijzelf/zyp ... nv.so.2.gz

Re: Midnight Commander on NAS542

Posted: Sun 9. Aug 2026, 13:28
by Mijzelf
That is actually a bug in the startscript. The startscript (${PKG_ROOT}/etc/init.d/MidnightCommand) contains this snippet:

Code: Select all

Startup()
{
        # Enable ld-linux.so on NAS5xx
        [ ! -f /lib/ld-linux.so.3 -a -f /lib/ld-linux-armhf.so.3 ] && ln -s ld-linux-armhf.so.3 /lib/ld-linux.so.3 

        for file in /bin/mc /bin/mcview /bin/mcedit
        do
                if [ "${PKG_FIRMWARE}" = "4" ] ; then
                        ln -s ${PKG_ROOT}/bin/mc ${file}
                else
                        local libiconv=${PKG_ROOT}/lib/libiconv.so.2
                        [ ! -f ${libiconv} ] && wget ${PKG_DOWNLOAD_URL}/libiconv.so.2.gz -O - | gunzip >${libiconv}
                        echo "#!/bin/sh" >${file}
                        echo LD_LIBRARY_PATH=${PKG_ROOT}/lib:${LD_LIBRARY_PATH} MC_DATADIR=${PKG_ROOT}/share/mc exec ${PKG_ROOT}${file} \"\$@\" >>${file}
                        chmod a+x ${file}
                fi
        done
}
So on a firmware 5 device it checks if ${PKG_ROOT}/lib/libiconv.so.2 exists, and else it downloads ${PKG_DOWNLOAD_URL}/libiconv.so.2.gz, and extracts it to ${PKG_ROOT}/lib/libiconv.so.2. The problem here is that if the download fails, an empty file is created, and the download is never retriggered. The remedy is to remove the empty file, and dis- and enable mc.
Another thing which can be wrong is PKG_DOWNLOAD_URL, which is set installtime by MetaRepository, and points to the URL where the package was downloaded. So that should be http://zyxel.ddnss.eu/Users/Mijzelf/zypkg-repo/fw5 in your case. Unfortunately this mechanism is not bulletproof, and it could point to the wrong URL.