The future is now: opkg vs apk

I tried without the echo line and without return 0 - same result.

For further troubleshooting:

x86-64 apk file:

https://drive.google.com/file/d/1GbfaqnSYJ5e9hnKyxZD0HDjAlfILDVd1/view?usp=sharing

geoip-shell OpenWrt releases repo:

https://github.com/friendly-bits/geoip-shell-openwrt

Makefile here:

https://github.com/friendly-bits/geoip-shell-openwrt/releases/tag/v0.6.8-r1

I meant to say "remove the exit calls in all the pre variants", the post ones shouldn't matter, by then everything is completed.

Tried that as well, no change.

One more suggestion:
remove the indentation from the lines in the Makefile prerm / postrm / postinst definitions. At least from the shebang line...
(Most of those function definitions in the source repo are without indentation)

Might be similar as with conffiles, that definitions should be done without indentation.

2 Likes

This did the trick. That said, I don't think the core issue is in the Makefile because same makefile with same postrm works fine with ipk. So first, IMO it's a regression. And second, probably the issue is either with the apk code or with the way package data is handed over to it.

Edit: I can file a Github issue if it's necessary.

You might file a GitHub issue, as the issue likely affects also the other (few) packages that have defined those sections with indentations (e.g. pbr from @stangri)

I would guess that the wrong script content handling mostly affects the shebang line, as other lines in a shell script can be indented in any case.

@robimarko did work on those package inst scripts with apk in November, so he mihgt have views on this.

2 Likes

Done:

https://github.com/openwrt/openwrt/issues/17439

1 Like

Yeah, good eye, that's almost certainly it. I did a PR that strips leading blanks from those makefile sections, so it should fix issues without need to mess with the packages' makefiles. https://github.com/openwrt/openwrt/pull/17440

2 Likes

Thanks for the tag, I've updated all the Makefiles to ensure shebangs in the postinst/prerm scripts have no indentation, will be creating PRs for snapshots shortly.

1 Like

i'm navigating apk, and most package manipulation and customizing things work for me. but im stuck on a basic step of replacing the apk-mbedtls binary wiht the apk-openssl version
what are the steps to move from mbedtls to openssl in the apk system?
on a vanilla snapshot build, the default apk is apk-mbedtls
i can successfully apk update, but
apk add apk-openssl yields this:

root@ap253:~# apk add apk-openssl
(1/2) Installing libopenssl3 (3.0.15-r1)
Executing libopenssl3-3.0.15-r1.post-install
(2/2) Installing apk-openssl (3.0.0_pre20241130-r2)
ERROR: apk-openssl-3.0.0_pre20241130-r2: trying to overwrite etc/apk/repositories.d/customfeeds.list owned by apk-mbedtls-3.0.0_pre20241130-r2.
ERROR: apk-openssl-3.0.0_pre20241130-r2: trying to overwrite usr/bin/apk owned by apk-mbedtls-3.0.0_pre20241130-r2.
Executing apk-openssl-3.0.0_pre20241130-r2.post-install
1 error; 42 MiB in 211 packages

if i apk delete apk-mbedtls, then there is no binary for apk.
thx

Yeah, these catch-22 situations are a pain. A scratch build using firmware selector will get you there, just change the package list and create a whole new image, but if you want to be adventurous...

You could try editing /etc/apk/world, change apk-mbedtls to apk-openssl, delete any references to mbedtls package (libmbedtls21? others?), then run apk fix and see what it does. Report back, I'm curious. :grin:

I guess upgrading with owut (using "-r apk-mbedtls -a apk-openssl") would be considered an overkill?

No, actually that's probably the easiest way to do it, now that you mention it.

How about
apk add --force-overwrite apk-openssl to allow overwriting ????
(quite similar as with opkg)

See apk add help:

root@router6000:~# apk add -h
apk-tools 3.0.0_pre20241130, compiled for aarch64.

usage: apk add [<OPTIONS>...] CONSTRAINTS...

Description:
  apk add adds or updates given constraints to WORLD (see world) and commit
  changes to disk. This usually involves installing new packages, but may also
  cause other changes to the installed packages.

