[LEDE-DEV] [PATCH v2 2/3] base-files: put board_name into separate file

Roman Yeryomin leroi.lists at gmail.com
Wed May 17 04:49:56 PDT 2017


Hi John,

the reasoning is that most scripts which need board_name, don't need
anything else, and those which do need more, they need only a fraction
of functions.sh
The other aspect is that, e.g. including board.sh is 50-60 times
faster than including functions.sh
I'm going to send another RFC email about other scripts rework but the
main idea (as described in v1 of this patch set) is to separate
functions.sh by usage and reconsider it's functions usage.

Regards,
Roman

On 16 May 2017 at 13:26, John Crispin <john at phrozen.org> wrote:
> Hi Roman,
>
> what is the reasoning behind moving this function to its own file ?
>
>     John
>
>
>
> On 09/05/17 11:17, Roman Yeryomin wrote:
>>
>> Signed-off-by: Roman Yeryomin <roman at advem.lv>
>> ---
>>   package/base-files/files/lib/functions.sh       | 4 +---
>>   package/base-files/files/lib/functions/board.sh | 6 ++++++
>>   2 files changed, 7 insertions(+), 3 deletions(-)
>>   create mode 100644 package/base-files/files/lib/functions/board.sh
>>
>> diff --git a/package/base-files/files/lib/functions.sh
>> b/package/base-files/files/lib/functions.sh
>> index 2b6415a..2aaafcf 100755
>> --- a/package/base-files/files/lib/functions.sh
>> +++ b/package/base-files/files/lib/functions.sh
>> @@ -353,8 +353,6 @@ user_exists() {
>>         grep -qs "^${1}:" ${IPKG_INSTROOT}/etc/passwd
>>   }
>>   -board_name() {
>> -       [ -e /tmp/sysinfo/board_name ] && cat /tmp/sysinfo/board_name ||
>> echo "generic"
>> -}
>> +. /lib/functions/board.sh
>>     [ -z "$IPKG_INSTROOT" -a -f /lib/config/uci.sh ] && .
>> /lib/config/uci.sh
>> diff --git a/package/base-files/files/lib/functions/board.sh
>> b/package/base-files/files/lib/functions/board.sh
>> new file mode 100644
>> index 0000000..d33edc8
>> --- /dev/null
>> +++ b/package/base-files/files/lib/functions/board.sh
>> @@ -0,0 +1,6 @@
>> +#!/bin/sh
>> +
>> +board_name()
>> +{
>> +       [ -e /tmp/sysinfo/board_name ] && cat /tmp/sysinfo/board_name ||
>> echo "generic"
>> +}
>
>



More information about the Lede-dev mailing list