Bosse_B
Posts: 966
Joined: Thu Jan 30, 2014 9:53 am

How to install self created software in Raspbian?

Wed Jan 22, 2020 4:34 pm

I am developing software for a control board I will attach to the 40-pin header.
The software will communicate with an external data collection system through relays and RS232 connections on the interface board.
The board itself has just been readied and I am thinking ahead on how to duplicate the system once it is ready...

The system consists of:
1) An application (binary, not interpreted), which acts as a cgi-bin handler to configure the system via the apache webserver.
2) The actual executable, which is run by cron at regular intervals when it checks if it is time to perform a measure cycle.
3) The data for configuration and the results are stored in an SQLite database

I can pretty easily set a system up manually, but I would prefer to have an installer like on Windows where I have used InnoSetup to create such installers.
Then also others could set it up and make it run...

What is the simplest way to do an installer on Raspbian?
It needs to deploy both the application itself and the configuration utility and for that it would have to interact with apache to configure the website used for the user interactions.

I come from Windows and is not used to creating installers on Linux at all...
Bo Berglund
Sweden

User avatar
topguy
Posts: 6466
Joined: Tue Oct 09, 2012 11:46 am
Location: Trondheim, Norway

Re: How to install self created software in Raspbian?

Wed Jan 22, 2020 5:18 pm

What build system do you use for your application "make" "CMake" something else ?
Will the program run as root ?

The most used method is to create a .deb package that can be installed ( and uninstalled ) the same way as all the other software on the system.
It is maybe not the easiest method but probably the most compatible if you plan to let many people try your software.
Simplest guide: https://askubuntu.com/questions/1345/wh ... ging-guide
( there are too many advanced guides )
I can pretty easily set a system up manually,
Turning this manual procedure into a script is probably required for most methods.

The simplest method could just be to collect all the files in an archive together with a script "install.sh" that one can run with "sudo".

jahboater
Posts: 5680
Joined: Wed Feb 04, 2015 6:38 pm
Location: West Dorset

Re: How to install self created software in Raspbian?

Wed Jan 22, 2020 5:25 pm

There is the "install" command.
See "man install"

Install is very simple to use and is one of the core utils so is widely available.
Pi4 8GB running PIOS64

Bosse_B
Posts: 966
Joined: Thu Jan 30, 2014 9:53 am

Re: How to install self created software in Raspbian?

Wed Jan 22, 2020 11:36 pm

topguy wrote:
Wed Jan 22, 2020 5:18 pm
What build system do you use for your application "make" "CMake" something else ?
I am using FreePascal with Lazarus as the IDE. Builds for a whole lot of target operating systems.
Will the program run as root ?
Not necessarily, but I am running it as user pi. The user must have gpio permissions, though, to activate the relays.
The config program is a binary called by Apache to build the response pages. It runs in whatever userspace Apache uses.
It is located in a /cgi-bin folder on the website.
The most used method is to create a .deb package that can be installed ( and uninstalled ) the same way as all the other software on the system.
It is maybe not the easiest method but probably the most compatible if you plan to let many people try your software.
Not many outsiders but mostly to simplify manufacture of the systems.
Simplest guide: https://askubuntu.com/questions/1345/wh ... ging-guide
( there are too many advanced guides )
I will have a look at that and see if it helps.
I can pretty easily set a system up manually,
Turning this manual procedure into a script is probably required for most methods.

The simplest method could just be to collect all the files in an archive together with a script "install.sh" that one can run with "sudo".
I hoped that there would be some tool available like it is in Windows to simplify the task.
But if I must I can of course write a script, don't know the best way to do that considering the files involved, which go to different destinations...

Files for the system go to different target folders (website folder tree, some others to /usr/bin/ or similar and documentation elsewhere.
And Apache needs to be configured properly during install too, so I need to deploy a conf file into apache2/sites-available etc etc.
Bo Berglund
Sweden

Bosse_B
Posts: 966
Joined: Thu Jan 30, 2014 9:53 am

Re: How to install self created software in Raspbian?

Thu Jan 23, 2020 10:24 am

Following my read of the suggested page I found that this ubuntu howto is good for the basics.
However, this only handles the way to put the package files onto the target system...

Say that the files have been successful put in place, then remains the following actions:
1- activate the newly configured website by running

Code: Select all

sudo a2ensite  sitename
sudo systemctl reload apache2
2- activate the monitoring itself by setting cron to run it every minute:

Code: Select all

crontab -e
#append the following line:
* * * * * /some/path/to/command > /dev/null 2>&1
In order to automate the crontab -e command I probably would need to use something like:

Code: Select all

crontab -l > cronfile.txt
echo "* * * * * /some/path/to/command> /dev/null 2>&1" >> cronfile.txt
crontab cronfile.txt
rm cronfile.txt

But then, how do I keep this from adding my command if it already exists in the file?
I am a complete dummy concerning on the fly editing and checking as well as understanding regular expressions so often used in these circumstances...

Is there a way to run a script as part of the package installation?
If so how?
Bo Berglund
Sweden

Return to “Raspberry Pi OS”