[Arm-netbook] Side-Topic: Liberating PocketCHIP

John Luke Gibson eaterjolly at gmail.com
Wed May 10 01:53:54 BST 2017


On 5/9/17, Benson Mitchell <benson.mitchell+arm-netbook at gmail.com> wrote:
> On May 9, 2017 7:02 PM, "John Luke Gibson" <eaterjolly at gmail.com> wrote:
>
> Like, the first file initiated by the main make file is
> support/setlocalversion which looks to just check a whole bunch of
> un-special variables which weren't set in the make script and had no
> opportunity to be set by any other files I know of (on my system the
> variables show as empty not having run anything from buildroot, but I
> can't imagine head would be set to such a specific git command on
> accident as the one it checks for). Then the if one of the conditions
> were some how filled, then all it does is print weird strings like
> this:
>
> printf '%s%s' -g $head
>
> Like this is the if statement:
>
> if head=`git rev-parse --verify --short HEAD 2>/dev/null`
>
> That "=" is assignment, and those "`"s are output substitution. It tries
> executing that git command, storing the output in the shell variable head.
> If git succeeds (returns zero), the then clause is executed; if git fails
> (returns non-zero), the else clause (if present) is executed.
>
> Mind you all this is printed to a variable in the make script called
> BR2_Version_Full which does nothing in the make script but get printed
> if a person asks the version, the script calls target-finalize or
> legal-info-prepare (which it looks like it does unconditionally in
> both cases). Like am I really that deep in over my head
>
> Apparently, but that's how we learn, right? :)
>
> or does this
> script really have a bug where if someone sets head to some weird
> obscure git command it prints that very command in it's legal info?
>
> No.
>
> Like how does that happen that way on accident? It looks like it might
> serve some obscure purpose if it ran the command (which from I can
> tell with bash, setting some $(shell x) might do that,
>
> "$(foo)" and "`foo`" are essentially the same. They both run foo, and
> substitute the output.
>

I ran this in terminal and got this:

john at john-ER922AA-ABA-SR1834NX-NA660:~/Documents/Code/OperationDaBlob/chip-buildroot+subsidiaries/CHIP-buildroot$
if head='git rev-parse --verify --short HEAD 2>/dev/null'; then
> echo $head;
> else
> echo "failed";
> fi
git rev-parse --verify --short HEAD 2>/dev/null
john at john-ER922AA-ABA-SR1834NX-NA660:~/Documents/Code/OperationDaBlob/chip-buildroot+subsidiaries/CHIP-buildroot$
#!/bin/bash
john at john-ER922AA-ABA-SR1834NX-NA660:~/Documents/Code/OperationDaBlob/chip-buildroot+subsidiaries/CHIP-buildroot$
# your code goes here
john at john-ER922AA-ABA-SR1834NX-NA660:~/Documents/Code/OperationDaBlob/chip-buildroot+subsidiaries/CHIP-buildroot$
if head=$(git rev-parse --verify --short HEAD 2>/dev/null); then
> echo $head;
> else
> echo "failed";
> fi
b52c25c
john at john-ER922AA-ABA-SR1834NX-NA660:~/Documents/Code/OperationDaBlob/chip-buildroot+subsidiaries/CHIP-buildroot$

So I do believe I found a bug, but I mixed up bash script and make
script when posing $(shell x) as a solution which retains
functionality.

@Jeff, that would be a best if we were starting from scratch. The Chip
community has put a lot into documentation and tutorials, so it might
not be best to throw all that out for a new os. Debian's not bad.



More information about the arm-netbook mailing list