Dasharo / dasharo-issues

The Dasharo issue tracker
https://dasharo.com/
25 stars 0 forks source link

Guide for building DTS for local network server #1131

Open artur-rs opened 1 week ago

artur-rs commented 1 week ago

DTS version

Question text

Forwarded request:

I want to build DTS for my local network server. It should run a script during system start on the same tty as the DTS menu. How can I achieve that? Just add my scripts to commands.sh and then build DTS? I just to inject it in /meta-dts/meta-dts-distro/recipes-dts/dts/dts/dts but it's no longer there, I guess the way the menu is created is different now.

DaniilKl commented 1 week ago

It seems like a Yocto recipe adding problem, not a problem related to any servers. Previously we held DTS scripts in meta-dts, that allowed for quick private script injections. Now we use a separate repo for DTS scripts (dasharo/dts-scripts), and therefore the recipe for it has been changed, that made it more difficult to add some private stuff.

There are two ways to handle this issue:

I could help with this exact problem - help to integrate the script. In this case, I need the information, what is the script purpose, what are the dependencies, how it should be installed, etc..

Or I could add recipe integration guide similar to the one from Zarhus.

m-iwanicki commented 1 week ago

To keep it as similar as it was previously you could:

  1. Fork dts-scripts repo
  2. Commit your changes
  3. Change SRC_URI and SRCREV to point to your changes

Probably easiest and fastest change. You could even keep your dts-scripts changes locally and use git:///path/to/repo;branch=custom_branch;protocol=file

Another way would be to either add your custom script to meta-dts/meta-dts-distro/recipes-dts/dts-scripts/dts-scripts/custom_script and in do_install inject call to this script with e.g. sed. You can also inject whole file with sed e.g. sed -i '/^while/r custom_script' dts to inject contents of custom_script into dts after matched pattern in this case it's line starting with while or before matched pattern sed -i '/^while/e cat custom_script' dts (just replace with correct paths in do_install)

DaniilKl commented 1 day ago

Our you can do it inside meta-dts:

  1. Create a subdirectory under dts-scripts directory and add your script:
λ mkdir meta-dts-distro/recipes-dts/dts-scripts/dts-scripts
λ vim meta-dts-distro/recipes-dts/dts-scripts/dts-scripts/your-script.sh
  1. Modify recipe for dts-scripts so it will install your script:
--- a/meta-dts-distro/recipes-dts/dts-scripts/dts-scripts_git.bb
+++ b/meta-dts-distro/recipes-dts/dts-scripts/dts-scripts_git.bb
@@ -2,13 +2,18 @@ SUMMARY = "Dasharo Tools Suite scripts."
 HOMEPAGE = "https://github.com/Dasharo/dts-scripts"
 SECTION = "tools"

+FILESEXTRAPATHS:prepend := "${THISDIR}/${PN}:"
+
 LICENSE = "Apache-2.0"
 LIC_FILES_CHKSUM = "file://LICENSES/Apache-2.0.txt;md5=c846ebb396f8b174b10ded4771514fcc"

 PV = "0.1+git${SRCPV}"

-SRC_URI = "git://github.com/Dasharo/dts-scripts;protocol=https;branch=main"
+SRC_URI = " \
+    git://github.com/Dasharo/dts-scripts;protocol=https;branch=main \
+    file://your-script.sh \
+    "
SRCREV = "895365d29902aaed17ed30cba1dd2944821f7218"

 S = "${WORKDIR}/git"

@@ -35,4 +40,9 @@ do_compile[noexec] = "1"

 do_install () {
     oe_runmake install DESTDIR="${D}"
+
+    install -d ${D}/script/destination/directory
+    install -m 755 ${WORKDIR}/your-script.sh ${D}/script/destination/directory
 }
+
+FILES:${PN}:append = " /script/destination/directory"
  1. Build DTS.
DaniilKl commented 1 day ago

@wessel-novacustom check whether these guides will help you.

m-iwanicki commented 1 day ago

@DaniilKl mention that your way won't run a script during system start

DaniilKl commented 1 day ago

mention that your way won't run a script during system start

I see I missed that part, yep, my guide only for adding script into FS, not for running it on start up.

wessel-novacustom commented 1 day ago

mention that your way won't run a script during system start

I see I missed that part, yep, my guide only for adding script into FS, not for running it on start up.

DaniilKl commented 1 day ago

@wessel-novacustom, I could do that. But I need some information:

  1. What the script will do?
  2. What are the dependencies for the script?
  3. At what moment you want to start your script?
wessel-novacustom commented 1 day ago

@wessel-novacustom, I could do that. But I need some information:

1. What the script will do?

2. What are the dependencies for the script?

3. At what moment you want to start your script?

I need to build DTS myself and it should check if autostart.sh in whatever folder is available. I should be able to include the autostart.sh in a folder that you specify. You can test it with something like echo Hello world! && pause 10 to check if it is working correctly.

In case it autostart.sh is available, it should execute that script. Otherwise, it should open the DTS main menu as usual.

I should fill the contents of autostart.sh myself as I would like to have that in my own control.