Re: [OpenWrt-Devel] [RFC] additional Docker images and CI testing

2019-06-12 Thread Paul Spooren
Hi Ted,
> This sounds like a good idea - would giving you commit access to our
> docker hub [0] repo be of any help? Is there anything else I could
> help with?

I'd be happy with commit access to the docker hub (not to mistake with
git commit access).

Please find here a reworked version with a README and scripts that can
also run locally:

https://github.com/aparcar/openwrt-docker

>
> I don't know if you saw this posting I made last year about a simple
> use of our Docker image for test buiilds. Issue #7735 [1]. I had
> pinned it
> but for some reason @heil un-pinned it and I left it be.

I hadn't checked the PR yet but will do so soonish!

Paul

___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel


[OpenWrt-Devel] [PATCH] opkg: add --license arg for installed packages

2019-06-12 Thread Paul Spooren
add --license option to print (SPDX) license tag in the
`installed-packages` overview. This is useful for manifest generation,
as it show all licenses used within an image. In case the license is not
available, a question mark (?) is printed instead.

base-files - 198-r10203+1-c12bd3a21b - GPL-2.0
bnx2-firmware - 20190416-1 - ?
busybox - 1.30.1-4 - GPL-2.0
dnsmasq - 2.80-13 - GPL-2.0
dropbear - 2019.78-2 - MIT
e2fsprogs - 1.44.5-1 - GPL-2.0
firewall - 2019-01-02-70f8785b-2 - ISC
fstools - 2019-03-28-ff1ded63-4 - GPL-2.0
fwtool - 1 - ?
getrandom - 2019-04-07-5130fa4d-2 - GPL-2.0
ip6tables - 1.8.2-3 - GPL-2.0
iptables - 1.8.2-3 - GPL-2.0
jshn - 2019-02-27-eeef7b50-1 - ISC
jsonfilter - 2018-02-04-c7e938d6-1 - ISC
...

CC: Jo-Philipp Wich 
Signed-off-by: Paul Spooren 
---
 libopkg/opkg_cmd.c  |  3 +++
 libopkg/opkg_conf.c |  1 +
 libopkg/opkg_conf.h |  1 +
 libopkg/pkg.c   | 11 +++
 libopkg/pkg.h   |  1 +
 libopkg/pkg_parse.c |  5 +
 libopkg/pkg_parse.h |  1 +
 src/opkg-cl.c   |  7 +++
 8 files changed, 30 insertions(+)

