WelcomeWelcome | FAQFAQ | DownloadsDownloads | WikiWiki

Author Topic: Suggestion for core modification  (Read 4753 times)

Offline Roberto A. Foglietta

  • Full Member
  • ***
  • Posts: 212
    • personal home page
Suggestion for core modification
« on: August 10, 2021, 05:13:16 PM »
Hi all,

 I suggest the following modification to the core:

  • replace fdisk from busybox with real fdisk because it more friendly with scripts and more informative
  • add base64 in busybox as applet because it is useful to embedded binary data in scripts

Thank you,
-R

Offline curaga

  • Administrator
  • Hero Member
  • *****
  • Posts: 10678
Re: Suggestion for core modification
« Reply #1 on: August 10, 2021, 11:12:52 PM »
Sorry, neither change is useful for the base. No base script embeds binary data, and they work with the busybox fdisk options.
The only barriers that can stop you are the ones you create yourself.

Offline Roberto A. Foglietta

  • Full Member
  • ***
  • Posts: 212
    • personal home page
Re: Suggestion for core modification
« Reply #2 on: August 11, 2021, 08:50:23 AM »
Dear Curaga,

 your user base might be larger than you think: also those are interested in using TC for embedded systems for example.
 I assume that they are a small fraction of users but for sure they could contribute more than average desktop user.

 I suggest to use this patch for busybox nosuid config, it adds only 4Kb in size

original version:

   600600 bytes (601 kB, 587 KiB)

suggested version:

   604696 bytes (605 kB, 591 KiB)

Thank you,
-R
« Last Edit: August 11, 2021, 08:55:45 AM by Roberto A. Foglietta »

Offline curaga

  • Administrator
  • Hero Member
  • *****
  • Posts: 10678
Re: Suggestion for core modification
« Reply #3 on: August 11, 2021, 09:32:14 AM »
I understand your concern, however keeping TC small is one of its main points. One man's feature is another's bloat.

CONFIG_FEATURE_CMDLINE_MODULE_OPTIONS=y looks fine, but not sure about the others. In particular linking bash to ash is just going to break users' scripts.
The only barriers that can stop you are the ones you create yourself.

Offline Roberto A. Foglietta

  • Full Member
  • ***
  • Posts: 212
    • personal home page
Re: Suggestion for core modification
« Reply #4 on: August 11, 2021, 09:51:39 AM »
Dear Curaga,

 4kb is very small bloat but I see your point, 4kb today, 4kb tomorrow, etc.  ​However, it remains a small size to add.
 The base64 is included in a 2MB tce and it the only reasonable way to embedded binary data into scripts / text.
 
 Other features increase compatibility also for desktop users and this it is a good thing.

 About linking bash to ash: at the moment if bash is not installed the scripts based on bash will simply fails.
 Obviously, it might be better that they fails immediately than seem to work. I can understand the point.
 
 Do whatever you think sane, please.
 Thank you,
-R
 

Offline Rich

  • Administrator
  • Hero Member
  • *****
  • Posts: 10252
Re: Suggestion for core modification
« Reply #5 on: August 11, 2021, 10:39:47 AM »
Hi Roberto A. Foglietta
... The base64 is included in a 2MB tce and it the only reasonable way to embedded binary data into scripts / text. ...
True, but you can separate  base64  into its own extension.  Base64  is 30k and compresses down to 16k in an extension:
Code: [Select]
tc@E310:~/sq$ ls -l base64/usr/local/bin/base64
-rwxr-xr-x 1 tc staff 30316 Aug 11 13:26 base64/usr/local/bin/base64
tc@E310:~/sq$ ls -l
total 20
drwxr-sr-x 3 tc staff  4096 Aug 11 13:29 base64/
-rw-r--r-- 1 tc staff 16384 Aug 11 13:30 base64.tcz
tc@E310:~/sq$

Offline Roberto A. Foglietta

  • Full Member
  • ***
  • Posts: 212
    • personal home page
Re: Suggestion for core modification
« Reply #6 on: August 11, 2021, 03:55:27 PM »
Hi Rich, is there an easy way to create a tcz inside TC? Thank you, R.

EDIT: using mksquashfs with tce-load -wi squashfs-tools.tcz

EDIT2: however, the last version of TinyCore Editor (suite) [1] allows me to quickly modify the source code and the config of the busybox including adding patches and deploy the last version. Moreover, it lets me to include the compiled busybox into a the rootfs.gz/core.gz with a single command.

NOTE: if you want to add "Provide compatible behavior for rare corner cases" which is useful for desktop then base64 and nproc do not add extra size but stays into that 4KB. A free run, with a useful extension.

[1] https://github.com/robang74/tinycore-editor
« Last Edit: August 11, 2021, 04:25:51 PM by Roberto A. Foglietta »

Offline Rich

  • Administrator
  • Hero Member
  • *****
  • Posts: 10252
