Commit Graph

30 Commits

Author SHA1 Message Date
Khem Raj
c0f8113f86 gen_build_files: Use C locale when calling sed on globbed files
When include/applets.h is re-generated

it generates code macros in include/applets.h e.g.

IF_XZCAT(APPLET_ODDNAME(xzcat, unxz, BB_DIR_USR_BIN, BB_SUID_DROP, xzcat))
...
IF_CHVT(APPLET_NOEXEC(chvt, chvt, BB_DIR_USR_BIN, BB_SUID_DROP, chvt))
...

sed is used to process source files like below to feed into this header
generation

sed -n 's@^//applet:@@p' "$srctree"/*/*.c "$srctree"/*/*/*.c

this means we let shell decide the order of .c files being fed into sed
tool, applets.h has code snippets thats generated out of code fragments
from these .c files and the order of the generated code depends on the
order of .c files being fed to sed and then piped to generate tool, even
though the generated code is logically same, it does result in re-odered
code in applets.h based on which shell was used during build on exact busybox
sources since sort order is different based on chosen locale and also default shell
being bash or dash

This sets the environment variable LC_ALL to the value C, which will
enforce bytewise sorting, irrespective of the shell

Signed-off-by: Khem Raj <raj.khem@gmail.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2021-06-05 17:36:19 +02:00
Ron Yorston
71df2d3589 hush: allow hush to run embedded scripts
Embedded scripts require a shell to be present in the BusyBox
binary.  Allow either ash or hush to be used for this purpose.
If both are enabled ash takes precedence.

The size of the binary is unchanged in the default configuration:
both ash and hush are present but support for embedded scripts
isn't compiled into hush.

Signed-off-by: Ron Yorston <rmy@pobox.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-11-27 16:13:07 +01:00
Ron Yorston
7b42f8fc76 Tweaks to build process for embedded scripts
- Force a rebuild if a script in applets_sh is changed.

- Move the dummy usage messages for custom applets to usage.h and
  change the name from 'dummy' to 'scripted'.

- Hide an error from gen_build_files.sh if an embed directory exists
  but is empty.

- Tidy up embedded_scripts script.

v2: Remove a couple of unnecessary tests in embedded_scripts, as
    pointed out by Xabier Oneca.
    Drop the stripping of comments.

Signed-off-by: Ron Yorston <rmy@pobox.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-11-27 10:38:10 +01:00
Ron Yorston
3778898f97 Treat custom and applet scripts as applets
BusyBox has support for embedded shell scripts.  Two types can be
distinguished:  custom scripts and scripts implementing applets.

Custom scripts should be placed in the 'embed' directory at build
time.  They are given a default applet configuration and appear
as applets to the user but no further configuration is possible.

Applet scripts are integrated with the BusyBox build system and
are intended to be used to ship standard applets that just happen
to be implemented as scripts.  They can be configured at build time
and appear just like native applets.

Such scripts should be placed in the 'applets_sh' directory.  A stub
C program should be written to provide the usual applet configuration
details and placed in a suitable subsystem directory.  It may be
helpful to have a configuration option to enable any dependencies the
script requires:  see the 'nologin' applet for an example.

function                                             old     new   delta
scripted_main                                          -      41     +41
applet_names                                        2773    2781      +8
applet_main                                         1600    1604      +4
i2cdetect_main                                       672     674      +2
applet_suid                                          100     101      +1
applet_install_loc                                   200     201      +1
applet_flags                                         100     101      +1
packed_usage                                       33180   33179      -1
tryexec                                              159     152      -7
evalcommand                                         1661    1653      -8
script_names                                           9       -      -9
packed_scripts                                       123     114      -9
complete_cmd_dir_file                                826     811     -15
shellexec                                            271     254     -17
find_command                                        1007     990     -17
busybox_main                                         642     624     -18
run_applet_and_exit                                  100      78     -22
find_script_by_name                                   51       -     -51
------------------------------------------------------------------------------
(add/remove: 1/2 grow/shrink: 6/9 up/down: 58/-174)          Total: -116 bytes
   text	   data	    bss	    dec	    hex	filename
 950034	    477	   7296	 957807	  e9d6f	busybox_old
 949918	    477	   7296	 957691	  e9cfb	busybox_unstripped

Signed-off-by: Ron Yorston <rmy@pobox.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-11-17 21:16:33 +01:00
Denys Vlasenko
bca4ea8b68 remove "local" bashism from a few scripts
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2017-01-24 20:52:42 +01:00
Denys Vlasenko
29f3526048 build system: for "find", use POSIX not operator (!) instead of -not
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2014-03-16 12:05:58 +01:00
Matthias Andree
9b76f895bc build system: fix non-portable sed constructs.
This includes proper line breaks for labels and closing braces,
and removing non-portable \n and \t in s/// functions.

Signed-off-by: Matthias Andree <matthias.andree@gmx.de>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2014-01-10 11:54:37 +01:00
Paulius Zaleckas
1c7724bf2a gen_build_files.sh: exclude hidden directories
I am using quilt to manage patches internally. Quilt creates dir .pc
and stores unmodified files there. Since I made change in one of
Config.src quilt made a copy in .pc/xxx.patch/xxx/Config.src. When
I run make it calls gen_build_files.sh and it generates
.pc/xxx.patch/xxx/Config.in. Now when I want to pop patch quilt
thinks I have made changes to original xxx/Config.in.

IMO the best solution is just to ignore hidden directories in
gen_build_files.sh. This also results in shorter build time in case
busybox is under git/svn versioning, since it avoids searching
many directories for Config.src.

Signed-off-by: Paulius Zaleckas <paulius.zaleckas@gmail.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2012-01-30 02:34:56 +01:00
Denys Vlasenko
4ea37d62c2 gen_build_files.sh: simplify "print everything up to INSERT line" part
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2011-10-19 21:17:20 +02:00
Denys Vlasenko
efd08bfa0a gen_build_files: don't pass 200k+ strings as params. Closes 4321
Also removes one grep per generated file.

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2011-10-19 17:54:42 +02:00
Denys Vlasenko
c3dadba699 gen_build_files.sh: do not use "sed --" for now
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2011-04-16 17:59:34 +02:00
Denys Vlasenko
7a3f8e2fe1 gen_build_files.sh: better comment
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2010-11-25 06:55:18 +01:00
Denys Vlasenko
749e305d36 build system: fix for dash
Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
2010-11-24 15:06:49 +01:00
Denys Vlasenko
f9d091316d gen_build_files.sh: restore deleted comment
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2010-11-21 22:10:07 +01:00
Mike Frysinger
f718e3a0db gen_build_files.sh: rewrite with sed
The shell parsing of files is incredibly slow on many systems.  With
one report, the process was taking a minute or two which made people
thing the build was hung.  So rewrite the craziness with sed and proper
shell functions.  On an idle system, this cut the runtime by half.

Signed-off-by: Mike Frysinger <vapier@gentoo.org>
2010-11-16 09:01:54 -05:00
Waldemar Brodkorb
95b83ba4f8 OpenBSD compatibility
Signed-off-by: Waldemar Brodkorb <wbx@openadk.org>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2010-08-06 09:17:26 +02:00
Alexander Shishkin
daf286cda5 Fix out-of-tree build's recursion
While doing O=build build I've noticed that it was getting gradually
slower with each invocation. The reason turned out to be that the build
directory was inside the source tree and got recreated inside itself
with all its subdirectories.

This patch changes the behavior so that only the directories with
Kbuild.src or Config.src in them are created in the out-of-tree build
directory. A quick rebuild from scratch revealed no problems with this.

Signed-off-by: Alexander Shishkin <virtuoso@slind.org>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2010-07-18 23:57:49 +02:00
Denys Vlasenko
1883cb1746 fix make O=dir build
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2010-07-09 01:25:36 +02:00
Denys Vlasenko
1d72d43940 gen_build_files.sh is an order prerequisite only for autoconf.h
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2010-06-25 13:30:59 +02:00
Denys Vlasenko
f0f9470061 make it possible to keep usage texts in .c files
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2010-06-06 01:53:38 +02:00
Denys Vlasenko
6c5bf0d347 make it possible to have include/applets.h-esque entries in .c files
As an example, bunzip2 and bzcat is changed to use it.

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2010-06-06 00:53:45 +02:00
Denys Vlasenko
76c936f522 build system: make gen_build_files.sh messages more inline with the rest
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2010-05-27 02:33:31 +02:00
Denys Vlasenko
a1db8b8415 make scripts/gen_build_files.sh standard-clean
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2010-05-18 00:24:17 +02:00
Denys Vlasenko
3015a1351a scripts/gen_build_files.sh: revert to using /bin/sh
People want busybox to build w/o bash, with /bin/sh = ash

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2010-05-17 01:59:16 +02:00
Denys Vlasenko
084e2284c7 gen_build_files.sh uses bashism, document it
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2010-05-15 21:08:51 +02:00
Denys Vlasenko
c84c85ae34 gen_build_files: use raw reads (ones which don't eat backslashes)
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2010-05-14 20:30:44 +02:00
Denys Vlasenko
8e3aff0ce0 more randomconfig testsuite fixes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2010-05-10 11:00:11 +02:00
Denys Vlasenko
1602a5cdb9 gen_build_files.sh should be executable
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2010-05-10 04:18:42 +02:00
Denys Vlasenko
572b9a3019 tweak scripts/gen_build_files.sh
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2010-05-09 16:20:52 +02:00
Denys Vlasenko
7fb68f199f make it possible to keep Config/Kbuild snippets in *.c files
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2010-05-09 04:22:48 +02:00