diff --git a/libopkg/opkg_cmd.c b/libopkg/opkg_cmd.c
index c823df8..e8a34f4 100644
--- a/libopkg/opkg_cmd.c
+++ b/libopkg/opkg_cmd.c
@@ -45,9 +45,12 @@ static void print_pkg(pkg_t * pkg)
 {
char *version = pkg_version_str_alloc(pkg);
char *description = pkg_get_string(pkg, PKG_DESCRIPTION);
+   char *license = pkg_get_string(pkg, PKG_LICENSE);
printf("%s - %s", pkg->name, version);
if (conf->size)
printf(" - %lu", (unsigned long) pkg_get_int(pkg, PKG_SIZE));
+   if (conf->license)
+   printf(" - %s", license ? license : "?");
if (description)
printf(" - %s", description);
printf("\n");
diff --git a/libopkg/opkg_conf.c b/libopkg/opkg_conf.c
index 08855eb..40b1734 100644
--- a/libopkg/opkg_conf.c
+++ b/libopkg/opkg_conf.c
@@ -70,6 +70,7 @@ opkg_option_t options[] = {
{"proxy_user", OPKG_OPT_TYPE_STRING, &_conf.proxy_user},
{"query-all", OPKG_OPT_TYPE_BOOL, &_conf.query_all},
{"size", OPKG_OPT_TYPE_BOOL, &_conf.size},
+   {"license", OPKG_OPT_TYPE_BOOL, &_conf.license},
{"tmp_dir", OPKG_OPT_TYPE_STRING, &_conf.tmp_dir},
{"verbosity", OPKG_OPT_TYPE_INT, &_conf.verbosity},
{NULL, 0, NULL}
diff --git a/libopkg/opkg_conf.h b/libopkg/opkg_conf.h
index 37f95a1..0413ccd 100644
--- a/libopkg/opkg_conf.h
+++ b/libopkg/opkg_conf.h
@@ -87,6 +87,7 @@ struct opkg_conf {
int verbosity;
int noaction;
int size;
+   int license;
int download_only;
char *cache;
 
diff --git a/libopkg/pkg.c b/libopkg/pkg.c
index e5bfe6f..fb1b2f1 100644
--- a/libopkg/pkg.c
+++ b/libopkg/pkg.c
@@ -777,6 +777,15 @@ void pkg_formatted_field(FILE * fp, pkg_t * pkg, const 
char *field)
}
}
break;
+   case 'l':
+   case 'L':
+   if (strcasecmp(field, "License") == 0) {
+   p = pkg_get_string(pkg, PKG_LICENSE);
+   if (p && *p) {
+   fprintf(fp, "License: %s\n", p);
+   }
+   }
+   break;
case 'm':
case 'M':
if (strcasecmp(field, "Maintainer") == 0) {
@@ -926,6 +935,7 @@ void pkg_formatted_info(FILE * fp, pkg_t * pkg)
pkg_formatted_field(fp, pkg, "Package");
pkg_formatted_field(fp, pkg, "Version");
pkg_formatted_field(fp, pkg, "Depends");
+   pkg_formatted_field(fp, pkg, "License");
pkg_formatted_field(fp, pkg, "Recommends");
pkg_formatted_field(fp, pkg, "Suggests");
pkg_formatted_field(fp, pkg, "Provides");
@@ -956,6 +966,7 @@ void pkg_print_status(pkg_t * pkg, FILE * file)
pkg_formatted_field(file, pkg, "Package");
pkg_formatted_field(file, pkg, "Version");
pkg_formatted_field(file, pkg, "Depends");
+   pkg_formatted_field(file, pkg, "License");
pkg_formatted_field(file, pkg, "Recommends");
pkg_formatted_field(file, pkg, "Suggests");
pkg_formatted_field(file, pkg, "Provides");
diff --git a/libopkg/pkg.h b/libopkg/pkg.h
index 600fc9e..0065043 100644
--- a/libopkg/pkg.h
+++ b/libopkg/pkg.h
@@ -79,6 +79,7 @@ typedef enum pkg_state_status pkg_state_status_t;
 
 enum pkg_fields {
PKG_MAINTAINER,
+   PKG_LICENSE,
PKG_PRIORITY,
PKG_SOURCE,
PKG_TAGS,
diff --git a/libopkg/pkg_parse.c b/libopkg/pkg_parse.c
index 0baa4db..87db2fa 100644
--- a/libopkg/pkg_parse.c
+++ b/libopkg/pkg_parse.c
@@ -269,6 +269,11 @@ int pkg_parse_line(void *ptr, char *line, uint mask)
pkg_set_int(pkg, PKG_INSTALLED_TIME, strtoul(line + 
strlen("Installed-Time") + 1, NULL, 0));
}
break;
+   case 'l':
+   case 'L':
+   if ((mask & PFM_LICENSE) && is_field("License:", line))
+   pkg_set_string(pkg, 

Re: [OpenWrt-Devel] [PATCH v3 2/3] network/config: add xfrm interface support scripts

2019-06-12 Thread Andre Valentin
Hi Hans!!
Am 11.06.19 um 22:16 schrieb Hans Dedecker:
> Hi,
> 
> On Mon, Jun 10, 2019 at 8:10 PM Andre Valentin  wrote:
>>
>> Hi Hans,
>>
>> after testing xfrm tunnels a bit I found to big differences compared to 
>> other convential tunnels.
>> 1) xfrm tunnel interfaces cannot be replaced with netlink
>> 2) xfrm tunnel interfaces DO NOT vanish if parent is deleted
>>
>> This leads to some errors and a loop in interface creation. With the changes 
>> below,
>> it works smoothly when not bound to ppp interfaces (using lan instead), see:
>> Mon Jun 10 11:42:06 2019 daemon.notice netifd: xfrm0 (14255): Command 
>> failed: Unknown error
>> Mon Jun 10 11:42:06 2019 daemon.notice netifd: Interface 'xfrm0' is now down
>> Mon Jun 10 11:42:06 2019 daemon.notice netifd: Interface 'xfrm0' is setting 
>> up now
>> Mon Jun 10 11:42:06 2019 daemon.notice netifd: xfrm0 (14281): Command 
>> failed: Unknown error
>> and so on
 What do you think?
> The description is a bit cryptic to me; could you explain what works
> and what does not work and why ?
Sorry for being cryptic, I tend to that;-) Okay, I do the following:
# ifup xfrm0
... use it
# ifdown xfrm0
The interface still exists (checked with ip link)