Re: Suggestion for core modification
« Reply #7 on: August 11, 2021, 06:18:15 PM »
Hi Roberto A. Foglietta
Hi Rich, is there an easy way to create a tcz inside TC? ...
Yes there is.

First create a work directory containing the subdirectories you need, for example:
Code: [Select]
mkdir -p package/usr/local/bin
Code: [Select]
mkdir -p package/usr/local/share/applications
Code: [Select]
mkdir -p package/usr/local/share/pixmaps
Populate those directories with the files you need. Then pack it up:
Code: [Select]
mksquashfs package MyExtension.tcz

Offline Roberto A. Foglietta

  • Full Member
  • ***
  • Posts: 212
    • personal home page
Re: Suggestion for core modification
« Reply #8 on: August 11, 2021, 11:56:13 PM »
Why do not use the following option in busybox? It can replace the busybox.suid approach.

(yes) Drop SUID state for most applets
(yes) Enable SUID configuration via /etc/busybox.conf (NEW)
(no) Suppress warning message if /etc/busybox.conf is not readable (NEW)

Used in combination with this /etc/busybox.conf [1] and obviously with the suided busybox, it will reduce size and simplify things: just one compilation and one binary instead of two.

original version:

   600600 bytes (601 kB, 587 KiB) nosuid
   75720 bytes (76 kB, 74 KiB) suid

suggested version:

   604696 bytes (605 kB, 591 KiB) nosuid
   75720 bytes (76 kB, 74 KiB) suid

suggested version but single file

   637464 bytes (637 kB, 623 KiB) single

In attachment the configuration file for a single file busybox.

As you can see my original version is 40kb larger because than yours (540kB) because I use -O2 for compilation.

I wish to receive a suggestion to use -Os because I tried to add to CFLAGS but it is ignored.

[1] http://lists.busybox.net/pipermail/busybox/2004-May/045643.html
« Last Edit: August 12, 2021, 12:03:39 AM by Roberto A. Foglietta »

Offline Roberto A. Foglietta

  • Full Member
  • ***
  • Posts: 212
    • personal home page
Re: Suggestion for core modification
« Reply #9 on: August 12, 2021, 12:02:56 AM »
This is /etc/busybox.conf for the change suggested above

Offline Roberto A. Foglietta

  • Full Member
  • ***
  • Posts: 212
    • personal home page
Re: Suggestion for core modification
« Reply #10 on: August 12, 2021, 01:17:29 AM »
If you adopt the single busybox file solution like I did in my suite, then

     etc/init.d/busybox-aliases
     etc/init.d/tc-config

should be purged by busybox.suid

Probably the etc/init.d/busybox-aliases becomes useless and might be removed.

Moreover with this you will save 14kB

roberto@vm-ubuntu18:~/tinycore-editor/tinycore$ advdef -z3 modules.gz
     8106613     8092402  99% modules.gz
     8106613     8092402  99%
roberto@vm-ubuntu18:~/tinycore-editor/tinycore$ echo $[8106613-8092402]
14211
« Last Edit: August 12, 2021, 01:34:52 AM by Roberto A. Foglietta »

Offline Rich

  • Administrator
  • Hero Member
  • *****
  • Posts: 10252
Re: Suggestion for core modification
« Reply #11 on: August 12, 2021, 05:08:13 AM »
Hi Roberto A. Foglietta
... I wish to receive a suggestion to use -Os because I tried to add to CFLAGS but it is ignored. ...
Look at the compile notes:
http://tinycorelinux.net/12.x/x86/release/src/busybox/compile_busybox
It uses  CC  and  CXX  instead of  CFLAGS  and  CXXFLAGS.

Offline Roberto A. Foglietta

  • Full Member
  • ***
  • Posts: 212
    • personal home page
Re: Suggestion for core modification
« Reply #12 on: August 12, 2021, 06:02:21 AM »
@curaga, @rich

Let busybox doing a link /bin/bash to ash breaks the bash.tcz, it should not be allowed.

In attachment the new proposed configuration for a single file busybox.

Offline Roberto A. Foglietta

  • Full Member
  • ***
  • Posts: 212
    • personal home page
Re: Suggestion for core modification
« Reply #13 on: August 12, 2021, 06:40:34 AM »
@Rich
I did it before and it did not work either with CC and CXX.
I do again, and it does not work. Both 1.33.0 and 1.331.

Offline Roberto A. Foglietta

  • Full Member
  • ***
  • Posts: 212
    • personal home page
Re: Suggestion for core modification
« Reply #14 on: August 12, 2021, 07:18:47 AM »
@Rich
I did it before and it did not work either with CC and CXX.
I do again, and it does not work. Both 1.33.0 and 1.331.

I compile under Ubuntu, probably this is the main reason of the size difference: linking libraries.
Changing the compiling options, I reach 1.1 MiB of size.
So I think 624 KiB is the minimum on Ubuntu.