Page 1 of 2
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.
Re: Midnight Commander on NAS542
Posted: Thu 13. Aug 2026, 12:10
by admin
Mijzelf wrote: Sun 9. Aug 2026, 13:28
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.
MidnightCommander.postinst contains the following code snippet:
Code: Select all
ExchangeDownloadUrl()
{
if [ -f /tmp/.MetaRepository/tmp/lasturl ] ; then
local url=$(cat /tmp/.MetaRepository/tmp/lasturl )
sed -i "s|^PKG_DOWNLOAD_URL=http://downloads.zyxel.nas-central.org/Users/Mijzelf/fw5|PKG_DOWNLOAD_URL=${url}|" ${PKG_ROOT}/etc/init.d
/${PKG_NAME}
fi
}
The PKG_DOWNLOAD_URL isn't replaced because the file /tmp/.MetaRepository/tmp/lasturl doesn't exist.
We could add libiconv.so.2 directly into the MidnightCommander fw5 package and/or change default PKG_DOWNLOAD_URL to
http://zyxel.ddnss.eu/Users/Mijzelf/zypkg-repo/fw5/ in ${PKG_ROOT}/etc/init.d/MidnightCommander and ${PKG_ROOT}/zypkg_conf/info/MidnightCommander.postinst.
Re: Midnight Commander on NAS542
Posted: Thu 13. Aug 2026, 14:26
by admin
I tried to modify the .zpkg file on Ubutu with tar xvf/tar cvf. Unfortunately the new file can't be installed. What is the right procdure to create .zpkg files?
Re: Midnight Commander on NAS542
Posted: Thu 13. Aug 2026, 18:02
by Mijzelf
How are you trying to install it?
There is nothing special in zpkg files. I used a script to create them, but that was including generating a startscript and pre- and post install scripts. One thing that can go wrong these days is tar. The latest Plex packages cannot be installed anymore, because it's somehow incompatible with the firmware busybox tar. I did some tests, when the problem arrived, and I couldn't reproduce the issue with self created tar files.
It's easy to test. Can you extract the file with firmware tar?
Another problem is the checksum. AS you may have seen the ZYPKGS file contains an MD5 checksum. If somehow your way of installing uses an old checksum, it will fail.
The easiest way to install it (providing the tar can be extracted) is to use the local repository in MetaRepository. Put your zypkg file together with a ZYPKGS file with the right checksum in it (when I remember well it is admin/local/), put it before the other repositories in the MR webinterface, and MR should install it.
Re: Midnight Commander on NAS542
Posted: Thu 13. Aug 2026, 18:10
by Mijzelf
admin wrote: Thu 13. Aug 2026, 12:10
The PKG_DOWNLOAD_URL isn't replaced because the file /tmp/.MetaRepository/tmp/lasturl doesn't exist.
It does. MetaRepository puts it there, when downloading a package. But of course that doesn't survive a reboot. In most cases the file is there, but when the firmware package manager gets the zypkg from an internal cache, it might not be there, or point to the wrong origin.
Re: Midnight Commander on NAS542
Posted: Thu 13. Aug 2026, 19:24
by shv
Mijzelf wrote: Thu 13. Aug 2026, 18:02
How are you trying to install it?
I put it in
https://zyxel.ddnss.eu/Users/Mijzelf/zy ... m_004.zpkg and changed the package name and md5 accorgingly in
https://zyxel.ddnss.eu/Users/Mijzelf/zy ... fw5/ZYPKGS.
Mijzelf wrote: Thu 13. Aug 2026, 18:02
It's easy to test. Can you extract the file with firmware tar?
I can't extract neither my nor your .zpkg packages neither with firmware nor with Entware tar/gzip packages installed. I get a gunzip error.
I unpacked your MidnightCommander zpkg file and packed it again with Ubuntu tar after I had chanded files.
Re: Midnight Commander on NAS542
Posted: Fri 14. Aug 2026, 08:23
by shv
Without further information I am not able to make changes based on existing zpkg files. It seams that for these files are packed with tar 2 or 3 times.
1. Create control.tar.gz and data.tar.gz
2. Create Midnightcommander.zpkg: tar cf Midnightcommander.zpkg control.tar.gz data.tar.gz
3. Create Midnightcommander.zpkg.tar: tar cf Midnightcommander.zpkg.tar Midnightcommander.zpkg
4. Rename Midnightcommander.zpkg.tar to Midnightcommander.zpkg
I am still not able to install my own zpkg files. Can you please provide me your script for further analysis to find out the concrete procedure to create zpkg files?
Re: Midnight Commander on NAS542
Posted: Fri 14. Aug 2026, 08:23
by Mijzelf
It works for me on my NAS520:
Code: Select all
admin@NAS520:/tmp/test$ wget http://zyxel.ddnss.eu/Users/Mijzelf/zypkg-repo/test/shv/fw5/MidnightCommander_4.6.1_arm_003.zpkg
Connecting to zyxel.ddnss.eu (130.61.246.67:80)
MidnightCommander_4. 100% |*************************************************************************************************************************************************| 780k 0:00:00 ETA
admin@NAS520:/tmp/test$ wget http://zyxel.ddnss.eu/Users/Mijzelf/zypkg-repo/test/shv/fw5/MidnightCommander_4.6.1_arm_004.zpkg
Connecting to zyxel.ddnss.eu (130.61.246.67:80)
MidnightCommander_4. 100% |*************************************************************************************************************************************************| 781k 0:00:00 ETA
admin@NAS520:/tmp/test$ /bin/busybox tar xf MidnightCommander_4.6.1_arm_003.zpkg
admin@NAS520:/tmp/test$ /bin/busybox tar xf MidnightCommander_4.6.1_arm_004.zpkg
admin@NAS520:/tmp/test$ ls -l
-rw-r--r-- 1 admin everyone 798794 Aug 14 09:09 MidnightCommander_4.6.1_arm_003.zpkg
-rw-r--r-- 1 admin everyone 800256 Aug 14 09:09 MidnightCommander_4.6.1_arm_004.zpkg
-rw-r--r-- 1 admin everyone 2198 Aug 14 06:58 control.tar.gz
-rw-r--r-- 1 admin everyone 795645 Aug 14 06:58 data.tar.gz
admin@NAS520:/tmp/test$
But:
Code: Select all
admin@NAS520:/tmp/test$ file MidnightCommander_4.6.1_arm_003.zpkg
MidnightCommander_4.6.1_arm_003.zpkg: gzip compressed data, last modified: Tue Oct 2 14:26:19 2018, max compression, from Unix
admin@NAS520:/tmp/test$ file MidnightCommander_4.6.1_arm_004.zpkg
MidnightCommander_4.6.1_arm_004.zpkg: POSIX tar archive (GNU)
so that might cause your package to be rejected. Use 'tar czf' to greate it. (And yes, it is silly to compress it when the content is already compressed).