Now I'll do ifup again and this happens endlessly:
>> Mon Jun 10 11:42:06 2019 daemon.notice netifd: xfrm0 (14255): Command 
>> failed: Unknown error
>> Mon Jun 10 11:42:06 2019 daemon.notice netifd: Interface 'xfrm0' is now down
>> Mon Jun 10 11:42:06 2019 daemon.notice netifd: Interface 'xfrm0' is setting 
>> up now
>> Mon Jun 10 11:42:06 2019 daemon.notice netifd: xfrm0 (14281): Command 
>> failed: Unknown error

In netifd the xfrm0 interface is created with the REPLACE flag, but that does 
not seem to work, it cannot be recreated and fails.
The result is the upper error repeating.
That's why I think about the call to "ip link delete xfrm0" before 
proto_init_update call and in the teardown call.

André


> 
> Hans
>>
>> Kind regards,
>>
>> André
>>
>>
>> Am 09.06.19 um 21:27 schrieb Hans Dedecker:
>>> On Sat, Jun 8, 2019 at 1:48 PM André Valentin  wrote:

 This package adds scripts for xfrm interfaces support.
 Example configuration via /etc/config/network:

 config interface 'xfrm0'
 option proto 'xfrm'
 option mtu '1300'
 option zone 'VPN'
 option tunlink 'wan'
 option ifid 30

 config interface 'xfrm0_static'
 option proto 'static'
 option ifname '@xfrm0'
 option ip6addr 'fe80::1/64'
 option ipaddr '10.0.0.1/30'

 Now set in strongswan IPsec policy:
 if_id_in = 30
 if_id_out = 30
 ---
  package/network/config/xfrm/Makefile  | 38 ++
  package/network/config/xfrm/files/xfrm.sh | 65 
 +++
  2 files changed, 103 insertions(+)
  create mode 100644 package/network/config/xfrm/Makefile
  create mode 100755 package/network/config/xfrm/files/xfrm.sh

 diff --git a/package/network/config/xfrm/Makefile 
 b/package/network/config/xfrm/Makefile
 new file mode 100644
 index 00..efc90cf318
 --- /dev/null
 +++ b/package/network/config/xfrm/Makefile
 @@ -0,0 +1,38 @@
 +
 +include $(TOPDIR)/rules.mk
 +
 +PKG_NAME:=xfrm
 +PKG_VERSION:=1
 +PKG_RELEASE:=1
 +PKG_LICENSE:=GPL-2.0
 +
 +include $(INCLUDE_DIR)/package.mk
 +
 +define Package/xfrm/Default
 +  SECTION:=net
 +  CATEGORY:=Network
 +  MAINTAINER:=Andre Valentin 
 +endef
 +
 +define Package/xfrm
 +$(call Package/xfrm/Default)
 +  TITLE:=XFRM IPsec Tunnel Interface config support
 +  DEPENDS:=+kmod-xfrm-interface
 +endef
 +
 +define Package/xfrm/description
 + XFRM IPsec Tunnel Interface config support (IPv4 and IPv6) in 
 /etc/config/network.
 +endef
 +
 +define Build/Compile
 +endef
 +
 +define Build/Configure
 +endef
 +
 +define Package/xfrm/install
 +   $(INSTALL_DIR) $(1)/lib/netifd/proto
 +   $(INSTALL_BIN) ./files/xfrm.sh $(1)/lib/netifd/proto/xfrm.sh
 +endef
 +
 +$(eval $(call BuildPackage,xfrm))
 diff --git a/package/network/config/xfrm/files/xfrm.sh 
 b/package/network/config/xfrm/files/xfrm.sh
 new file mode 100755
 index 00..df28d38613
 --- /dev/null
 +++ b/package/network/config/xfrm/files/xfrm.sh
 @@ -0,0 +1,65 @@
 +#!/bin/sh
 +
 +[ -n "$INCLUDE_ONLY" ] || {
 +   . /lib/functions.sh
 +   . /lib/functions/network.sh
 +   . ../netifd-proto.sh
 +   init_proto "$@"
 +}
 +
 +proto_xfrm_setup() {
 +   local cfg="$1"
 +   local mode="xfrm"
 +
 +   local tunlink ifid mtu zone
 +   json_get_vars tunlink ifid mtu zone
 +
>> if exists .. ip link del "$cfg"
>>
 +   proto_init_update "$cfg" 1
 +

Re: [OpenWrt-Devel] [firewall3] utils: coverity resource leak warning

2019-06-12 Thread Jo-Philipp Wich
Hi Kevin,

ACK. Feel free to push.

~ Jo

___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel


[OpenWrt-Devel] [firewall3] utils: coverity resource leak warning

2019-06-12 Thread Kevin Darbyshire-Bryant
solve coverity reported resource leak (socket handle)

Signed-off-by: Kevin Darbyshire-Bryant 
---
 utils.c | 18 --
 1 file changed, 12 insertions(+), 6 deletions(-)

diff --git a/utils.c b/utils.c
index 7f09787..fc6bbd7 100644
--- a/utils.c
+++ b/utils.c
@@ -944,18 +944,24 @@ bool
 fw3_check_loopback_dev(const char *name)
 {
struct ifreq ifr;
-   int s = socket(AF_LOCAL, SOCK_DGRAM, 0);
+   int s;
bool rv = false;
 
+   s = socket(AF_LOCAL, SOCK_DGRAM, 0);
+
+   if (s < 0)
+   return false;
+
memset(, 0, sizeof(ifr));
strncpy(ifr.ifr_name, name, sizeof(ifr.ifr_name) - 1);
 
-   if (s < 0 || ioctl(s, SIOCGIFFLAGS, ) < 0)
-   goto out;
+   if (ioctl(s, SIOCGIFFLAGS, ) >= 0) {
+   if (ifr.ifr_flags & IFF_LOOPBACK)
+   rv = true;
+   }
+
+   close(s);
 
-   if (ifr.ifr_flags & IFF_LOOPBACK)
-   rv = true;
-out:
return rv;
 }
 
-- 
2.20.1 (Apple Git-117)


___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel


Re: [OpenWrt-Devel] KERNEL_PATCHVER in master

2019-06-12 Thread Koen Vandeputte



On 12.06.19 14:06, Jonas Gorski wrote:

On Wed, 12 Jun 2019 at 11:02, Koen Vandeputte
 wrote:


On 11.06.19 23:12, Jonas Gorski wrote:

Hi,

On Tue, 11 Jun 2019 at 23:08, Stijn Tintel  wrote:

Hi,

Since we now have a 19.07 branch, is it OK to switch KERNEL_PATCHVER for
targets in master that have 4.19 support to 4.19?

Fine by me. The earlier we start testing 4.19, the faster we can iron
out the kinks, hopefully reducing the maturation phase of the next
release.


Fine for me, but please hold off a little bit until I pushed my kernel
bump later today. (already in staging)

Otherwise there's a chance I need to redo it ;-)

This is only about enabling 4.19 by default if supported, not adding
4.19 support where missing. So shouldn't affect any kernel bumps.


Very true,

But I'm expecting patches coming in fast when people start testing this.
When this happens, I'll need to rebase this bump continuously. ;-)

Most bumps don't require to much alteration, but this one in staging 
took me a few hours ..


Koen


Regards

Jonas


___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel


Re: [OpenWrt-Devel] KERNEL_PATCHVER in master

2019-06-12 Thread Jonas Gorski
On Wed, 12 Jun 2019 at 11:02, Koen Vandeputte
 wrote:
>
>
> On 11.06.19 23:12, Jonas Gorski wrote:
> > Hi,
> >
> > On Tue, 11 Jun 2019 at 23:08, Stijn Tintel  wrote:
> >> Hi,
> >>
> >> Since we now have a 19.07 branch, is it OK to switch KERNEL_PATCHVER for
> >> targets in master that have 4.19 support to 4.19?
> > Fine by me. The earlier we start testing 4.19, the faster we can iron
> > out the kinks, hopefully reducing the maturation phase of the next
> > release.
> >
> Fine for me, but please hold off a little bit until I pushed my kernel
> bump later today. (already in staging)
>
> Otherwise there's a chance I need to redo it ;-)

This is only about enabling 4.19 by default if supported, not adding
4.19 support where missing. So shouldn't affect any kernel bumps.

Regards

Jonas

___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel


Re: [OpenWrt-Devel] [RFC] sysupgrade: Cross-flashing NOR/NAND proof of concept

2019-06-12 Thread Chuanhong Guo
Hi!

On Wed, Jun 12, 2019 at 8:42 AM Jeff Kletsky  wrote:
>
> From: Jeff Kletsky 
>   * The kernel and software for both the NOR- and NAND-resident
> variants need to be able to read/write raw MTD as well as UBI.
>
>   * The existing sysupgrade paths already prevent flashing of a
> NOR-intended image onto a NAND-based device, as well as the other
> way around. As such, even if a approach like this is accepted
> after these board names are "in the wild", sysupgrade will be
> "safe" on "old" builds against future additions to SUPPORTED_DEVICES.

Why would someone do such a cross-flashing at the first place?
If you want to recover the firmware in SPI NAND with a firmware in SPI
NOR, You could just flash a initramfs image of the NAND variant into
NOR flash. (And vice versa)

>
>   * The MTD partitioning for both variants need to define both NOR and
> NAND partitioning

GL-AR300M has an NOR-only variant and by adding SPI NAND node into the
NOR variant you'll add some unnecessary error messages into kernel
log.

Regards,
Chuanhong Guo

___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel


Re: [OpenWrt-Devel] [PATCH 4/4] package: fix "LTO" option resulted in building error

2019-06-12 Thread Nylon Chen
On Tue, Jun 11, 2019 at 11:21:45PM +0800, Felix Fietkau wrote:
> On 2019-06-11 12:32, Nylon Chen wrote:
> > When a building package has -flto option leads to building error
> > 
> > We must use the gcc-ar wrapper instead of ar to invoke ar with the right
> > plugin arguments for handling the LTO objects when -flto is specified.
> > 
> > Signed-off-by: Che-Wei Chuang 
> > Signed-off-by: Nylon Chen 
> Why is this nds32 specific?
Not only nds32
> Does it not make sense to extend this to all targets?
I am not sure, but I am trying the others toolchain

x86-gcc
gcc version 7.4.0 (Ubuntu 7.4.0-1ubuntu1~18.04)
cc -flto -c f1.c
cc -flto -c f2.c
ar -r f.a f1.o f2.o
ar: creating f.a
rm -rf *.o *.a

gcc version 5.4.0 20160609 (Ubuntu 5.4.0-6ubuntu1~16.04.11)
cc -flto -c f1.c
cc -flto -c f2.c
ar -r f.a f1.o f2.o
ar: creating f.a
ar: f1.o: plugin needed to handle lto object
ar: f2.o: plugin needed to handle lto object
rm -rf *.o *.a

riscv
riscv64-linux-gcc -flto -c f1.c
riscv64-linux-gcc -flto -c f2.c
riscv64-linux-ar -r f.a f1.o f2.o
riscv64-linux-ar: creating f.a
rm -rf *.o *.a

nds32
nds32le-linux-gcc -flto -c f1.c
nds32le-linux-gcc -flto -c f2.c
nds32le-linux-ar -r f.a f1.o f2.o
nds32le-linux-ar: creating f.a
nds32le-linux-ar: f1.o: plugin needed to handle lto object
nds32le-linux-ar: f2.o: plugin needed to handle lto object
nds32le-linux-gcc-ar -r f.a f1.o f2.o
nds32le-linux-glibc-v3-upstream/bin/../lib/gcc/nds32le-linux/8.0.1/../../../../nds32le-linux/bin/ar:
 creating f.a
rm -rf *.o *.a

arm
arm-none-eabi-gcc -flto -c f1.c
arm-none-eabi-gcc -flto -c f2.c
arm-none-eabi-ar -r f.a f1.o f2.o
arm-none-eabi-ar: creating f.a
arm-none-eabi-ar: f1.o: plugin needed to handle lto object
arm-none-eabi-ar: f2.o: plugin needed to handle lto object
arm-none-eabi-gcc-ar -r f.a f1.o f2.o
gcc-arm-none-eabi-8-2018-q4-major/bin/../lib/gcc/arm-none-eabi/8.2.1/../../../../arm-none-eabi/bin/ar:
 creating f.a
rm -rf *.o *.a

summary
1.the same issue could be found in other vendors' toolchain
2.pass on newer than x86-gcc5.4 version
3.specificed -ffat-lto-objects during building toolchain could be solved
> 
> - Felix

___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel


Re: [OpenWrt-Devel] KERNEL_PATCHVER in master

2019-06-12 Thread Koen Vandeputte



On 11.06.19 23:12, Jonas Gorski wrote:

Hi,

On Tue, 11 Jun 2019 at 23:08, Stijn Tintel  wrote:

Hi,

Since we now have a 19.07 branch, is it OK to switch KERNEL_PATCHVER for
targets in master that have 4.19 support to 4.19?

Fine by me. The earlier we start testing 4.19, the faster we can iron
out the kinks, hopefully reducing the maturation phase of the next
release.

Fine for me, but please hold off a little bit until I pushed my kernel 
bump later today. (already in staging)


Otherwise there's a chance I need to redo it ;-)

Thanks,

Koen


Regards
Jonas

___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel


___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel


[OpenWrt-Devel] [PATCH opkg] alternatives: special-case busybox as alternatives provider

2019-06-12 Thread Yousong Zhou
From: Yousong Zhou 

Almost all busybox applets are alternatives to some other existing
"full" utilities.  To lift the maintenance burden of enumerating CONFIG
symbols, symlink path of each applet, we special case busybox here as a
known alternatives provider.

All file pathes provided by busybox will serve as fallback alternatives
with -inf priority.  Packages intending to switch to using alternatives
mechanism will also not need to depend on the same kind of change be
applied on busybox in base system

Signed-off-by: Yousong Zhou 
---
 libopkg/pkg_alternatives.c | 35 ---
 1 file changed, 32 insertions(+), 3 deletions(-)

diff --git a/libopkg/pkg_alternatives.c b/libopkg/pkg_alternatives.c
index 50e9d12..4a1a31c 100644
--- a/libopkg/pkg_alternatives.c
+++ b/libopkg/pkg_alternatives.c
@@ -27,6 +27,28 @@
 #include "pkg_alternatives.h"
 #include "sprintf_alloc.h"
 
+static bool pkg_alternatives_check_busybox(const char *path)
+{
+   pkg_t *pkg;
+   str_list_t *files;
+   str_list_elt_t *iter;
+   bool found = false;
+
+   pkg = pkg_hash_fetch_installed_by_name("busybox");
+   if (!pkg) {
+   return false;
+   }
+   files = pkg_get_installed_files(pkg);
+   for (iter = str_list_first(files); iter; iter = str_list_next(files, 
iter)) {
+   if (!strcmp(path, (char *)(iter->data))) {
+   found = true;
+   break;
+   }
+   }
+   pkg_free_installed_files(pkg);
+   return found;
+}
+
 static int pkg_alternatives_update_path(pkg_t *pkg, const pkg_vec_t 
*installed, const char *path)
 {
struct pkg_alternatives *pkg_alts;
@@ -35,6 +57,7 @@ static int pkg_alternatives_update_path(pkg_t *pkg, const 
pkg_vec_t *installed,
int i, j;
int r;
char *path_in_dest;
+   char *target_path = NULL;
 
for (i = 0; i < installed->len; i++) {
pkg_t *pkg = installed->pkgs[i];
@@ -60,6 +83,12 @@ static int pkg_alternatives_update_path(pkg_t *pkg, const 
pkg_vec_t *installed,
return -1;
 
if (the_alt) {
+   target_path = the_alt->altpath;
+   } else if (pkg_alternatives_check_busybox(path)) {
+   target_path = "/bin/busybox";
+   }
+
+   if (target_path) {
struct stat sb;
 
r = lstat(path_in_dest, );
@@ -72,7 +101,7 @@ static int pkg_alternatives_update_path(pkg_t *pkg, const 
pkg_vec_t *installed,
goto out;
}
realpath = xreadlink(path_in_dest);
-   if (realpath && strcmp(realpath, the_alt->altpath))
+   if (realpath && strcmp(realpath, target_path))
unlink(path_in_dest);
free(realpath);
} else if (errno != ENOENT) {
@@ -87,7 +116,7 @@ static int pkg_alternatives_update_path(pkg_t *pkg, const 
pkg_vec_t *installed,
if (r) {
goto out;
}
-   r = symlink(the_alt->altpath, path_in_dest);
+   r = symlink(target_path, path_in_dest);
if (r && errno == EEXIST) {
/*
 * the strcmp & unlink check above will make 
sure that if EEXIST
@@ -96,7 +125,7 @@ static int pkg_alternatives_update_path(pkg_t *pkg, const 
pkg_vec_t *installed,
r = 0;
}
if (r) {
-   opkg_perror(ERROR, "failed symlinking %s -> 
%s", path_in_dest, the_alt->altpath);
+   opkg_perror(ERROR, "failed symlinking %s -> 
%s", path_in_dest, target_path);
}
}
} else {

___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel