Commit Graph

529 Commits

Author SHA1 Message Date
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
Baruch Siach
3d07446cef install.sh: don't clobber dangling symlinks
Symlinks in a subdirectory that is to become target rootfs are sometimes
dangling because they link to canonical file names that are not present
on the host, but are present relative to the target rootfs root. Don't
copy over dangling symlinks when noclobber is enabled

The -e test treats dangling symlinks as non-existent files. Add -h test
that returns true for all symlinks.

Cc: Yann E. MORIN <yann.morin.1998@free.fr>
Signed-off-by: Baruch Siach <baruch@tkos.co.il>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-07-31 15:49:19 +02:00
Yann E. MORIN
296381ff4f applets/install: don't try to install nothing
Commit 952d5a6024 (applets/install: accept more than one install
option) changed the way we handle install options: before that commit, a
missing install type would mean to install nothing; after, we would
iterate over options, so we would never notice there was a mising
option.

Fix that by introducing an explicit --none option to specify to install
nothing.

Reported-by: Aaro Koskinen <aaro.koskinen@iki.fi>
Cc: Aaro Koskinen <aaro.koskinen@iki.fi>
Cc: Denys Vlasenko <vda.linux@googlemail.com>
Signed-off-by: Yann E. MORIN <yann.morin.1998@free.fr>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-04-15 12:07:22 +02:00
Michael Olbrich
43dd006222 build system: fix parallel building issue
The files generated by the include/config/MARKER target are in the
dependency list for applets/applet_tables.
If applets/applet_tables is created first during applets_dir then it will
be created again later as part of $(busybox-dirs).
As a result include/applet_tables.h is created again. This time while other
build commands may need it.

Let applets_dir depend on include/config/MARKER to avoid this particular
race condition and create the header files atomically to ensure that the
compiler never sees incomplete files.

Signed-off-by: Michael Olbrich <m.olbrich@pengutronix.de>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-04-14 01:55:51 +02:00
Denys Vlasenko
bf39d97e9d Fix install with hardlinks and a custom PREFIX. Closes 10801
Trying to install busybox with hardlinks and a custom PREFIX will fail
for applets not in the /bin directory, because relative pathnames are
used. applets/install.sh is *supposed to* use the absolute pathname
for hardlinks but it fails to do so because the wrong check is used
in the if statement.

While fixing it, shore up other sloppy coding in applets/install.sh

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-02-23 16:29:26 +01:00
Yann E. MORIN
952d5a6024 applets/install: accept more than one install option
Currently, it is impossible to pass more than one option to the isntall
script, so it totally prevents using --noclobber.

Signed-off-by: Yann E. MORIN <yann.morin.1998@free.fr>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-01-04 14:43:46 +01:00
Yann E. MORIN
84be5ce0d8 applets/install: respect noclobber for script wrappers too
Simplify the handling of --noclobber so that it applies to all types of
installation types, even to script wrappers.

Signed-off-by: Yann E. MORIN <yann.morin.1998@free.fr>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-01-04 14:36:17 +01:00
Denys Vlasenko
fe93624fb6 Automatically disable FEATURE_COMPRESS_USAGE for small builds.
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2017-01-06 19:16:36 +01:00
Denys Vlasenko
0dddbc1a59 build system: always rewrite NUM_APPLETS.h
Conditional rewrite can keep NUM_APPLETS.h mtime old,
this causes make to try to regenerate it at every invocation.

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2016-08-23 20:21:36 +02:00
Denys Vlasenko
d8e61bbf13 build system: different fix for include/applet_tables.h/include/NUM_APPLETS.h
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2016-08-21 22:00:20 +02:00
Denys Vlasenko
9e5820a862 build system: fix include/NUM_APPLETS.h generation
TBH, it's more like "work around my bad makefile-fu" than "fix"...

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2016-08-14 02:54:27 +02:00
Denys Vlasenko
0fb0045aa9 config: disentangle PREFER_APPLETS from SH_STANDALONE and SH_NOFORK
On user request.
I thought enabling/disabling them all together is more consistent.
Evidently, some people do want them to be separately selectable.

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2016-07-22 18:48:38 +02:00
Denys Vlasenko
f4f8fe841c build system: fix a few warnings for allnoconfig build
Not that allnoconfig build is useful in any way...

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2016-07-05 21:43:28 +02:00
Denys Vlasenko
dd02a05e08 build system: finer-grained selection of search speedup table.
KNOWN_APPNAME_OFFSETS=8 versus KNOWN_APPNAME_OFFSETS=0:

