Tiny Core Linux

Tiny Core Extensions => TCE Talk => Topic started by: Mypresus on December 12, 2021, 01:59:53 AM

Title: RPI-64 export flags
Post by: Mypresus on December 12, 2021, 01:59:53 AM
Hi there, can someone please let me know what the official export flags are for RPi-64.  I have found the x86-32, x86-64, and RPi-32 but no RPi-64 one. I have used the following in my script which work fine, but would like a confirmation on what should be use for RPI-64:
x86-32^ CFLAGS="-march=i486 -mtune=i686 -Os" CXXFLAGS="{$CFLAGS}" LDFLAGS="-wl,-01"
x86-64^ CFLAGS="-march=generic -Os" CXXFLAGS="{$CFLAGS}" LDFLAGS="-wl,-01"
RPi-32^ CFLAGS="-Os" CXXFLAGS="{$CFLAGS}" LDFLAGS="-wl,-01"
RPi-64^ CFLAGS="-march=aarch64 -mtune=generic -Os" CXXFLAGS="{$CFLAGS}" LDFLAGS="-wl,-01"
Any help would be appreciated, cheers Rob
Title: Re: RPI-64 export flags
Post by: Juanito on December 12, 2021, 02:14:44 AM
piCore "-march=armv6zk -mtune=arm1176jzf-s -mfpu=vfp -Os -pipe"

piCore64 "-march=armv8-a+crc -mtune=cortex-a72 -Os -pipe"

Edit: added "-pipe".
Title: Re: RPI-64 export flags
Post by: Mypresus on December 12, 2021, 02:30:57 AM
Thank you Juanito for your quick reply.   Will use these  ;D and hope to be able to contribute to the TCE soon.

Cheers Rob
Title: Re: RPI-64 export flags
Post by: Juanito on December 12, 2021, 02:38:08 AM
You can also try "-flto" and with cxx "-fno-exceptions" and "-fno-rtti" though one or more of these may fail.

In addition, removing "-g" and "-O2" from the Makefile(s) will reduce the size of the compiled binary/library.
Title: Re: RPI-64 export flags
Post by: Mypresus on December 12, 2021, 02:56:13 AM
Thank you Juanito, as I'm scripting the complete process I'm looking for the lowest common denominator that will work, although smallest is good, successful compilation is paramount  ;D
just for some background this is what the config file  for the script currently looks like.
Title: Re: RPI-64 export flags
Post by: Juanito on December 12, 2021, 03:06:49 AM
You might also look at the work done by @Rich here:
http://forum.tinycorelinux.net/index.php/topic,23623.0.html

..and by @andyj here:
http://tinycorelinux.net/10.x/x86_64/tcz/src/net-snmp/build-net-snmp.sh
Title: Re: RPI-64 export flags
Post by: Juanito on December 12, 2021, 03:10:31 AM
just for some background this is what the config file  for the script currently looks like.

Note that in tinycore all items not in the base should come under /usr/local, for example /usr/local/etc/extension_name/config.file
Title: Re: RPI-64 export flags
Post by: Mypresus on December 12, 2021, 03:22:24 AM
Thank you, this is some great info that will help in a better insight.  I started by wanting to install an extension that was not there so down the rabbit hole i went.  know I'm only a newbie to TC so I'm very grateful for all the info.
Title: Re: RPI-64 export flags
Post by: Mypresus on December 12, 2021, 03:39:51 AM
Hi Juanito, all the files in the example .cfg come under the  /tmp/tcloop/user/local.
This brings me to another question as in the example haproxy looks for a .cfg file under /etc/haproxy. My solution was the write a script in tce.installed that will create a haproxy file and symlink to where haproxy was looking and direct it to permanent storage /etc/sysconfig/tcedir/.config/haproxy/haproxy.cfg   Is this the way it should be done as this is the only permanent storage available without doing backup.
Title: Re: RPI-64 export flags
Post by: Juanito on December 12, 2021, 03:48:25 AM
Many apps will allow you to set --sysconfdir=/usr/local/etc

