diff options
author | Paul Spooren <mail@aparcar.org> | 2024-05-03 18:24:17 +0200 |
---|---|---|
committer | Paul Spooren <mail@aparcar.org> | 2024-05-14 12:37:08 +0200 |
commit | 2f8fd44b7d34ac9cc1dbb326d4ad89c70910b90c (patch) | |
tree | a65d741597a305a8087faa3f417b4857ce14cf24 | |
parent | be0c7b4e299214287b72fc42650329d6c40e1bfe (diff) | |
download | openwrt-2f8fd44b7d34ac9cc1dbb326d4ad89c70910b90c.tar.gz openwrt-2f8fd44b7d34ac9cc1dbb326d4ad89c70910b90c.tar.bz2 openwrt-2f8fd44b7d34ac9cc1dbb326d4ad89c70910b90c.zip |
base-files: add compatibility for APK and OPKG
Both package managers work slightly different, i.e. stores files at
different places. Modify the `functions.sh` file to cover those.
Signed-off-by: Paul Spooren <mail@aparcar.org>
-rw-r--r-- | package/base-files/files/lib/functions.sh | 26 |
1 files changed, 20 insertions, 6 deletions
diff --git a/package/base-files/files/lib/functions.sh b/package/base-files/files/lib/functions.sh index 1126a93e88..313b8466f0 100644 --- a/package/base-files/files/lib/functions.sh +++ b/package/base-files/files/lib/functions.sh @@ -211,8 +211,10 @@ config_list_foreach() { default_prerm() { local root="${IPKG_INSTROOT}" - local pkgname="$(basename ${1%.*})" + [ -z "$pkgname" ] && local pkgname="$(basename ${1%.*})" local ret=0 + local filelist="/usr/lib/opkg/info/${pkgname}.list" + [ -f "$root/lib/apk/packages/${pkgname}.list" ] && filelist="$root/lib/apk/packages/${pkgname}.list" if [ -f "$root/usr/lib/opkg/info/${pkgname}.prerm-pkg" ]; then ( . "$root/usr/lib/opkg/info/${pkgname}.prerm-pkg" ) @@ -220,7 +222,7 @@ default_prerm() { fi local shell="$(command -v bash)" - for i in $(grep -s "^/etc/init.d/" "$root/usr/lib/opkg/info/${pkgname}.list"); do + for i in $(grep -s "^/etc/init.d/" "$filelist"); do if [ -n "$root" ]; then ${shell:-/bin/sh} "$root/etc/rc.common" "$root$i" disable else @@ -235,8 +237,11 @@ default_prerm() { } add_group_and_user() { - local pkgname="$1" + [ -z "$pkgname" ] && local pkgname="$(basename ${1%.*})" local rusers="$(sed -ne 's/^Require-User: *//p' $root/usr/lib/opkg/info/${pkgname}.control 2>/dev/null)" + if [ -f "$root/lib/apk/packages/${pkgname}.rusers" ]; then + local rusers="$(cat $root/lib/apk/packages/${pkgname}.rusers)" + fi if [ -n "$rusers" ]; then local tuple oIFS="$IFS" @@ -337,11 +342,20 @@ update_alternatives() { default_postinst() { local root="${IPKG_INSTROOT}" - local pkgname="$(basename ${1%.*})" + [ -z "$pkgname" ] && local pkgname="$(basename ${1%.*})" local filelist="/usr/lib/opkg/info/${pkgname}.list" + [ -f "$root/lib/apk/packages/${pkgname}.list" ] && filelist="$root/lib/apk/packages/${pkgname}.list" local ret=0 - add_group_and_user "${pkgname}" + if [ -e "${root}/usr/lib/opkg/info/${pkgname}.list" ]; then + filelist="${root}/usr/lib/opkg/info/${pkgname}.list" + add_group_and_user "${pkgname}" + fi + + if [ -e "${root}/lib/apk/packages/${pkgname}.list" ]; then + filelist="${root}/lib/apk/packages/${pkgname}.list" + update_alternatives install "${pkgname}" + fi if [ -d "$root/rootfs-overlay" ]; then cp -R $root/rootfs-overlay/. $root/ @@ -374,7 +388,7 @@ default_postinst() { fi local shell="$(command -v bash)" - for i in $(grep -s "^/etc/init.d/" "$root$filelist"); do + for i in $(grep -s "^/etc/init.d/" "$filelist"); do if [ -n "$root" ]; then ${shell:-/bin/sh} "$root/etc/rc.common" "$root$i" enable else |