function                                             old     new   delta
find_applet_by_name                                   55     136     +81
applet_nameofs                                         -      14     +14
run_applet_and_exit                                  757     758      +1

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2016-04-02 15:18:26 +02:00
Ron Yorston
610c4c385b applet_tables: save space by removing applet name offsets
The array applet_nameofs consumes two bytes per applet.  It encodes

   nofork/noexec flags
   suid flags
   the offset of the applet name in the applet_name string

Change the applet_table build tool to store the flags in two separate
arrays (applet_flags and applet_suid).  Replace applet_nameofs[] with a
smaller version that only stores a limited number of offsets.

This requires changes to the macros APPLET_IS_NOFORK, APPLET_IS_NOEXEC
and APPLET_SUID.

   According to Valgrind the original find_applet_by_name required
   353 cycles per call, averaged over all names.  Adjusting the number
   of known offsets allows space to be traded off against execution time:

      KNOWN_OFFSETS     cycles     bytes (wrt KNOWN_OFFSETS = 0)

           0             9057        -
           2             4604       32
           4             2407       75
           8             1342       98
          16              908      130
          32              884      194

   This patch uses KNOWN_OFFSETS = 8.

v2:
   Remove some dead code from the applet_table tool;
   Treat the applet in the middle of the table as a special case.

v3:
   Use the middle applet to adjust the start of the linear search as
   well as the last applet found.

v4:
   Use an augmented linear search in find_applet_by_name.
   Drop the special treatment of the middle name from get_applet_name:
   most of the advantage now derives from the last stored value.

v5:
   Don't store index in applet_nameofs, it can be calculated.

v6:
   Tweaks by Denys

function                                             old     new   delta
find_applet_by_name                                   25     125    +100
applet_suid                                            -      92     +92
run_applet_no_and_exit                               452     460      +8
run_applet_and_exit                                  695     697      +2
applet_name_compare                                   31       -     -31
applet_nameofs                                       734      14    -720
------------------------------------------------------------------------------
(add/remove: 1/1 grow/shrink: 3/1 up/down: 202/-751)         Total: -549 bytes
   text       data        bss        dec        hex    filename
 925464        906      17160     943530      e65aa    busybox_old
 924915        906      17160     942981      e6385    busybox_unstripped

Signed-off-by: Ron Yorston <rmy@pobox.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2016-03-30 00:44:11 +02:00
Denys Vlasenko
5fa6d1a632 Aboriginal linux/musl build fixes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2015-10-05 11:15:43 +02:00
Clayton Shotwell
b7ee7e1e13 applets: Add installation of individual binaries
Adding support to install individual binaries if the option is
enabled. This also installs the shared libbusybox.so.* library.

Signed-off-by: Clayton Shotwell <clshotwe@rockwellcollins.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2015-07-01 19:10:03 +02:00
Denys Vlasenko
cd7a38a87d false: make "false --help" exit with 1
function                                             old     new   delta
run_applet_no_and_exit                               447     445      -2

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2014-09-18 00:47:05 +02:00
Denys Vlasenko
195c436f84 build system: use od -b instead of od -t x1
od -t is not available in non-CONFIG_DESKTOPed busybox od

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2013-11-26 14:56:29 +01:00
Denys Vlasenko
924a179cb7 build system: do not generate MAX_APPLET_NAME_LEN (unused)
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2013-11-26 12:03:24 +01:00
Bernhard Reutner-Fischer
9078633fee buildsys: Add helper to list suid applets
Add a helper script that lists all applets that
- do or may require SUID provileges (busybox.cfg.suid)
- do not require SUID provileges (busybox.cfg.nosuid)