In addition, many apps allow for a user specific config under ~/.config, which tinycore will backup by default if a backup is enabled.

Title: Re: RPI-64 export flags
Post by: Mypresus on December 12, 2021, 04:02:57 AM
As haproxy is a run as a server/daemon so when logged out would ~/.config no longer be available (sorry have a Win background) so not sure?  I found TC be to great at providing a clean slate on boot this is one of the reasons of being a fan of TC, so don't run backup and have sd/usb for permanent storage.  Hence the permanent storage for .cfg I maybe thinking this all wrong so apologies in advance .  Cheers Rob
Title: Re: RPI-64 export flags
Post by: Juanito on December 12, 2021, 04:25:15 AM
I can’t comment on the specific case of haproxy, but files under ~/.config will only be lost on reboot without a backup.

You can also make a customised local extension that contains whatever config you wish.
Title: Re: RPI-64 export flags
Post by: Mypresus on December 12, 2021, 05:07:41 AM
Hi  Juanito i'm here to learn on how the whole concept works, and I understand each program/extension user/organisation has its own requirements. so not here to judge or complain just working out the logic.  My understanding so far is if a program/extension is truly user based then ~/.config is used for .cfg and must use backup, other wise .cfg is lost.  In the case of programs specifically looking for a .cfg file through configuration by command line or other means etc. we can create a symlink of where the program is expecting the find the .cfg and create the actual file in ~/.config or on permanent storage somewhere.  If there can be a standard file designation created for this situation for permanent storage that would be great as this will assist in creating scripts on the fly etc...  such as in tce.installed script.
Title: Re: RPI-64 export flags
Post by: Rich on December 12, 2021, 08:57:41 AM
Hi Mypresus
Attached is the script I used for the most recent package I submitted. It's fairly well commented but I'll point out
some of the things I'm doing anyway. The script handles compiling and creating all of the package files. If you
open the script using the following command you can view it with line numbers to follow along:
Code: [Select]
less -N CompileResizerYou can navigate with the PageUp, PageDown, up arrow, and down arrow keys.

-------------------------------------------------------------------------------------------------------
Line:
__3  I alias to busybox commands when possible since they are always present and because the GNU counterparts
     sometimes behave differently. I  also set options to the commands there.
_28  Sets the compiler flags to match the processor you are currently running on.
_65 to _79  I don't use make files for stuff I write so the compile and link commands go here. The size and
     ls commands give me an indication of how big my program is getting as I develop it.
     You would replace this with:
          export CFLAGS CXXFLAGS LDFLAGS PREFIX DESTDIR     plus any other variables you need to export.
          ./configure --prefix=$PREFIX
          make
          make install
_81  Uncomment this line to exit the script early if you are getting build errors. Re-comment it once the
     errors have been resolved and rerun the script.
_94  The build results are archived in a separate subdirectory for each processor type. This way you can
     use a removable drive to build on different architectures while retaining a backup of the other builds.
117  This is where the  .info  file is created. Most of the variable fields get updated automatically. The
     Change-log:  field (line 188) needs to be updated manually when new versions are created.
-------------------------------------------------------------------------------------------------------


You can download the the Resizer tarball (8 KBytes) from here if you want to run the script and see the results:
http://tinycorelinux.net/12.x/x86/tcz/src/Resizer/

I've also attached an older less refined script that builds the gpicview image viewer. That package does use
./configure  and  make.  It also makes other fixes for Tinycore compatibility, such as  .desktop  files and  icons.
It also sets some variables such as PREFIX and DESTDIR so you may want to take a peek at that.
You should be able to run this script directly since it downloads the source code itself. Place the script in its
own subdirectory if you want to do this.
Title: Re: RPI-64 export flags
Post by: Juanito on December 12, 2021, 09:53:55 AM
If there can be a standard file designation created for this situation for permanent storage that would be great as this will assist in creating scripts on the fly etc...  such as in tce.installed script.

