openwrt / packages

Community maintained packages for OpenWrt. Documentation for submitting pull requests is in CONTRIBUTING.md
GNU General Public License v2.0
3.94k stars 3.45k forks source link

gzip: sysupgrade error after installation #14925

Closed fanck0605 closed 3 years ago

fanck0605 commented 3 years ago

Maintainer: @bk138

Environment:

Description:

After I installed gzip, the command zcat would actually call gzip.

However, zcat does not seem to work properly when it is called by the sysupgrade script /lib/upgrade/platform.sh#L52

Since I am using a gzip-compressed image, the function get_image will call zcat to decompress the firmware, but it says /bin/zcat: exec: line 51: gzip: not found (although zcat works fine when I run it in the terminal), thus causing the entire sysupgrade process to fail.

After I removed the gzip, everything works will.

Here is the sysupgrade log

root@OpenWrt:/# sysupgrade -v -n /tmp/openwrt-rockchip-armv8-friendlyarm_nanopi-
r2s-squashfs-sysupgrade.img.gz 
Thu Jan 21 17:10:37 CST 2016 upgrade: Reading partition table from bootdisk...

gzip: stdout: Broken pipe
Thu Jan 21 17:10:37 CST 2016 upgrade: Reading partition table from image...
Thu Jan 21 17:10:37 CST 2016 upgrade: Commencing upgrade. Closing all shell sessions.
killall: telnetd: no process killed
Thu Jan 21 17:10:38 CST 2016 upgrade: Sending TERM to remaining processes ... uhttpd vsftpd dbus-daemon avahi-daemon thd miniupnpd dnsmasq ubusd crond urngd smbd nmbd ntpd netdata netdata ttyd wsdd2 logd rpcd netifd odhcpd
Thu Jan 21 17:10:41 CST 2016 upgrade: Sending KILL to remaining processes ...
[  105.137201] sh (4300): drop_caches: 3
Thu Jan 21 17:10:43 CST 2016 upgrade: Switching to ramdisk...
[  106.938611] EXT4-fs (mmcblk0p2): re-mounted. Opts: (null)
Thu Jan 21 09:10:44 UTC 2016 upgrade: Performing system upgrade...
Thu Jan 21 09:10:45 UTC 2016 upgrade: Reading partition table from bootdisk...
/bin/zcat: exec: line 51: gzip: not found
0+0 records in
0+0 records out
Thu Jan 21 09:10:45 UTC 2016 upgrade: Reading partition table from image...
Thu Jan 21 09:10:45 UTC 2016 upgrade: Invalid partition table on /tmp/image.bs
[  107.231703] reboot: Restarting system

U-Boot TPL 2021.01 (Feb 25 2021 - 14:13:13)
bk138 commented 3 years ago

It seems from the Makefile that zcat is actually installed into /usr/libexec/ and then some kind of linking is done to make /bin/zcat point there. What does ls -la /bin/zcat yield for you? I guess that during sysupgrade /usr/ might me unmounted, but that needs verification from someone more into it.

neheb commented 3 years ago

ping @zhanhb

zhanhb commented 3 years ago

IMO, the best way to solve this problem is to replace zcat with busybox zcat. https://github.com/openwrt/openwrt/pull/3940#pullrequestreview-605439894