[PATCH v2 6/7] coreutils: Import from packages feed
Brian Norris
computersforpeace at gmail.com
Mon Jan 9 11:51:53 PST 2023
On Mon, Jan 9, 2023 at 11:21 AM Christian Marangi <ansuelsmth at gmail.com> wrote:
>
> On Mon, Jan 09, 2023 at 03:35:56PM +0100, Petr Štetiar wrote:
> > Petr Štetiar <ynezz at true.cz> [2023-01-09 11:50:37]:
> >
> > Hi,
> >
> > > BTW ucode has `b64dec()`[1] so perhaps another viable option.
> > >
> > > 1. https://github.com/jow-/ucode#663-b64decstr
> >
> > wanted to refresh my ucode brain cells, so I've explored feasibility of that
> > suggestion and it seems to work just fine:
> >
> > #!/usr/bin/ucode
> >
> > import { stdin, open, error } from 'fs';
> >
> > if (length(ARGV) == 0 && stdin.isatty()) {
> > warn("usage: b64decode [stdin|path]\n");
> > exit(1);
> > }
> >
> > let fp = stdin;
> > let source = ARGV[0];
> >
> > if (source) {
> > fp = open(source);
> > if (!fp) {
> > warn(`b64decode: unable to open ${source}: ${error()}\n`);
> > exit(1);
> > }
> > }
> >
> > print(b64dec(fp.read("all")));
> > fp.close();
> > exit(0);
> >
> > BTW it needs recent ucode with fs.stdin.isatty() support[1].
> >
> > Thanks Jo for helping me making above script more idiomatic. IMO it looks more
> > human readable, portable and maintanable then that awk based solution.
> >
> > 1. https://github.com/jow-/ucode/commit/be30472bfdbbb410e8934b48a56d26c5c630d0f1
I sidestepped the isatty() stuff (below), and this works for me too.
> Thanks for helping with this. I really like the ucode way. Just a few
> question:
> 1. How this should be handled? A script that the target will provide?
> Part of a common function?
For my use, it feels like a simplified form (which only needs to be a
stdin/stdout pipeline) would be pretty easy to inline into the
caldata/firmware-loader script:
ucode -e 'import { stdin } from "fs"; print(b64dec(stdin.read("all")));'
> 2. Ucode is part of the core packages? Or an optional dependency for
> luci and fw4? In theory it should be always present or as a safe thing
> we should add ucode in the required packages for this target?
So far I don't find it as a strict core dependency, but just happens
to be available by default due to dependencies. I guess similar
questions to the busybox, coreutils, etc., stuff -- whether we're OK
with forcing 'ucode' as a per-target dependency / DEVICE_PACKAGES.
Brian
More information about the openwrt-devel
mailing list