There’s a provision in tinycore for /home and/opt on permanent storage, but not files in other locations.

You could save files to the tce folder, but users might not want them there.

If you don’t wish to use a backup, you could load extensions with a simple script that copied the required config file from permanent storage.
Title: Re: RPI-64 export flags
Post by: Rich on December 12, 2021, 10:51:09 AM
Hi Mypresus
Some programs when you run them will automatically create configuration files under the users ~/.config directory, such
as geany, gpicview, libreoffice, mc, wireshark, etc. Some will create hidden directories directly in the users
home directory, such as claws-mail, dillo, fifth, mozilla (Firefox), ssh, etc.

Some extensions conditionally create config directories/files through their tce.installed script, such as bash, grabber
and gtk3.

If you boot an ISO, there is no persistence, and I don't think a backup option is available either.
If Tinycore  is installed,  /home  and  /opt  are backed up when you use the  Exit  icon.
If Tinycore  is installed, and you have persistent  /home  and/or  /opt  directories, those directories should not be backed up.
Title: Re: RPI-64 export flags
Post by: Mypresus on December 13, 2021, 02:58:03 PM
Hi Rich,
Sorry for the late reply, other life things have gotten in the way.  Firstly thank you for sharing your scripts with me I haven't had a chance to go over them yet but at a quick look I see some valuable info.  My script was created to get a greater understanding of how TC and Linux works and hope that it may have value to the TC community.  Hope that the following will give content to may earlier questions

The script I have written uses the .cfg file as input to the script the intent is:
1 The script must run on TC out of the box (busybox and ash), I used RPi-64 install for this so far.
1 Only the .cfg file needs to be altered for creating an extension no need to alter the script.
2 The aim is to be able to create most binaries into .tcz with the accompanying files.
3 To easily create .tcz so that the repository will grow and therefore making TC a more valuable OS.

I have attached the script I'm working on, for a better understanding of what I'm trying to achieve.  Please note it works on RPi-64 no other testing has been done, this is a work in progress so beta if you like. If you or anyone else would like to assist, give feedback or test that would much appreciated.

Please note the file is from win .txt (notepad utf-8) and has end of line characters, still need to figure out how to  correct this any help appreciated :)
Cheers Rob
Title: Re: RPI-64 export flags
Post by: Mypresus on December 13, 2021, 03:43:14 PM
Hi Juanito,
Thank you for your reply.  As the current extension I'm working on is server/daemon the .cfg file and i presume in most daemon scenarios is that some files need to be available with an altering state (being able to be altered and preserved).  I believe that daemons may not or should not access home directories.  As my current understanding is that home files etc get backed up as compressed files within the tce/mydata.tgz on exit and therefor not available to daemons when loged out .
I understand that some programs can not or should not be run under ISO image (read only format), but under all other read/write formats the tce directory can or is created (such as in RPi-64 on SD card out of box).

Creating a .cfg file through creating a script could be done through tce.installed for ISO but that means recreating the ISO every time a .cfg file needs to be modified this is possible but maybe unpractical.

This then i believe leaves the only option for non read only formats a place somewhere under the tce directory. For read only formats I can see remastering/re-imaging as the only option.  I suppose what I'm asking is there a place for this situation or is the TC community willing to create a place for the daemon scenario?
Cheers Rob
Title: Re: RPI-64 export flags
Post by: Mypresus on December 13, 2021, 04:12:49 PM
Hi Rich,
Thank you for for the insight, is this is how you run scripts on login? I don't know if this will help with the daemon scenario as I presume you will still need to be logged in or need to create a .cfg from here to the tce/ directory when logging out.  By looking at the examples of the programs you have given, I believe they are all user based not server/deamon based, sorry still a newbie to Linux. 
Quote
Some programs when you run them will automatically create configuration files under the users ~/.config directory, such
as geany, gpicview, libreoffice, mc, wireshark, etc. Some will create hidden directories directly in the users
home directory, such as claws-mail, dillo, fifth, mozilla (Firefox), ssh, etc.

