[Toybox] [PATCH] cpio: fixes for Android kernel build.

Rob Landley rob at landley.net
Fri Aug 21 03:15:18 PDT 2020



On 8/19/20 6:05 PM, enh wrote:
> 
> On Wed, Aug 19, 2020 at 3:59 PM Rob Landley <rob at landley.net
> <mailto:rob at landley.net>> wrote:
> 
> 
> 
>     On 8/19/20 4:51 PM, enh via Toybox wrote:
>     > Allow -pd to work by changing -p from an option that takes an
>     > argument to an option that implies there will be an argument (that
>     > is, `-pd x` is `-p -d x` with x being the directory for -p, rather
>     > than `-p d x` with d being the directory, as we previously interpreted
>     > it).
>     >
>     > Fix -d (aka --make-directories) to not be a no-op. Previously we
>     > acted as if this was always on.
>     >
>     > Accept --quiet and effectively just ignore it, since toybox cpio
>     > doesn't seem to produce any output that --quiet would suppress.
> 
>     $ echo yank | cpio out -pd
>     cpio: You must specify one of -oipt options.
>     Try `cpio --help' or `cpio --usage' for more information.
>     It's not position independent, it uses Unix System 6 parsing logic like
>     "tar cvfC file dir" does. Your fix doesn't make the semantics match, it works
>     around a specific bug.

No it doesn't. The gnu/dammit cpio is apparently using some horrible hand-rolled
option parsing that's inconsistent between options:

  $ find . | cpio -Ho newc
  cpio: invalid archive format `o'; valid formats are:
  crc newc odc bin ustar tar (all-caps also recognized)
  $ find . | cpio -oH newc
  0707010490302E0000...

  $ cpio -pHd newc sub
  cpio: invalid archive format `d'; valid formats are:
  crc newc odc bin ustar tar (all-caps also recognized)
  $ cpio -pdH newc sub
  cpio: Archive format is not specified in copy-pass mode (use --format option)
  $ cpio -pdHnewc sub
  cpio: Archive format is not specified in copy-pass mode (use --format option)
  $ cpio -pdHnexc sub
  cpio: invalid archive format `nexc'; valid formats are:
  crc newc odc bin ustar tar (all-caps also recognized)

so -H is parsed with modern collating style, and -p is parsed with unixv6
collating style, IN THE SAME COMMAND LINE.

I'm starting to lean back towards applying your patch verbatim. While I _can_
teach lib/args.c how to do that, it's TOO STUPID FOR WORDS and I'd wait for a
second outright broken command to need it before... ow?

Rob


More information about the Toybox mailing list