Some setups prefer to build two busybox binaries, one that is suid which
contains all applets that do or may require suid privileges, and a
second one for all the rest (which drops suid). To ease splitting these
two binaries, generate a list of CONFIG_ items for the suid binary.

Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
2013-07-26 13:39:46 +02:00
Denys Vlasenko
a0fd4a789c style fixes, no code changes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2012-09-02 14:29:14 +02:00
Denys Vlasenko
78a3b6739c Fix one-applet build for tcpsvd
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2012-03-19 04:38:00 +01:00
Denys Vlasenko
6d2d652cd3 applet_tables: fix single applet build failure. Closes 4009
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2011-09-16 14:28:32 +02:00
Denys Vlasenko
c0644cac0d applets/install.sh: afer quoting of variables
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2011-04-05 02:37:15 +02:00
Denys Vlasenko
12140e607c fix install.sh
Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2011-04-04 03:53:23 +02:00
Denys Vlasenko
6ec1510f71 applet_tables: do not include libbb.h, that header ir for target builds
...and applets/applet_tables.c is built on *host*.

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2011-03-28 01:23:38 +02:00
Denys Vlasenko
bff5f3f2b4 fix bit rot in scripts/Makefile.IMA #2
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2011-03-06 23:48:24 +01:00
Bjørn Forsman
102b8bde3b .gitignore: add missing ignores
Ignore output files created by "make defconfig; make".

Signed-off-by: Bjørn Forsman <bjorn.forsman@gmail.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2011-03-06 19:54:15 +01:00
Bernd Jendrissek
55988aed47 fix "make install"
Signed-off-by: Bernd Jendrissek <bernd.jendrissek@gmail.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2011-02-20 05:50:04 +01:00
Denys Vlasenko
b7c9fb27cb whitespace fixes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2011-02-03 00:05:48 +01:00
Denys Vlasenko
0fdf2e1026 simpler check for od
Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
2010-09-16 15:46:20 +02:00
Denys Vlasenko
06a80bdbea build system: test that od is present in the host system
Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
2010-09-16 13:23:15 +02:00
Denys Vlasenko
0ef64bdb40 *: make GNU licensing statement forms more regular
This change retains "or later" state! No licensing _changes_ here,
only form is adjusted (article, space between "GPL" and "v2" and so on).

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2010-08-16 20:14:46 +02:00
Denys Vlasenko
9768a82eb0 *: fix "see file License ..." - the file is named LICENSE (in uppercase)
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2010-08-16 03:04:14 +02:00
Denys Vlasenko
1d36f24bcb make usage_compressed.h generation _always_ update mtime
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2010-07-08 02:29:47 +02:00
Denys Vlasenko
9297dbc9d2 randomconfig fixes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2010-07-05 21:37:12 +02:00
Denys Vlasenko
08f0b784fd Yet another attempt to stamp out "make -j" problems
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2010-07-04 23:34:02 +02:00
Denys Vlasenko
1fcbff2fac build system: do not rebuild ash and hush on any change to any .c file
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2010-06-26 02:40:08 +02:00
Denys Vlasenko
2f32bf8be6 remove defconfig. Now "make defconfig" simply uses defaults from Config.in
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2010-06-06 04:14:28 +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
0e5ba0843b Remove requirement that include/applets.h must be sorted
First, I _again_ violated it - two xz-related applets are in wrong positions.
Second, planned in-applet help text thing will be so much easier without
this requirement...

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2010-06-05 23:11:07 +02:00
Denys Vlasenko
da929a95aa mass renaming Kbuild -> Kbuild.src, Config.in -> Config.src
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2010-06-04 20:10:51 +02:00
Denys Vlasenko
1497484839 ash,hush: make it possible to build them individually
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2010-03-23 01:08:26 +01:00
Denys Vlasenko
3581c62515 whitespace fixes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2010-01-25 13:39:24 +01:00
Denys Vlasenko
18221506e5 build system: more fixes to parallel build
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-11-25 00:22:31 +01:00
Denys Vlasenko
b24c1139fb build system: fix parallel make
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-11-24 22:23:21 +01:00
Bernhard Reutner-Fischer
b35e3a8612 applets/usage_compressed: combine many seds in one; hide dd stats
Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-10-27 17:06:32 +01:00
Denys Vlasenko
149a32a19b mkfs_ext2: use compatible inode sizes; add -I <inodesize>. (by Vladimir)
function                                             old     new   delta
mkfs_ext2_main                                      2385    2495    +110
packed_usage                                       26400   26447     +47
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 2/0 up/down: 157/0)             Total: 157 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-10-22 12:12:17 +02:00
Denys Vlasenko
f228913fed ok, last fix wasn't correct... this one is better
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-10-02 01:21:31 +02:00