Some extensions conditionally create config directories/files through their tce.installed script, such as bash, grabber
and gtk3.

If you boot an ISO, there is no persistence, and I don't think a backup option is available either.
If Tinycore  is installed,  /home  and  /opt  are backed up when you use the  Exit  icon.
If Tinycore  is installed, and you have persistent  /home  and/or  /opt  directories, those directories should not be backed up.
Title: Re: RPI-64 export flags
Post by: Mypresus on December 13, 2021, 04:23:51 PM
Please ignore previous attachments these attachments should better.  Please also note there are no comments in the script if there is any interest I will document the script.  Oops sorry double .cfg attachments.

    [EDIT]: Removed duplicate attachment.  Rich
Title: Re: RPI-64 export flags
Post by: Rich on December 13, 2021, 05:07:43 PM
Hi Mypresus
... Please note the file is from win .txt (notepad utf-8) and has end of line characters, still need to figure out how to  correct this any help appreciated :)
Try this:
Code: [Select]
dos2unix buid.cfg
When it comes to automatically starting programs, scripts, daemons, etc., the basic rules of thumb are:
1. Things that need to run before a GUI are started (like kmaps) should go into  /opt/bootsync.sh.
2. Things that need to run after a GUI are started (like starting a GUI app) should go into  ~/.X.d.
3. Things that are not sensitive to when they are started can go into  /opt/bootlocal.sh  which runs in the background.

When starting something from numbers 1 or 3, you need to specify a full path. They run before any user is logged in.

Item 2 is unique to each user.

Title: Re: RPI-64 export flags
Post by: Mypresus on December 13, 2021, 07:50:50 PM
Hi Rich,
Thank you for dos2unix buid.cfg will give this a try.

For creating extensions for the repository and locating .cfg files I think I have got it, lets see if I'm correct.

Don't write anything in the tce/ directory  structure such as tce/.config/sample unless for personal use.

Write a tce.installed script on tce-load -i sample.tcz (so everytime the program is run the link would be created else the .tcz would need to be recreated every time a change is made to the script) the scripted symlink is created either for the ~/.config or ~/.X.d for a .cfg file. The other option is to create a script in tce.installed to copy a .cfg file or run another script that will copy/create the .cfg from ~/.config or ~/.X.d to the place where the program will find it and if a change is made upload new .cfg or restart program or backup and reboot. The problem is any program commands used to alter a .cfg file is written to (RAM) and will not be saved unless a exit script is written to save the information to ~/.config/... or ~/.X.d/... before backup and exit.
 
When there is a change made to the .cfg, run the backup (this means a backup must be run on exit otherwise the .cfg changes will be lost).

The /opt/ files can be altered (but presumably not advised to do so) as a backup/restore will be performed on those files in mydata.tgz?

If the pc is rebooted say by power outage it must have an automated login (and Onboot entry) else the software is not started (or can a tce-load be done before login ?) and there will be no script as ~/.config will not be created.

The system should be single user sign in, the danger is if another user logs on, their .cfg file in that users ~/.config will be used.

Just a little note, there is no .config file in RPi-64 13.0.0 on a clean install is this an oversite or is the ~/.config being phased out? 
Title: Re: RPI-64 export flags
Post by: Rich on December 13, 2021, 09:56:13 PM
Hi Mypresus
When you make an extension, you create a directory structure to package, for example:
Code: [Select]
mkdir -p pkg/usr/local/bin
Code: [Select]
mkdir -p pkg/usr/local/etc/haproxyIt then gets packaged using  squashfs-tools.tcz:
Code: [Select]
mksquashfs pkg haproxy.tcz -noappendWhen  tce-load  installs the extension, it mounts it under  /tmp/tcloop/  and links the files to the  /usr/local  file system.
It then runs the  tce.installed  script if it exists.