Global options:
  -h, --help            Print the list of all commands with descriptions
  -f, --force           Enable selected --force-* options (deprecated)
  -i, --interactive     Ask confirmation before performing certain
                        operations
  -p, --root ROOT       Manage file system at ROOT
  -q, --quiet           Print less information
  -U, --update-cache    Alias for '--cache-max-age 1'
  -v, --verbose         Print more information (can be specified twice)
  -V, --version         Print program version and exit
  -X, --repository REPO
                        Specify additional package repository
  --allow-untrusted     Install packages with untrusted signature or no
                        signature
  --arch ARCH           Temporarily override architectures
  --cache-dir CACHEDIR  Temporarily override the cache directory
  --cache-max-age AGE   Maximum AGE (in minutes) for index in cache before
                        it's refreshed
  --force-binary-stdout
                        Continue even if binary data will be printed to the
                        terminal
  --force-broken-world  DANGEROUS: Delete world constraints until a solution
                        without conflicts is found
  --force-missing-repositories
                        Continue even if some of the repository indexes are
                        not available
  --force-no-chroot     Disable chroot for scripts
  --force-non-repository
                        Continue even if packages may be lost on reboot
  --force-old-apk       Continue even if packages use unsupported features
  --force-overwrite     Overwrite files in other packages
  --force-refresh       Do not use cached files (local or from proxy)
  --keys-dir KEYSDIR    Override directory of trusted keys
  --no-cache            Do not use any local cache path
  --no-check-certificate
                        Do not validate the HTTPS server certificates
  --no-interactive      Disable interactive mode
...

I do it here to the other direction:

root@router6000:~# apk list -I apk*
apk-openssl-3.0.0_pre20241130-r2 aarch64_cortex-a53 {feeds/base/system/apk} (GPL-2.0-only) [installed]

root@router6000:~# apk add --force-overwrite apk-mbedtls
fetch https://downloads.openwrt.org/snapshots/targets/mediatek/filogic/packages/packages.adb
fetch https://downloads.openwrt.org/snapshots/packages/aarch64_cortex-a53/base/packages.adb
fetch https://downloads.openwrt.org/snapshots/packages/aarch64_cortex-a53/luci/packages.adb
fetch https://downloads.openwrt.org/snapshots/packages/aarch64_cortex-a53/packages/packages.adb
fetch https://downloads.openwrt.org/snapshots/packages/aarch64_cortex-a53/routing/packages.adb
(1/2) Installing libmbedtls21 (3.6.2-r1)
Executing libmbedtls21-3.6.2-r1.post-install
(2/2) Installing apk-mbedtls (3.0.0_pre20241130-r2)
WARNING: apk-mbedtls-3.0.0_pre20241130-r2: overwriting etc/apk/repositories.d/customfeeds.list owned by apk-openssl-3.0.0_pre20241130-r2.
WARNING: apk-mbedtls-3.0.0_pre20241130-r2: overwriting usr/bin/apk owned by apk-openssl-3.0.0_pre20241130-r2.
Executing apk-mbedtls-3.0.0_pre20241130-r2.post-install
OK: 72 MiB in 309 packages

root@router6000:~# apk list -I apk*
apk-mbedtls-3.0.0_pre20241130-r2 aarch64_cortex-a53 {feeds/base/package/system/apk} (GPL-2.0-only) [installed]
apk-openssl-3.0.0_pre20241130-r2 aarch64_cortex-a53 {feeds/base/system/apk} (GPL-2.0-only) [installed]
1 Like

this problem arose because firmware-selector is not yet functional for the mx4300. so only the prebuilt image was available. once firmware selctor catches up, the immediate problem goes away, but i'm still curious about how to do this.
the apk add --force-overwrite errorred amd the apk command still pointed to apk-mbedtls. when i removed mbedtls, the apk command yielded 'ash: apk: not found.'
edit -
now - 18 hours later and after apk update, the fore-overwrite option succeeds. but i have not completely elimated mbedtls due to other binaries. i'm
not sure what the problem was before, an di'll report back with another attempt
from a skelton mbedtls build

1 Like

Any fixes for the first 2 issues?

owut - OpenWrt Upgrade Tool 2024.12.10~e38844ae-r1 (/usr/bin/owut)
ERROR: ubus: Not found: Failed to invoke function 'packagelist' on object 'rpc-sys'
 from: 'ubus call rpc-sys packagelist { "all": true }'
This is a bug in 'owut/2024.12.10~e38844ae-r1', please report at
  https://github.com/efahl/owut/issues

In [anonymous function](), file /usr/bin/owut, line 103, byte 24:
  called from function [anonymous function] (/usr/bin/owut:245:58)
  called from function [anonymous function] (/usr/bin/owut:250:74)
  called from function collect_packages (/usr/bin/owut:981:67)
  called from function collect_all (/usr/bin/owut:1373:19)
  called from anonymous function (/usr/bin/owut:2065:15)

 `           `  ${issue_url}\n`);`
  Near here -------------------^

Is there any luci package to handle this?

ah,

apk upgrade
reboot

that was easy :wink:

further update to switch from mbedtls to openssl on skeleton image:

apk update 
apk add --force-overwrite apk-openssl libustream-openssl wpad-openssl
apk del *mbed*

success!

3 Likes

That is symptomatic of a broken installation, specifically the ucode-mod-ubus package is not installed. It is a hard dependency of owut and should have been installed as part of the owut installation.

That probably reinstalled owut and its dependencies, fixing the issue.

1 Like