How to get latest kernel.ipk URL via shell script?

I try to build an auto-upgrade script for EXT4 users to avoid reboot and duplicate configuration.
Base on this article: https://zhmail.com/2019/02/02/upgrading-an-openwrt-18-06-1-x86_64-ext4-image-to-18-06-2/ , but I don't know how to get the latest kernel.ipk URL in step 1.Any idea?
As I know, the kernel cannot upgrade simply via "opkg upgrade kernel", So I need download it then install it via "opkg install", am I right?

APPEND:
I found a script, but it looks not work.

Why are you not just using sysupgrade to do this? Having looked through the article you've linked it still looks like you'd have to reboot the router. Updating packages in the way described by that article, including the kernel, sounds like a recipe for disaster..

2 Likes

Cause sysupgrade designed for squash-fs which is OpenWRT default, not ext4, if use it on ext4, you will lose all configuration.

No, you don't. I'm using ext4 on my RPi4 and it updates just fine. I've done it several times, including yesterday, and haven't lost any configuration on any upgrade.

1 Like

The kernel is outside the rootfs, it's not packaged and can't be upgraded (other than sysupgrading) by opkg.

3 Likes

No, you don't. I'm using ext4 on my RPi4 and it updates just fine. I've done it several times, including yesterday, and haven't lost any configuration on any upgrade.

Which Image Files do you choose? Could you give me more details? I tried to upgrade via sysupgrade. Looks sysupgrade just overlay all files in image, and those package entries which installed after firstboot will lose in opkg installed-packages list.That is what I said "lose configuration"

The kernel is outside the rootfs, it's not packaged and can't be upgraded (other than sysupgrading) by opkg.

That's not true, you can see I mentioned link above. I said 'kernal' above is kernal.ipk from below link.
https://downloads.openwrt.org/releases/19.07.4/targets/x86/64/packages/kernel_4.14.195-1-68143adfcb7fc62a239c4be112fe40de_x86_64.ipk

I build my own image as I use a number of additional packages. But it shouldn't be any different using something like https://downloads.openwrt.org/releases/19.07.4/targets/x86/64/openwrt-19.07.4-x86-64-combined-ext4.img.gz.

Sysupgrade backs up current config files (and any other files you add to /etc/sysupgrade.conf) and restores them once the upgrade is complete. It does this with both squashfs and ext4 images. User installed packages aren't carried over when upgrading, but again that's the same with both squashfs and ext4.

What did you actually lose when you used sysupgrade with an ext4 image?

It will lose installed packages list, even those package files still there, it will lead to some unexpected problem. And other files which doesn't contain by sysupgrade backup list. And contain all packages file rely on patch this list is unrealistic

I build my own image as I use a number of additional packages.

That's different, I use pre-compile img which release at https://downloads.openwrt.org/, you compile by yourself will not like that cause you already add packages you need in the final img.

Have a read through OpenWrt Project: Upgrading OpenWrt firmware via LuCI and CLI. It explains several methods to back up the list of currently installed packages and then reinstall them after using sysupgrade to upgrade OpenWRT.

I read it before, and add opkg list file to /lib/upgrade/keep.d maybe good resolve "package list lack", but I still worry other files in the corner has been overwritten. I'd rather install new kernal&vmlinuz and edit disfeed manually to avoid those potential flaws.

Oh I just remembered. The BIGGEST reason I cannot use openwrt.img is I resize the partition, if I use sysupgrade will replace disk partition information, the part size will back to default, something like 250MB? Not enough for me and may break my current filesystem, and sysupgrade just flash whole .img to disk directly so I can't use it. Sorry to mention this too late, my router runtime too much to remenber details.Anyway, thanks your help!

That 'kernel' ipk is just an empty package.

1 Like

Maybe just need its pre/post install script to inform system the new current kernel?

I checked the scripts too, just some default scripts.
The package don't include the vmlinuz or download or update the vmlinuz anywhere.

urls vary pending release... did you mention what release you are using?

You cannot avoid it anyways, because OpenWrt is not optimized for package upgrades.
Either customize /etc/sysupgrade.conf and perform upgrade with sysupgrade, or better find another distribution.
A general-purpose Linux distribution like Fedora/CentOS/Ubuntu/Debian should survive upgrades pretty well.

Please check top link I mentioned, it download& replace vmlinuz manually.

I know, so I want make a general script to suitable any release version.

True, but we can still upgrade manually like top link. Actually I used do what sysupgrade do manually, which is use sysupgrade -b to create backup file then download generic-rootfs.tar.gz and extract to overwrite rootfs at last recover backup via sysupgrade too, and don't forget replace new vmlinuz at /boot. It's perfect and work well. And now I know overwrite whole root is unnecessary, so just do what top link mentioned manually you can upgrade OpenWrt without flash disk img.

It would be quicker and simpler to just set up a local build system so you can then include any additional required packages and set the root filesystem partition size to the required size. You can then just use sysupgrade as and when required.

1 Like

Right, self build truly is an alternative, I just find another more simple way to upgrade it. And if there no way to get latest URL I will use $1 delivery URL manually.

That link make sense, very similar like I do during upgrade from 19.07.3 to 19.07.4 manully.
But " opkg install kernel_***" is really not necessary. this package is useless for upgrade.
I really hope openwrt can support self build/upgrade in-place on generic arm/x86 platform.

1 Like