Typically what you would do is place a default configuration file in:
Code: [Select]
pkg/usr/local/etc/haproxy/haproxy.cfgIf the location of the .cfg is hardcoded to /etc, have the tce.installed script create a link to  /usr/local/etc/haproxy.
If the end user wants to customize the  .cfg  file, they can make it editable by:
Code: [Select]
sudo busybox cp /usr/local/etc/haproxy/haproxy.cfg /usr/local/etc/haproxy/Then make their changes, add  usr/local/etc/haproxy/haproxy.cfg  to  /opt/.filetool.lst , and run a backup.

... When there is a change made to the .cfg, run the backup (this means a backup must be run on exit otherwise the .cfg changes will be lost). ...
Use the ControlPanel to call up the  Backup/Restore  application.

Quote
... The /opt/ files can be altered (but presumably not advised to do so) as a backup/restore will be performed on those files in mydata.tgz? ...
If something needs to be altered in  /opt/ , that should be mentioned in the  Comments:  section of the  .info  file.

Quote
... If the pc is rebooted say by power outage it must have an automated login ...
The default user is  tc  and is logged in automatically when booting.

Quote
... (and Onboot entry) else the software is not started (or can a tce-load be done before login ?) and there will be no script as ~/.config will not be created. ...
When the system boots, It checks the  tce  directory for  onboot.lst  and loads all of the extensions listed in there. It
then runs all of the  tce.installed  scripts.

Quote
... Just a little note, there is no .config file in RPi-64 13.0.0 on a clean install is this an oversite or is the ~/.config being phased out?
I don't think that directory gets created until something actually needs it.

    [EDIT]: Corrected path information in backup description.  Rich
Title: Re: RPI-64 export flags
Post by: Rich on December 13, 2021, 10:17:01 PM
Hi Mypresus
These links may also be useful to better understand how Tinycore works:

https://web.archive.org/web/20191011055117/http://wiki.tinycorelinux.net/wiki:the_boot_process

https://web.archive.org/web/20191020231635/http://distro.ibiblio.org/tinycorelinux/architecture.html
Title: Re: RPI-64 export flags
Post by: Mypresus on December 13, 2021, 10:44:35 PM
Hi rich,
Thank you very much for your feedback, the penny just dropped, the missing link to my evolution  :) was not knowing the /opt/filetool.lst backup process so that changes can be saved. Now the pieces fit  :)

Quote
Typically what you would do is place a default configuration file in:
Code: [Select]
pkg/usr/local/etc/haproxy/haproxy.cfg
If the location of the .cfg is hardcoded to /etc, have the tce.installed script create a link to  /usr/local/etc/haproxy.
If the end user wants to customize the  .cfg  file, they can make it editable by:
Code: [Select]
sudo busybox cp /usr/local/etc/haproxy/haproxy.cfg /usr/local/etc/haproxy/
Then make their changes, add  /usr/local/etc/haproxy/haproxy.cfg  to  /opt/filetool.lst , and run a backup.

Now some simple editing and should be sorted.  :) Also just noticed you have different area for scripting in the forum so sorry for raising it here and will post scripting questions there in the future.  Cheers Rob
Title: Re: RPI-64 export flags
Post by: Rich on December 14, 2021, 07:26:58 AM
Hi Mypresus
Thank you very much for your feedback,  ...
You are welcome.

Quote
Typically what you would do is place a default configuration file in:

 ----- SNIP -----

add  /usr/local/etc/haproxy/haproxy.cfg  to  /opt/filetool.lst , and run a backup.
Correction, that should have said:
add  usr/local/etc/haproxy/haproxy.cfg  to  /opt/.filetool.lst , and run a backup.
Just wanted to mention that in case someone decides to make the changes manually rather than using the app.

Quote
... Also just noticed you have different area for scripting in the forum so sorry for raising it here ...
Since this was less of a scripting issue and more of a  "How Tinycore works"  issue I think it is fine over here.